/* File timetable_defs.cpp */ /*************************************************************************** timetable_defs.cpp - description ------------------- begin : Sat Mar 15 2003 copyright : (C) 2003 by Lalescu Liviu email : Please see https://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address) ***************************************************************************/ /*************************************************************************** * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Affero General Public License as * * published by the Free Software Foundation, either version 3 of the * * License, or (at your option) any later version. * * * ***************************************************************************/ #include "timetable_defs.h" //#include #include #include #include bool checkForUpdates; QString internetVersion; int STUDENTS_COMBO_BOXES_STYLE=STUDENTS_COMBO_BOXES_STYLE_SIMPLE; /** FET version */ const QString FET_VERSION="6.2.0"; /** FET language */ QString FET_LANGUAGE="en_US"; /** 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 will be problems. */ QString OUTPUT_DIR; bool LANGUAGE_STYLE_RIGHT_TO_LEFT; QString LANGUAGE_FOR_HTML; /** Timetable html css javaScript Level, by Volker Dirr */ int TIMETABLE_HTML_LEVEL; bool TIMETABLE_HTML_PRINT_ACTIVITY_TAGS; bool PRINT_DETAILED_HTML_TIMETABLES; bool PRINT_DETAILED_HTML_TEACHERS_FREE_PERIODS; bool PRINT_NOT_AVAILABLE_TIME_SLOTS; bool PRINT_BREAK_TIME_SLOTS; bool PRINT_ACTIVITIES_WITH_SAME_STARTING_TIME; bool DIVIDE_HTML_TIMETABLES_WITH_TIME_AXIS_BY_DAYS; bool TIMETABLE_HTML_REPEAT_NAMES; bool VERBOSE; //these hashes are needed to get the IDs for html and css in timetableexport and statistics /*QHash hashSubjectIDs; QHash hashActivityTagIDs; QHash hashStudentIDs; QHash hashTeacherIDs; QHash hashRoomIDs; QHash hashDayIDs;*/ /** A log file explaining how the xml input file was parsed */ const QString XML_PARSING_LOG_FILENAME="file_open.log"; /** The predefined names of the days of the week */ /* const QString PREDEFINED_DAYS_OF_THE_WEEK[]={"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday2", "Tuesday2", "Wednesday2", "Thursday2", "Friday2", "Saturday2", "Sunday2", "Monday3", "Tuesday3", "Wednesday3", "Thursday3", "Friday3", "Saturday3", "Sunday3", "Monday4", "Tuesday4", "Wednesday4", "Thursday4", "Friday4", "Saturday4", "Sunday4"}; */ /** File and directory separator */ const QString FILE_SEP="/"; QString protect(const QString& str) //used for XML { QString p=str; p.replace("&", "&"); p.replace("\"", """); p.replace(">", ">"); p.replace("<", "<"); p.replace("'", "'"); return p; } QString protect2(const QString& str) //used for HTML { QString p=str; p.replace("&", "&"); p.replace("\"", """); p.replace(">", ">"); p.replace("<", "<"); //p.replace("'", "'"); return p; } QString protect2vert(const QString& str) //used for HTML { QString p=str; p.replace("&", "&"); p.replace("\"", """); p.replace(">", ">"); p.replace("<", "<"); //p.replace("'", "'"); QString returnstring; for(int i=0; i=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; } QString CustomFETString::number(int n) { return QString::number(n); } QString CustomFETString::number(double x) { QString tmp=QString::number(x, 'f', CUSTOM_DOUBLE_PRECISION); //remove trailing zeroes AFTER the decimal points if(tmp.contains('.')){ int n=tmp.length()-1; int del=0; while(tmp.at(n)=='0'){ n--; del++; } if(tmp.at(n)=='.'){ n--; del++; } tmp.chop(del); } return tmp; } QString CustomFETString::numberPlusTwoDigitsPrecision(double x) { QString tmp=QString::number(x, 'f', CUSTOM_DOUBLE_PRECISION+2); //remove trailing zeroes AFTER the decimal points if(tmp.contains('.')){ int n=tmp.length()-1; int del=0; while(tmp.at(n)=='0'){ n--; del++; } if(tmp.at(n)=='.'){ n--; del++; } tmp.chop(del); } return tmp; } double customFETStrToDouble(const QString& str, bool* ok) { QLocale c(QLocale::C); //tricks to convert numbers like 97.123456789 to 97.123457, to CUSTOM_DOUBLE_PRECISION (6) decimal digits after the 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); } ///////end tricks bool BEEP_AT_END_OF_GENERATION=true; bool ENABLE_COMMAND_AT_END_OF_GENERATION=true; QString commandAtEndOfGeneration=QString(""); //bool DETACHED_NOTIFICATION=false; //int terminateCommandAfterSeconds=0; //int killCommandAfterSeconds=0; /* int XX; int YY; int ZZ; //random routines void initRandomKnuth() { 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(nullptr)); qint64 tt=qint64(time(nullptr)); //XX is the current time //XX = 1 + ( (unsigned(tt)) % (unsigned(MM-1)) ); XX = 1 + int( tt%(qint64(MM-1)) ); assert(XX>0); assert(XX0); assert(YY0); assert(YY0); assert(ZZ0); assert(XX0); assert(XX0); assert(YY0); assert(YY0); assert(ZZ=0); assert(_s11>=0); assert(_s12>=0); assert(_s20>=0); assert(_s21>=0); assert(_s22>=0); assert(_s10 < m1); assert(_s11 < m1); assert(_s12 < m1); assert(_s20 < m2); assert(_s21 < m2); assert(_s22 < m2); assert(_s10>0 || _s11>0 || _s12>0); assert(_s20>0 || _s21>0 || _s22>0); s10=_s10; s11=_s11; s12=_s12; s20=_s20; s21=_s21; s22=_s22; } void MRG32k3a::initializeMRG32k3a() { qint64 _s10, _s11, _s12, _s20, _s21, _s22; //qint64 tt=qint64(time(nullptr)); std::chrono::seconds s=std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()); qint64 si=static_cast(s.count()); //cout<<"si=="<=0); _s10=si%m1; if(_s10==0) //just in case :-) . It could even be allowed to be 0, but then we wouldn't have a certain guarantee that not all seeds in component 1 are 0. _s10=1; _s20=si%m2; if(_s20==0) //just in case :-) . It could even be allowed to be 0, but then we wouldn't have a certain guarantee that not all seeds in component 2 are 0. _s20=1; /*_s10 = 1 + tt%(m1-1); assert(_s10>=1); assert(_s10=1); assert(_s20(std::chrono::system_clock::now().time_since_epoch()); qint64 nsi=static_cast(ns.count()); //cout<<"nsi=="<=0); _s11=nsi%1000000000; std::chrono::nanoseconds ns2=std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()); qint64 nsi2=static_cast(ns2.count()); //cout<<"nsi2=="<=0); _s21=nsi2%1000000000; _s12=0; //We could try other better methods, but they need to be portable. _s22=0; initializeMRG32k3a(_s10, _s11, _s12, _s20, _s21, _s22); } unsigned int MRG32k3a::uiMRG32k3a() { assert(s10>0 || s11>0 || s12>0); assert(s20>0 || s21>0 || s22>0); qint64 p, p1, p2; /* Component 1 */ p1 = a12*s11 - a13n*s10; p1%=m1; if(p1<0) p1+=m1; assert(p1>=0 && p1=0 && p2=0 && p=0.0); assert(p<1.0); return p; }*/ int MRG32k3a::intMRG32k3a(int k) { qint64 q=(qint64(uiMRG32k3a())*qint64(k))/m1; assert(q