Back to index

fet  5.18.0
Classes | Functions | Variables
timetable_defs.h File Reference
#include <cassert>
#include <QString>
#include <QtGlobal>
#include "centerwidgetonscreen.h"

Go to the source code of this file.

Classes

class  CustomFETString

Functions

QString protect (const QString &str)
 A function used in xml saving.
QString protect2 (const QString &str)
 A function used in html saving.
QString protect2vert (const QString &str)
 A function used in html saving.
QString protect2id (const QString &str)
 A function used in html saving.
QString protect2java (const QString &str)
 A function used in html saving.
void weight_sscanf (const QString &str, const char *fmt, double *result)
double customFETStrToDouble (const QString &str, bool *ok=0)
void initRandomKnuth ()
int randomKnuth1MM1 ()
int randomKnuth (int k)

Variables

const QString FET_VERSION
 The version number.
QString FET_LANGUAGE
 The language.
bool LANGUAGE_STYLE_RIGHT_TO_LEFT
QString LANGUAGE_FOR_HTML
int TIMETABLE_HTML_LEVEL
 Timetable html css javaScript Level, added by Volker Dirr.
bool PRINT_NOT_AVAILABLE_TIME_SLOTS
bool PRINT_BREAK_TIME_SLOTS
bool DIVIDE_HTML_TIMETABLES_WITH_TIME_AXIS_BY_DAYS
bool PRINT_ACTIVITIES_WITH_SAME_STARTING_TIME
bool USE_GUI_COLORS
bool SHOW_SHORTCUTS_ON_MAIN_WINDOW
bool ENABLE_ACTIVITY_TAG_MAX_HOURS_DAILY
bool ENABLE_STUDENTS_MAX_GAPS_PER_DAY
bool SHOW_WARNING_FOR_NOT_PERFECT_CONSTRAINTS
bool ENABLE_STUDENTS_MIN_HOURS_DAILY_WITH_ALLOW_EMPTY_DAYS
bool SHOW_WARNING_FOR_STUDENTS_MIN_HOURS_DAILY_WITH_ALLOW_EMPTY_DAYS
bool CONFIRM_ACTIVITY_PLANNING
bool CONFIRM_SPREAD_ACTIVITIES
bool CONFIRM_REMOVE_REDUNDANT
bool CONFIRM_SAVE_TIMETABLE
const int MAX_TOTAL_SUBGROUPS = 30000
 The maximum total number of different subgroups of students.
const int MAX_ROOM_CAPACITY = 30000
const int MAX_TEACHERS = 6000
 The maximum number of different teachers.
const int MAX_SUBJECTS = 6000
 The maximum number of different subjects.
const int MAX_ACTIVITIES = 30000
 The maximum number of activities IMPORTANT: must be qint16 (max 32767), because we are using qint16 for each activity index and for unallocated activity = max_activities.
const int MAX_SPLIT_OF_AN_ACTIVITY = 35
const int MAX_ROOMS = 6000
 The maximum number of rooms IMPORTANT: max_rooms+1 must be qint16 (max 32766 for max_rooms), because we are using qint16 for each room index and for unallocated space = max_rooms and for unspecified room = max_rooms+1.
const int MAX_BUILDINGS = 6000
 The maximum number of buildings.
const qint16 UNALLOCATED_ACTIVITY = MAX_ACTIVITIES
 This constant represents an unallocated activity.
const int MAX_HOURS_PER_DAY = 60
 The maximum number of working hours per day.
const int MAX_DAYS_PER_WEEK = 35
 The maximum number of working days per week.
const QString PREDEFINED_DAYS_OF_THE_WEEK []
 The predefined names of the days of the week.
const int MAX_HOURS_PER_WEEK = MAX_HOURS_PER_DAY * MAX_DAYS_PER_WEEK
 The maximum number of working hours in a week.
const qint16 UNALLOCATED_TIME = MAX_HOURS_PER_WEEK
 This constant represents unallocated time for an activity.
const qint16 UNALLOCATED_SPACE = MAX_ROOMS
 This constant represents unallocated space for an activity.
const qint16 UNSPECIFIED_ROOM = MAX_ROOMS+1
const QString FILE_SEP
 The maximum number of time constraints.
QString INPUT_FILENAME_XML
 The timetable's rules input file name.
QString WORKING_DIRECTORY
 The working directory.
QString IMPORT_DIRECTORY
 The import directory.
QString OUTPUT_DIR
 The output directory.
const QString XML_PARSING_LOG_FILENAME
 A log file explaining how the xml input file was parsed.
const qint16 TEACHER_HAS_SINGLE_GAP = 0
 This constants represents free periods of a teacher in the teachers free periods timetable.
const qint16 TEACHER_HAS_BORDER_GAP = 1
const qint16 TEACHER_HAS_BIG_GAP = 2
const qint16 TEACHER_MUST_COME_EARLIER = 4
const qint16 TEACHER_MUST_COME_MUCH_EARLIER = 6
const qint16 TEACHER_MUST_STAY_LONGER = 3
const qint16 TEACHER_MUST_STAY_MUCH_LONGER = 5
const qint16 TEACHER_HAS_A_FREE_DAY = 7
const qint16 TEACHER_IS_NOT_AVAILABLE = 8
const int TEACHERS_FREE_PERIODS_N_CATEGORIES = 9
bool checkForUpdates
QString internetVersion
const int CUSTOM_DOUBLE_PRECISION = 6
const int MM = 2147483647
const int AA = 48271
const int QQ = 44488
const int RR = 3399
const int MMM = 2147483399
const int AAA = 40692
const int QQQ = 52774
const int RRR = 3791

Function Documentation

double customFETStrToDouble ( const QString &  str,
bool *  ok = 0 
)

Definition at line 181 of file timetable_defs.cpp.

{
       QLocale c(QLocale::C);

       //tricks to convert numbers like 97.123456789 to 97.123457, to CUSTOM_DOUBLE_PRECISION (6) decimal digits after decimal point
       double tmpd=c.toDouble(str, ok);
       if(ok!=0)
              if((*ok)==false)
                     return tmpd;
       QString tmps=CustomFETString::number(tmpd);
       return c.toDouble(tmps, ok);
}

Here is the call graph for this function:

void initRandomKnuth ( )

Definition at line 200 of file timetable_defs.cpp.

{
       assert(MM==2147483647);
       assert(AA==48271);
       assert(QQ==44488);
       assert(RR==3399);
       
       assert(MMM==2147483399);
       assert(MMM==MM-248);
       assert(AAA==40692);
       assert(QQQ==52774);
       assert(RRR==3791);
       
       //a few tests
       XX=123; YY=123;
       int tttt=randomKnuth1MM1();
       assert(XX==5937333);
       assert(YY==5005116);
       assert(tttt==932217);

       XX=4321; YY=54321;
       tttt=randomKnuth1MM1();
       assert(XX==208578991);
       assert(YY==62946733);
       assert(tttt==145632258);

       XX=87654321; YY=987654321;
       tttt=randomKnuth1MM1();
       assert(XX==618944401);
       assert(YY==1625301246);
       assert(tttt==1141126801);

       XX=1; YY=1;
       tttt=randomKnuth1MM1();
       assert(XX==48271);
       assert(YY==40692);
       assert(tttt==7579);

       XX=MM-1; YY=MMM-1;
       tttt=randomKnuth1MM1();
       assert(XX==2147435376);
       assert(YY==2147442707);
       assert(tttt==2147476315);

       XX=100; YY=1000;
       tttt=randomKnuth1MM1();
       assert(XX==4827100);
       assert(YY==40692000);
       assert(tttt==2111618746);
       
       //unsigned tt=unsigned(time(NULL));
       qint64 tt=qint64(time(NULL));
       
       //XX is the current time
       //XX = 1 + ( (unsigned(tt)) % (unsigned(MM-1)) );
       XX = 1 + int( tt%(qint64(MM-1)) );
       assert(XX>0);
       assert(XX<MM);

       //YY is the next random, after initializing YY with the current time
       //YY = 1 + ( (unsigned(tt)) % (unsigned(MMM-1)) );
       YY = 1 + int( tt%(qint64(MMM-1)) );
       assert(YY>0);
       assert(YY<MMM);
       YY=AAA*(YY%QQQ)-RRR*(YY/QQQ);
       if(YY<0)
              YY+=MMM;
       assert(YY>0);
       assert(YY<MMM);
       
       ZZ=XX-YY;
       if(ZZ<=0)
              ZZ+=MM-1; //-1 is not written in Knuth TAOCP vol. 2 third edition; I think it would be an improvement. (Later edit: yes, the author confirmed that).
       assert(ZZ>0);
       assert(ZZ<MM); //again, modified from Knuth TAOCP vol. 2 third edition, ZZ is strictly lower than MM (the author confirmed that, too).
}

Here is the call graph for this function:

Here is the caller graph for this function:

QString protect ( const QString &  str)

A function used in xml saving.

Definition at line 97 of file timetable_defs.cpp.

{
       QString p=str;
       p.replace("&", "&amp;");
       p.replace("\"", "&quot;");
       p.replace(">", "&gt;");
       p.replace("<", "&lt;");
       p.replace("'", "&apos;");
       return p;
}
QString protect2 ( const QString &  str)

A function used in html saving.

Definition at line 108 of file timetable_defs.cpp.

{
       QString p=str;
       p.replace("&", "&amp;");
       p.replace("\"", "&quot;");
       p.replace(">", "&gt;");
       p.replace("<", "&lt;");
       //p.replace("'", "&apos;");
       return p;
}
QString protect2id ( const QString &  str)

A function used in html saving.

QString protect2java ( const QString &  str)

A function used in html saving.

QString protect2vert ( const QString &  str)

A function used in html saving.

Definition at line 119 of file timetable_defs.cpp.

{
       QString p=str;
       p.replace("&", "&amp;");
       p.replace("\"", "&quot;");
       p.replace(">", "&gt;");
       p.replace("<", "&lt;");
       //p.replace("'", "&apos;");

       QString returnstring;
       for(int i=0; i<p.size();i++){
              QString a=p.at(i);
              QString b="<br />";
              returnstring.append(a);
              returnstring.append(b);
       }
       return returnstring;
}

Here is the caller graph for this function:

int randomKnuth ( int  k)

Definition at line 309 of file timetable_defs.cpp.

{
       //like in Knuth TAOCP vol.2, reject some numbers (very few), so that the distribution is perfectly uniform
       for(;;){
              int U=randomKnuth1MM1();
              if( U <= k * ((MM-1)/k) )
                     return U%k;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int randomKnuth1MM1 ( )

Definition at line 278 of file timetable_defs.cpp.

{
       assert(XX>0);
       assert(XX<MM);

       XX=AA*(XX%QQ)-RR*(XX/QQ);
       if(XX<0)
              XX+=MM;

       assert(XX>0);
       assert(XX<MM);

       assert(YY>0);
       assert(YY<MMM);

       YY=AAA*(YY%QQQ)-RRR*(YY/QQQ);
       if(YY<0)
              YY+=MMM;
       
       assert(YY>0);
       assert(YY<MMM);

       ZZ=XX-YY;
       if(ZZ<=0)
              ZZ+=MM-1; //-1 is not written in Knuth TAOCP vol. 2 third edition; I think it would be an improvement. (Later edit: yes, the author confirmed that).
       assert(ZZ>0);
       assert(ZZ<MM); //again, modified from Knuth TAOCP vol. 2 third edition, ZZ is strictly lower than MM (the author confirmed that, too).
       
       return ZZ;
}

Here is the caller graph for this function:

void weight_sscanf ( const QString &  str,
const char *  fmt,
double *  result 
)

Definition at line 139 of file timetable_defs.cpp.

{
       assert(QString(fmt)==QString("%lf"));

       bool ok;
       double myres=customFETStrToDouble(str, &ok);
       if(!ok)
              (*result)=-2.5; //any value that does not belong to {>=0.0 and <=100.0} or {-1.0}
                                          //not -1.0 because of modify multiple constraints min days between activities,
                                          //-1 there represents any weight
                                          //potential bug found by Volker Dirr
       else
              (*result)=myres;
}

Here is the call graph for this function:


Variable Documentation

const int AA = 48271

Definition at line 290 of file timetable_defs.h.

const int AAA = 40692

Definition at line 295 of file timetable_defs.h.

Definition at line 30 of file timetable_defs.cpp.

Definition at line 277 of file fetmainform.cpp.

Definition at line 279 of file fetmainform.cpp.

Definition at line 280 of file fetmainform.cpp.

Definition at line 278 of file fetmainform.cpp.

const int CUSTOM_DOUBLE_PRECISION = 6

Definition at line 269 of file timetable_defs.h.

Definition at line 67 of file timetable_defs.cpp.

Definition at line 267 of file fetmainform.cpp.

Definition at line 268 of file fetmainform.cpp.

Definition at line 273 of file fetmainform.cpp.

QString FET_LANGUAGE

The language.

Definition at line 42 of file timetable_defs.cpp.

const QString FET_VERSION

The version number.

Definition at line 37 of file timetable_defs.cpp.

const QString FILE_SEP

The maximum number of time constraints.

The maximum number of space constraints File and directory separator

Definition at line 95 of file timetable_defs.cpp.

The import directory.

Definition at line 119 of file fet.cpp.

The timetable's rules input file name.

Definition at line 109 of file fet.cpp.

QString internetVersion

Definition at line 32 of file timetable_defs.cpp.

Definition at line 54 of file timetable_defs.cpp.

Definition at line 52 of file timetable_defs.cpp.

const int MAX_ACTIVITIES = 30000

The maximum number of activities IMPORTANT: must be qint16 (max 32767), because we are using qint16 for each activity index and for unallocated activity = max_activities.

Definition at line 104 of file timetable_defs.h.

const int MAX_BUILDINGS = 6000

The maximum number of buildings.

Definition at line 120 of file timetable_defs.h.

const int MAX_DAYS_PER_WEEK = 35

The maximum number of working days per week.

IMPORTANT: max hours per day * max days per week = max hours per week must be qint16 (max 32767) because each time is qint16 and unallocated time is qint16

Definition at line 139 of file timetable_defs.h.

const int MAX_HOURS_PER_DAY = 60

The maximum number of working hours per day.

IMPORTANT: max hours per day * max days per week = max hours per week must be qint16 (max 32767), because each time is qint16 and unallocated time is qint16

Definition at line 132 of file timetable_defs.h.

The maximum number of working hours in a week.

Hours in a week are arranged like this: Mo Tu We Th Fr 1 0 1 2 3 4 2 5 6 7 8 9 3 10 11 12 13 14 4 15 16 17 18 19 5 20 21 22 23 24 6 25 26 27 28 29 etc.

IMPORTANT: MAX_HOURS_PER_DAY * MAX_DAYS_PER_WEEK == MAX_HOURS_PER_WEEK must be qint16 (max 32767) because each time is qint16 and unallocated time is qint16

Definition at line 161 of file timetable_defs.h.

const int MAX_ROOM_CAPACITY = 30000

Definition at line 87 of file timetable_defs.h.

const int MAX_ROOMS = 6000

The maximum number of rooms IMPORTANT: max_rooms+1 must be qint16 (max 32766 for max_rooms), because we are using qint16 for each room index and for unallocated space = max_rooms and for unspecified room = max_rooms+1.

Definition at line 115 of file timetable_defs.h.

const int MAX_SPLIT_OF_AN_ACTIVITY = 35

Definition at line 108 of file timetable_defs.h.

const int MAX_SUBJECTS = 6000

The maximum number of different subjects.

Definition at line 97 of file timetable_defs.h.

const int MAX_TEACHERS = 6000

The maximum number of different teachers.

Definition at line 92 of file timetable_defs.h.

const int MAX_TOTAL_SUBGROUPS = 30000

The maximum total number of different subgroups of students.

Definition at line 85 of file timetable_defs.h.

const int MM = 2147483647

Definition at line 289 of file timetable_defs.h.

const int MMM = 2147483399

Definition at line 294 of file timetable_defs.h.

QString OUTPUT_DIR

The output directory.

Please be careful when editing it, because the functions add a FILE_SEP sign at the end of it and then the name of a file. If you make OUTPUT_DIR="", there might be problems.

Please be careful when editing it, because the functions add a FILE_SEP sign at the end of it and then the name of a file. If you make OUTPUT_DIR="", there will be problems.

Definition at line 50 of file timetable_defs.cpp.

const QString PREDEFINED_DAYS_OF_THE_WEEK[]

The predefined names of the days of the week.

Definition at line 85 of file timetable_defs.cpp.

Definition at line 65 of file timetable_defs.cpp.

Definition at line 63 of file timetable_defs.cpp.

Definition at line 61 of file timetable_defs.cpp.

const int QQ = 44488

Definition at line 291 of file timetable_defs.h.

const int QQQ = 52774

Definition at line 296 of file timetable_defs.h.

const int RR = 3399

Definition at line 292 of file timetable_defs.h.

const int RRR = 3791

Definition at line 297 of file timetable_defs.h.

Definition at line 265 of file fetmainform.cpp.

Definition at line 270 of file fetmainform.cpp.

Definition at line 275 of file fetmainform.cpp.

const qint16 TEACHER_HAS_A_FREE_DAY = 7

Definition at line 258 of file timetable_defs.h.

const qint16 TEACHER_HAS_BIG_GAP = 2

Definition at line 250 of file timetable_defs.h.

const qint16 TEACHER_HAS_BORDER_GAP = 1

Definition at line 249 of file timetable_defs.h.

const qint16 TEACHER_HAS_SINGLE_GAP = 0

This constants represents free periods of a teacher in the teachers free periods timetable.

Definition at line 248 of file timetable_defs.h.

const qint16 TEACHER_IS_NOT_AVAILABLE = 8

Definition at line 260 of file timetable_defs.h.

const qint16 TEACHER_MUST_COME_EARLIER = 4

Definition at line 252 of file timetable_defs.h.

Definition at line 253 of file timetable_defs.h.

const qint16 TEACHER_MUST_STAY_LONGER = 3

Definition at line 255 of file timetable_defs.h.

Definition at line 256 of file timetable_defs.h.

Definition at line 262 of file timetable_defs.h.

Timetable html css javaScript Level, added by Volker Dirr.

Definition at line 59 of file timetable_defs.cpp.

This constant represents an unallocated activity.

Definition at line 125 of file timetable_defs.h.

const qint16 UNALLOCATED_SPACE = MAX_ROOMS

This constant represents unallocated space for an activity.

Definition at line 171 of file timetable_defs.h.

This constant represents unallocated time for an activity.

Definition at line 166 of file timetable_defs.h.

const qint16 UNSPECIFIED_ROOM = MAX_ROOMS+1

Definition at line 173 of file timetable_defs.h.

Definition at line 263 of file fetmainform.cpp.

The working directory.

Definition at line 114 of file fet.cpp.

const QString XML_PARSING_LOG_FILENAME

A log file explaining how the xml input file was parsed.

Definition at line 80 of file timetable_defs.cpp.