1 /* 2 File generate_pre.h 3 */ 4 5 /*************************************************************************** 6 generate_pre.h - description 7 ------------------- 8 begin : 2002 9 copyright : (C) 2002 by Lalescu Liviu 10 email : Please see https://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address) 11 ***************************************************************************/ 12 13 /*************************************************************************** 14 * * 15 * This program is free software: you can redistribute it and/or modify * 16 * it under the terms of the GNU Affero General Public License as * 17 * published by the Free Software Foundation, either version 3 of the * 18 * License, or (at your option) any later version. * 19 * * 20 ***************************************************************************/ 21 22 #ifndef GENERATE_PRE_H 23 #define GENERATE_PRE_H 24 25 #include "timetable_defs.h" 26 #include "timetable.h" 27 28 #include "matrix.h" 29 30 #include <QSet> 31 #include <QHash> 32 #include <QList> 33 #include <QPair> 34 35 #include <list> 36 37 #include <QTextStream> 38 39 #include <QtGlobal> 40 41 class QWidget; 42 43 const int MIN_HOURS_DAILY_INDEX_IN_ARRAY=1; 44 45 extern bool haveStudentsMinHoursDailyRealDaysAllowEmptyDays; 46 47 extern Matrix1D<QSet<int>> tmpPreferredRealRooms; 48 extern Matrix1D<bool> tmpFoundNonEmpty; 49 50 extern QSet<int> fixedVirtualSpaceNonZeroButNotTimeActivities; 51 52 //extern bool thereAreTeachersWithMaxHoursDailyWithUnder100Weight; 53 extern bool thereAreTeachersWithMaxHoursDailyOrPerRealDayWithUnder100Weight; 54 //extern bool thereAreSubgroupsWithMaxHoursDailyWithUnder100Weight; 55 extern bool thereAreSubgroupsWithMaxHoursDailyOrPerRealDayWithUnder100Weight; 56 57 extern Matrix1D<QList<SpaceConstraint*>> constraintsForActivity; 58 59 extern Matrix1D<bool> visitedActivityResultantRealRooms; 60 ////////end rooms 61 62 extern Matrix1D<int> initialOrderOfActivitiesIndices; 63 64 extern Matrix1D<int> daysTeacherIsAvailable; 65 extern Matrix1D<int> daysSubgroupIsAvailable; 66 extern Matrix1D<int> requestedDaysForTeachers; 67 extern Matrix1D<int> requestedDaysForSubgroups; 68 extern Matrix1D<int> nReqForTeacher; 69 extern Matrix1D<int> nReqForSubgroup; 70 71 //used only in homeRoomsAreOk 72 extern Matrix1D<int> nHoursRequiredForRoom; 73 extern Matrix1D<int> nHoursAvailableForRoom; 74 ///////////////////////////// 75 76 extern bool haveTeacherRoomNotAllowedTimesConstraints; 77 qint64 teacherRoomQInt64Combination(int teacher, int room); 78 qint64 dayHourQInt64Combination(int day, int hour); 79 extern QHash<QPair<qint64, qint64>, double> notAllowedTeacherRoomTimePercentages; 80 //first qint64 is (teacher, room), second qint64 is (day, hour) 81 bool computeNotAllowedTeacherRoomTimePercentages(); 82 83 class PreferredRoomsItem{ 84 public: 85 double percentage; 86 QSet<int> preferredRooms; 87 }; 88 89 /////////used only in sortActivities 90 extern Matrix1D<int> nIncompatible; 91 extern Matrix1D<double> nMinDaysConstraintsBroken; 92 extern Matrix1D<int> nRoomsIncompat; 93 extern Matrix1D<double> nHoursForRoom; 94 extern Matrix1D<PreferredRoomsItem> maxPercentagePrefRooms; 95 extern Matrix1D<int> reprNInc; 96 //////////////////////////////////// 97 98 extern Matrix1D<int> nIncompatibleFromFather; 99 extern Matrix1D<int> fatherActivityInInitialOrder; 100 //////////////////////////////////// 101 102 inline bool findEquivalentSubgroupsCompareFunction(int i1, int i2); 103 104 inline bool compareFunctionGeneratePre(int i, int j); 105 106 inline bool compareFunctionGeneratePreWithGroupedActivities(int i, int j); 107 108 extern Matrix1D<int> permutation; 109 extern Matrix1D<int> copyOfInitialPermutation; 110 //the permutation matrix to obtain activities in decreasing difficulty order 111 112 bool processTimeSpaceConstraints(QWidget* parent, QTextStream* initialOrderStream=nullptr); 113 114 115 ////////BEGIN BASIC TIME CONSTRAINTS 116 //a value >=0 equal with the weight of the maximum weightPercentage of a basic time constraint 117 extern Matrix1D<QHash<int, int>> activitiesConflictingPercentage; 118 119 bool computeActivitiesConflictingPercentage(QWidget* parent); 120 121 void sortActivities(QWidget* parent, const QHash<int, int>& reprSameStartingTime, const QHash<int, QSet<int>>& reprSameActivitiesSet, QTextStream* initialOrderStream=nullptr); 122 ////////END BASIC TIME CONSTRAINTS 123 124 125 ////////BEGIN MIN DAYS TIME CONSTRAINTS 126 extern Matrix1D<QList<int>> minDaysListOfActivities; 127 extern Matrix1D<QList<int>> minDaysListOfMinDays; 128 extern Matrix1D<QList<double>> minDaysListOfWeightPercentages; 129 extern Matrix1D<QList<bool>> minDaysListOfConsecutiveIfSameDay; 130 131 bool computeMinDays(QWidget* parent); 132 ////////END MIN DAYS TIME CONSTRAINTS 133 134 135 ////////BEGIN MAX DAYS TIME CONSTRAINTS 136 extern Matrix1D<QList<int>> maxDaysListOfActivities; 137 extern Matrix1D<QList<int>> maxDaysListOfMaxDays; 138 extern Matrix1D<QList<double>> maxDaysListOfWeightPercentages; 139 140 bool computeMaxDays(QWidget* parent); 141 ////////END MAX DAYS TIME CONSTRAINTS 142 143 144 ////////BEGIN MIN GAPS between activities TIME CONSTRAINTS 145 extern Matrix1D<QList<int>> minGapsBetweenActivitiesListOfActivities; 146 extern Matrix1D<QList<int>> minGapsBetweenActivitiesListOfMinGaps; 147 extern Matrix1D<QList<double>> minGapsBetweenActivitiesListOfWeightPercentages; 148 149 bool computeMinGapsBetweenActivities(QWidget* parent); 150 ////////END MIN GAPS between activities TIME CONSTRAINTS 151 152 ////////BEGIN MAX GAPS between activities TIME CONSTRAINTS 153 extern Matrix1D<QList<int> > maxGapsBetweenActivitiesListOfActivities; 154 extern Matrix1D<QList<int> > maxGapsBetweenActivitiesListOfMaxGaps; 155 extern Matrix1D<QList<double> > maxGapsBetweenActivitiesListOfWeightPercentages; 156 157 bool computeMaxGapsBetweenActivities(QWidget* parent); 158 ////////END MAX GAPS between activities TIME CONSTRAINTS 159 160 161 ////////BEGIN st. not available, tch not avail., break, activity preferred time, 162 ////////activity preferred times, activities preferred times 163 //percentage of allowed time, -1 if no restriction 164 extern Matrix2D<double> notAllowedTimesPercentages; 165 166 //break, which is not considered gap, false means no break, true means 100% break 167 //break can only be 100% or none 168 extern Matrix2D<bool> breakDayHour; 169 170 //students set not available, which is not considered gap, false means available, true means 100% not available 171 //students set not available can only be 100% or none 172 extern Matrix3D<bool> subgroupNotAvailableDayHour; 173 174 //used in students timetable view time horizontal dialog 175 extern QHash<QString, QSet<QPair<int, int>>> studentsSetNotAvailableDayHour; 176 177 //teacher not available, which is not considered gap, false means available, true means 100% not available 178 //teacher not available can only be 100% or none 179 extern Matrix3D<bool> teacherNotAvailableDayHour; 180 181 bool computeNotAllowedTimesPercentages(QWidget* parent); 182 ////////END st. not available, tch not avail., break, activity preferred time, 183 ////////activity preferred time, activities preferred times 184 185 186 ////////BEGIN students max gaps and early 187 bool computeNHoursPerSubgroup(QWidget* parent); 188 bool computeSubgroupsEarlyAndMaxGapsPercentages(QWidget* parent); 189 190 extern Matrix1D<double> subgroupsEarlyMaxBeginningsAtSecondHourPercentage; 191 extern Matrix1D<int> subgroupsEarlyMaxBeginningsAtSecondHourMaxBeginnings; 192 extern Matrix1D<double> subgroupsMaxGapsPerWeekPercentage; 193 extern Matrix1D<int> subgroupsMaxGapsPerWeekMaxGaps; 194 195 extern Matrix1D<int> nHoursPerSubgroup; //used also for students min hours daily 196 197 //max gaps per day (not perfect!!!) 198 bool computeSubgroupsMaxGapsPerDayPercentages(QWidget* parent); 199 200 extern Matrix1D<double> subgroupsMaxGapsPerDayPercentage; 201 extern Matrix1D<int> subgroupsMaxGapsPerDayMaxGaps; 202 extern bool haveStudentsMaxGapsPerDay; 203 204 //max gaps per real day (not perfect!!!) 205 bool computeSubgroupsMaxGapsPerRealDayPercentages(QWidget* parent); 206 207 extern Matrix1D<double> subgroupsMaxGapsPerRealDayPercentage; 208 extern Matrix1D<int> subgroupsMaxGapsPerRealDayMaxGaps; 209 extern bool haveStudentsMaxGapsPerRealDay; 210 211 //2020-07-29 212 //max gaps per week for real days (not perfect!!!) 213 extern Matrix1D<double> subgroupsMaxGapsPerWeekForRealDaysPercentage; 214 extern Matrix1D<int> subgroupsMaxGapsPerWeekForRealDaysMaxGaps; 215 //extern bool haveStudentsMaxGapsPerRealDay; 216 ////////END students max gaps and early 217 218 ////////BEGIN students max days per week 219 //activities indices (in 0..gt.rules.nInternalActivities-1) for each subgroup 220 extern Matrix1D<int> subgroupsMaxDaysPerWeekMaxDays; //-1 for not existing 221 extern Matrix1D<double> subgroupsMaxDaysPerWeekWeightPercentages; //-1 for not existing 222 //it is practically better to use the variable below and to put it exactly like in generate.cpp, 223 //the order of activities changes 224 extern Matrix1D<QList<int>> subgroupsWithMaxDaysPerWeekForActivities; 225 226 //for mornings-afternoons 227 //activities indices (in 0..gt.rules.nInternalActivities-1) for each subgroup 228 extern Matrix1D<int> subgroupsMaxRealDaysPerWeekMaxDays; //-1 for not existing 229 extern Matrix1D<double> subgroupsMaxRealDaysPerWeekWeightPercentages; //-1 for not existing 230 //it is practically better to use the variable below and to put it exactly like in generate.cpp, 231 //the order of activities changes 232 extern Matrix1D<QList<int>> subgroupsWithMaxRealDaysPerWeekForActivities; 233 234 ////////BEGIN teachers max days per week 235 //activities indices (in 0..gt.rules.nInternalActivities-1) for each teacher 236 extern Matrix1D<int> teachersMaxDaysPerWeekMaxDays; //-1 for not existing 237 extern Matrix1D<double> teachersMaxDaysPerWeekWeightPercentages; //-1 for not existing 238 //it is practically better to use the variable below and to put it exactly like in generate.cpp, 239 //the order of activities changes 240 extern Matrix1D<QList<int>> teachersWithMaxDaysPerWeekForActivities; 241 242 bool computeMaxDaysPerWeekForTeachers(QWidget* parent); 243 244 bool computeMaxDaysPerWeekForStudents(QWidget* parent); 245 ////////END teachers max days per week 246 247 248 ////////BEGIN teachers max three consecutive days 249 //activities indices (in 0..gt.rules.nInternalActivities-1) for each teacher 250 extern Matrix1D<bool> teachersMaxThreeConsecutiveDaysAllowAMAMException; 251 extern Matrix1D<double> teachersMaxThreeConsecutiveDaysPercentages; //-1 for not existing 252 //it is practically better to use the variable below and to put it exactly like in generate.cpp, 253 //the order of activities changes 254 extern Matrix1D<QList<int>> teachersWithMaxThreeConsecutiveDaysForActivities; 255 256 bool computeMaxThreeConsecutiveDaysForTeachers(QWidget* parent); 257 ////////END teachers max three consecutive days 258 259 260 //for mornings-afternoons 261 //activities indices (in 0..gt.rules.nInternalActivities-1) for each teacher 262 extern Matrix1D<int> teachersMaxRealDaysPerWeekMaxDays; //-1 for not existing 263 extern Matrix1D<double> teachersMaxRealDaysPerWeekWeightPercentages; //-1 for not existing 264 //it is practically better to use the variable below and to put it exactly like in generate.cpp, 265 //the order of activities changes 266 extern Matrix1D<QList<int>> teachersWithMaxRealDaysPerWeekForActivities; 267 268 bool computeMaxRealDaysPerWeekForTeachers(QWidget* parent); 269 bool computeMaxAfternoonsPerWeekForTeachers(QWidget* parent); 270 bool computeMaxMorningsPerWeekForTeachers(QWidget* parent); 271 272 bool computeMaxRealDaysPerWeekForStudents(QWidget* parent); 273 bool computeMaxAfternoonsPerWeekForStudents(QWidget* parent); 274 bool computeMaxMorningsPerWeekForStudents(QWidget* parent); 275 276 277 ////////BEGIN teachers max afternoons per week 278 //activities indices (in 0..gt.rules.nInternalActivities-1) for each teacher 279 extern Matrix1D<int> teachersMaxAfternoonsPerWeekMaxAfternoons; //-1 for not existing 280 extern Matrix1D<double> teachersMaxAfternoonsPerWeekWeightPercentages; //-1 for not existing 281 //it is practically better to use the variable below and to put it exactly like in generate.cpp, 282 //the order of activities changes 283 extern Matrix1D<QList<int>> teachersWithMaxAfternoonsPerWeekForActivities; 284 285 ////////BEGIN teachers max mornings per week 286 //activities indices (in 0..gt.rules.nInternalActivities-1) for each teacher 287 extern Matrix1D<int> teachersMaxMorningsPerWeekMaxMornings; //-1 for not existing 288 extern Matrix1D<double> teachersMaxMorningsPerWeekWeightPercentages; //-1 for not existing 289 //it is practically better to use the variable below and to put it exactly like in generate.cpp, 290 //the order of activities changes 291 extern Matrix1D<QList<int>> teachersWithMaxMorningsPerWeekForActivities; 292 293 //bool computeMaxRealDaysPerWeekForTeachers(QWidget* parent); 294 ////////END teachers max mornings per week 295 296 297 ////////BEGIN students max afternoons per week 298 //activities indices (in 0..gt.rules.nInternalActivities-1) for each subgroup 299 extern Matrix1D<int> subgroupsMaxAfternoonsPerWeekMaxAfternoons; //-1 for not existing 300 extern Matrix1D<double> subgroupsMaxAfternoonsPerWeekWeightPercentages; //-1 for not existing 301 //it is practically better to use the variable below and to put it exactly like in generate.cpp, 302 //the order of activities changes 303 extern Matrix1D<QList<int>> subgroupsWithMaxAfternoonsPerWeekForActivities; 304 305 ////////BEGIN students max mornings per week 306 //activities indices (in 0..gt.rules.nInternalActivities-1) for each subgroup 307 extern Matrix1D<int> subgroupsMaxMorningsPerWeekMaxMornings; //-1 for not existing 308 extern Matrix1D<double> subgroupsMaxMorningsPerWeekWeightPercentages; //-1 for not existing 309 //it is practically better to use the variable below and to put it exactly like in generate.cpp, 310 //the order of activities changes 311 extern Matrix1D<QList<int>> subgroupsWithMaxMorningsPerWeekForActivities; 312 ////////END students max mornings per week 313 314 315 bool computeTeachersAfternoonsEarlyMaxBeginningsAtSecondHourPercentages(QWidget* parent); 316 extern Matrix1D<double> teachersAfternoonsEarlyMaxBeginningsAtSecondHourPercentage; 317 extern Matrix1D<int> teachersAfternoonsEarlyMaxBeginningsAtSecondHourMaxBeginnings; 318 319 extern bool haveTeachersAfternoonsEarly; 320 321 322 bool computeSubgroupsAfternoonsEarlyMaxBeginningsAtSecondHourPercentages(QWidget* parent); 323 extern Matrix1D<double> subgroupsAfternoonsEarlyMaxBeginningsAtSecondHourPercentage; 324 extern Matrix1D<int> subgroupsAfternoonsEarlyMaxBeginningsAtSecondHourMaxBeginnings; 325 326 extern bool haveStudentsAfternoonsEarly; 327 328 329 bool computeTeachersMorningsEarlyMaxBeginningsAtSecondHourPercentages(QWidget* parent); 330 extern Matrix1D<double> teachersMorningsEarlyMaxBeginningsAtSecondHourPercentage; 331 extern Matrix1D<int> teachersMorningsEarlyMaxBeginningsAtSecondHourMaxBeginnings; 332 333 extern bool haveTeachersMorningsEarly; 334 335 336 bool computeSubgroupsMorningsEarlyMaxBeginningsAtSecondHourPercentages(QWidget* parent); 337 extern Matrix1D<double> subgroupsMorningsEarlyMaxBeginningsAtSecondHourPercentage; 338 extern Matrix1D<int> subgroupsMorningsEarlyMaxBeginningsAtSecondHourMaxBeginnings; 339 340 extern bool haveStudentsMorningsEarly; 341 342 343 ////////BEGIN teachers max gaps per week and per day and per morning and afternoon 344 extern Matrix1D<double> teachersMaxGapsPerWeekPercentage; 345 extern Matrix1D<int> teachersMaxGapsPerWeekMaxGaps; 346 347 extern Matrix1D<double> teachersMaxGapsPerDayPercentage; 348 extern Matrix1D<int> teachersMaxGapsPerDayMaxGaps; 349 350 extern Matrix1D<double> teachersMaxGapsPerMorningAndAfternoonPercentage; 351 extern Matrix1D<int> teachersMaxGapsPerMorningAndAfternoonMaxGaps; 352 353 extern Matrix1D<int> nHoursPerTeacher; 354 bool computeNHoursPerTeacher(QWidget* parent); 355 bool computeTeachersMaxGapsPerWeekPercentage(QWidget* parent); 356 bool computeTeachersMaxGapsPerDayPercentage(QWidget* parent); 357 bool computeTeachersMaxGapsPerMorningAndAfternoonPercentage(QWidget* parent); 358 ////////END teachers max gaps per week and per day and per morning and afternoon 359 360 361 //max gaps per real day - not perfect!!! 362 extern Matrix1D<double> teachersMaxGapsPerRealDayPercentage; 363 extern Matrix1D<int> teachersMaxGapsPerRealDayMaxGaps; 364 extern Matrix1D<bool> teachersMaxGapsPerRealDayAllowException; 365 extern bool haveTeachersMaxGapsPerRealDay; 366 367 bool computeTeachersMaxGapsPerRealDayPercentage(QWidget* parent); 368 369 //2020-07-29 370 //max gaps per week for real days - not perfect!!! 371 extern Matrix1D<double> teachersMaxGapsPerWeekForRealDaysPercentage; 372 extern Matrix1D<int> teachersMaxGapsPerWeekForRealDaysMaxGaps; 373 //extern bool haveTeachersMaxGapsPerRealDay; 374 375 //bool computeTeachersMaxGapsPerWeekForRealDaysPercentage(QWidget* parent); 376 ////////END teachers max gaps 377 378 extern Matrix1D<bool> teacherConstrainedToZeroGapsPerAfternoon; 379 bool computeTeachersConstrainedToZeroGapsPerAfternoon(QWidget* parent); 380 381 382 ////////BEGIN activities same starting time 383 extern Matrix1D<QList<int>> activitiesSameStartingTimeActivities; 384 extern Matrix1D<QList<double>> activitiesSameStartingTimePercentages; 385 bool computeActivitiesSameStartingTime(QWidget* parent, QHash<int, int> & reprSameStartingTime, QHash<int, QSet<int>> & reprSameActivitiesSet); 386 ////////END activities same starting time 387 388 389 ////////BEGIN activities same starting hour 390 extern Matrix1D<QList<int>> activitiesSameStartingHourActivities; 391 extern Matrix1D<QList<double>> activitiesSameStartingHourPercentages; 392 void computeActivitiesSameStartingHour(); 393 ////////END activities same starting hour 394 395 396 ////////BEGIN activities same starting day 397 extern Matrix1D<QList<int>> activitiesSameStartingDayActivities; 398 extern Matrix1D<QList<double>> activitiesSameStartingDayPercentages; 399 void computeActivitiesSameStartingDay(); 400 ////////END activities same starting hour 401 402 403 ////////BEGIN activities not overlapping 404 extern Matrix1D<QList<int>> activitiesNotOverlappingActivities; 405 extern Matrix1D<QList<double>> activitiesNotOverlappingPercentages; 406 void computeActivitiesNotOverlapping(); 407 ////////END activities not overlapping 408 409 410 ////////BEGIN teacher(s) max hours daily 411 extern Matrix1D<double> teachersMaxHoursDailyPercentages1; 412 extern Matrix1D<int> teachersMaxHoursDailyMaxHours1; 413 414 extern Matrix1D<double> teachersMaxHoursDailyPercentages2; 415 extern Matrix1D<int> teachersMaxHoursDailyMaxHours2; 416 417 bool computeTeachersMaxHoursDaily(QWidget* parent); 418 419 //for mornings-afternoons 420 extern Matrix1D<double> teachersMaxHoursDailyRealDaysPercentages1; 421 extern Matrix1D<int> teachersMaxHoursDailyRealDaysMaxHours1; 422 423 extern Matrix1D<double> teachersMaxHoursDailyRealDaysPercentages2; 424 extern Matrix1D<int> teachersMaxHoursDailyRealDaysMaxHours2; 425 426 bool computeTeachersMaxHoursDailyRealDays(QWidget* parent); 427 ////////END teacher(s) max hours daily 428 429 430 ////////BEGIN teacher(s) max hours continuously 431 extern Matrix1D<double> teachersMaxHoursContinuouslyPercentages1; 432 extern Matrix1D<int> teachersMaxHoursContinuouslyMaxHours1; 433 434 extern Matrix1D<double> teachersMaxHoursContinuouslyPercentages2; 435 extern Matrix1D<int> teachersMaxHoursContinuouslyMaxHours2; 436 437 bool computeTeachersMaxHoursContinuously(QWidget* parent); 438 ////////END teacher(s) max hours continuously 439 440 441 ///////BEGIN teacher(s) activity tag max hours daily 442 extern bool haveTeachersActivityTagMaxHoursDaily; 443 444 extern Matrix1D<QList<int>> teachersActivityTagMaxHoursDailyMaxHours; 445 extern Matrix1D<QList<int>> teachersActivityTagMaxHoursDailyActivityTag; 446 extern Matrix1D<QList<double>> teachersActivityTagMaxHoursDailyPercentage; 447 448 bool computeTeachersActivityTagMaxHoursDaily(QWidget* parent); 449 ///////END teacher(s) activity tag max hours daily 450 451 452 ///////BEGIN teacher(s) activity tag max hours daily real days 453 extern bool haveTeachersActivityTagMaxHoursDailyRealDays; 454 455 extern Matrix1D<QList<int>> teachersActivityTagMaxHoursDailyRealDaysMaxHours; 456 extern Matrix1D<QList<int>> teachersActivityTagMaxHoursDailyRealDaysActivityTag; 457 extern Matrix1D<QList<double>> teachersActivityTagMaxHoursDailyRealDaysPercentage; 458 459 bool computeTeachersActivityTagMaxHoursDailyRealDays(QWidget* parent); 460 ///////END teacher(s) activity tag max hours daily real days 461 462 463 ///////BEGIN teacher(s) activity tag max hours continuously 464 extern bool haveTeachersActivityTagMaxHoursContinuously; 465 466 extern Matrix1D<QList<int>> teachersActivityTagMaxHoursContinuouslyMaxHours; 467 extern Matrix1D<QList<int>> teachersActivityTagMaxHoursContinuouslyActivityTag; 468 extern Matrix1D<QList<double>> teachersActivityTagMaxHoursContinuouslyPercentage; 469 470 bool computeTeachersActivityTagMaxHoursContinuously(QWidget* parent); 471 ///////END teacher(s) activity tag max hours continuously 472 473 474 ////////BEGIN teacher(s) min hours daily 475 extern Matrix2D<double> teachersMinHoursDailyPercentages; //If having mornings-afternoons: 0 is for morning, 1 is for afternoon 476 extern Matrix2D<int> teachersMinHoursDailyMinHours; //If having official: both should be equal, but we use 1. 477 478 bool computeTeachersMinHoursDaily(QWidget* parent); 479 480 //real days 481 extern Matrix1D<double> teachersMinHoursDailyRealDaysPercentages; 482 extern Matrix1D<int> teachersMinHoursDailyRealDaysMinHours; 483 484 bool computeTeachersMinHoursDailyRealDays(QWidget* parent); 485 ////////END teacher(s) min hours daily 486 487 488 ////////BEGIN teacher(s) min days per week 489 extern Matrix1D<double> teachersMinDaysPerWeekPercentages; 490 extern Matrix1D<int> teachersMinDaysPerWeekMinDays; 491 492 bool computeTeachersMinDaysPerWeek(QWidget* parent); 493 ////////END teacher(s) min days per week 494 495 496 ////////BEGIN teacher(s) min real days per week 497 extern Matrix1D<double> teachersMinRealDaysPerWeekPercentages; 498 extern Matrix1D<int> teachersMinRealDaysPerWeekMinDays; 499 500 bool computeTeachersMinRealDaysPerWeek(QWidget* parent); 501 ////////END teacher(s) min real days per week 502 503 504 505 ////////BEGIN teacher(s) min mornings and afternoons per week 506 extern Matrix1D<double> teachersMinMorningsPerWeekPercentages; 507 extern Matrix1D<int> teachersMinMorningsPerWeekMinMornings; 508 extern Matrix1D<double> teachersMinAfternoonsPerWeekPercentages; 509 extern Matrix1D<int> teachersMinAfternoonsPerWeekMinAfternoons; 510 511 bool computeTeachersMinMorningsAfternoonsPerWeek(QWidget* parent); 512 ////////END teacher(s) min mornings and afternoons per week 513 514 515 //2020-06-28 516 extern Matrix1D<double> teachersMaxHoursPerAllAfternoonsPercentages; 517 extern Matrix1D<int> teachersMaxHoursPerAllAfternoonsMaxHours; 518 519 bool computeTeachersMaxHoursPerAllAfternoons(QWidget* parent); 520 //////////// 521 522 523 //2020-06-28 524 extern Matrix1D<double> subgroupsMaxHoursPerAllAfternoonsPercentages; 525 extern Matrix1D<int> subgroupsMaxHoursPerAllAfternoonsMaxHours; 526 527 bool computeStudentsMaxHoursPerAllAfternoons(QWidget* parent); 528 //////////// 529 530 531 ////////BEGIN students min mornings and afternoons per week 532 extern Matrix1D<double> subgroupsMinMorningsPerWeekPercentages; 533 extern Matrix1D<int> subgroupsMinMorningsPerWeekMinMornings; 534 extern Matrix1D<double> subgroupsMinAfternoonsPerWeekPercentages; 535 extern Matrix1D<int> subgroupsMinAfternoonsPerWeekMinAfternoons; 536 537 bool computeStudentsMinMorningsAfternoonsPerWeek(QWidget* parent); 538 ////////END students min mornings and afternoons per week 539 540 541 ////////BEGIN students (set) max hours daily 542 extern Matrix1D<double> subgroupsMaxHoursDailyPercentages1; 543 extern Matrix1D<int> subgroupsMaxHoursDailyMaxHours1; 544 545 extern Matrix1D<double> subgroupsMaxHoursDailyPercentages2; 546 extern Matrix1D<int> subgroupsMaxHoursDailyMaxHours2; 547 548 bool computeSubgroupsMaxHoursDaily(QWidget* parent); 549 ////////END students (set) max hours daily 550 551 552 ////////BEGIN students (set) max hours daily real days 553 extern Matrix1D<double> subgroupsMaxHoursDailyRealDaysPercentages1; 554 extern Matrix1D<int> subgroupsMaxHoursDailyRealDaysMaxHours1; 555 556 extern Matrix1D<double> subgroupsMaxHoursDailyRealDaysPercentages2; 557 extern Matrix1D<int> subgroupsMaxHoursDailyRealDaysMaxHours2; 558 559 bool computeSubgroupsMaxHoursDailyRealDays(QWidget* parent); 560 ////////END students (set) max hours daily real days 561 562 563 ////////BEGIN students (set) max hours continuously 564 extern Matrix1D<double> subgroupsMaxHoursContinuouslyPercentages1; 565 extern Matrix1D<int> subgroupsMaxHoursContinuouslyMaxHours1; 566 567 extern Matrix1D<double> subgroupsMaxHoursContinuouslyPercentages2; 568 extern Matrix1D<int> subgroupsMaxHoursContinuouslyMaxHours2; 569 570 bool computeStudentsMaxHoursContinuously(QWidget* parent); 571 ////////END students (set) max hours continuously 572 573 574 ///////BEGIN students (set) activity tag max hours daily 575 extern bool haveStudentsActivityTagMaxHoursDaily; 576 577 extern Matrix1D<QList<int>> subgroupsActivityTagMaxHoursDailyMaxHours; 578 extern Matrix1D<QList<int>> subgroupsActivityTagMaxHoursDailyActivityTag; 579 extern Matrix1D<QList<double>> subgroupsActivityTagMaxHoursDailyPercentage; 580 581 bool computeStudentsActivityTagMaxHoursDaily(QWidget* parent); 582 ///////END students (set) activity tag max hours daily 583 584 585 ///////BEGIN students (set) activity tag max hours daily real days 586 extern bool haveStudentsActivityTagMaxHoursDailyRealDays; 587 588 extern Matrix1D<QList<int>> subgroupsActivityTagMaxHoursDailyRealDaysMaxHours; 589 extern Matrix1D<QList<int>> subgroupsActivityTagMaxHoursDailyRealDaysActivityTag; 590 extern Matrix1D<QList<double>> subgroupsActivityTagMaxHoursDailyRealDaysPercentage; 591 592 bool computeStudentsActivityTagMaxHoursDailyRealDays(QWidget* parent); 593 ///////END students (set) activity tag max hours daily real days 594 595 596 ///////BEGIN students (set) activity tag max hours continuously 597 extern bool haveStudentsActivityTagMaxHoursContinuously; 598 599 extern Matrix1D<QList<int>> subgroupsActivityTagMaxHoursContinuouslyMaxHours; 600 extern Matrix1D<QList<int>> subgroupsActivityTagMaxHoursContinuouslyActivityTag; 601 extern Matrix1D<QList<double>> subgroupsActivityTagMaxHoursContinuouslyPercentage; 602 603 bool computeStudentsActivityTagMaxHoursContinuously(QWidget* parent); 604 ///////END students (set) activity tag max hours continuously 605 606 607 ////////BEGIN students (set) min hours daily 608 extern Matrix2D<double> subgroupsMinHoursDailyPercentages; //If having mornings-afternoons: 0 is for morning, 1 is for afternoon 609 extern Matrix2D<int> subgroupsMinHoursDailyMinHours; //If having official: both should be equal, but we use 1. 610 extern Matrix1D<bool> subgroupsMinHoursDailyAllowEmptyDays; 611 extern Matrix1D<bool> subgroupsMinHoursPerMorningAllowEmptyMornings; 612 bool computeSubgroupsMinHoursDaily(QWidget* parent); 613 ////////END students (set) min hours daily 614 615 616 //////////////BEGIN 2 activities consecutive 617 //index represents the first activity, value in array represents the second activity 618 extern Matrix1D<QList<double>> constrTwoActivitiesConsecutivePercentages; 619 extern Matrix1D<QList<int>> constrTwoActivitiesConsecutiveActivities; 620 void computeConstrTwoActivitiesConsecutive(); 621 622 //index represents the second activity, value in array represents the first activity 623 extern Matrix1D<QList<double>> inverseConstrTwoActivitiesConsecutivePercentages; 624 extern Matrix1D<QList<int>> inverseConstrTwoActivitiesConsecutiveActivities; 625 //////////////END 2 activities consecutive 626 627 628 //////////////BEGIN 2 activities grouped 629 //index represents the first activity, value in array represents the second activity 630 extern Matrix1D<QList<double>> constrTwoActivitiesGroupedPercentages; 631 extern Matrix1D<QList<int>> constrTwoActivitiesGroupedActivities; 632 void computeConstrTwoActivitiesGrouped(); 633 634 635 //////////////BEGIN 3 activities grouped 636 //index represents the first activity, value in array represents the second and third activities 637 extern Matrix1D<QList<double>> constrThreeActivitiesGroupedPercentages; 638 extern Matrix1D<QList<QPair<int, int>>> constrThreeActivitiesGroupedActivities; 639 void computeConstrThreeActivitiesGrouped(); 640 641 642 //////////////BEGIN 2 activities ordered 643 //index represents the first activity, value in array represents the second activity 644 extern Matrix1D<QList<double>> constrTwoActivitiesOrderedPercentages; 645 extern Matrix1D<QList<int>> constrTwoActivitiesOrderedActivities; 646 void computeConstrTwoActivitiesOrdered(); 647 648 //index represents the second activity, value in array represents the first activity 649 extern Matrix1D<QList<double>> inverseConstrTwoActivitiesOrderedPercentages; 650 extern Matrix1D<QList<int>> inverseConstrTwoActivitiesOrderedActivities; 651 //////////////END 2 activities ordered 652 653 //////////////BEGIN 2 activities ordered if same day 654 //index represents the first activity, value in array represents the second activity 655 extern Matrix1D<QList<double>> constrTwoActivitiesOrderedIfSameDayPercentages; 656 extern Matrix1D<QList<int>> constrTwoActivitiesOrderedIfSameDayActivities; 657 void computeConstrTwoActivitiesOrderedIfSameDay(); 658 659 //index represents the second activity, value in array represents the first activity 660 extern Matrix1D<QList<double>> inverseConstrTwoActivitiesOrderedIfSameDayPercentages; 661 extern Matrix1D<QList<int>> inverseConstrTwoActivitiesOrderedIfSameDayActivities; 662 //////////////END 2 activities ordered if same day 663 664 665 ////////////BEGIN activity ends students day 666 extern Matrix1D<double> activityEndsStudentsDayPercentages; //-1 for not existing 667 bool computeActivityEndsStudentsDayPercentages(QWidget* parent); 668 extern bool haveActivityEndsStudentsDay; 669 ////////////END activity ends students day 670 671 ////////////BEGIN activity ends teachers day 672 extern Matrix1D<double> activityEndsTeachersDayPercentages; //-1 for not existing 673 bool computeActivityEndsTeachersDayPercentages(QWidget* parent); 674 extern bool haveActivityEndsTeachersDay; 675 ////////////END activity ends teachers day 676 677 678 bool checkMinDays100Percent(QWidget* parent); 679 bool checkMinDaysConsecutiveIfSameDay(QWidget* parent); 680 681 682 bool checkMaxHoursForActivityDuration(QWidget* parent); 683 684 685 ///////BEGIN teachers interval max days per week 686 extern Matrix1D<QList<double>> teachersIntervalMaxDaysPerWeekPercentages; 687 extern Matrix1D<QList<int>> teachersIntervalMaxDaysPerWeekMaxDays; 688 extern Matrix1D<QList<int>> teachersIntervalMaxDaysPerWeekIntervalStart; 689 extern Matrix1D<QList<int>> teachersIntervalMaxDaysPerWeekIntervalEnd; 690 691 bool computeTeachersIntervalMaxDaysPerWeek(QWidget* parent); 692 ///////END teachers interval max days per week 693 694 //morning 695 extern Matrix1D<QList<double>> teachersMorningIntervalMaxDaysPerWeekPercentages; 696 extern Matrix1D<QList<int>> teachersMorningIntervalMaxDaysPerWeekMaxDays; 697 extern Matrix1D<QList<int>> teachersMorningIntervalMaxDaysPerWeekIntervalStart; 698 extern Matrix1D<QList<int>> teachersMorningIntervalMaxDaysPerWeekIntervalEnd; 699 700 bool computeTeachersMorningIntervalMaxDaysPerWeek(QWidget* parent); 701 702 //afternoon 703 extern Matrix1D<QList<double>> teachersAfternoonIntervalMaxDaysPerWeekPercentages; 704 extern Matrix1D<QList<int>> teachersAfternoonIntervalMaxDaysPerWeekMaxDays; 705 extern Matrix1D<QList<int>> teachersAfternoonIntervalMaxDaysPerWeekIntervalStart; 706 extern Matrix1D<QList<int>> teachersAfternoonIntervalMaxDaysPerWeekIntervalEnd; 707 708 bool computeTeachersAfternoonIntervalMaxDaysPerWeek(QWidget* parent); 709 710 711 extern Matrix1D<double> teachersMaxTwoConsecutiveMorningsPercentage; 712 extern Matrix1D<double> teachersMaxTwoConsecutiveAfternoonsPercentage; 713 714 bool computeTeachersMaxTwoConsecutiveMornings(QWidget* parent); 715 bool computeTeachersMaxTwoConsecutiveAfternoons(QWidget* parent); 716 717 718 ///////BEGIN subgroups interval max days per week 719 extern Matrix1D<QList<double>> subgroupsIntervalMaxDaysPerWeekPercentages; 720 extern Matrix1D<QList<int>> subgroupsIntervalMaxDaysPerWeekMaxDays; 721 extern Matrix1D<QList<int>> subgroupsIntervalMaxDaysPerWeekIntervalStart; 722 extern Matrix1D<QList<int>> subgroupsIntervalMaxDaysPerWeekIntervalEnd; 723 724 bool computeSubgroupsIntervalMaxDaysPerWeek(QWidget* parent); 725 ///////END subgroups interval max days per week 726 727 728 //2020-06-26 729 ///////BEGIN subgroups morning interval max days per week 730 extern Matrix1D<QList<double>> subgroupsMorningIntervalMaxDaysPerWeekPercentages; 731 extern Matrix1D<QList<int>> subgroupsMorningIntervalMaxDaysPerWeekMaxDays; 732 extern Matrix1D<QList<int>> subgroupsMorningIntervalMaxDaysPerWeekIntervalStart; 733 extern Matrix1D<QList<int>> subgroupsMorningIntervalMaxDaysPerWeekIntervalEnd; 734 735 bool computeSubgroupsMorningIntervalMaxDaysPerWeek(QWidget* parent); 736 ///////END subgroups morning interval max days per week 737 738 ///////BEGIN subgroups afternoon interval max days per week 739 extern Matrix1D<QList<double>> subgroupsAfternoonIntervalMaxDaysPerWeekPercentages; 740 extern Matrix1D<QList<int>> subgroupsAfternoonIntervalMaxDaysPerWeekMaxDays; 741 extern Matrix1D<QList<int>> subgroupsAfternoonIntervalMaxDaysPerWeekIntervalStart; 742 extern Matrix1D<QList<int>> subgroupsAfternoonIntervalMaxDaysPerWeekIntervalEnd; 743 744 bool computeSubgroupsAfternoonIntervalMaxDaysPerWeek(QWidget* parent); 745 ///////END subgroups afternoon interval max days per week 746 747 748 //2017-02-06 749 extern Matrix1D<int> teachersMaxSpanPerDayMaxSpan; //-1 for not existing 750 extern Matrix1D<double> teachersMaxSpanPerDayPercentages; //-1 for not existing 751 extern Matrix1D<bool> teachersMaxSpanPerDayAllowOneDayExceptionPlusOne; 752 753 754 /////////////// 755 extern Matrix1D<int> teachersMaxSpanPerRealDayMaxSpan; //-1 for not existing 756 extern Matrix1D<double> teachersMaxSpanPerRealDayPercentages; //-1 for not existing 757 extern Matrix1D<bool> teachersMaxSpanPerRealDayAllowOneDayExceptionPlusOne; 758 759 extern Matrix1D<int> subgroupsMaxSpanPerRealDayMaxSpan; //-1 for not existing 760 extern Matrix1D<double> subgroupsMaxSpanPerRealDayPercentages; //-1 for not existing 761 762 bool computeTeachersMaxSpanPerRealDay(QWidget* parent); 763 bool computeSubgroupsMaxSpanPerRealDay(QWidget* parent); 764 /////////////// 765 766 767 extern Matrix1D<int> teachersMinRestingHoursCircularMinHours; //-1 for not existing 768 extern Matrix1D<double> teachersMinRestingHoursCircularPercentages; //-1 for not existing 769 extern Matrix1D<int> teachersMinRestingHoursNotCircularMinHours; //-1 for not existing 770 extern Matrix1D<double> teachersMinRestingHoursNotCircularPercentages; //-1 for not existing 771 772 extern Matrix1D<int> subgroupsMaxSpanPerDayMaxSpan; //-1 for not existing 773 extern Matrix1D<double> subgroupsMaxSpanPerDayPercentages; //-1 for not existing 774 775 extern Matrix1D<int> subgroupsMinRestingHoursCircularMinHours; //-1 for not existing 776 extern Matrix1D<double> subgroupsMinRestingHoursCircularPercentages; //-1 for not existing 777 extern Matrix1D<int> subgroupsMinRestingHoursNotCircularMinHours; //-1 for not existing 778 extern Matrix1D<double> subgroupsMinRestingHoursNotCircularPercentages; //-1 for not existing 779 780 bool computeTeachersMaxSpanPerDay(QWidget* parent); 781 bool computeTeachersMinRestingHours(QWidget* parent); 782 bool computeSubgroupsMaxSpanPerDay(QWidget* parent); 783 bool computeSubgroupsMinRestingHours(QWidget* parent); 784 //////////// 785 786 787 //2020-07-20 788 /////////////// 789 extern Matrix1D<int> teachersMinRestingHoursBetweenMorningAndAfternoonMinHours; //-1 for not existing 790 extern Matrix1D<double> teachersMinRestingHoursBetweenMorningAndAfternoonPercentages; //-1 for not existing 791 792 extern Matrix1D<int> subgroupsMinRestingHoursBetweenMorningAndAfternoonMinHours; //-1 for not existing 793 extern Matrix1D<double> subgroupsMinRestingHoursBetweenMorningAndAfternoonPercentages; //-1 for not existing 794 bool computeTeachersMinRestingHoursBetweenMorningAndAfternoon(QWidget* parent); 795 bool computeSubgroupsMinRestingHoursBetweenMorningAndAfternoon(QWidget* parent); 796 /////////////// 797 798 799 extern Matrix1D<double> teachersMaxTwoActivityTagsPerDayFromN1N2N3Percentages; 800 extern Matrix1D<int> activityTagN1N2N3; 801 extern Matrix1D<QList<int>> teachersWithN1N2N3ForActivities; 802 803 bool computeN1N2N3(QWidget* parent); 804 805 806 ////////BEGIN rooms 807 bool computeBasicSpace(QWidget* parent); 808 809 extern Matrix2D<double> notAllowedRoomTimePercentages; //-1 for available 810 bool computeNotAllowedRoomTimePercentages(); 811 812 extern Matrix1D<QList<PreferredRoomsItem>> activitiesPreferredRoomsList; 813 extern Matrix1D<bool> unspecifiedPreferredRoom; 814 815 extern Matrix1D<QList<int>> activitiesHomeRoomsHomeRooms; 816 extern Matrix1D<double> activitiesHomeRoomsPercentage; 817 extern Matrix1D<bool> unspecifiedHomeRoom; 818 819 extern Matrix1D<QSet<int>> preferredRealRooms; 820 821 bool computeActivitiesRoomsPreferences(QWidget* parent); 822 ////////END rooms 823 824 825 ////////BEGIN building changes 826 extern Matrix1D<double> maxBuildingChangesPerWeekForStudentsPercentages; 827 extern Matrix1D<int> maxBuildingChangesPerWeekForStudentsMaxChanges; 828 bool computeMaxBuildingChangesPerWeekForStudents(QWidget* parent); 829 830 extern Matrix1D<double> maxBuildingChangesPerDayForStudentsPercentages; 831 extern Matrix1D<int> maxBuildingChangesPerDayForStudentsMaxChanges; 832 bool computeMaxBuildingChangesPerDayForStudents(QWidget* parent); 833 834 extern Matrix1D<double> minGapsBetweenBuildingChangesForStudentsPercentages; 835 extern Matrix1D<int> minGapsBetweenBuildingChangesForStudentsMinGaps; 836 bool computeMinGapsBetweenBuildingChangesForStudents(QWidget* parent); 837 838 extern Matrix1D<double> maxBuildingChangesPerWeekForTeachersPercentages; 839 extern Matrix1D<int> maxBuildingChangesPerWeekForTeachersMaxChanges; 840 bool computeMaxBuildingChangesPerWeekForTeachers(QWidget* parent); 841 842 extern Matrix1D<double> maxBuildingChangesPerDayForTeachersPercentages; 843 extern Matrix1D<int> maxBuildingChangesPerDayForTeachersMaxChanges; 844 bool computeMaxBuildingChangesPerDayForTeachers(QWidget* parent); 845 846 extern Matrix1D<double> minGapsBetweenBuildingChangesForTeachersPercentages; 847 extern Matrix1D<int> minGapsBetweenBuildingChangesForTeachersMinGaps; 848 bool computeMinGapsBetweenBuildingChangesForTeachers(QWidget* parent); 849 ////////END building changes 850 851 852 ////////BEGIN room changes 853 extern Matrix1D<double> maxRoomChangesPerWeekForStudentsPercentages; 854 extern Matrix1D<int> maxRoomChangesPerWeekForStudentsMaxChanges; 855 bool computeMaxRoomChangesPerWeekForStudents(QWidget* parent); 856 857 extern Matrix1D<double> maxRoomChangesPerDayForStudentsPercentages; 858 extern Matrix1D<int> maxRoomChangesPerDayForStudentsMaxChanges; 859 bool computeMaxRoomChangesPerDayForStudents(QWidget* parent); 860 861 extern Matrix1D<double> minGapsBetweenRoomChangesForStudentsPercentages; 862 extern Matrix1D<int> minGapsBetweenRoomChangesForStudentsMinGaps; 863 bool computeMinGapsBetweenRoomChangesForStudents(QWidget* parent); 864 865 extern Matrix1D<double> maxRoomChangesPerWeekForTeachersPercentages; 866 extern Matrix1D<int> maxRoomChangesPerWeekForTeachersMaxChanges; 867 bool computeMaxRoomChangesPerWeekForTeachers(QWidget* parent); 868 869 extern Matrix1D<double> maxRoomChangesPerDayForTeachersPercentages; 870 extern Matrix1D<int> maxRoomChangesPerDayForTeachersMaxChanges; 871 bool computeMaxRoomChangesPerDayForTeachers(QWidget* parent); 872 873 extern Matrix1D<double> minGapsBetweenRoomChangesForTeachersPercentages; 874 extern Matrix1D<int> minGapsBetweenRoomChangesForTeachersMinGaps; 875 bool computeMinGapsBetweenRoomChangesForTeachers(QWidget* parent); 876 877 878 //BEGIN room changes per real day for teachers 879 extern Matrix1D<double> maxRoomChangesPerRealDayForTeachersPercentages; 880 extern Matrix1D<int> maxRoomChangesPerRealDayForTeachersMaxChanges; 881 bool computeMaxRoomChangesPerRealDayForTeachers(QWidget* parent); 882 //END room changes per real day for teachers 883 884 //BEGIN room changes per real day for students 885 extern Matrix1D<double> maxRoomChangesPerRealDayForSubgroupsPercentages; 886 extern Matrix1D<int> maxRoomChangesPerRealDayForSubgroupsMaxChanges; 887 bool computeMaxRoomChangesPerRealDayForStudents(QWidget* parent); 888 //END room changes per real day for students 889 890 ////////END room changes 891 892 893 extern Matrix1D<QList<int>> mustComputeTimetableSubgroups; 894 extern Matrix1D<QList<int>> mustComputeTimetableTeachers; 895 extern Matrix1D<bool> mustComputeTimetableSubgroup; 896 extern Matrix1D<bool> mustComputeTimetableTeacher; 897 898 void computeMustComputeTimetableSubgroups(); 899 void computeMustComputeTimetableTeachers(); 900 901 902 bool homeRoomsAreOk(QWidget* parent); 903 904 905 //2011-09-25 - Constraint activities occupy max time slots from selection 906 class ActivitiesOccupyMaxTimeSlotsFromSelection_item 907 { 908 public: 909 //double weight; -> must be 100.0% 910 QList<int> activitiesList; 911 QSet<int> activitiesSet; 912 QList<int> selectedTimeSlotsList; 913 QSet<int> selectedTimeSlotsSet; 914 int maxOccupiedTimeSlots; 915 }; 916 917 //We need the references to the elements to be valid, so we need this to be a std::list 918 extern std::list<ActivitiesOccupyMaxTimeSlotsFromSelection_item> aomtsList; 919 extern Matrix1D<QList<ActivitiesOccupyMaxTimeSlotsFromSelection_item*>> aomtsListForActivity; 920 921 bool computeActivitiesOccupyMaxTimeSlotsFromSelection(QWidget* parent); 922 923 //2019-11-16 - Constraint activities occupy min time slots from selection 924 class ActivitiesOccupyMinTimeSlotsFromSelection_item 925 { 926 public: 927 //double weight; -> must be 100.0% 928 QList<int> activitiesList; 929 QSet<int> activitiesSet; 930 QList<int> selectedTimeSlotsList; 931 QSet<int> selectedTimeSlotsSet; 932 int minOccupiedTimeSlots; 933 }; 934 935 //We need the references to the elements to be valid, so we need this to be a std::list 936 extern std::list<ActivitiesOccupyMinTimeSlotsFromSelection_item> aomintsList; 937 extern Matrix1D<QList<ActivitiesOccupyMinTimeSlotsFromSelection_item*>> aomintsListForActivity; 938 939 bool computeActivitiesOccupyMinTimeSlotsFromSelection(QWidget* parent); 940 941 //2011-09-30 - Constraint activities max simultaneous in selected time slots 942 class ActivitiesMaxSimultaneousInSelectedTimeSlots_item 943 { 944 public: 945 //double weight; -> must be 100.0% 946 QList<int> activitiesList; 947 QSet<int> activitiesSet; 948 QList<int> selectedTimeSlotsList; 949 QSet<int> selectedTimeSlotsSet; 950 int maxSimultaneous; 951 }; 952 953 //We need the references to the elements to be valid, so we need this to be a std::list 954 extern std::list<ActivitiesMaxSimultaneousInSelectedTimeSlots_item> amsistsList; 955 extern Matrix1D<QList<ActivitiesMaxSimultaneousInSelectedTimeSlots_item*>> amsistsListForActivity; 956 957 bool computeActivitiesMaxSimultaneousInSelectedTimeSlots(QWidget* parent); 958 959 //2019-11-16 - Constraint activities min simultaneous in selected time slots 960 class ActivitiesMinSimultaneousInSelectedTimeSlots_item 961 { 962 public: 963 //double weight; -> must be 100.0% 964 QList<int> activitiesList; 965 QSet<int> activitiesSet; 966 QList<int> selectedTimeSlotsList; 967 QSet<int> selectedTimeSlotsSet; 968 int minSimultaneous; 969 970 bool allowEmptySlots; 971 }; 972 973 //We need the references to the elements to be valid, so we need this to be a std::list 974 extern std::list<ActivitiesMinSimultaneousInSelectedTimeSlots_item> aminsistsList; 975 extern Matrix1D<QList<ActivitiesMinSimultaneousInSelectedTimeSlots_item*>> aminsistsListForActivity; 976 977 bool computeActivitiesMinSimultaneousInSelectedTimeSlots(QWidget* parent); 978 979 extern bool haveActivitiesOccupyMaxConstraints; 980 extern Matrix1D<bool> activityHasOccupyMaxConstraints; 981 982 extern bool haveActivitiesMaxSimultaneousConstraints; 983 extern Matrix1D<bool> activityHasMaxSimultaneousConstraints; 984 985 //2020-05-01 - Constraint max total activities from set in selected time slots 986 class ActivitiesMaxTotalFromSetInSelectedTimeSlots_item 987 { 988 public: 989 //double weight; -> must be 100.0% 990 QList<int> activitiesList; 991 //QSet<int> activitiesSet; 992 //QList<int> selectedTimeSlotsList; 993 QSet<int> selectedTimeSlotsSet; 994 int maxActivities; 995 }; 996 997 //The next variable should be a std::list!!! 998 //We need the references to the elements to be valid 999 extern std::list<ActivitiesMaxTotalFromSetInSelectedTimeSlots_item> amtfsistsList; 1000 extern Matrix1D<QList<ActivitiesMaxTotalFromSetInSelectedTimeSlots_item*>> amtfsistsListForActivity; 1001 1002 bool computeActivitiesMaxTotalFromSetInSelectedTimeSlots(QWidget* parent); 1003 1004 //for terms 1005 //2020-01-14 - Constraint activities max in a term 1006 1007 class ActivitiesMaxInATerm_item 1008 { 1009 public: 1010 //double weight; -> must be 100.0% 1011 QList<int> activitiesList; 1012 int maxActivitiesInATerm; 1013 }; 1014 1015 //The next variable should be a std::list!!! 1016 //We need the references to the elements to be valid 1017 extern std::list<ActivitiesMaxInATerm_item> amiatList; 1018 extern Matrix1D<QList<ActivitiesMaxInATerm_item*>> amiatListForActivity; 1019 1020 bool computeActivitiesMaxInATerm(QWidget* parent); 1021 1022 //2020-01-14 - Constraint activities occupy max terms 1023 1024 class ActivitiesOccupyMaxTerms_item 1025 { 1026 public: 1027 //double weight; -> must be 100.0% 1028 QList<int> activitiesList; 1029 int maxOccupiedTerms; 1030 }; 1031 1032 //The next variable should be a std::list!!! 1033 //We need the references to the elements to be valid 1034 extern std::list<ActivitiesOccupyMaxTerms_item> aomtList; 1035 extern Matrix1D<QList<ActivitiesOccupyMaxTerms_item*>> aomtListForActivity; 1036 1037 bool computeActivitiesOccupyMaxTerms(QWidget* parent); 1038 1039 //2019-06-08 - Constraint students (set) min gaps between ordered pair of activity tags 1040 class StudentsMinGapsBetweenOrderedPairOfActivityTags_item{ 1041 public: 1042 //double weight; -> must be 100.0% 1043 QSet<int> canonicalSetOfSubgroups; 1044 int minGaps; 1045 int firstActivityTag; 1046 int secondActivityTag; 1047 }; 1048 1049 //We need the references to the elements to be valid, so we need this to be a std::list 1050 extern std::list<StudentsMinGapsBetweenOrderedPairOfActivityTags_item> smgbopoatList; 1051 extern Matrix1D<QList<StudentsMinGapsBetweenOrderedPairOfActivityTags_item*>> smgbopoatListForActivity; 1052 1053 bool computeStudentsMinGapsBetweenOrderedPairOfActivityTags(QWidget* parent); 1054 1055 //2019-06-08 - Constraint teacher(s) min gaps between ordered pair of activity tags 1056 class TeachersMinGapsBetweenOrderedPairOfActivityTags_item{ 1057 public: 1058 //double weight; -> must be 100.0% 1059 QSet<int> canonicalSetOfTeachers; 1060 int minGaps; 1061 int firstActivityTag; 1062 int secondActivityTag; 1063 }; 1064 1065 //We need the references to the elements to be valid, so we need this to be a std::list 1066 extern std::list<TeachersMinGapsBetweenOrderedPairOfActivityTags_item> tmgbopoatList; 1067 extern Matrix1D<QList<TeachersMinGapsBetweenOrderedPairOfActivityTags_item*>> tmgbopoatListForActivity; 1068 1069 bool computeTeachersMinGapsBetweenOrderedPairOfActivityTags(QWidget* parent); 1070 1071 //2012-04-29 - Constraint activities occupy max different rooms 1072 class ActivitiesOccupyMaxDifferentRooms_item 1073 { 1074 public: 1075 //double weight; -> must be 100.0% 1076 QList<int> activitiesList; 1077 QSet<int> activitiesSet; 1078 int maxDifferentRooms; 1079 }; 1080 1081 //We need the references to the elements to be valid, so we need this to be a std::list 1082 extern std::list<ActivitiesOccupyMaxDifferentRooms_item> aomdrList; 1083 extern Matrix1D<QList<ActivitiesOccupyMaxDifferentRooms_item*>> aomdrListForActivity; 1084 1085 bool computeActivitiesOccupyMaxDifferentRooms(QWidget* parent); 1086 1087 //2013-09-14 - Constraint activities same room if consecutive 1088 class ActivitiesSameRoomIfConsecutive_item 1089 { 1090 public: 1091 //double weight; -> must be 100.0% 1092 QList<int> activitiesList; 1093 QSet<int> activitiesSet; 1094 }; 1095 1096 //We need the references to the elements to be valid, so we need this to be a std::list 1097 extern std::list<ActivitiesSameRoomIfConsecutive_item> asricList; 1098 extern Matrix1D<QList<ActivitiesSameRoomIfConsecutive_item*>> asricListForActivity; 1099 1100 bool computeActivitiesSameRoomIfConsecutive(QWidget* parent); 1101 1102 ///////////////////////////////////////////////////////////////////////// 1103 1104 //2019-11-20 1105 class SubgroupActivityTagMinHoursDaily_item 1106 { 1107 public: 1108 int activityTag; 1109 int minHoursDaily; 1110 bool allowEmptyDays; 1111 int durationOfActivitiesWithActivityTagForSubgroup; 1112 }; 1113 1114 //We need the references to the elements to be valid, so we need this to be a std::list 1115 extern std::list<SubgroupActivityTagMinHoursDaily_item> satmhdList; 1116 extern Matrix1D<QList<SubgroupActivityTagMinHoursDaily_item*>> satmhdListForSubgroup; 1117 extern bool haveStudentsActivityTagMinHoursDaily; 1118 1119 bool computeStudentsActivityTagMinHoursDaily(QWidget* parent); 1120 1121 //2019-11-20 1122 class TeacherActivityTagMinHoursDaily_item 1123 { 1124 public: 1125 int activityTag; 1126 int minHoursDaily; 1127 bool allowEmptyDays; 1128 int durationOfActivitiesWithActivityTagForTeacher; 1129 }; 1130 1131 //We need the references to the elements to be valid, so we need this to be a std::list 1132 extern std::list<TeacherActivityTagMinHoursDaily_item> tatmhdList; 1133 extern Matrix1D<QList<TeacherActivityTagMinHoursDaily_item*>> tatmhdListForTeacher; 1134 extern bool haveTeachersActivityTagMinHoursDaily; 1135 1136 bool computeTeachersActivityTagMinHoursDaily(QWidget* parent); 1137 1138 ///////////////////////////////////////////////////////////////////////// 1139 1140 extern Matrix1D<bool> fixedTimeActivity; 1141 extern Matrix1D<bool> fixedSpaceActivity; 1142 bool computeFixedActivities(QWidget* parent); 1143 1144 class GeneratePreTranslate: public QObject{ 1145 Q_OBJECT 1146 }; 1147 1148 #endif 1149