1 /* 2 File timeconstraint.h 3 */ 4 5 /*************************************************************************** 6 timeconstraint.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 TIMECONSTRAINT_H 23 #define TIMECONSTRAINT_H 24 25 #include <QCoreApplication> 26 27 #include "timetable_defs.h" 28 29 #include <QString> 30 #include <QList> 31 #include <QStringList> 32 33 class Rules; 34 class Solution; 35 class TimeConstraint; 36 class Activity; 37 class Teacher; 38 class Subject; 39 class ActivityTag; 40 class StudentsSet; 41 42 class FakeString; 43 44 class QWidget; 45 46 typedef QList<TimeConstraint*> TimeConstraintsList; 47 48 const int CONSTRAINT_GENERIC_TIME =0; 49 50 const int CONSTRAINT_BASIC_COMPULSORY_TIME =1; 51 const int CONSTRAINT_BREAK_TIMES =2; 52 53 const int CONSTRAINT_TEACHER_NOT_AVAILABLE_TIMES =3; 54 const int CONSTRAINT_TEACHERS_MAX_HOURS_DAILY =4; 55 const int CONSTRAINT_TEACHER_MAX_DAYS_PER_WEEK =5; 56 const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_WEEK =6; 57 const int CONSTRAINT_TEACHER_MAX_GAPS_PER_WEEK =7; 58 const int CONSTRAINT_TEACHER_MAX_HOURS_DAILY =8; 59 const int CONSTRAINT_TEACHERS_MAX_HOURS_CONTINUOUSLY =9; 60 const int CONSTRAINT_TEACHER_MAX_HOURS_CONTINUOUSLY =10; 61 62 const int CONSTRAINT_TEACHERS_MIN_HOURS_DAILY =11; 63 const int CONSTRAINT_TEACHER_MIN_HOURS_DAILY =12; 64 const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_DAY =13; 65 const int CONSTRAINT_TEACHER_MAX_GAPS_PER_DAY =14; 66 67 const int CONSTRAINT_STUDENTS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =15; 68 const int CONSTRAINT_STUDENTS_SET_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =16; 69 const int CONSTRAINT_STUDENTS_SET_NOT_AVAILABLE_TIMES =17; 70 const int CONSTRAINT_STUDENTS_MAX_GAPS_PER_WEEK =18; 71 const int CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_WEEK =19; 72 73 const int CONSTRAINT_STUDENTS_MAX_HOURS_DAILY =20; 74 const int CONSTRAINT_STUDENTS_SET_MAX_HOURS_DAILY =21; 75 const int CONSTRAINT_STUDENTS_MAX_HOURS_CONTINUOUSLY =22; 76 const int CONSTRAINT_STUDENTS_SET_MAX_HOURS_CONTINUOUSLY =23; 77 78 const int CONSTRAINT_STUDENTS_MIN_HOURS_DAILY =24; 79 const int CONSTRAINT_STUDENTS_SET_MIN_HOURS_DAILY =25; 80 81 const int CONSTRAINT_ACTIVITY_ENDS_STUDENTS_DAY =26; 82 const int CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME =27; 83 const int CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME =28; 84 const int CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING =29; 85 const int CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES =30; 86 const int CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS =31; 87 const int CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS =32; 88 const int CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES =33; 89 const int CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES =34; 90 const int CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR =35; 91 const int CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY =36; 92 const int CONSTRAINT_TWO_ACTIVITIES_CONSECUTIVE =37; 93 const int CONSTRAINT_TWO_ACTIVITIES_ORDERED =38; 94 const int CONSTRAINT_MIN_GAPS_BETWEEN_ACTIVITIES =39; 95 const int CONSTRAINT_SUBACTIVITIES_PREFERRED_TIME_SLOTS =40; 96 const int CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES =41; 97 98 const int CONSTRAINT_TEACHER_INTERVAL_MAX_DAYS_PER_WEEK =42; 99 const int CONSTRAINT_TEACHERS_INTERVAL_MAX_DAYS_PER_WEEK =43; 100 const int CONSTRAINT_STUDENTS_SET_INTERVAL_MAX_DAYS_PER_WEEK =44; 101 const int CONSTRAINT_STUDENTS_INTERVAL_MAX_DAYS_PER_WEEK =45; 102 103 const int CONSTRAINT_ACTIVITIES_END_STUDENTS_DAY =46; 104 105 const int CONSTRAINT_TWO_ACTIVITIES_GROUPED =47; 106 107 const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY =48; 108 const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY =49; 109 const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY =50; 110 const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY =51; 111 112 const int CONSTRAINT_TEACHERS_MAX_DAYS_PER_WEEK =52; 113 114 const int CONSTRAINT_THREE_ACTIVITIES_GROUPED =53; 115 const int CONSTRAINT_MAX_DAYS_BETWEEN_ACTIVITIES =54; 116 117 const int CONSTRAINT_TEACHERS_MIN_DAYS_PER_WEEK =55; 118 const int CONSTRAINT_TEACHER_MIN_DAYS_PER_WEEK =56; 119 120 const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MAX_HOURS_DAILY =57; 121 const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MAX_HOURS_DAILY =58; 122 const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MAX_HOURS_DAILY =59; 123 const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MAX_HOURS_DAILY =60; 124 125 const int CONSTRAINT_STUDENTS_MAX_GAPS_PER_DAY =61; 126 const int CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_DAY =62; 127 128 const int CONSTRAINT_ACTIVITIES_OCCUPY_MAX_TIME_SLOTS_FROM_SELECTION =63; 129 const int CONSTRAINT_ACTIVITIES_MAX_SIMULTANEOUS_IN_SELECTED_TIME_SLOTS =64; 130 131 const int CONSTRAINT_STUDENTS_SET_MAX_DAYS_PER_WEEK =65; 132 const int CONSTRAINT_STUDENTS_MAX_DAYS_PER_WEEK =66; 133 134 //2017-02-06 135 const int CONSTRAINT_TEACHER_MAX_SPAN_PER_DAY =67; 136 const int CONSTRAINT_TEACHERS_MAX_SPAN_PER_DAY =68; 137 const int CONSTRAINT_TEACHER_MIN_RESTING_HOURS =69; 138 const int CONSTRAINT_TEACHERS_MIN_RESTING_HOURS =70; 139 const int CONSTRAINT_STUDENTS_SET_MAX_SPAN_PER_DAY =71; 140 const int CONSTRAINT_STUDENTS_MAX_SPAN_PER_DAY =72; 141 const int CONSTRAINT_STUDENTS_SET_MIN_RESTING_HOURS =73; 142 const int CONSTRAINT_STUDENTS_MIN_RESTING_HOURS =74; 143 144 //2018-06-13 145 const int CONSTRAINT_TWO_ACTIVITIES_ORDERED_IF_SAME_DAY =75; 146 147 //2019-06-08 148 const int CONSTRAINT_STUDENTS_SET_MIN_GAPS_BETWEEN_ORDERED_PAIR_OF_ACTIVITY_TAGS =76; 149 const int CONSTRAINT_STUDENTS_MIN_GAPS_BETWEEN_ORDERED_PAIR_OF_ACTIVITY_TAGS =77; 150 const int CONSTRAINT_TEACHER_MIN_GAPS_BETWEEN_ORDERED_PAIR_OF_ACTIVITY_TAGS =78; 151 const int CONSTRAINT_TEACHERS_MIN_GAPS_BETWEEN_ORDERED_PAIR_OF_ACTIVITY_TAGS =79; 152 153 const int CONSTRAINT_ACTIVITY_TAGS_NOT_OVERLAPPING =80; 154 155 const int CONSTRAINT_ACTIVITIES_OCCUPY_MIN_TIME_SLOTS_FROM_SELECTION =81; 156 const int CONSTRAINT_ACTIVITIES_MIN_SIMULTANEOUS_IN_SELECTED_TIME_SLOTS =82; 157 158 const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MIN_HOURS_DAILY =83; 159 const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MIN_HOURS_DAILY =84; 160 const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MIN_HOURS_DAILY =85; 161 const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MIN_HOURS_DAILY =86; 162 163 const int CONSTRAINT_ACTIVITY_ENDS_TEACHERS_DAY =87; 164 const int CONSTRAINT_ACTIVITIES_END_TEACHERS_DAY =88; 165 166 //Begin for mornings-afternoons 167 const int CONSTRAINT_TEACHERS_MAX_HOURS_DAILY_REAL_DAYS =89; 168 const int CONSTRAINT_TEACHER_MAX_REAL_DAYS_PER_WEEK =90; 169 const int CONSTRAINT_TEACHER_MAX_HOURS_DAILY_REAL_DAYS =91; 170 171 const int CONSTRAINT_STUDENTS_MAX_HOURS_DAILY_REAL_DAYS =92; 172 const int CONSTRAINT_STUDENTS_SET_MAX_HOURS_DAILY_REAL_DAYS =93; 173 174 const int CONSTRAINT_TEACHERS_MAX_REAL_DAYS_PER_WEEK =94; 175 176 const int CONSTRAINT_TEACHERS_MIN_REAL_DAYS_PER_WEEK =95; 177 const int CONSTRAINT_TEACHER_MIN_REAL_DAYS_PER_WEEK =96; 178 179 const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MAX_HOURS_DAILY_REAL_DAYS =97; 180 const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MAX_HOURS_DAILY_REAL_DAYS =98; 181 const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MAX_HOURS_DAILY_REAL_DAYS =99; 182 const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MAX_HOURS_DAILY_REAL_DAYS=100; 183 184 const int CONSTRAINT_TEACHER_MAX_AFTERNOONS_PER_WEEK =101; 185 const int CONSTRAINT_TEACHERS_MAX_AFTERNOONS_PER_WEEK =102; 186 const int CONSTRAINT_TEACHER_MAX_MORNINGS_PER_WEEK =103; 187 const int CONSTRAINT_TEACHERS_MAX_MORNINGS_PER_WEEK =104; 188 189 const int CONSTRAINT_TEACHER_MAX_TWO_ACTIVITY_TAGS_PER_DAY_FROM_N1N2N3 =105; 190 const int CONSTRAINT_TEACHERS_MAX_TWO_ACTIVITY_TAGS_PER_DAY_FROM_N1N2N3 =106; 191 192 const int CONSTRAINT_TEACHERS_MIN_MORNINGS_PER_WEEK =107; 193 const int CONSTRAINT_TEACHER_MIN_MORNINGS_PER_WEEK =108; 194 const int CONSTRAINT_TEACHERS_MIN_AFTERNOONS_PER_WEEK =109; 195 const int CONSTRAINT_TEACHER_MIN_AFTERNOONS_PER_WEEK =110; 196 197 const int CONSTRAINT_TEACHER_MAX_TWO_CONSECUTIVE_MORNINGS =111; 198 const int CONSTRAINT_TEACHERS_MAX_TWO_CONSECUTIVE_MORNINGS =112; 199 const int CONSTRAINT_TEACHER_MAX_TWO_CONSECUTIVE_AFTERNOONS =113; 200 const int CONSTRAINT_TEACHERS_MAX_TWO_CONSECUTIVE_AFTERNOONS =114; 201 202 //Added in FET Algeria and Morocco on 2018-11-02 203 const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_REAL_DAY =115; 204 const int CONSTRAINT_TEACHER_MAX_GAPS_PER_REAL_DAY =116; 205 const int CONSTRAINT_STUDENTS_MAX_GAPS_PER_REAL_DAY =117; 206 const int CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_REAL_DAY =118; 207 208 //2019-07-03 209 const int CONSTRAINT_TEACHERS_MIN_HOURS_DAILY_REAL_DAYS =119; 210 const int CONSTRAINT_TEACHER_MIN_HOURS_DAILY_REAL_DAYS =120; 211 212 //2019-08-18 - for Said213 213 const int CONSTRAINT_TEACHERS_AFTERNOONS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =121; 214 const int CONSTRAINT_TEACHER_AFTERNOONS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =122; 215 216 const int CONSTRAINT_TEACHERS_MIN_HOURS_PER_MORNING =123; 217 const int CONSTRAINT_TEACHER_MIN_HOURS_PER_MORNING =124; 218 219 const int CONSTRAINT_TEACHER_MAX_SPAN_PER_REAL_DAY =125; 220 const int CONSTRAINT_TEACHERS_MAX_SPAN_PER_REAL_DAY =126; 221 const int CONSTRAINT_STUDENTS_SET_MAX_SPAN_PER_REAL_DAY =127; 222 const int CONSTRAINT_STUDENTS_MAX_SPAN_PER_REAL_DAY =128; 223 224 const int CONSTRAINT_TEACHER_MORNING_INTERVAL_MAX_DAYS_PER_WEEK =129; 225 const int CONSTRAINT_TEACHERS_MORNING_INTERVAL_MAX_DAYS_PER_WEEK =130; 226 227 const int CONSTRAINT_TEACHER_AFTERNOON_INTERVAL_MAX_DAYS_PER_WEEK =131; 228 const int CONSTRAINT_TEACHERS_AFTERNOON_INTERVAL_MAX_DAYS_PER_WEEK =132; 229 230 const int CONSTRAINT_STUDENTS_MIN_HOURS_PER_MORNING =133; 231 const int CONSTRAINT_STUDENTS_SET_MIN_HOURS_PER_MORNING =134; 232 233 const int CONSTRAINT_TEACHER_MAX_ZERO_GAPS_PER_AFTERNOON =135; 234 const int CONSTRAINT_TEACHERS_MAX_ZERO_GAPS_PER_AFTERNOON =136; 235 236 const int CONSTRAINT_STUDENTS_SET_MAX_AFTERNOONS_PER_WEEK =137; 237 const int CONSTRAINT_STUDENTS_MAX_AFTERNOONS_PER_WEEK =138; 238 const int CONSTRAINT_STUDENTS_SET_MAX_MORNINGS_PER_WEEK =139; 239 const int CONSTRAINT_STUDENTS_MAX_MORNINGS_PER_WEEK =140; 240 241 const int CONSTRAINT_STUDENTS_MIN_MORNINGS_PER_WEEK =141; 242 const int CONSTRAINT_STUDENTS_SET_MIN_MORNINGS_PER_WEEK =142; 243 const int CONSTRAINT_STUDENTS_MIN_AFTERNOONS_PER_WEEK =143; 244 const int CONSTRAINT_STUDENTS_SET_MIN_AFTERNOONS_PER_WEEK =144; 245 246 const int CONSTRAINT_STUDENTS_SET_MORNING_INTERVAL_MAX_DAYS_PER_WEEK =145; 247 const int CONSTRAINT_STUDENTS_MORNING_INTERVAL_MAX_DAYS_PER_WEEK =146; 248 const int CONSTRAINT_STUDENTS_SET_AFTERNOON_INTERVAL_MAX_DAYS_PER_WEEK =147; 249 const int CONSTRAINT_STUDENTS_AFTERNOON_INTERVAL_MAX_DAYS_PER_WEEK =148; 250 251 const int CONSTRAINT_TEACHER_MAX_HOURS_PER_ALL_AFTERNOONS =149; 252 const int CONSTRAINT_TEACHERS_MAX_HOURS_PER_ALL_AFTERNOONS =150; 253 254 const int CONSTRAINT_STUDENTS_SET_MAX_HOURS_PER_ALL_AFTERNOONS =151; 255 const int CONSTRAINT_STUDENTS_MAX_HOURS_PER_ALL_AFTERNOONS =152; 256 257 const int CONSTRAINT_TEACHER_MIN_RESTING_HOURS_BETWEEN_MORNING_AND_AFTERNOON =153; 258 const int CONSTRAINT_TEACHERS_MIN_RESTING_HOURS_BETWEEN_MORNING_AND_AFTERNOON =154; 259 const int CONSTRAINT_STUDENTS_SET_MIN_RESTING_HOURS_BETWEEN_MORNING_AND_AFTERNOON =155; 260 const int CONSTRAINT_STUDENTS_MIN_RESTING_HOURS_BETWEEN_MORNING_AND_AFTERNOON =156; 261 262 //2020-07-24 - for lakhdarbe 263 const int CONSTRAINT_STUDENTS_SET_AFTERNOONS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =157; 264 const int CONSTRAINT_STUDENTS_AFTERNOONS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =158; 265 266 //Added in FET Algeria and Morocco on 2020-07-29 267 const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_WEEK_FOR_REAL_DAYS =159; 268 const int CONSTRAINT_TEACHER_MAX_GAPS_PER_WEEK_FOR_REAL_DAYS =160; 269 const int CONSTRAINT_STUDENTS_MAX_GAPS_PER_WEEK_FOR_REAL_DAYS =161; 270 const int CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_WEEK_FOR_REAL_DAYS =162; 271 272 const int CONSTRAINT_STUDENTS_SET_MAX_REAL_DAYS_PER_WEEK =163; 273 const int CONSTRAINT_STUDENTS_MAX_REAL_DAYS_PER_WEEK =164; 274 //End for mornings-afternoons 275 276 //For block-planning mode 277 const int CONSTRAINT_MAX_TOTAL_ACTIVITIES_FROM_SET_IN_SELECTED_TIME_SLOTS =165; 278 279 const int CONSTRAINT_MAX_GAPS_BETWEEN_ACTIVITIES =166; 280 281 //For terms mode 282 const int CONSTRAINT_ACTIVITIES_MAX_IN_A_TERM =167; 283 const int CONSTRAINT_ACTIVITIES_OCCUPY_MAX_TERMS =168; 284 285 //Begin for mornings-afternoons - 2021-08-12 286 const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_MORNING_AND_AFTERNOON =169; 287 const int CONSTRAINT_TEACHER_MAX_GAPS_PER_MORNING_AND_AFTERNOON =170; 288 289 const int CONSTRAINT_TEACHERS_MORNINGS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =171; 290 const int CONSTRAINT_TEACHER_MORNINGS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =172; 291 const int CONSTRAINT_STUDENTS_SET_MORNINGS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =173; 292 const int CONSTRAINT_STUDENTS_MORNINGS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =174; 293 //End for mornings-afternoons 294 295 const int CONSTRAINT_TWO_SETS_OF_ACTIVITIES_ORDERED =175; 296 297 //Begin for mornings-afternoons - 2021-09-26 298 const int CONSTRAINT_TEACHERS_MAX_THREE_CONSECUTIVE_DAYS =176; 299 const int CONSTRAINT_TEACHER_MAX_THREE_CONSECUTIVE_DAYS =177; 300 //End for mornings-afternoons - 2021-09-26 301 302 QString getActivityDetailedDescription(Rules& r, int id); 303 304 /** 305 This class represents a time constraint 306 */ 307 class TimeConstraint{ 308 Q_DECLARE_TR_FUNCTIONS(TimeConstraint) 309 310 public: 311 /** 312 The percentage weight of this constraint, 100% compulsory, 0% non-compulsory 313 */ 314 double weightPercentage; 315 316 bool active; 317 318 QString comments; 319 320 /** 321 Specifies the type of this constraint (using the above constants). 322 */ 323 int type; 324 325 /** 326 True for mandatory constraints, false for non-mandatory constraints. 327 */ 328 //bool compulsory; 329 330 /** 331 Dummy constructor - needed for the static array of constraints. 332 Any other use should be avoided. 333 */ 334 TimeConstraint(); 335 336 virtual ~TimeConstraint()=0; 337 338 /** 339 DEPRECATED COMMENT BELOW: 340 Constructor - please note that the maximum allowed weight is 100.0 341 The reason: unallocated activities must have very big conflict weight, 342 and any other constraints must have much more lower weight, 343 so that the timetable can evolve when starting with uninitialized activities. 344 */ 345 TimeConstraint(double wp); 346 347 bool canBeUsedInOfficialMode(); 348 bool canBeUsedInMorningsAfternoonsMode(); 349 bool canBeUsedInBlockPlanningMode(); 350 bool canBeUsedInTermsMode(); 351 352 /** 353 The function that calculates the fitness of a solution, according to this 354 constraint. We need the solution to compute this fitness factor. 355 If conflictsString!=nullptr, it will be initialized with a text explaining 356 where this constraint is broken. 357 */ 358 virtual double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr)=0; 359 360 /** 361 Returns an XML description of this constraint 362 */ 363 virtual QString getXmlDescription(Rules& r)=0; 364 365 /** 366 Computes the internal structure for this constraint. 367 368 It returns false if the constraint is an activity related 369 one and it depends on only inactive activities. 370 */ 371 virtual bool computeInternalStructure(QWidget* parent, Rules& r)=0; 372 373 virtual bool hasInactiveActivities(Rules& r)=0; 374 375 /** 376 Returns a small description string for this constraint 377 */ 378 virtual QString getDescription(Rules& r)=0; 379 380 /** 381 Returns a detailed description string for this constraint 382 */ 383 virtual QString getDetailedDescription(Rules& r)=0; 384 385 /** 386 Returns true if this constraint is related to this activity 387 */ 388 virtual bool isRelatedToActivity(Rules& r, Activity* a)=0; 389 390 /** 391 Returns true if this constraint is related to this teacher 392 */ 393 virtual bool isRelatedToTeacher(Teacher* t)=0; 394 395 /** 396 Returns true if this constraint is related to this subject 397 */ 398 virtual bool isRelatedToSubject(Subject* s)=0; 399 400 /** 401 Returns true if this constraint is related to this activity tag 402 */ 403 virtual bool isRelatedToActivityTag(ActivityTag* s)=0; 404 405 /** 406 Returns true if this constraint is related to this students set 407 */ 408 virtual bool isRelatedToStudentsSet(Rules& r, StudentsSet* s)=0; 409 410 virtual bool hasWrongDayOrHour(Rules& r)=0; 411 virtual bool canRepairWrongDayOrHour(Rules& r)=0; 412 virtual bool repairWrongDayOrHour(Rules& r)=0; 413 }; 414 415 /** 416 This class comprises all the basic compulsory constraints (constraints 417 which must be fulfilled for any timetable) - the time allocation part 418 */ 419 class ConstraintBasicCompulsoryTime: public TimeConstraint{ 420 Q_DECLARE_TR_FUNCTIONS(ConstraintBasicCompulsoryTime) 421 422 public: 423 ConstraintBasicCompulsoryTime(); 424 425 ConstraintBasicCompulsoryTime(double wp); 426 427 bool computeInternalStructure(QWidget* parent, Rules& r); 428 429 bool hasInactiveActivities(Rules& r); 430 431 QString getXmlDescription(Rules& r); 432 433 QString getDescription(Rules& r); 434 435 QString getDetailedDescription(Rules& r); 436 437 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 438 439 bool isRelatedToActivity(Rules& r, Activity* a); 440 441 bool isRelatedToTeacher(Teacher* t); 442 443 bool isRelatedToSubject(Subject* s); 444 445 bool isRelatedToActivityTag(ActivityTag* s); 446 447 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 448 449 bool hasWrongDayOrHour(Rules& r); 450 bool canRepairWrongDayOrHour(Rules& r); 451 bool repairWrongDayOrHour(Rules& r); 452 }; 453 454 class ConstraintTeacherNotAvailableTimes: public TimeConstraint{ 455 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherNotAvailableTimes) 456 457 public: 458 QList<int> days; 459 QList<int> hours; 460 461 /** 462 The teacher's name 463 */ 464 QString teacher; 465 466 /** 467 The teacher's id, or index in the rules 468 */ 469 int teacher_ID; 470 471 ConstraintTeacherNotAvailableTimes(); 472 473 ConstraintTeacherNotAvailableTimes(double wp, const QString& tn, QList<int> d, QList<int> h); 474 475 bool computeInternalStructure(QWidget* parent, Rules& r); 476 477 bool hasInactiveActivities(Rules& r); 478 479 QString getXmlDescription(Rules& r); 480 481 QString getDescription(Rules& r); 482 483 QString getDetailedDescription(Rules& r); 484 485 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 486 487 bool isRelatedToActivity(Rules& r, Activity* a); 488 489 bool isRelatedToTeacher(Teacher* t); 490 491 bool isRelatedToSubject(Subject* s); 492 493 bool isRelatedToActivityTag(ActivityTag* s); 494 495 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 496 497 bool hasWrongDayOrHour(Rules& r); 498 bool canRepairWrongDayOrHour(Rules& r); 499 bool repairWrongDayOrHour(Rules& r); 500 }; 501 502 class ConstraintStudentsSetNotAvailableTimes: public TimeConstraint{ 503 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetNotAvailableTimes) 504 505 public: 506 QList<int> days; 507 QList<int> hours; 508 509 /** 510 The name of the students 511 */ 512 QString students; 513 514 /** 515 The subgroups involved in this constraint 516 */ 517 QList<int> iSubgroupsList; 518 519 ConstraintStudentsSetNotAvailableTimes(); 520 521 ConstraintStudentsSetNotAvailableTimes(double wp, const QString& sn, QList<int> d, QList<int> h); 522 523 bool computeInternalStructure(QWidget* parent, Rules& r); 524 525 bool hasInactiveActivities(Rules& r); 526 527 QString getXmlDescription(Rules& r); 528 529 QString getDescription(Rules& r); 530 531 QString getDetailedDescription(Rules& r); 532 533 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 534 535 bool isRelatedToActivity(Rules& r, Activity* a); 536 537 bool isRelatedToTeacher(Teacher* t); 538 539 bool isRelatedToSubject(Subject* s); 540 541 bool isRelatedToActivityTag(ActivityTag* s); 542 543 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 544 545 bool hasWrongDayOrHour(Rules& r); 546 bool canRepairWrongDayOrHour(Rules& r); 547 bool repairWrongDayOrHour(Rules& r); 548 }; 549 550 class ConstraintActivitiesSameStartingTime: public TimeConstraint{ 551 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameStartingTime) 552 553 public: 554 /** 555 The number of activities involved in this constraint 556 */ 557 int n_activities; 558 559 /** 560 The activities involved in this constraint (id) 561 */ 562 QList<int> activitiesId; 563 //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME]; 564 565 /** 566 The number of activities involved in this constraint - internal structure 567 */ 568 int _n_activities; 569 570 /** 571 The activities involved in this constraint (indexes in the rules) - internal structure 572 */ 573 //int _activities[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME]; 574 QList<int> _activities; 575 576 ConstraintActivitiesSameStartingTime(); 577 578 /** 579 Constructor, using: 580 the weight, the number of activities and the list of activities' id-s. 581 */ 582 //ConstraintActivitiesSameStartingTime(double wp, int n_act, const int act[]); 583 ConstraintActivitiesSameStartingTime(double wp, int n_act, const QList<int>& act); 584 585 bool computeInternalStructure(QWidget* parent, Rules& r); 586 587 bool hasInactiveActivities(Rules& r); 588 589 QString getXmlDescription(Rules& r); 590 591 QString getDescription(Rules& r); 592 593 QString getDetailedDescription(Rules& r); 594 595 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 596 597 void removeUseless(Rules& r); 598 599 bool isRelatedToActivity(Rules& r, Activity* a); 600 601 bool isRelatedToTeacher(Teacher* t); 602 603 bool isRelatedToSubject(Subject* s); 604 605 bool isRelatedToActivityTag(ActivityTag* s); 606 607 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 608 609 bool hasWrongDayOrHour(Rules& r); 610 bool canRepairWrongDayOrHour(Rules& r); 611 bool repairWrongDayOrHour(Rules& r); 612 }; 613 614 /** 615 This is a constraint. 616 It aims at scheduling a set of activities so that they do not overlap. 617 The number of conflicts is considered the number of overlapping 618 hours. 619 */ 620 class ConstraintActivitiesNotOverlapping: public TimeConstraint{ 621 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesNotOverlapping) 622 623 public: 624 /** 625 The number of activities involved in this constraint 626 */ 627 int n_activities; 628 629 /** 630 The activities involved in this constraint (id) 631 */ 632 QList<int> activitiesId; 633 //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING]; 634 635 /** 636 The number of activities involved in this constraint - internal structure 637 */ 638 int _n_activities; 639 640 /** 641 The activities involved in this constraint (index in the rules) - internal structure 642 */ 643 //int _activities[MAX_CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING]; 644 QList<int> _activities; 645 646 ConstraintActivitiesNotOverlapping(); 647 648 /** 649 Constructor, using: 650 the weight, the number of activities and the list of activities. 651 */ 652 ConstraintActivitiesNotOverlapping(double wp, int n_act, const QList<int>& act); 653 654 bool computeInternalStructure(QWidget* parent, Rules& r); 655 656 bool hasInactiveActivities(Rules& r); 657 658 QString getXmlDescription(Rules& r); 659 660 QString getDescription(Rules& r); 661 662 QString getDetailedDescription(Rules& r); 663 664 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 665 666 void removeUseless(Rules &r); 667 668 bool isRelatedToActivity(Rules& r, Activity* a); 669 670 bool isRelatedToTeacher(Teacher* t); 671 672 bool isRelatedToSubject(Subject* s); 673 674 bool isRelatedToActivityTag(ActivityTag* s); 675 676 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 677 678 bool hasWrongDayOrHour(Rules& r); 679 bool canRepairWrongDayOrHour(Rules& r); 680 bool repairWrongDayOrHour(Rules& r); 681 }; 682 683 class ConstraintActivityTagsNotOverlapping: public TimeConstraint{ 684 Q_DECLARE_TR_FUNCTIONS(ConstraintActivityTagsNotOverlapping) 685 686 public: 687 QStringList activityTagsNames; 688 689 //internal 690 QList<int> activityTagsIndices; 691 692 QList<QList<int>> activitiesIndicesLists; 693 694 ConstraintActivityTagsNotOverlapping(); 695 696 ConstraintActivityTagsNotOverlapping(double wp, const QStringList& atl); 697 698 bool computeInternalStructure(QWidget* parent, Rules& r); 699 700 bool hasInactiveActivities(Rules& r); 701 702 QString getXmlDescription(Rules& r); 703 704 QString getDescription(Rules& r); 705 706 QString getDetailedDescription(Rules& r); 707 708 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 709 710 bool isRelatedToActivity(Rules& r, Activity* a); 711 712 bool isRelatedToTeacher(Teacher* t); 713 714 bool isRelatedToSubject(Subject* s); 715 716 bool isRelatedToActivityTag(ActivityTag* s); 717 718 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 719 720 bool hasWrongDayOrHour(Rules& r); 721 bool canRepairWrongDayOrHour(Rules& r); 722 bool repairWrongDayOrHour(Rules& r); 723 }; 724 725 /** 726 This is a constraint. 727 It aims at scheduling a set of activities so that they 728 have a minimum of N days between any two of them. 729 */ 730 class ConstraintMinDaysBetweenActivities: public TimeConstraint{ 731 Q_DECLARE_TR_FUNCTIONS(ConstraintMinDaysBetweenActivities) 732 733 public: 734 bool consecutiveIfSameDay; 735 736 /** 737 The number of activities involved in this constraint 738 */ 739 int n_activities; 740 741 /** 742 The activities involved in this constraint (id) 743 */ 744 QList<int> activitiesId; 745 //int activitiesId[MAX_CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES]; 746 747 /** 748 The number of minimum days between each 2 activities 749 */ 750 int minDays; 751 752 //internal structure (redundant) 753 754 /** 755 The number of activities involved in this constraint - internal structure 756 */ 757 int _n_activities; 758 759 /** 760 The activities involved in this constraint (index in the rules) - internal structure 761 */ 762 QList<int> _activities; 763 //int _activities[MAX_CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES]; 764 765 ConstraintMinDaysBetweenActivities(); 766 767 /** 768 Constructor, using: 769 the weight, the number of activities and the list of activities. 770 */ 771 //ConstraintMinDaysBetweenActivities(double wp, bool adjacentIfBroken, int n_act, const int act[], int n); 772 ConstraintMinDaysBetweenActivities(double wp, bool adjacentIfBroken, int n_act, const QList<int>& act, int n); 773 774 /** 775 Comparison operator - to be sure that we do not introduce duplicates 776 */ 777 bool operator==(ConstraintMinDaysBetweenActivities& c); 778 779 bool computeInternalStructure(QWidget* parent, Rules& r); 780 781 bool hasInactiveActivities(Rules& r); 782 783 QString getXmlDescription(Rules& r); 784 785 QString getDescription(Rules& r); 786 787 QString getDetailedDescription(Rules& r); 788 789 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 790 791 void removeUseless(Rules &r); 792 793 bool isRelatedToActivity(Rules& r, Activity* a); 794 795 bool isRelatedToTeacher(Teacher* t); 796 797 bool isRelatedToSubject(Subject* s); 798 799 bool isRelatedToActivityTag(ActivityTag* s); 800 801 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 802 803 bool hasWrongDayOrHour(Rules& r); 804 bool canRepairWrongDayOrHour(Rules& r); 805 bool repairWrongDayOrHour(Rules& r); 806 }; 807 808 class ConstraintMaxDaysBetweenActivities: public TimeConstraint{ 809 Q_DECLARE_TR_FUNCTIONS(ConstraintMaxDaysBetweenActivities) 810 811 public: 812 /** 813 The number of activities involved in this constraint 814 */ 815 int n_activities; 816 817 /** 818 The activities involved in this constraint (id) 819 */ 820 QList<int> activitiesId; 821 822 /** 823 The number of maximum days between each 2 activities 824 */ 825 int maxDays; 826 827 //internal structure (redundant) 828 829 /** 830 The number of activities involved in this constraint - internal structure 831 */ 832 int _n_activities; 833 834 /** 835 The activities involved in this constraint (index in the rules) - internal structure 836 */ 837 QList<int> _activities; 838 839 ConstraintMaxDaysBetweenActivities(); 840 841 /** 842 Constructor, using: 843 the weight, the number of activities and the list of activities. 844 */ 845 ConstraintMaxDaysBetweenActivities(double wp, int n_act, const QList<int>& act, int n); 846 847 bool computeInternalStructure(QWidget* parent, Rules& r); 848 849 bool hasInactiveActivities(Rules& r); 850 851 QString getXmlDescription(Rules& r); 852 853 QString getDescription(Rules& r); 854 855 QString getDetailedDescription(Rules& r); 856 857 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 858 859 void removeUseless(Rules &r); 860 861 bool isRelatedToActivity(Rules& r, Activity* a); 862 863 bool isRelatedToTeacher(Teacher* t); 864 865 bool isRelatedToSubject(Subject* s); 866 867 bool isRelatedToActivityTag(ActivityTag* s); 868 869 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 870 871 bool hasWrongDayOrHour(Rules& r); 872 bool canRepairWrongDayOrHour(Rules& r); 873 bool repairWrongDayOrHour(Rules& r); 874 }; 875 876 class ConstraintMinGapsBetweenActivities: public TimeConstraint{ 877 Q_DECLARE_TR_FUNCTIONS(ConstraintMinGapsBetweenActivities) 878 879 public: 880 /** 881 The number of activities involved in this constraint 882 */ 883 int n_activities; 884 885 /** 886 The activities involved in this constraint (id) 887 */ 888 QList<int> activitiesId; 889 890 /** 891 The number of minimum gaps between each 2 activities, if on the same day 892 */ 893 int minGaps; 894 895 //internal structure (redundant) 896 897 /** 898 The number of activities involved in this constraint - internal structure 899 */ 900 int _n_activities; 901 902 /** 903 The activities involved in this constraint (index in the rules) - internal structure 904 */ 905 QList<int> _activities; 906 907 ConstraintMinGapsBetweenActivities(); 908 909 /** 910 Constructor, using: 911 the weight, the number of activities and the list of activities. 912 */ 913 //ConstraintMinGapsBetweenActivities(double wp, int n_act, const int act[], int ngaps); 914 ConstraintMinGapsBetweenActivities(double wp, int n_act, const QList<int>& actList, int ngaps); 915 916 bool computeInternalStructure(QWidget* parent, Rules& r); 917 918 bool hasInactiveActivities(Rules& r); 919 920 QString getXmlDescription(Rules& r); 921 922 QString getDescription(Rules& r); 923 924 QString getDetailedDescription(Rules& r); 925 926 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 927 928 void removeUseless(Rules &r); 929 930 bool isRelatedToActivity(Rules& r, Activity* a); 931 932 bool isRelatedToTeacher(Teacher* t); 933 934 bool isRelatedToSubject(Subject* s); 935 936 bool isRelatedToActivityTag(ActivityTag* s); 937 938 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 939 940 bool hasWrongDayOrHour(Rules& r); 941 bool canRepairWrongDayOrHour(Rules& r); 942 bool repairWrongDayOrHour(Rules& r); 943 }; 944 945 class ConstraintMaxGapsBetweenActivities: public TimeConstraint{ 946 Q_DECLARE_TR_FUNCTIONS(ConstraintMaxGapsBetweenActivities) 947 948 public: 949 /** 950 The number of activities involved in this constraint 951 */ 952 int n_activities; 953 954 /** 955 The activities involved in this constraint (id) 956 */ 957 QList<int> activitiesId; 958 959 /** 960 The number of maximum gaps between each 2 activities, if on the same day 961 */ 962 int maxGaps; 963 964 //internal structure (redundant) 965 966 /** 967 The number of activities involved in this constraint - internal structure 968 */ 969 int _n_activities; 970 971 /** 972 The activities involved in this constraint (index in the rules) - internal structure 973 */ 974 QList<int> _activities; 975 976 ConstraintMaxGapsBetweenActivities(); 977 978 /** 979 Constructor, using: 980 the weight, the number of activities and the list of activities. 981 */ 982 //ConstraintMaxGapsBetweenActivities(double wp, int n_act, const int act[], int ngaps); 983 ConstraintMaxGapsBetweenActivities(double wp, int n_act, const QList<int>& actList, int ngaps); 984 985 bool computeInternalStructure(QWidget* parent, Rules& r); 986 987 bool hasInactiveActivities(Rules& r); 988 989 QString getXmlDescription(Rules& r); 990 991 QString getDescription(Rules& r); 992 993 QString getDetailedDescription(Rules& r); 994 995 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 996 997 void removeUseless(Rules &r); 998 999 bool isRelatedToActivity(Rules& r, Activity* a); 1000 1001 bool isRelatedToTeacher(Teacher* t); 1002 1003 bool isRelatedToSubject(Subject* s); 1004 1005 bool isRelatedToActivityTag(ActivityTag* s); 1006 1007 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1008 1009 bool hasWrongDayOrHour(Rules& r); 1010 bool canRepairWrongDayOrHour(Rules& r); 1011 bool repairWrongDayOrHour(Rules& r); 1012 }; 1013 1014 /** 1015 This is a constraint, aimed at obtaining timetables 1016 which do not allow more than X hours in a day for any teacher 1017 */ 1018 class ConstraintTeachersMaxHoursDaily: public TimeConstraint{ 1019 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxHoursDaily) 1020 1021 public: 1022 /** 1023 The maximum hours daily 1024 */ 1025 int maxHoursDaily; 1026 1027 ConstraintTeachersMaxHoursDaily(); 1028 1029 ConstraintTeachersMaxHoursDaily(double wp, int maxhours); 1030 1031 QString getXmlDescription(Rules& r); 1032 1033 bool computeInternalStructure(QWidget* parent, Rules& r); 1034 1035 bool hasInactiveActivities(Rules& r); 1036 1037 QString getDescription(Rules& r); 1038 1039 QString getDetailedDescription(Rules& r); 1040 1041 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1042 1043 bool isRelatedToActivity(Rules& r, Activity* a); 1044 1045 bool isRelatedToTeacher(Teacher* t); 1046 1047 bool isRelatedToSubject(Subject* s); 1048 1049 bool isRelatedToActivityTag(ActivityTag* s); 1050 1051 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1052 1053 bool hasWrongDayOrHour(Rules& r); 1054 bool canRepairWrongDayOrHour(Rules& r); 1055 bool repairWrongDayOrHour(Rules& r); 1056 }; 1057 1058 class ConstraintTeacherMaxHoursDaily: public TimeConstraint{ 1059 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxHoursDaily) 1060 1061 public: 1062 /** 1063 The maximum hours daily 1064 */ 1065 int maxHoursDaily; 1066 1067 QString teacherName; 1068 1069 int teacher_ID; 1070 1071 ConstraintTeacherMaxHoursDaily(); 1072 1073 ConstraintTeacherMaxHoursDaily(double wp, int maxhours, const QString& teacher); 1074 1075 QString getXmlDescription(Rules& r); 1076 1077 bool computeInternalStructure(QWidget* parent, Rules& r); 1078 1079 bool hasInactiveActivities(Rules& r); 1080 1081 QString getDescription(Rules& r); 1082 1083 QString getDetailedDescription(Rules& r); 1084 1085 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1086 1087 bool isRelatedToActivity(Rules& r, Activity* a); 1088 1089 bool isRelatedToTeacher(Teacher* t); 1090 1091 bool isRelatedToSubject(Subject* s); 1092 1093 bool isRelatedToActivityTag(ActivityTag* s); 1094 1095 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1096 1097 bool hasWrongDayOrHour(Rules& r); 1098 bool canRepairWrongDayOrHour(Rules& r); 1099 bool repairWrongDayOrHour(Rules& r); 1100 }; 1101 1102 /** 1103 This is a constraint, aimed at obtaining timetables 1104 which do not allow more than X hours in a row for any teacher 1105 */ 1106 class ConstraintTeachersMaxHoursContinuously: public TimeConstraint{ 1107 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxHoursContinuously) 1108 1109 public: 1110 /** 1111 The maximum hours continuously 1112 */ 1113 int maxHoursContinuously; 1114 1115 ConstraintTeachersMaxHoursContinuously(); 1116 1117 ConstraintTeachersMaxHoursContinuously(double wp, int maxhours); 1118 1119 QString getXmlDescription(Rules& r); 1120 1121 bool computeInternalStructure(QWidget* parent, Rules& r); 1122 1123 bool hasInactiveActivities(Rules& r); 1124 1125 QString getDescription(Rules& r); 1126 1127 QString getDetailedDescription(Rules& r); 1128 1129 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1130 1131 bool isRelatedToActivity(Rules& r, Activity* a); 1132 1133 bool isRelatedToTeacher(Teacher* t); 1134 1135 bool isRelatedToSubject(Subject* s); 1136 1137 bool isRelatedToActivityTag(ActivityTag* s); 1138 1139 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1140 1141 bool hasWrongDayOrHour(Rules& r); 1142 bool canRepairWrongDayOrHour(Rules& r); 1143 bool repairWrongDayOrHour(Rules& r); 1144 }; 1145 1146 class ConstraintTeacherMaxHoursContinuously: public TimeConstraint{ 1147 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxHoursContinuously) 1148 1149 public: 1150 /** 1151 The maximum hours continuously 1152 */ 1153 int maxHoursContinuously; 1154 1155 QString teacherName; 1156 1157 int teacher_ID; 1158 1159 ConstraintTeacherMaxHoursContinuously(); 1160 1161 ConstraintTeacherMaxHoursContinuously(double wp, int maxhours, const QString& teacher); 1162 1163 QString getXmlDescription(Rules& r); 1164 1165 bool computeInternalStructure(QWidget* parent, Rules& r); 1166 1167 bool hasInactiveActivities(Rules& r); 1168 1169 QString getDescription(Rules& r); 1170 1171 QString getDetailedDescription(Rules& r); 1172 1173 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1174 1175 bool isRelatedToActivity(Rules& r, Activity* a); 1176 1177 bool isRelatedToTeacher(Teacher* t); 1178 1179 bool isRelatedToSubject(Subject* s); 1180 1181 bool isRelatedToActivityTag(ActivityTag* s); 1182 1183 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1184 1185 bool hasWrongDayOrHour(Rules& r); 1186 bool canRepairWrongDayOrHour(Rules& r); 1187 bool repairWrongDayOrHour(Rules& r); 1188 }; 1189 1190 class ConstraintTeachersActivityTagMaxHoursContinuously: public TimeConstraint{ 1191 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMaxHoursContinuously) 1192 1193 public: 1194 /** 1195 The maximum hours continuously 1196 */ 1197 int maxHoursContinuously; 1198 1199 QString activityTagName; 1200 1201 int activityTagIndex; 1202 1203 QList<int> canonicalTeachersList; 1204 1205 ConstraintTeachersActivityTagMaxHoursContinuously(); 1206 1207 ConstraintTeachersActivityTagMaxHoursContinuously(double wp, int maxhours, const QString& activityTag); 1208 1209 QString getXmlDescription(Rules& r); 1210 1211 bool computeInternalStructure(QWidget* parent, Rules& r); 1212 1213 bool hasInactiveActivities(Rules& r); 1214 1215 QString getDescription(Rules& r); 1216 1217 QString getDetailedDescription(Rules& r); 1218 1219 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1220 1221 bool isRelatedToActivity(Rules& r, Activity* a); 1222 1223 bool isRelatedToTeacher(Teacher* t); 1224 1225 bool isRelatedToSubject(Subject* s); 1226 1227 bool isRelatedToActivityTag(ActivityTag* s); 1228 1229 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1230 1231 bool hasWrongDayOrHour(Rules& r); 1232 bool canRepairWrongDayOrHour(Rules& r); 1233 bool repairWrongDayOrHour(Rules& r); 1234 }; 1235 1236 class ConstraintTeacherActivityTagMaxHoursContinuously: public TimeConstraint{ 1237 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMaxHoursContinuously) 1238 1239 public: 1240 /** 1241 The maximum hours continuously 1242 */ 1243 int maxHoursContinuously; 1244 1245 QString teacherName; 1246 1247 QString activityTagName; 1248 1249 int teacher_ID; 1250 1251 int activityTagIndex; 1252 1253 QList<int> canonicalTeachersList; 1254 1255 ConstraintTeacherActivityTagMaxHoursContinuously(); 1256 1257 ConstraintTeacherActivityTagMaxHoursContinuously(double wp, int maxhours, const QString& teacher, const QString& activityTag); 1258 1259 QString getXmlDescription(Rules& r); 1260 1261 bool computeInternalStructure(QWidget* parent, Rules& r); 1262 1263 bool hasInactiveActivities(Rules& r); 1264 1265 QString getDescription(Rules& r); 1266 1267 QString getDetailedDescription(Rules& r); 1268 1269 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1270 1271 bool isRelatedToActivity(Rules& r, Activity* a); 1272 1273 bool isRelatedToTeacher(Teacher* t); 1274 1275 bool isRelatedToSubject(Subject* s); 1276 1277 bool isRelatedToActivityTag(ActivityTag* s); 1278 1279 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1280 1281 bool hasWrongDayOrHour(Rules& r); 1282 bool canRepairWrongDayOrHour(Rules& r); 1283 bool repairWrongDayOrHour(Rules& r); 1284 }; 1285 1286 /** 1287 This is a constraint. 1288 The resulting timetable must respect the requirement 1289 that this teacher must not have too much working 1290 days per week. 1291 */ 1292 class ConstraintTeacherMaxDaysPerWeek: public TimeConstraint{ 1293 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxDaysPerWeek) 1294 1295 public: 1296 /** 1297 The number of maximum allowed working days per week (-1 for don't care) 1298 */ 1299 int maxDaysPerWeek; 1300 1301 /** 1302 The teacher's name 1303 */ 1304 QString teacherName; 1305 1306 /** 1307 The teacher's id, or index in the rules 1308 */ 1309 int teacher_ID; 1310 1311 ConstraintTeacherMaxDaysPerWeek(); 1312 1313 ConstraintTeacherMaxDaysPerWeek(double wp, int maxnd, const QString& t); 1314 1315 bool computeInternalStructure(QWidget* parent, Rules& r); 1316 1317 bool hasInactiveActivities(Rules& r); 1318 1319 QString getXmlDescription(Rules& r); 1320 1321 QString getDescription(Rules& r); 1322 1323 QString getDetailedDescription(Rules& r); 1324 1325 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1326 1327 bool isRelatedToActivity(Rules& r, Activity* a); 1328 1329 bool isRelatedToTeacher(Teacher* t); 1330 1331 bool isRelatedToSubject(Subject* s); 1332 1333 bool isRelatedToActivityTag(ActivityTag* s); 1334 1335 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1336 1337 bool hasWrongDayOrHour(Rules& r); 1338 bool canRepairWrongDayOrHour(Rules& r); 1339 bool repairWrongDayOrHour(Rules& r); 1340 }; 1341 1342 class ConstraintTeachersMaxDaysPerWeek: public TimeConstraint{ 1343 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxDaysPerWeek) 1344 1345 public: 1346 /** 1347 The number of maximum allowed working days per week (-1 for don't care) 1348 */ 1349 int maxDaysPerWeek; 1350 1351 ConstraintTeachersMaxDaysPerWeek(); 1352 1353 ConstraintTeachersMaxDaysPerWeek(double wp, int maxnd); 1354 1355 bool computeInternalStructure(QWidget* parent, Rules& r); 1356 1357 bool hasInactiveActivities(Rules& r); 1358 1359 QString getXmlDescription(Rules& r); 1360 1361 QString getDescription(Rules& r); 1362 1363 QString getDetailedDescription(Rules& r); 1364 1365 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1366 1367 bool isRelatedToActivity(Rules& r, Activity* a); 1368 1369 bool isRelatedToTeacher(Teacher* t); 1370 1371 bool isRelatedToSubject(Subject* s); 1372 1373 bool isRelatedToActivityTag(ActivityTag* s); 1374 1375 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1376 1377 bool hasWrongDayOrHour(Rules& r); 1378 bool canRepairWrongDayOrHour(Rules& r); 1379 bool repairWrongDayOrHour(Rules& r); 1380 }; 1381 1382 class ConstraintTeacherMinDaysPerWeek: public TimeConstraint{ 1383 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinDaysPerWeek) 1384 1385 public: 1386 int minDaysPerWeek; 1387 1388 /** 1389 The teacher's name 1390 */ 1391 QString teacherName; 1392 1393 /** 1394 The teacher's id, or index in the rules 1395 */ 1396 int teacher_ID; 1397 1398 ConstraintTeacherMinDaysPerWeek(); 1399 1400 ConstraintTeacherMinDaysPerWeek(double wp, int mindays, const QString& t); 1401 1402 bool computeInternalStructure(QWidget* parent, Rules& r); 1403 1404 bool hasInactiveActivities(Rules& r); 1405 1406 QString getXmlDescription(Rules& r); 1407 1408 QString getDescription(Rules& r); 1409 1410 QString getDetailedDescription(Rules& r); 1411 1412 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1413 1414 bool isRelatedToActivity(Rules& r, Activity* a); 1415 1416 bool isRelatedToTeacher(Teacher* t); 1417 1418 bool isRelatedToSubject(Subject* s); 1419 1420 bool isRelatedToActivityTag(ActivityTag* s); 1421 1422 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1423 1424 bool hasWrongDayOrHour(Rules& r); 1425 bool canRepairWrongDayOrHour(Rules& r); 1426 bool repairWrongDayOrHour(Rules& r); 1427 }; 1428 1429 class ConstraintTeachersMinDaysPerWeek: public TimeConstraint{ 1430 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinDaysPerWeek) 1431 1432 public: 1433 int minDaysPerWeek; 1434 1435 ConstraintTeachersMinDaysPerWeek(); 1436 1437 ConstraintTeachersMinDaysPerWeek(double wp, int mindays); 1438 1439 bool computeInternalStructure(QWidget* parent, Rules& r); 1440 1441 bool hasInactiveActivities(Rules& r); 1442 1443 QString getXmlDescription(Rules& r); 1444 1445 QString getDescription(Rules& r); 1446 1447 QString getDetailedDescription(Rules& r); 1448 1449 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1450 1451 bool isRelatedToActivity(Rules& r, Activity* a); 1452 1453 bool isRelatedToTeacher(Teacher* t); 1454 1455 bool isRelatedToSubject(Subject* s); 1456 1457 bool isRelatedToActivityTag(ActivityTag* s); 1458 1459 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1460 1461 bool hasWrongDayOrHour(Rules& r); 1462 bool canRepairWrongDayOrHour(Rules& r); 1463 bool repairWrongDayOrHour(Rules& r); 1464 }; 1465 1466 /** 1467 This is a constraint. 1468 It constrains the timetable to not schedule any activity 1469 in the specified day, during the start hour and end hour. 1470 */ 1471 class ConstraintBreakTimes: public TimeConstraint{ 1472 Q_DECLARE_TR_FUNCTIONS(ConstraintBreakTimes) 1473 1474 public: 1475 QList<int> days; 1476 QList<int> hours; 1477 1478 ConstraintBreakTimes(); 1479 1480 ConstraintBreakTimes(double wp, QList<int> d, QList<int> h); 1481 1482 bool computeInternalStructure(QWidget* parent, Rules& r); 1483 1484 bool hasInactiveActivities(Rules& r); 1485 1486 QString getXmlDescription(Rules& r); 1487 1488 QString getDescription(Rules& r); 1489 1490 QString getDetailedDescription(Rules& r); 1491 1492 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1493 1494 bool isRelatedToActivity(Rules& r, Activity* a); 1495 1496 bool isRelatedToTeacher(Teacher* t); 1497 1498 bool isRelatedToSubject(Subject* s); 1499 1500 bool isRelatedToActivityTag(ActivityTag* s); 1501 1502 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1503 1504 bool hasWrongDayOrHour(Rules& r); 1505 bool canRepairWrongDayOrHour(Rules& r); 1506 bool repairWrongDayOrHour(Rules& r); 1507 }; 1508 1509 /** 1510 This is a constraint. It adds, to the fitness of 1511 the solution, a conflicts factor computed from the gaps 1512 existing in the timetable (regarding the students). 1513 The overall result is a timetable having less gaps for the students. 1514 */ 1515 class ConstraintStudentsMaxGapsPerWeek: public TimeConstraint{ 1516 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxGapsPerWeek) 1517 1518 public: 1519 int maxGaps; 1520 1521 ConstraintStudentsMaxGapsPerWeek(); 1522 1523 ConstraintStudentsMaxGapsPerWeek(double wp, int mg); 1524 1525 bool computeInternalStructure(QWidget* parent, Rules& r); 1526 1527 bool hasInactiveActivities(Rules& r); 1528 1529 QString getXmlDescription(Rules& r); 1530 1531 QString getDescription(Rules& r); 1532 1533 QString getDetailedDescription(Rules& r); 1534 1535 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1536 1537 bool isRelatedToActivity(Rules& r, Activity* a); 1538 1539 bool isRelatedToTeacher(Teacher* t); 1540 1541 bool isRelatedToSubject(Subject* s); 1542 1543 bool isRelatedToActivityTag(ActivityTag* s); 1544 1545 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1546 1547 bool hasWrongDayOrHour(Rules& r); 1548 bool canRepairWrongDayOrHour(Rules& r); 1549 bool repairWrongDayOrHour(Rules& r); 1550 }; 1551 1552 /** 1553 This is a constraint. It adds, to the fitness of 1554 the solution, a conflicts factor computed from the gaps 1555 existing in the timetable (regarding the specified students set). 1556 */ 1557 class ConstraintStudentsSetMaxGapsPerWeek: public TimeConstraint{ 1558 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxGapsPerWeek) 1559 1560 public: 1561 int maxGaps; 1562 1563 /** 1564 The name of the students set for this constraint 1565 */ 1566 QString students; 1567 1568 //internal redundant data 1569 1570 /** 1571 The number of subgroups 1572 */ 1573 //int nSubgroups; 1574 1575 /** 1576 The subgroups 1577 */ 1578 QList<int> iSubgroupsList; 1579 1580 ConstraintStudentsSetMaxGapsPerWeek(); 1581 1582 ConstraintStudentsSetMaxGapsPerWeek(double wp, int mg, const QString& st); 1583 1584 bool computeInternalStructure(QWidget* parent, Rules& r); 1585 1586 bool hasInactiveActivities(Rules& r); 1587 1588 QString getXmlDescription(Rules& r); 1589 1590 QString getDescription(Rules& r); 1591 1592 QString getDetailedDescription(Rules& r); 1593 1594 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1595 1596 bool isRelatedToActivity(Rules& r, Activity* a); 1597 1598 bool isRelatedToTeacher(Teacher* t); 1599 1600 bool isRelatedToSubject(Subject* s); 1601 1602 bool isRelatedToActivityTag(ActivityTag* s); 1603 1604 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1605 1606 bool hasWrongDayOrHour(Rules& r); 1607 bool canRepairWrongDayOrHour(Rules& r); 1608 bool repairWrongDayOrHour(Rules& r); 1609 }; 1610 1611 class ConstraintTeachersMaxGapsPerWeek: public TimeConstraint{ 1612 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerWeek) 1613 1614 public: 1615 int maxGaps; 1616 1617 ConstraintTeachersMaxGapsPerWeek(); 1618 1619 ConstraintTeachersMaxGapsPerWeek(double wp, int maxGaps); 1620 1621 bool computeInternalStructure(QWidget* parent, Rules& r); 1622 1623 bool hasInactiveActivities(Rules& r); 1624 1625 QString getXmlDescription(Rules& r); 1626 1627 QString getDescription(Rules& r); 1628 1629 QString getDetailedDescription(Rules& r); 1630 1631 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1632 1633 bool isRelatedToActivity(Rules& r, Activity* a); 1634 1635 bool isRelatedToTeacher(Teacher* t); 1636 1637 bool isRelatedToSubject(Subject* s); 1638 1639 bool isRelatedToActivityTag(ActivityTag* s); 1640 1641 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1642 1643 bool hasWrongDayOrHour(Rules& r); 1644 bool canRepairWrongDayOrHour(Rules& r); 1645 bool repairWrongDayOrHour(Rules& r); 1646 }; 1647 1648 class ConstraintTeacherMaxGapsPerWeek: public TimeConstraint{ 1649 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerWeek) 1650 1651 public: 1652 int maxGaps; 1653 1654 QString teacherName; 1655 1656 int teacherIndex; 1657 1658 ConstraintTeacherMaxGapsPerWeek(); 1659 1660 ConstraintTeacherMaxGapsPerWeek(double wp, const QString& tn, int maxGaps); 1661 1662 bool computeInternalStructure(QWidget* parent, Rules& r); 1663 1664 bool hasInactiveActivities(Rules& r); 1665 1666 QString getXmlDescription(Rules& r); 1667 1668 QString getDescription(Rules& r); 1669 1670 QString getDetailedDescription(Rules& r); 1671 1672 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1673 1674 bool isRelatedToActivity(Rules& r, Activity* a); 1675 1676 bool isRelatedToTeacher(Teacher* t); 1677 1678 bool isRelatedToSubject(Subject* s); 1679 1680 bool isRelatedToActivityTag(ActivityTag* s); 1681 1682 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1683 1684 bool hasWrongDayOrHour(Rules& r); 1685 bool canRepairWrongDayOrHour(Rules& r); 1686 bool repairWrongDayOrHour(Rules& r); 1687 }; 1688 1689 class ConstraintTeachersMaxGapsPerDay: public TimeConstraint{ 1690 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerDay) 1691 1692 public: 1693 int maxGaps; 1694 1695 ConstraintTeachersMaxGapsPerDay(); 1696 1697 ConstraintTeachersMaxGapsPerDay(double wp, int maxGaps); 1698 1699 bool computeInternalStructure(QWidget* parent, Rules& r); 1700 1701 bool hasInactiveActivities(Rules& r); 1702 1703 QString getXmlDescription(Rules& r); 1704 1705 QString getDescription(Rules& r); 1706 1707 QString getDetailedDescription(Rules& r); 1708 1709 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1710 1711 bool isRelatedToActivity(Rules& r, Activity* a); 1712 1713 bool isRelatedToTeacher(Teacher* t); 1714 1715 bool isRelatedToSubject(Subject* s); 1716 1717 bool isRelatedToActivityTag(ActivityTag* s); 1718 1719 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1720 1721 bool hasWrongDayOrHour(Rules& r); 1722 bool canRepairWrongDayOrHour(Rules& r); 1723 bool repairWrongDayOrHour(Rules& r); 1724 }; 1725 1726 class ConstraintTeacherMaxGapsPerDay: public TimeConstraint{ 1727 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerDay) 1728 1729 public: 1730 int maxGaps; 1731 1732 QString teacherName; 1733 1734 int teacherIndex; 1735 1736 ConstraintTeacherMaxGapsPerDay(); 1737 1738 ConstraintTeacherMaxGapsPerDay(double wp, const QString& tn, int maxGaps); 1739 1740 bool computeInternalStructure(QWidget* parent, Rules& r); 1741 1742 bool hasInactiveActivities(Rules& r); 1743 1744 QString getXmlDescription(Rules& r); 1745 1746 QString getDescription(Rules& r); 1747 1748 QString getDetailedDescription(Rules& r); 1749 1750 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1751 1752 bool isRelatedToActivity(Rules& r, Activity* a); 1753 1754 bool isRelatedToTeacher(Teacher* t); 1755 1756 bool isRelatedToSubject(Subject* s); 1757 1758 bool isRelatedToActivityTag(ActivityTag* s); 1759 1760 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1761 1762 bool hasWrongDayOrHour(Rules& r); 1763 bool canRepairWrongDayOrHour(Rules& r); 1764 bool repairWrongDayOrHour(Rules& r); 1765 }; 1766 1767 class ConstraintTeachersMaxGapsPerMorningAndAfternoon: public TimeConstraint{ 1768 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerMorningAndAfternoon) 1769 1770 public: 1771 int maxGaps; 1772 1773 ConstraintTeachersMaxGapsPerMorningAndAfternoon(); 1774 1775 ConstraintTeachersMaxGapsPerMorningAndAfternoon(double wp, int maxGaps); 1776 1777 bool computeInternalStructure(QWidget* parent, Rules& r); 1778 1779 bool hasInactiveActivities(Rules& r); 1780 1781 QString getXmlDescription(Rules& r); 1782 1783 QString getDescription(Rules& r); 1784 1785 QString getDetailedDescription(Rules& r); 1786 1787 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1788 1789 bool isRelatedToActivity(Rules& r, Activity* a); 1790 1791 bool isRelatedToTeacher(Teacher* t); 1792 1793 bool isRelatedToSubject(Subject* s); 1794 1795 bool isRelatedToActivityTag(ActivityTag* s); 1796 1797 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1798 1799 bool hasWrongDayOrHour(Rules& r); 1800 bool canRepairWrongDayOrHour(Rules& r); 1801 bool repairWrongDayOrHour(Rules& r); 1802 }; 1803 1804 class ConstraintTeacherMaxGapsPerMorningAndAfternoon: public TimeConstraint{ 1805 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerMorningAndAfternoon) 1806 1807 public: 1808 int maxGaps; 1809 1810 QString teacherName; 1811 1812 int teacherIndex; 1813 1814 ConstraintTeacherMaxGapsPerMorningAndAfternoon(); 1815 1816 ConstraintTeacherMaxGapsPerMorningAndAfternoon(double wp, const QString& tn, int maxGaps); 1817 1818 bool computeInternalStructure(QWidget* parent, Rules& r); 1819 1820 bool hasInactiveActivities(Rules& r); 1821 1822 QString getXmlDescription(Rules& r); 1823 1824 QString getDescription(Rules& r); 1825 1826 QString getDetailedDescription(Rules& r); 1827 1828 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1829 1830 bool isRelatedToActivity(Rules& r, Activity* a); 1831 1832 bool isRelatedToTeacher(Teacher* t); 1833 1834 bool isRelatedToSubject(Subject* s); 1835 1836 bool isRelatedToActivityTag(ActivityTag* s); 1837 1838 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1839 1840 bool hasWrongDayOrHour(Rules& r); 1841 bool canRepairWrongDayOrHour(Rules& r); 1842 bool repairWrongDayOrHour(Rules& r); 1843 }; 1844 1845 /** 1846 This is a constraint. It adds, to the fitness of 1847 the solution, a fitness factor that is related to how early 1848 the students begin their courses. The result is a timetable 1849 having more activities scheduled at the beginning of the day. 1850 IMPORTANT: fortnightly activities are treated as weekly ones, 1851 for speed and because in normal situations this does not matter. 1852 */ 1853 class ConstraintStudentsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ 1854 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsEarlyMaxBeginningsAtSecondHour) 1855 1856 public: 1857 1858 int maxBeginningsAtSecondHour; 1859 1860 ConstraintStudentsEarlyMaxBeginningsAtSecondHour(); 1861 1862 ConstraintStudentsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH); 1863 1864 bool computeInternalStructure(QWidget* parent, Rules& r); 1865 1866 bool hasInactiveActivities(Rules& r); 1867 1868 QString getXmlDescription(Rules& r); 1869 1870 QString getDescription(Rules& r); 1871 1872 QString getDetailedDescription(Rules& r); 1873 1874 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1875 1876 bool isRelatedToActivity(Rules& r, Activity* a); 1877 1878 bool isRelatedToTeacher(Teacher* t); 1879 1880 bool isRelatedToSubject(Subject* s); 1881 1882 bool isRelatedToActivityTag(ActivityTag* s); 1883 1884 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1885 1886 bool hasWrongDayOrHour(Rules& r); 1887 bool canRepairWrongDayOrHour(Rules& r); 1888 bool repairWrongDayOrHour(Rules& r); 1889 }; 1890 1891 class ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ 1892 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour) 1893 1894 public: 1895 int maxBeginningsAtSecondHour; 1896 1897 /** 1898 The name of the students 1899 */ 1900 QString students; 1901 1902 /** 1903 The number of subgroups involved in this constraint 1904 */ 1905 //int nSubgroups; 1906 1907 /** 1908 The subgroups involved in this constraint 1909 */ 1910 //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; 1911 QList<int> iSubgroupsList; 1912 1913 ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour(); 1914 1915 ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour(double wp, int mBSH, const QString& students); 1916 1917 bool computeInternalStructure(QWidget* parent, Rules& r); 1918 1919 bool hasInactiveActivities(Rules& r); 1920 1921 QString getXmlDescription(Rules& r); 1922 1923 QString getDescription(Rules& r); 1924 1925 QString getDetailedDescription(Rules& r); 1926 1927 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1928 1929 bool isRelatedToActivity(Rules& r, Activity* a); 1930 1931 bool isRelatedToTeacher(Teacher* t); 1932 1933 bool isRelatedToSubject(Subject* s); 1934 1935 bool isRelatedToActivityTag(ActivityTag* s); 1936 1937 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1938 1939 bool hasWrongDayOrHour(Rules& r); 1940 bool canRepairWrongDayOrHour(Rules& r); 1941 bool repairWrongDayOrHour(Rules& r); 1942 }; 1943 1944 class ConstraintStudentsMaxHoursDaily: public TimeConstraint{ 1945 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxHoursDaily) 1946 1947 public: 1948 int maxHoursDaily; 1949 1950 ConstraintStudentsMaxHoursDaily(); 1951 1952 ConstraintStudentsMaxHoursDaily(double wp, int maxnh); 1953 1954 bool computeInternalStructure(QWidget* parent, Rules& r); 1955 1956 bool hasInactiveActivities(Rules& r); 1957 1958 QString getXmlDescription(Rules& r); 1959 1960 QString getDescription(Rules& r); 1961 1962 QString getDetailedDescription(Rules& r); 1963 1964 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 1965 1966 bool isRelatedToActivity(Rules& r, Activity* a); 1967 1968 bool isRelatedToTeacher(Teacher* t); 1969 1970 bool isRelatedToSubject(Subject* s); 1971 1972 bool isRelatedToActivityTag(ActivityTag* s); 1973 1974 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 1975 1976 bool hasWrongDayOrHour(Rules& r); 1977 bool canRepairWrongDayOrHour(Rules& r); 1978 bool repairWrongDayOrHour(Rules& r); 1979 }; 1980 1981 class ConstraintStudentsSetMaxHoursDaily: public TimeConstraint{ 1982 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxHoursDaily) 1983 1984 public: 1985 int maxHoursDaily; 1986 1987 /** 1988 The students set name 1989 */ 1990 QString students; 1991 1992 //internal variables 1993 1994 /** 1995 The number of subgroups 1996 */ 1997 //int nSubgroups; 1998 1999 /** 2000 The subgroups 2001 */ 2002 //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; 2003 QList<int> iSubgroupsList; 2004 2005 ConstraintStudentsSetMaxHoursDaily(); 2006 2007 ConstraintStudentsSetMaxHoursDaily(double wp, int maxnh, const QString& s); 2008 2009 bool computeInternalStructure(QWidget* parent, Rules& r); 2010 2011 bool hasInactiveActivities(Rules& r); 2012 2013 QString getXmlDescription(Rules& r); 2014 2015 QString getDescription(Rules& r); 2016 2017 QString getDetailedDescription(Rules& r); 2018 2019 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2020 2021 bool isRelatedToActivity(Rules& r, Activity* a); 2022 2023 bool isRelatedToTeacher(Teacher* t); 2024 2025 bool isRelatedToSubject(Subject* s); 2026 2027 bool isRelatedToActivityTag(ActivityTag* s); 2028 2029 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2030 2031 bool hasWrongDayOrHour(Rules& r); 2032 bool canRepairWrongDayOrHour(Rules& r); 2033 bool repairWrongDayOrHour(Rules& r); 2034 }; 2035 2036 class ConstraintStudentsMaxHoursContinuously: public TimeConstraint{ 2037 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxHoursContinuously) 2038 2039 public: 2040 int maxHoursContinuously; 2041 2042 ConstraintStudentsMaxHoursContinuously(); 2043 2044 ConstraintStudentsMaxHoursContinuously(double wp, int maxnh); 2045 2046 bool computeInternalStructure(QWidget* parent, Rules& r); 2047 2048 bool hasInactiveActivities(Rules& r); 2049 2050 QString getXmlDescription(Rules& r); 2051 2052 QString getDescription(Rules& r); 2053 2054 QString getDetailedDescription(Rules& r); 2055 2056 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2057 2058 bool isRelatedToActivity(Rules& r, Activity* a); 2059 2060 bool isRelatedToTeacher(Teacher* t); 2061 2062 bool isRelatedToSubject(Subject* s); 2063 2064 bool isRelatedToActivityTag(ActivityTag* s); 2065 2066 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2067 2068 bool hasWrongDayOrHour(Rules& r); 2069 bool canRepairWrongDayOrHour(Rules& r); 2070 bool repairWrongDayOrHour(Rules& r); 2071 }; 2072 2073 class ConstraintStudentsSetMaxHoursContinuously: public TimeConstraint{ 2074 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxHoursContinuously) 2075 2076 public: 2077 int maxHoursContinuously; 2078 2079 /** 2080 The students set name 2081 */ 2082 QString students; 2083 2084 //internal variables 2085 2086 /** 2087 The number of subgroups 2088 */ 2089 //int nSubgroups; 2090 2091 /** 2092 The subgroups 2093 */ 2094 //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; 2095 QList<int> iSubgroupsList; 2096 2097 ConstraintStudentsSetMaxHoursContinuously(); 2098 2099 ConstraintStudentsSetMaxHoursContinuously(double wp, int maxnh, const QString& s); 2100 2101 bool computeInternalStructure(QWidget* parent, Rules& r); 2102 2103 bool hasInactiveActivities(Rules& r); 2104 2105 QString getXmlDescription(Rules& r); 2106 2107 QString getDescription(Rules& r); 2108 2109 QString getDetailedDescription(Rules& r); 2110 2111 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2112 2113 bool isRelatedToActivity(Rules& r, Activity* a); 2114 2115 bool isRelatedToTeacher(Teacher* t); 2116 2117 bool isRelatedToSubject(Subject* s); 2118 2119 bool isRelatedToActivityTag(ActivityTag* s); 2120 2121 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2122 2123 bool hasWrongDayOrHour(Rules& r); 2124 bool canRepairWrongDayOrHour(Rules& r); 2125 bool repairWrongDayOrHour(Rules& r); 2126 }; 2127 2128 class ConstraintStudentsActivityTagMaxHoursContinuously: public TimeConstraint{ 2129 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMaxHoursContinuously) 2130 2131 public: 2132 int maxHoursContinuously; 2133 2134 QString activityTagName; 2135 2136 int activityTagIndex; 2137 2138 QList<int> canonicalSubgroupsList; 2139 2140 ConstraintStudentsActivityTagMaxHoursContinuously(); 2141 2142 ConstraintStudentsActivityTagMaxHoursContinuously(double wp, int maxnh, const QString& activityTag); 2143 2144 bool computeInternalStructure(QWidget* parent, Rules& r); 2145 2146 bool hasInactiveActivities(Rules& r); 2147 2148 QString getXmlDescription(Rules& r); 2149 2150 QString getDescription(Rules& r); 2151 2152 QString getDetailedDescription(Rules& r); 2153 2154 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2155 2156 bool isRelatedToActivity(Rules& r, Activity* a); 2157 2158 bool isRelatedToTeacher(Teacher* t); 2159 2160 bool isRelatedToSubject(Subject* s); 2161 2162 bool isRelatedToActivityTag(ActivityTag* s); 2163 2164 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2165 2166 bool hasWrongDayOrHour(Rules& r); 2167 bool canRepairWrongDayOrHour(Rules& r); 2168 bool repairWrongDayOrHour(Rules& r); 2169 }; 2170 2171 class ConstraintStudentsSetActivityTagMaxHoursContinuously: public TimeConstraint{ 2172 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMaxHoursContinuously) 2173 2174 public: 2175 int maxHoursContinuously; 2176 2177 /** 2178 The students set name 2179 */ 2180 QString students; 2181 2182 QString activityTagName; 2183 2184 //internal variables 2185 2186 int activityTagIndex; 2187 2188 /** 2189 The number of subgroups 2190 */ 2191 //int nSubgroups; 2192 2193 /** 2194 The subgroups 2195 */ 2196 //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; 2197 QList<int> iSubgroupsList; 2198 2199 QList<int> canonicalSubgroupsList; 2200 2201 ConstraintStudentsSetActivityTagMaxHoursContinuously(); 2202 2203 ConstraintStudentsSetActivityTagMaxHoursContinuously(double wp, int maxnh, const QString& s, const QString& activityTag); 2204 2205 bool computeInternalStructure(QWidget* parent, Rules& r); 2206 2207 bool hasInactiveActivities(Rules& r); 2208 2209 QString getXmlDescription(Rules& r); 2210 2211 QString getDescription(Rules& r); 2212 2213 QString getDetailedDescription(Rules& r); 2214 2215 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2216 2217 bool isRelatedToActivity(Rules& r, Activity* a); 2218 2219 bool isRelatedToTeacher(Teacher* t); 2220 2221 bool isRelatedToSubject(Subject* s); 2222 2223 bool isRelatedToActivityTag(ActivityTag* s); 2224 2225 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2226 2227 bool hasWrongDayOrHour(Rules& r); 2228 bool canRepairWrongDayOrHour(Rules& r); 2229 bool repairWrongDayOrHour(Rules& r); 2230 }; 2231 2232 class ConstraintStudentsMinHoursDaily: public TimeConstraint{ 2233 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinHoursDaily) 2234 2235 public: 2236 int minHoursDaily; 2237 2238 bool allowEmptyDays; 2239 2240 ConstraintStudentsMinHoursDaily(); 2241 2242 ConstraintStudentsMinHoursDaily(double wp, int minnh, bool _allowEmptyDays); 2243 2244 bool computeInternalStructure(QWidget* parent, Rules& r); 2245 2246 bool hasInactiveActivities(Rules& r); 2247 2248 QString getXmlDescription(Rules& r); 2249 2250 QString getDescription(Rules& r); 2251 2252 QString getDetailedDescription(Rules& r); 2253 2254 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2255 2256 bool isRelatedToActivity(Rules& r, Activity* a); 2257 2258 bool isRelatedToTeacher(Teacher* t); 2259 2260 bool isRelatedToSubject(Subject* s); 2261 2262 bool isRelatedToActivityTag(ActivityTag* s); 2263 2264 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2265 2266 bool hasWrongDayOrHour(Rules& r); 2267 bool canRepairWrongDayOrHour(Rules& r); 2268 bool repairWrongDayOrHour(Rules& r); 2269 }; 2270 2271 class ConstraintStudentsSetMinHoursDaily: public TimeConstraint{ 2272 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinHoursDaily) 2273 2274 public: 2275 int minHoursDaily; 2276 2277 /** 2278 The students set name 2279 */ 2280 QString students; 2281 2282 bool allowEmptyDays; 2283 2284 //internal variables 2285 2286 /** 2287 The number of subgroups 2288 */ 2289 //int nSubgroups; 2290 2291 /** 2292 The subgroups 2293 */ 2294 //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; 2295 QList<int> iSubgroupsList; 2296 2297 ConstraintStudentsSetMinHoursDaily(); 2298 2299 ConstraintStudentsSetMinHoursDaily(double wp, int minnh, const QString& s, bool _allowEmptyDays); 2300 2301 bool computeInternalStructure(QWidget* parent, Rules& r); 2302 2303 bool hasInactiveActivities(Rules& r); 2304 2305 QString getXmlDescription(Rules& r); 2306 2307 QString getDescription(Rules& r); 2308 2309 QString getDetailedDescription(Rules& r); 2310 2311 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2312 2313 bool isRelatedToActivity(Rules& r, Activity* a); 2314 2315 bool isRelatedToTeacher(Teacher* t); 2316 2317 bool isRelatedToSubject(Subject* s); 2318 2319 bool isRelatedToActivityTag(ActivityTag* s); 2320 2321 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2322 2323 bool hasWrongDayOrHour(Rules& r); 2324 bool canRepairWrongDayOrHour(Rules& r); 2325 bool repairWrongDayOrHour(Rules& r); 2326 }; 2327 2328 /** 2329 This is a constraint. 2330 It adds, to the fitness of the solution, a fitness factor that 2331 grows as the activity is scheduled farther from the wanted time 2332 For the moment, fitness factor increases with one unit for every hour 2333 and one unit for every day. 2334 */ 2335 class ConstraintActivityPreferredStartingTime: public TimeConstraint{ 2336 Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredStartingTime) 2337 2338 public: 2339 /** 2340 Activity id 2341 */ 2342 int activityId; 2343 2344 /** 2345 The preferred day. If -1, then the user does not care about the day. 2346 */ 2347 int day; 2348 2349 /** 2350 The preferred hour. If -1, then the user does not care about the hour. 2351 */ 2352 int hour; 2353 2354 bool permanentlyLocked; //if this is true, then this activity cannot be unlocked from the timetable view form 2355 2356 //internal variables 2357 /** 2358 The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 2359 */ 2360 int activityIndex; 2361 2362 ConstraintActivityPreferredStartingTime(); 2363 2364 ConstraintActivityPreferredStartingTime(double wp, int actId, int d, int h, bool perm); 2365 2366 /** 2367 Comparison operator - to be sure that we do not introduce duplicates 2368 */ 2369 bool operator==(const ConstraintActivityPreferredStartingTime& c); 2370 2371 bool computeInternalStructure(QWidget* parent, Rules& r); 2372 2373 bool hasInactiveActivities(Rules& r); 2374 2375 QString getXmlDescription(Rules& r); 2376 2377 QString getDescription(Rules& r); 2378 2379 QString getDetailedDescription(Rules& r); 2380 2381 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2382 2383 bool isRelatedToActivity(Rules& r, Activity* a); 2384 2385 bool isRelatedToTeacher(Teacher* t); 2386 2387 bool isRelatedToSubject(Subject* s); 2388 2389 bool isRelatedToActivityTag(ActivityTag* s); 2390 2391 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2392 2393 bool hasWrongDayOrHour(Rules& r); 2394 bool canRepairWrongDayOrHour(Rules& r); 2395 bool repairWrongDayOrHour(Rules& r); 2396 }; 2397 2398 /** 2399 This is a constraint. 2400 It returns conflicts if the activity is scheduled in another interval 2401 than the preferred set of times. 2402 */ 2403 class ConstraintActivityPreferredTimeSlots: public TimeConstraint{ 2404 Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredTimeSlots) 2405 2406 public: 2407 /** 2408 Activity id 2409 */ 2410 int p_activityId; 2411 2412 /** 2413 The number of preferred times 2414 */ 2415 int p_nPreferredTimeSlots_L; 2416 2417 /** 2418 The preferred days. If -1, then the user does not care about the day. 2419 */ 2420 //int p_days[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS]; 2421 QList<int> p_days_L; 2422 2423 /** 2424 The preferred hour. If -1, then the user does not care about the hour. 2425 */ 2426 //int p_hours[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS]; 2427 QList<int> p_hours_L; 2428 2429 //internal variables 2430 /** 2431 The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 2432 */ 2433 int p_activityIndex; 2434 2435 ConstraintActivityPreferredTimeSlots(); 2436 2437 //ConstraintActivityPreferredTimeSlots(double wp, int actId, int nPT, int d[], int h[]); 2438 ConstraintActivityPreferredTimeSlots(double wp, int actId, int nPT_L, QList<int> d_L, QList<int> h_L); 2439 2440 bool computeInternalStructure(QWidget* parent, Rules& r); 2441 2442 bool hasInactiveActivities(Rules& r); 2443 2444 QString getXmlDescription(Rules& r); 2445 2446 QString getDescription(Rules& r); 2447 2448 QString getDetailedDescription(Rules& r); 2449 2450 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2451 2452 bool isRelatedToActivity(Rules& r, Activity* a); 2453 2454 bool isRelatedToTeacher(Teacher* t); 2455 2456 bool isRelatedToSubject(Subject* s); 2457 2458 bool isRelatedToActivityTag(ActivityTag* s); 2459 2460 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2461 2462 bool hasWrongDayOrHour(Rules& r); 2463 bool canRepairWrongDayOrHour(Rules& r); 2464 bool repairWrongDayOrHour(Rules& r); 2465 }; 2466 2467 class ConstraintActivityPreferredStartingTimes: public TimeConstraint{ 2468 Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredStartingTimes) 2469 2470 public: 2471 /** 2472 Activity id 2473 */ 2474 int activityId; 2475 2476 /** 2477 The number of preferred times 2478 */ 2479 int nPreferredStartingTimes_L; 2480 2481 /** 2482 The preferred days. If -1, then the user does not care about the day. 2483 */ 2484 //int days[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES]; 2485 QList<int> days_L; 2486 2487 /** 2488 The preferred hour. If -1, then the user does not care about the hour. 2489 */ 2490 //int hours[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES]; 2491 QList<int> hours_L; 2492 2493 //internal variables 2494 /** 2495 The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 2496 */ 2497 int activityIndex; 2498 2499 ConstraintActivityPreferredStartingTimes(); 2500 2501 //ConstraintActivityPreferredStartingTimes(double wp, int actId, int nPT, int d[], int h[]); 2502 ConstraintActivityPreferredStartingTimes(double wp, int actId, int nPT_L, QList<int> d_L, QList<int> h_L); 2503 2504 bool computeInternalStructure(QWidget* parent, Rules& r); 2505 2506 bool hasInactiveActivities(Rules& r); 2507 2508 QString getXmlDescription(Rules& r); 2509 2510 QString getDescription(Rules& r); 2511 2512 QString getDetailedDescription(Rules& r); 2513 2514 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2515 2516 bool isRelatedToActivity(Rules& r, Activity* a); 2517 2518 bool isRelatedToTeacher(Teacher* t); 2519 2520 bool isRelatedToSubject(Subject* s); 2521 2522 bool isRelatedToActivityTag(ActivityTag* s); 2523 2524 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2525 2526 bool hasWrongDayOrHour(Rules& r); 2527 bool canRepairWrongDayOrHour(Rules& r); 2528 bool repairWrongDayOrHour(Rules& r); 2529 }; 2530 2531 /** 2532 This is a constraint. 2533 It returns conflicts if a set of activities is scheduled in another interval 2534 than the preferred set of times. 2535 The set of activities is specified by a subject, teacher, students or a combination 2536 of these. 2537 */ 2538 class ConstraintActivitiesPreferredTimeSlots: public TimeConstraint{ 2539 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesPreferredTimeSlots) 2540 2541 public: 2542 /** 2543 The teacher. If void, all teachers. 2544 */ 2545 QString p_teacherName; 2546 2547 /** 2548 The students. If void, all students. 2549 */ 2550 QString p_studentsName; 2551 2552 /** 2553 The subject. If void, all subjects. 2554 */ 2555 QString p_subjectName; 2556 2557 /** 2558 The activity tag. If void, all activity tags. 2559 */ 2560 QString p_activityTagName; 2561 2562 int duration; //if -1, neglected. Otherwise, >=1. 2563 2564 /** 2565 The number of preferred times 2566 */ 2567 int p_nPreferredTimeSlots_L; 2568 2569 /** 2570 The preferred days. If -1, then the user does not care about the day. 2571 */ 2572 //int p_days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS]; 2573 QList<int> p_days_L; 2574 2575 /** 2576 The preferred hours. If -1, then the user does not care about the hour. 2577 */ 2578 //int p_hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS]; 2579 QList<int> p_hours_L; 2580 2581 //internal variables 2582 2583 /** 2584 The number of activities which are represented by the subject, teacher and students requirements. 2585 */ 2586 int p_nActivities; 2587 2588 /** 2589 The indices of the activities in the rules (from 0 to rules.nActivities-1) 2590 These are indices in the internal list -> Rules::internalActivitiesList 2591 */ 2592 QList<int> p_activitiesIndices; 2593 2594 ConstraintActivitiesPreferredTimeSlots(); 2595 2596 //ConstraintActivitiesPreferredTimeSlots(double wp, QString te, 2597 // QString st, QString su, QString sut, int nPT, int d[], int h[]); 2598 ConstraintActivitiesPreferredTimeSlots(double wp, const QString& te, 2599 const QString& st, const QString& su, const QString& sut, int dur, int nPT_L, QList<int> d_L, QList<int> h_L); 2600 2601 bool computeInternalStructure(QWidget* parent, Rules& r); 2602 2603 bool hasInactiveActivities(Rules& r); 2604 2605 QString getXmlDescription(Rules& r); 2606 2607 QString getDescription(Rules& r); 2608 2609 QString getDetailedDescription(Rules& r); 2610 2611 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2612 2613 bool isRelatedToActivity(Rules& r, Activity* a); 2614 2615 bool isRelatedToTeacher(Teacher* t); 2616 2617 bool isRelatedToSubject(Subject* s); 2618 2619 bool isRelatedToActivityTag(ActivityTag* s); 2620 2621 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2622 2623 bool hasWrongDayOrHour(Rules& r); 2624 bool canRepairWrongDayOrHour(Rules& r); 2625 bool repairWrongDayOrHour(Rules& r); 2626 }; 2627 2628 class ConstraintSubactivitiesPreferredTimeSlots: public TimeConstraint{ 2629 Q_DECLARE_TR_FUNCTIONS(ConstraintSubactivitiesPreferredTimeSlots) 2630 2631 public: 2632 int componentNumber; 2633 2634 /** 2635 The teacher. If void, all teachers. 2636 */ 2637 QString p_teacherName; 2638 2639 /** 2640 The students. If void, all students. 2641 */ 2642 QString p_studentsName; 2643 2644 /** 2645 The subject. If void, all subjects. 2646 */ 2647 QString p_subjectName; 2648 2649 /** 2650 The activity tag. If void, all activity tags. 2651 */ 2652 QString p_activityTagName; 2653 2654 int duration; //if -1, neglected. Otherwise, >=1. 2655 2656 /** 2657 The number of preferred times 2658 */ 2659 int p_nPreferredTimeSlots_L; 2660 2661 /** 2662 The preferred days. If -1, then the user does not care about the day. 2663 */ 2664 //int p_days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS]; 2665 QList<int> p_days_L; 2666 2667 /** 2668 The preferred hours. If -1, then the user does not care about the hour. 2669 */ 2670 //int p_hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS]; 2671 QList<int> p_hours_L; 2672 2673 //internal variables 2674 2675 /** 2676 The number of activities which are represented by the subject, teacher and students requirements. 2677 */ 2678 int p_nActivities; 2679 2680 /** 2681 The indices of the activities in the rules (from 0 to rules.nActivities-1) 2682 These are indices in the internal list -> Rules::internalActivitiesList 2683 */ 2684 QList<int> p_activitiesIndices; 2685 2686 ConstraintSubactivitiesPreferredTimeSlots(); 2687 2688 //ConstraintSubactivitiesPreferredTimeSlots(double wp, int compNo, QString te, 2689 // QString st, QString su, QString sut, int nPT, int d[], int h[]); 2690 ConstraintSubactivitiesPreferredTimeSlots(double wp, int compNo, const QString& te, 2691 const QString& st, const QString& su, const QString& sut, int dur, int nPT_L, QList<int> d_L, QList<int> h_L); 2692 2693 bool computeInternalStructure(QWidget* parent, Rules& r); 2694 2695 bool hasInactiveActivities(Rules& r); 2696 2697 QString getXmlDescription(Rules& r); 2698 2699 QString getDescription(Rules& r); 2700 2701 QString getDetailedDescription(Rules& r); 2702 2703 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2704 2705 bool isRelatedToActivity(Rules& r, Activity* a); 2706 2707 bool isRelatedToTeacher(Teacher* t); 2708 2709 bool isRelatedToSubject(Subject* s); 2710 2711 bool isRelatedToActivityTag(ActivityTag* s); 2712 2713 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2714 2715 bool hasWrongDayOrHour(Rules& r); 2716 bool canRepairWrongDayOrHour(Rules& r); 2717 bool repairWrongDayOrHour(Rules& r); 2718 }; 2719 2720 class ConstraintActivitiesPreferredStartingTimes: public TimeConstraint{ 2721 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesPreferredStartingTimes) 2722 2723 public: 2724 /** 2725 The teacher. If void, all teachers. 2726 */ 2727 QString teacherName; 2728 2729 /** 2730 The students. If void, all students. 2731 */ 2732 QString studentsName; 2733 2734 /** 2735 The subject. If void, all subjects. 2736 */ 2737 QString subjectName; 2738 2739 /** 2740 The activity tag. If void, all activity tags. 2741 */ 2742 QString activityTagName; 2743 2744 int duration; //if -1, neglected. Otherwise, >=1. 2745 2746 /** 2747 The number of preferred times 2748 */ 2749 int nPreferredStartingTimes_L; 2750 2751 /** 2752 The preferred days. If -1, then the user does not care about the day. 2753 */ 2754 //int days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES]; 2755 QList<int> days_L; 2756 2757 /** 2758 The preferred hours. If -1, then the user does not care about the hour. 2759 */ 2760 //int hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES]; 2761 QList<int> hours_L; 2762 2763 //internal variables 2764 2765 /** 2766 The number of activities which are represented by the subject, teacher and students requirements. 2767 */ 2768 int nActivities; 2769 2770 /** 2771 The indices of the activities in the rules (from 0 to rules.nActivities-1) 2772 These are indices in the internal list -> Rules::internalActivitiesList 2773 */ 2774 QList<int> activitiesIndices; 2775 2776 ConstraintActivitiesPreferredStartingTimes(); 2777 2778 //ConstraintActivitiesPreferredStartingTimes(double wp, QString te, 2779 // QString st, QString su, QString sut, int nPT, int d[], int h[]); 2780 ConstraintActivitiesPreferredStartingTimes(double wp, const QString& te, 2781 const QString& st, const QString& su, const QString& sut, int dur, int nPT_L, QList<int> d_L, QList<int> h_L); 2782 2783 bool computeInternalStructure(QWidget* parent, Rules& r); 2784 2785 bool hasInactiveActivities(Rules& r); 2786 2787 QString getXmlDescription(Rules& r); 2788 2789 QString getDescription(Rules& r); 2790 2791 QString getDetailedDescription(Rules& r); 2792 2793 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2794 2795 bool isRelatedToActivity(Rules& r, Activity* a); 2796 2797 bool isRelatedToTeacher(Teacher* t); 2798 2799 bool isRelatedToSubject(Subject* s); 2800 2801 bool isRelatedToActivityTag(ActivityTag* s); 2802 2803 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2804 2805 bool hasWrongDayOrHour(Rules& r); 2806 bool canRepairWrongDayOrHour(Rules& r); 2807 bool repairWrongDayOrHour(Rules& r); 2808 }; 2809 2810 class ConstraintSubactivitiesPreferredStartingTimes: public TimeConstraint{ 2811 Q_DECLARE_TR_FUNCTIONS(ConstraintSubactivitiesPreferredStartingTimes) 2812 2813 public: 2814 int componentNumber; 2815 2816 /** 2817 The teacher. If void, all teachers. 2818 */ 2819 QString teacherName; 2820 2821 /** 2822 The students. If void, all students. 2823 */ 2824 QString studentsName; 2825 2826 /** 2827 The subject. If void, all subjects. 2828 */ 2829 QString subjectName; 2830 2831 /** 2832 The activity tag. If void, all activity tags. 2833 */ 2834 QString activityTagName; 2835 2836 int duration; //if -1, neglected. Otherwise, >=1. 2837 2838 /** 2839 The number of preferred times 2840 */ 2841 int nPreferredStartingTimes_L; 2842 2843 /** 2844 The preferred days. If -1, then the user does not care about the day. 2845 */ 2846 //int days[MAX_N_CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES]; 2847 QList<int> days_L; 2848 2849 /** 2850 The preferred hours. If -1, then the user does not care about the hour. 2851 */ 2852 //int hours[MAX_N_CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES]; 2853 QList<int> hours_L; 2854 2855 //internal variables 2856 2857 /** 2858 The number of activities which are represented by the subject, teacher and students requirements. 2859 */ 2860 int nActivities; 2861 2862 /** 2863 The indices of the activities in the rules (from 0 to rules.nActivities-1) 2864 These are indices in the internal list -> Rules::internalActivitiesList 2865 */ 2866 QList<int> activitiesIndices; 2867 2868 ConstraintSubactivitiesPreferredStartingTimes(); 2869 2870 ConstraintSubactivitiesPreferredStartingTimes(double wp, int compNo, const QString& te, 2871 const QString& st, const QString& su, const QString& sut, int dur, int nPT_L, QList<int> d_L, QList<int> h_L); 2872 2873 bool computeInternalStructure(QWidget* parent, Rules& r); 2874 2875 bool hasInactiveActivities(Rules& r); 2876 2877 QString getXmlDescription(Rules& r); 2878 2879 QString getDescription(Rules& r); 2880 2881 QString getDetailedDescription(Rules& r); 2882 2883 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2884 2885 bool isRelatedToActivity(Rules& r, Activity* a); 2886 2887 bool isRelatedToTeacher(Teacher* t); 2888 2889 bool isRelatedToSubject(Subject* s); 2890 2891 bool isRelatedToActivityTag(ActivityTag* s); 2892 2893 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2894 2895 bool hasWrongDayOrHour(Rules& r); 2896 bool canRepairWrongDayOrHour(Rules& r); 2897 bool repairWrongDayOrHour(Rules& r); 2898 }; 2899 2900 class ConstraintActivitiesSameStartingHour: public TimeConstraint{ 2901 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameStartingHour) 2902 2903 public: 2904 /** 2905 The number of activities involved in this constraint 2906 */ 2907 int n_activities; 2908 2909 /** 2910 The activities involved in this constraint (id) 2911 */ 2912 QList<int> activitiesId; 2913 //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR]; 2914 2915 /** 2916 The number of activities involved in this constraint - internal structure 2917 */ 2918 int _n_activities; 2919 2920 /** 2921 The activities involved in this constraint (index in the rules) - internal structure 2922 */ 2923 QList<int> _activities; 2924 //int _activities[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR]; 2925 2926 ConstraintActivitiesSameStartingHour(); 2927 2928 /** 2929 Constructor, using: 2930 the weight, the number of activities and the list of activities' id-s. 2931 */ 2932 //ConstraintActivitiesSameStartingHour(double wp, int n_act, const int act[]); 2933 ConstraintActivitiesSameStartingHour(double wp, int n_act, const QList<int>& act); 2934 2935 bool computeInternalStructure(QWidget* parent, Rules& r); 2936 2937 bool hasInactiveActivities(Rules& r); 2938 2939 QString getXmlDescription(Rules& r); 2940 2941 QString getDescription(Rules& r); 2942 2943 QString getDetailedDescription(Rules& r); 2944 2945 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 2946 2947 void removeUseless(Rules& r); 2948 2949 bool isRelatedToActivity(Rules& r, Activity* a); 2950 2951 2952 bool isRelatedToTeacher(Teacher* t); 2953 2954 bool isRelatedToSubject(Subject* s); 2955 2956 bool isRelatedToActivityTag(ActivityTag* s); 2957 2958 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 2959 2960 bool hasWrongDayOrHour(Rules& r); 2961 bool canRepairWrongDayOrHour(Rules& r); 2962 bool repairWrongDayOrHour(Rules& r); 2963 }; 2964 2965 class ConstraintActivitiesSameStartingDay: public TimeConstraint{ 2966 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameStartingDay) 2967 2968 public: 2969 /** 2970 The number of activities involved in this constraint 2971 */ 2972 int n_activities; 2973 2974 /** 2975 The activities involved in this constraint (id) 2976 */ 2977 QList<int> activitiesId; 2978 //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY]; 2979 2980 /** 2981 The number of activities involved in this constraint - internal structure 2982 */ 2983 int _n_activities; 2984 2985 /** 2986 The activities involved in this constraint (index in the rules) - internal structure 2987 */ 2988 //int _activities[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY]; 2989 QList<int> _activities; 2990 2991 ConstraintActivitiesSameStartingDay(); 2992 2993 /** 2994 Constructor, using: 2995 the weight, the number of activities and the list of activities' id-s. 2996 */ 2997 //ConstraintActivitiesSameStartingDay(double wp, int n_act, const int act[]); 2998 ConstraintActivitiesSameStartingDay(double wp, int n_act, const QList<int>& act); 2999 3000 bool computeInternalStructure(QWidget* parent, Rules& r); 3001 3002 bool hasInactiveActivities(Rules& r); 3003 3004 QString getXmlDescription(Rules& r); 3005 3006 QString getDescription(Rules& r); 3007 3008 QString getDetailedDescription(Rules& r); 3009 3010 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3011 3012 void removeUseless(Rules& r); 3013 3014 bool isRelatedToActivity(Rules& r, Activity* a); 3015 3016 bool isRelatedToTeacher(Teacher* t); 3017 3018 bool isRelatedToSubject(Subject* s); 3019 3020 bool isRelatedToActivityTag(ActivityTag* s); 3021 3022 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3023 3024 bool hasWrongDayOrHour(Rules& r); 3025 bool canRepairWrongDayOrHour(Rules& r); 3026 bool repairWrongDayOrHour(Rules& r); 3027 }; 3028 3029 class ConstraintTwoActivitiesConsecutive: public TimeConstraint{ 3030 Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesConsecutive) 3031 3032 public: 3033 /** 3034 First activity id 3035 */ 3036 int firstActivityId; 3037 3038 /** 3039 Second activity id 3040 */ 3041 int secondActivityId; 3042 3043 //internal variables 3044 /** 3045 The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 3046 */ 3047 int firstActivityIndex; 3048 3049 /** 3050 The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 3051 */ 3052 int secondActivityIndex; 3053 3054 ConstraintTwoActivitiesConsecutive(); 3055 3056 ConstraintTwoActivitiesConsecutive(double wp, int firstActId, int secondActId); 3057 3058 bool computeInternalStructure(QWidget* parent, Rules& r); 3059 3060 bool hasInactiveActivities(Rules& r); 3061 3062 QString getXmlDescription(Rules& r); 3063 3064 QString getDescription(Rules& r); 3065 3066 QString getDetailedDescription(Rules& r); 3067 3068 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3069 3070 bool isRelatedToActivity(Rules& r, Activity* a); 3071 3072 bool isRelatedToTeacher(Teacher* t); 3073 3074 bool isRelatedToSubject(Subject* s); 3075 3076 bool isRelatedToActivityTag(ActivityTag* s); 3077 3078 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3079 3080 bool hasWrongDayOrHour(Rules& r); 3081 bool canRepairWrongDayOrHour(Rules& r); 3082 bool repairWrongDayOrHour(Rules& r); 3083 }; 3084 3085 class ConstraintTwoActivitiesGrouped: public TimeConstraint{ 3086 Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesGrouped) 3087 3088 public: 3089 /** 3090 First activity id 3091 */ 3092 int firstActivityId; 3093 3094 /** 3095 Second activity id 3096 */ 3097 int secondActivityId; 3098 3099 //internal variables 3100 /** 3101 The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 3102 */ 3103 int firstActivityIndex; 3104 3105 /** 3106 The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 3107 */ 3108 int secondActivityIndex; 3109 3110 ConstraintTwoActivitiesGrouped(); 3111 3112 ConstraintTwoActivitiesGrouped(double wp, int firstActId, int secondActId); 3113 3114 bool computeInternalStructure(QWidget* parent, Rules& r); 3115 3116 bool hasInactiveActivities(Rules& r); 3117 3118 QString getXmlDescription(Rules& r); 3119 3120 QString getDescription(Rules& r); 3121 3122 QString getDetailedDescription(Rules& r); 3123 3124 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3125 3126 bool isRelatedToActivity(Rules& r, Activity* a); 3127 3128 bool isRelatedToTeacher(Teacher* t); 3129 3130 bool isRelatedToSubject(Subject* s); 3131 3132 bool isRelatedToActivityTag(ActivityTag* s); 3133 3134 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3135 3136 bool hasWrongDayOrHour(Rules& r); 3137 bool canRepairWrongDayOrHour(Rules& r); 3138 bool repairWrongDayOrHour(Rules& r); 3139 }; 3140 3141 class ConstraintThreeActivitiesGrouped: public TimeConstraint{ 3142 Q_DECLARE_TR_FUNCTIONS(ConstraintThreeActivitiesGrouped) 3143 3144 public: 3145 /** 3146 First activity id 3147 */ 3148 int firstActivityId; 3149 3150 /** 3151 Second activity id 3152 */ 3153 int secondActivityId; 3154 3155 int thirdActivityId; 3156 3157 //internal variables 3158 /** 3159 The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 3160 */ 3161 int firstActivityIndex; 3162 3163 /** 3164 The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 3165 */ 3166 int secondActivityIndex; 3167 3168 int thirdActivityIndex; 3169 3170 ConstraintThreeActivitiesGrouped(); 3171 3172 ConstraintThreeActivitiesGrouped(double wp, int firstActId, int secondActId, int thirdActId); 3173 3174 bool computeInternalStructure(QWidget* parent, Rules& r); 3175 3176 bool hasInactiveActivities(Rules& r); 3177 3178 QString getXmlDescription(Rules& r); 3179 3180 QString getDescription(Rules& r); 3181 3182 QString getDetailedDescription(Rules& r); 3183 3184 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3185 3186 bool isRelatedToActivity(Rules& r, Activity* a); 3187 3188 bool isRelatedToTeacher(Teacher* t); 3189 3190 bool isRelatedToSubject(Subject* s); 3191 3192 bool isRelatedToActivityTag(ActivityTag* s); 3193 3194 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3195 3196 bool hasWrongDayOrHour(Rules& r); 3197 bool canRepairWrongDayOrHour(Rules& r); 3198 bool repairWrongDayOrHour(Rules& r); 3199 }; 3200 3201 class ConstraintTwoActivitiesOrdered: public TimeConstraint{ 3202 Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesOrdered) 3203 3204 public: 3205 /** 3206 First activity id 3207 */ 3208 int firstActivityId; 3209 3210 /** 3211 Second activity id 3212 */ 3213 int secondActivityId; 3214 3215 //internal variables 3216 /** 3217 The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 3218 */ 3219 int firstActivityIndex; 3220 3221 /** 3222 The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 3223 */ 3224 int secondActivityIndex; 3225 3226 ConstraintTwoActivitiesOrdered(); 3227 3228 ConstraintTwoActivitiesOrdered(double wp, int firstActId, int secondActId); 3229 3230 bool computeInternalStructure(QWidget* parent, Rules& r); 3231 3232 bool hasInactiveActivities(Rules& r); 3233 3234 QString getXmlDescription(Rules& r); 3235 3236 QString getDescription(Rules& r); 3237 3238 QString getDetailedDescription(Rules& r); 3239 3240 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3241 3242 bool isRelatedToActivity(Rules& r, Activity* a); 3243 3244 bool isRelatedToTeacher(Teacher* t); 3245 3246 bool isRelatedToSubject(Subject* s); 3247 3248 bool isRelatedToActivityTag(ActivityTag* s); 3249 3250 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3251 3252 bool hasWrongDayOrHour(Rules& r); 3253 bool canRepairWrongDayOrHour(Rules& r); 3254 bool repairWrongDayOrHour(Rules& r); 3255 }; 3256 3257 class ConstraintTwoSetsOfActivitiesOrdered: public TimeConstraint{ 3258 Q_DECLARE_TR_FUNCTIONS(ConstraintTwoSetsOfActivitiesOrdered) 3259 3260 public: 3261 QList<int> firstActivitiesIdsList; 3262 3263 QList<int> secondActivitiesIdsList; 3264 3265 //internal variables 3266 QList<int> firstActivitiesIndicesList; 3267 3268 QList<int> secondActivitiesIndicesList; 3269 3270 ConstraintTwoSetsOfActivitiesOrdered(); 3271 3272 ConstraintTwoSetsOfActivitiesOrdered(double wp, const QList<int>& firstActsIds, const QList<int>& secondActsIds); 3273 3274 bool computeInternalStructure(QWidget* parent, Rules& r); 3275 3276 bool hasInactiveActivities(Rules& r); 3277 3278 QString getXmlDescription(Rules& r); 3279 3280 QString getDescription(Rules& r); 3281 3282 QString getDetailedDescription(Rules& r); 3283 3284 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3285 3286 void removeUseless(Rules &r); 3287 3288 bool isRelatedToActivity(Rules& r, Activity* a); 3289 3290 bool isRelatedToTeacher(Teacher* t); 3291 3292 bool isRelatedToSubject(Subject* s); 3293 3294 bool isRelatedToActivityTag(ActivityTag* s); 3295 3296 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3297 3298 bool hasWrongDayOrHour(Rules& r); 3299 bool canRepairWrongDayOrHour(Rules& r); 3300 bool repairWrongDayOrHour(Rules& r); 3301 }; 3302 3303 class ConstraintTwoActivitiesOrderedIfSameDay: public TimeConstraint{ 3304 Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesOrderedIfSameDay) 3305 3306 public: 3307 /** 3308 First activity id 3309 */ 3310 int firstActivityId; 3311 3312 /** 3313 Second activity id 3314 */ 3315 int secondActivityId; 3316 3317 //internal variables 3318 /** 3319 The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 3320 */ 3321 int firstActivityIndex; 3322 3323 /** 3324 The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 3325 */ 3326 int secondActivityIndex; 3327 3328 ConstraintTwoActivitiesOrderedIfSameDay(); 3329 3330 ConstraintTwoActivitiesOrderedIfSameDay(double wp, int firstActId, int secondActId); 3331 3332 bool computeInternalStructure(QWidget* parent, Rules& r); 3333 3334 bool hasInactiveActivities(Rules& r); 3335 3336 QString getXmlDescription(Rules& r); 3337 3338 QString getDescription(Rules& r); 3339 3340 QString getDetailedDescription(Rules& r); 3341 3342 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3343 3344 bool isRelatedToActivity(Rules& r, Activity* a); 3345 3346 bool isRelatedToTeacher(Teacher* t); 3347 3348 bool isRelatedToSubject(Subject* s); 3349 3350 bool isRelatedToActivityTag(ActivityTag* s); 3351 3352 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3353 3354 bool hasWrongDayOrHour(Rules& r); 3355 bool canRepairWrongDayOrHour(Rules& r); 3356 bool repairWrongDayOrHour(Rules& r); 3357 }; 3358 3359 class ConstraintActivityEndsStudentsDay: public TimeConstraint{ 3360 Q_DECLARE_TR_FUNCTIONS(ConstraintActivityEndsStudentsDay) 3361 3362 public: 3363 /** 3364 Activity id 3365 */ 3366 int activityId; 3367 3368 //internal variables 3369 /** 3370 The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 3371 */ 3372 int activityIndex; 3373 3374 ConstraintActivityEndsStudentsDay(); 3375 3376 ConstraintActivityEndsStudentsDay(double wp, int actId); 3377 3378 bool computeInternalStructure(QWidget* parent, Rules& r); 3379 3380 bool hasInactiveActivities(Rules& r); 3381 3382 QString getXmlDescription(Rules& r); 3383 3384 QString getDescription(Rules& r); 3385 3386 QString getDetailedDescription(Rules& r); 3387 3388 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3389 3390 bool isRelatedToActivity(Rules& r, Activity* a); 3391 3392 bool isRelatedToTeacher(Teacher* t); 3393 3394 bool isRelatedToSubject(Subject* s); 3395 3396 bool isRelatedToActivityTag(ActivityTag* s); 3397 3398 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3399 3400 bool hasWrongDayOrHour(Rules& r); 3401 bool canRepairWrongDayOrHour(Rules& r); 3402 bool repairWrongDayOrHour(Rules& r); 3403 }; 3404 3405 class ConstraintTeachersMinHoursDaily: public TimeConstraint{ 3406 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinHoursDaily) 3407 3408 public: 3409 /** 3410 The minimum hours daily 3411 */ 3412 int minHoursDaily; 3413 3414 bool allowEmptyDays; 3415 3416 ConstraintTeachersMinHoursDaily(); 3417 3418 ConstraintTeachersMinHoursDaily(double wp, int minhours, bool _allowEmptyDays); 3419 3420 QString getXmlDescription(Rules& r); 3421 3422 bool computeInternalStructure(QWidget* parent, Rules& r); 3423 3424 bool hasInactiveActivities(Rules& r); 3425 3426 QString getDescription(Rules& r); 3427 3428 QString getDetailedDescription(Rules& r); 3429 3430 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3431 3432 bool isRelatedToActivity(Rules& r, Activity* a); 3433 3434 bool isRelatedToTeacher(Teacher* t); 3435 3436 bool isRelatedToSubject(Subject* s); 3437 3438 bool isRelatedToActivityTag(ActivityTag* s); 3439 3440 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3441 3442 bool hasWrongDayOrHour(Rules& r); 3443 bool canRepairWrongDayOrHour(Rules& r); 3444 bool repairWrongDayOrHour(Rules& r); 3445 }; 3446 3447 class ConstraintTeacherMinHoursDaily: public TimeConstraint{ 3448 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinHoursDaily) 3449 3450 public: 3451 /** 3452 The minimum hours daily 3453 */ 3454 int minHoursDaily; 3455 3456 QString teacherName; 3457 3458 int teacher_ID; 3459 3460 bool allowEmptyDays; 3461 3462 ConstraintTeacherMinHoursDaily(); 3463 3464 ConstraintTeacherMinHoursDaily(double wp, int minhours, const QString& teacher, bool _allowEmptyDays); 3465 3466 QString getXmlDescription(Rules& r); 3467 3468 bool computeInternalStructure(QWidget* parent, Rules& r); 3469 3470 bool hasInactiveActivities(Rules& r); 3471 3472 QString getDescription(Rules& r); 3473 3474 QString getDetailedDescription(Rules& r); 3475 3476 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3477 3478 bool isRelatedToActivity(Rules& r, Activity* a); 3479 3480 bool isRelatedToTeacher(Teacher* t); 3481 3482 bool isRelatedToSubject(Subject* s); 3483 3484 bool isRelatedToActivityTag(ActivityTag* s); 3485 3486 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3487 3488 bool hasWrongDayOrHour(Rules& r); 3489 bool canRepairWrongDayOrHour(Rules& r); 3490 bool repairWrongDayOrHour(Rules& r); 3491 }; 3492 3493 class ConstraintTeacherIntervalMaxDaysPerWeek: public TimeConstraint{ 3494 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherIntervalMaxDaysPerWeek) 3495 3496 public: 3497 /** 3498 The number of maximum allowed working days per week 3499 */ 3500 int maxDaysPerWeek; 3501 3502 int startHour; 3503 3504 int endHour; //might be = to gt.rules.nHoursPerDay 3505 3506 /** 3507 The teacher's name 3508 */ 3509 QString teacherName; 3510 3511 /** 3512 The teacher's id, or index in the rules 3513 */ 3514 int teacher_ID; 3515 3516 ConstraintTeacherIntervalMaxDaysPerWeek(); 3517 3518 ConstraintTeacherIntervalMaxDaysPerWeek(double wp, int maxnd, const QString& tn, int sh, int eh); 3519 3520 bool computeInternalStructure(QWidget* parent, Rules& r); 3521 3522 bool hasInactiveActivities(Rules& r); 3523 3524 QString getXmlDescription(Rules& r); 3525 3526 QString getDescription(Rules& r); 3527 3528 QString getDetailedDescription(Rules& r); 3529 3530 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3531 3532 bool isRelatedToActivity(Rules& r, Activity* a); 3533 3534 bool isRelatedToTeacher(Teacher* t); 3535 3536 bool isRelatedToSubject(Subject* s); 3537 3538 bool isRelatedToActivityTag(ActivityTag* s); 3539 3540 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3541 3542 bool hasWrongDayOrHour(Rules& r); 3543 bool canRepairWrongDayOrHour(Rules& r); 3544 bool repairWrongDayOrHour(Rules& r); 3545 }; 3546 3547 class ConstraintTeachersIntervalMaxDaysPerWeek: public TimeConstraint{ 3548 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersIntervalMaxDaysPerWeek) 3549 3550 public: 3551 /** 3552 The number of maximum allowed working days per week 3553 */ 3554 int maxDaysPerWeek; 3555 3556 int startHour; 3557 3558 int endHour; //might be = to gt.rules.nHoursPerDay 3559 3560 ConstraintTeachersIntervalMaxDaysPerWeek(); 3561 3562 ConstraintTeachersIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh); 3563 3564 bool computeInternalStructure(QWidget* parent, Rules& r); 3565 3566 bool hasInactiveActivities(Rules& r); 3567 3568 QString getXmlDescription(Rules& r); 3569 3570 QString getDescription(Rules& r); 3571 3572 QString getDetailedDescription(Rules& r); 3573 3574 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3575 3576 bool isRelatedToActivity(Rules& r, Activity* a); 3577 3578 bool isRelatedToTeacher(Teacher* t); 3579 3580 bool isRelatedToSubject(Subject* s); 3581 3582 bool isRelatedToActivityTag(ActivityTag* s); 3583 3584 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3585 3586 bool hasWrongDayOrHour(Rules& r); 3587 bool canRepairWrongDayOrHour(Rules& r); 3588 bool repairWrongDayOrHour(Rules& r); 3589 }; 3590 3591 class ConstraintStudentsSetIntervalMaxDaysPerWeek: public TimeConstraint{ 3592 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetIntervalMaxDaysPerWeek) 3593 3594 public: 3595 /** 3596 The number of maximum allowed working days per week 3597 */ 3598 int maxDaysPerWeek; 3599 3600 int startHour; 3601 3602 int endHour; //might be = to gt.rules.nHoursPerDay 3603 3604 /** 3605 The name of the students set for this constraint 3606 */ 3607 QString students; 3608 3609 //internal redundant data 3610 3611 /** 3612 The number of subgroups 3613 */ 3614 //int nSubgroups; 3615 3616 /** 3617 The subgroups 3618 */ 3619 QList<int> iSubgroupsList; 3620 3621 ConstraintStudentsSetIntervalMaxDaysPerWeek(); 3622 3623 ConstraintStudentsSetIntervalMaxDaysPerWeek(double wp, int maxnd, const QString& sn, int sh, int eh); 3624 3625 bool computeInternalStructure(QWidget* parent, Rules& r); 3626 3627 bool hasInactiveActivities(Rules& r); 3628 3629 QString getXmlDescription(Rules& r); 3630 3631 QString getDescription(Rules& r); 3632 3633 QString getDetailedDescription(Rules& r); 3634 3635 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3636 3637 bool isRelatedToActivity(Rules& r, Activity* a); 3638 3639 bool isRelatedToTeacher(Teacher* t); 3640 3641 bool isRelatedToSubject(Subject* s); 3642 3643 bool isRelatedToActivityTag(ActivityTag* s); 3644 3645 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3646 3647 bool hasWrongDayOrHour(Rules& r); 3648 bool canRepairWrongDayOrHour(Rules& r); 3649 bool repairWrongDayOrHour(Rules& r); 3650 }; 3651 3652 class ConstraintStudentsIntervalMaxDaysPerWeek: public TimeConstraint{ 3653 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsIntervalMaxDaysPerWeek) 3654 3655 public: 3656 /** 3657 The number of maximum allowed working days per week 3658 */ 3659 int maxDaysPerWeek; 3660 3661 int startHour; 3662 3663 int endHour; //might be = to gt.rules.nHoursPerDay 3664 3665 ConstraintStudentsIntervalMaxDaysPerWeek(); 3666 3667 ConstraintStudentsIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh); 3668 3669 bool computeInternalStructure(QWidget* parent, Rules& r); 3670 3671 bool hasInactiveActivities(Rules& r); 3672 3673 QString getXmlDescription(Rules& r); 3674 3675 QString getDescription(Rules& r); 3676 3677 QString getDetailedDescription(Rules& r); 3678 3679 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3680 3681 bool isRelatedToActivity(Rules& r, Activity* a); 3682 3683 bool isRelatedToTeacher(Teacher* t); 3684 3685 bool isRelatedToSubject(Subject* s); 3686 3687 bool isRelatedToActivityTag(ActivityTag* s); 3688 3689 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3690 3691 bool hasWrongDayOrHour(Rules& r); 3692 bool canRepairWrongDayOrHour(Rules& r); 3693 bool repairWrongDayOrHour(Rules& r); 3694 }; 3695 3696 class ConstraintActivitiesEndStudentsDay: public TimeConstraint{ 3697 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesEndStudentsDay) 3698 3699 public: 3700 /** 3701 The teacher. If void, all teachers. 3702 */ 3703 QString teacherName; 3704 3705 /** 3706 The students. If void, all students. 3707 */ 3708 QString studentsName; 3709 3710 /** 3711 The subject. If void, all subjects. 3712 */ 3713 QString subjectName; 3714 3715 /** 3716 The activity tag. If void, all activity tags. 3717 */ 3718 QString activityTagName; 3719 3720 3721 //internal data 3722 3723 /** 3724 The number of activities which are represented by the subject, teacher and students requirements. 3725 */ 3726 int nActivities; 3727 3728 /** 3729 The indices of the activities in the rules (from 0 to rules.nActivities-1) 3730 These are indices in the internal list -> Rules::internalActivitiesList 3731 */ 3732 QList<int> activitiesIndices; 3733 3734 ConstraintActivitiesEndStudentsDay(); 3735 3736 ConstraintActivitiesEndStudentsDay(double wp, const QString& te, const QString& st, const QString& su, const QString& sut); 3737 3738 bool computeInternalStructure(QWidget* parent, Rules& r); 3739 3740 bool hasInactiveActivities(Rules& r); 3741 3742 QString getXmlDescription(Rules& r); 3743 3744 QString getDescription(Rules& r); 3745 3746 QString getDetailedDescription(Rules& r); 3747 3748 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3749 3750 bool isRelatedToActivity(Rules& r, Activity* a); 3751 3752 bool isRelatedToTeacher(Teacher* t); 3753 3754 bool isRelatedToSubject(Subject* s); 3755 3756 bool isRelatedToActivityTag(ActivityTag* s); 3757 3758 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3759 3760 bool hasWrongDayOrHour(Rules& r); 3761 bool canRepairWrongDayOrHour(Rules& r); 3762 bool repairWrongDayOrHour(Rules& r); 3763 }; 3764 3765 class ConstraintActivityEndsTeachersDay: public TimeConstraint{ 3766 Q_DECLARE_TR_FUNCTIONS(ConstraintActivityEndsTeachersDay) 3767 3768 public: 3769 /** 3770 Activity id 3771 */ 3772 int activityId; 3773 3774 //internal variables 3775 /** 3776 The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity 3777 */ 3778 int activityIndex; 3779 3780 ConstraintActivityEndsTeachersDay(); 3781 3782 ConstraintActivityEndsTeachersDay(double wp, int actId); 3783 3784 bool computeInternalStructure(QWidget* parent, Rules& r); 3785 3786 bool hasInactiveActivities(Rules& r); 3787 3788 QString getXmlDescription(Rules& r); 3789 3790 QString getDescription(Rules& r); 3791 3792 QString getDetailedDescription(Rules& r); 3793 3794 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3795 3796 bool isRelatedToActivity(Rules& r, Activity* a); 3797 3798 bool isRelatedToTeacher(Teacher* t); 3799 3800 bool isRelatedToSubject(Subject* s); 3801 3802 bool isRelatedToActivityTag(ActivityTag* s); 3803 3804 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3805 3806 bool hasWrongDayOrHour(Rules& r); 3807 bool canRepairWrongDayOrHour(Rules& r); 3808 bool repairWrongDayOrHour(Rules& r); 3809 }; 3810 3811 class ConstraintActivitiesEndTeachersDay: public TimeConstraint{ 3812 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesEndTeachersDay) 3813 3814 public: 3815 /** 3816 The teacher. If void, all teachers. 3817 */ 3818 QString teacherName; 3819 3820 /** 3821 The students. If void, all students. 3822 */ 3823 QString studentsName; 3824 3825 /** 3826 The subject. If void, all subjects. 3827 */ 3828 QString subjectName; 3829 3830 /** 3831 The activity tag. If void, all activity tags. 3832 */ 3833 QString activityTagName; 3834 3835 3836 //internal data 3837 3838 /** 3839 The number of activities which are represented by the subject, teacher and students requirements. 3840 */ 3841 int nActivities; 3842 3843 /** 3844 The indices of the activities in the rules (from 0 to rules.nActivities-1) 3845 These are indices in the internal list -> Rules::internalActivitiesList 3846 */ 3847 //int activitiesIndices[MAX_ACTIVITIES]; 3848 QList<int> activitiesIndices; 3849 3850 ConstraintActivitiesEndTeachersDay(); 3851 3852 ConstraintActivitiesEndTeachersDay(double wp, const QString& te, const QString& st, const QString& su, const QString& sut); 3853 3854 bool computeInternalStructure(QWidget* parent, Rules& r); 3855 3856 bool hasInactiveActivities(Rules& r); 3857 3858 QString getXmlDescription(Rules& r); 3859 3860 QString getDescription(Rules& r); 3861 3862 QString getDetailedDescription(Rules& r); 3863 3864 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3865 3866 bool isRelatedToActivity(Rules& r, Activity* a); 3867 3868 bool isRelatedToTeacher(Teacher* t); 3869 3870 bool isRelatedToSubject(Subject* s); 3871 3872 bool isRelatedToActivityTag(ActivityTag* s); 3873 3874 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3875 3876 bool hasWrongDayOrHour(Rules& r); 3877 bool canRepairWrongDayOrHour(Rules& r); 3878 bool repairWrongDayOrHour(Rules& r); 3879 }; 3880 3881 class ConstraintTeachersActivityTagMaxHoursDaily: public TimeConstraint{ 3882 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMaxHoursDaily) 3883 3884 public: 3885 /** 3886 The maximum hours daily 3887 */ 3888 int maxHoursDaily; 3889 3890 QString activityTagName; 3891 3892 int activityTagIndex; 3893 3894 QList<int> canonicalTeachersList; 3895 3896 ConstraintTeachersActivityTagMaxHoursDaily(); 3897 3898 ConstraintTeachersActivityTagMaxHoursDaily(double wp, int maxhours, const QString& activityTag); 3899 3900 QString getXmlDescription(Rules& r); 3901 3902 bool computeInternalStructure(QWidget* parent, Rules& r); 3903 3904 bool hasInactiveActivities(Rules& r); 3905 3906 QString getDescription(Rules& r); 3907 3908 QString getDetailedDescription(Rules& r); 3909 3910 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3911 3912 bool isRelatedToActivity(Rules& r, Activity* a); 3913 3914 bool isRelatedToTeacher(Teacher* t); 3915 3916 bool isRelatedToSubject(Subject* s); 3917 3918 bool isRelatedToActivityTag(ActivityTag* s); 3919 3920 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3921 3922 bool hasWrongDayOrHour(Rules& r); 3923 bool canRepairWrongDayOrHour(Rules& r); 3924 bool repairWrongDayOrHour(Rules& r); 3925 }; 3926 3927 class ConstraintTeacherActivityTagMaxHoursDaily: public TimeConstraint{ 3928 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMaxHoursDaily) 3929 3930 public: 3931 /** 3932 The maximum hours daily 3933 */ 3934 int maxHoursDaily; 3935 3936 QString teacherName; 3937 3938 QString activityTagName; 3939 3940 int teacher_ID; 3941 3942 int activityTagIndex; 3943 3944 QList<int> canonicalTeachersList; 3945 3946 ConstraintTeacherActivityTagMaxHoursDaily(); 3947 3948 ConstraintTeacherActivityTagMaxHoursDaily(double wp, int maxhours, const QString& teacher, const QString& activityTag); 3949 3950 QString getXmlDescription(Rules& r); 3951 3952 bool computeInternalStructure(QWidget* parent, Rules& r); 3953 3954 bool hasInactiveActivities(Rules& r); 3955 3956 QString getDescription(Rules& r); 3957 3958 QString getDetailedDescription(Rules& r); 3959 3960 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 3961 3962 bool isRelatedToActivity(Rules& r, Activity* a); 3963 3964 bool isRelatedToTeacher(Teacher* t); 3965 3966 bool isRelatedToSubject(Subject* s); 3967 3968 bool isRelatedToActivityTag(ActivityTag* s); 3969 3970 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 3971 3972 bool hasWrongDayOrHour(Rules& r); 3973 bool canRepairWrongDayOrHour(Rules& r); 3974 bool repairWrongDayOrHour(Rules& r); 3975 }; 3976 3977 class ConstraintStudentsActivityTagMaxHoursDaily: public TimeConstraint{ 3978 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMaxHoursDaily) 3979 3980 public: 3981 int maxHoursDaily; 3982 3983 QString activityTagName; 3984 3985 int activityTagIndex; 3986 3987 QList<int> canonicalSubgroupsList; 3988 3989 ConstraintStudentsActivityTagMaxHoursDaily(); 3990 3991 ConstraintStudentsActivityTagMaxHoursDaily(double wp, int maxnh, const QString& activityTag); 3992 3993 bool computeInternalStructure(QWidget* parent, Rules& r); 3994 3995 bool hasInactiveActivities(Rules& r); 3996 3997 QString getXmlDescription(Rules& r); 3998 3999 QString getDescription(Rules& r); 4000 4001 QString getDetailedDescription(Rules& r); 4002 4003 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4004 4005 bool isRelatedToActivity(Rules& r, Activity* a); 4006 4007 bool isRelatedToTeacher(Teacher* t); 4008 4009 bool isRelatedToSubject(Subject* s); 4010 4011 bool isRelatedToActivityTag(ActivityTag* s); 4012 4013 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4014 4015 bool hasWrongDayOrHour(Rules& r); 4016 bool canRepairWrongDayOrHour(Rules& r); 4017 bool repairWrongDayOrHour(Rules& r); 4018 }; 4019 4020 class ConstraintStudentsSetActivityTagMaxHoursDaily: public TimeConstraint{ 4021 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMaxHoursDaily) 4022 4023 public: 4024 int maxHoursDaily; 4025 4026 /** 4027 The students set name 4028 */ 4029 QString students; 4030 4031 QString activityTagName; 4032 4033 //internal variables 4034 4035 int activityTagIndex; 4036 4037 /** 4038 The number of subgroups 4039 */ 4040 //int nSubgroups; 4041 4042 /** 4043 The subgroups 4044 */ 4045 //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; 4046 QList<int> iSubgroupsList; 4047 4048 QList<int> canonicalSubgroupsList; 4049 4050 ConstraintStudentsSetActivityTagMaxHoursDaily(); 4051 4052 ConstraintStudentsSetActivityTagMaxHoursDaily(double wp, int maxnh, const QString& s, const QString& activityTag); 4053 4054 bool computeInternalStructure(QWidget* parent, Rules& r); 4055 4056 bool hasInactiveActivities(Rules& r); 4057 4058 QString getXmlDescription(Rules& r); 4059 4060 QString getDescription(Rules& r); 4061 4062 QString getDetailedDescription(Rules& r); 4063 4064 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4065 4066 bool isRelatedToActivity(Rules& r, Activity* a); 4067 4068 bool isRelatedToTeacher(Teacher* t); 4069 4070 bool isRelatedToSubject(Subject* s); 4071 4072 bool isRelatedToActivityTag(ActivityTag* s); 4073 4074 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4075 4076 bool hasWrongDayOrHour(Rules& r); 4077 bool canRepairWrongDayOrHour(Rules& r); 4078 bool repairWrongDayOrHour(Rules& r); 4079 }; 4080 4081 class ConstraintTeachersActivityTagMinHoursDaily: public TimeConstraint{ 4082 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMinHoursDaily) 4083 4084 public: 4085 /** 4086 The minimum hours daily 4087 */ 4088 int minHoursDaily; 4089 4090 bool allowEmptyDays; 4091 4092 QString activityTagName; 4093 4094 int activityTagIndex; 4095 4096 QList<int> canonicalTeachersList; 4097 4098 ConstraintTeachersActivityTagMinHoursDaily(); 4099 4100 ConstraintTeachersActivityTagMinHoursDaily(double wp, int minhours, bool allowemptydays, const QString& activityTag); 4101 4102 QString getXmlDescription(Rules& r); 4103 4104 bool computeInternalStructure(QWidget* parent, Rules& r); 4105 4106 bool hasInactiveActivities(Rules& r); 4107 4108 QString getDescription(Rules& r); 4109 4110 QString getDetailedDescription(Rules& r); 4111 4112 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4113 4114 bool isRelatedToActivity(Rules& r, Activity* a); 4115 4116 bool isRelatedToTeacher(Teacher* t); 4117 4118 bool isRelatedToSubject(Subject* s); 4119 4120 bool isRelatedToActivityTag(ActivityTag* s); 4121 4122 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4123 4124 bool hasWrongDayOrHour(Rules& r); 4125 bool canRepairWrongDayOrHour(Rules& r); 4126 bool repairWrongDayOrHour(Rules& r); 4127 }; 4128 4129 class ConstraintTeacherActivityTagMinHoursDaily: public TimeConstraint{ 4130 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMinHoursDaily) 4131 4132 public: 4133 /** 4134 The minimum hours daily 4135 */ 4136 int minHoursDaily; 4137 4138 bool allowEmptyDays; 4139 4140 QString teacherName; 4141 4142 QString activityTagName; 4143 4144 int teacher_ID; 4145 4146 int activityTagIndex; 4147 4148 QList<int> canonicalTeachersList; 4149 4150 ConstraintTeacherActivityTagMinHoursDaily(); 4151 4152 ConstraintTeacherActivityTagMinHoursDaily(double wp, int minhours, bool allowemptydays, const QString& teacher, const QString& activityTag); 4153 4154 QString getXmlDescription(Rules& r); 4155 4156 bool computeInternalStructure(QWidget* parent, Rules& r); 4157 4158 bool hasInactiveActivities(Rules& r); 4159 4160 QString getDescription(Rules& r); 4161 4162 QString getDetailedDescription(Rules& r); 4163 4164 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4165 4166 bool isRelatedToActivity(Rules& r, Activity* a); 4167 4168 bool isRelatedToTeacher(Teacher* t); 4169 4170 bool isRelatedToSubject(Subject* s); 4171 4172 bool isRelatedToActivityTag(ActivityTag* s); 4173 4174 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4175 4176 bool hasWrongDayOrHour(Rules& r); 4177 bool canRepairWrongDayOrHour(Rules& r); 4178 bool repairWrongDayOrHour(Rules& r); 4179 }; 4180 4181 class ConstraintStudentsActivityTagMinHoursDaily: public TimeConstraint{ 4182 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMinHoursDaily) 4183 4184 public: 4185 int minHoursDaily; 4186 4187 bool allowEmptyDays; 4188 4189 QString activityTagName; 4190 4191 int activityTagIndex; 4192 4193 QList<int> canonicalSubgroupsList; 4194 4195 ConstraintStudentsActivityTagMinHoursDaily(); 4196 4197 ConstraintStudentsActivityTagMinHoursDaily(double wp, int maxnh, bool allowEmptyDays, const QString& activityTag); 4198 4199 bool computeInternalStructure(QWidget* parent, Rules& r); 4200 4201 bool hasInactiveActivities(Rules& r); 4202 4203 QString getXmlDescription(Rules& r); 4204 4205 QString getDescription(Rules& r); 4206 4207 QString getDetailedDescription(Rules& r); 4208 4209 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4210 4211 bool isRelatedToActivity(Rules& r, Activity* a); 4212 4213 bool isRelatedToTeacher(Teacher* t); 4214 4215 bool isRelatedToSubject(Subject* s); 4216 4217 bool isRelatedToActivityTag(ActivityTag* s); 4218 4219 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4220 4221 bool hasWrongDayOrHour(Rules& r); 4222 bool canRepairWrongDayOrHour(Rules& r); 4223 bool repairWrongDayOrHour(Rules& r); 4224 }; 4225 4226 class ConstraintStudentsSetActivityTagMinHoursDaily: public TimeConstraint{ 4227 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMinHoursDaily) 4228 4229 public: 4230 int minHoursDaily; 4231 4232 bool allowEmptyDays; 4233 4234 /** 4235 The students set name 4236 */ 4237 QString students; 4238 4239 QString activityTagName; 4240 4241 //internal variables 4242 4243 int activityTagIndex; 4244 4245 /** 4246 The number of subgroups 4247 */ 4248 //int nSubgroups; 4249 4250 /** 4251 The subgroups 4252 */ 4253 //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; 4254 QList<int> iSubgroupsList; 4255 4256 QList<int> canonicalSubgroupsList; 4257 4258 ConstraintStudentsSetActivityTagMinHoursDaily(); 4259 4260 ConstraintStudentsSetActivityTagMinHoursDaily(double wp, int minnh, bool allowEmptyDays, const QString& s, const QString& activityTag); 4261 4262 bool computeInternalStructure(QWidget* parent, Rules& r); 4263 4264 bool hasInactiveActivities(Rules& r); 4265 4266 QString getXmlDescription(Rules& r); 4267 4268 QString getDescription(Rules& r); 4269 4270 QString getDetailedDescription(Rules& r); 4271 4272 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4273 4274 bool isRelatedToActivity(Rules& r, Activity* a); 4275 4276 bool isRelatedToTeacher(Teacher* t); 4277 4278 bool isRelatedToSubject(Subject* s); 4279 4280 bool isRelatedToActivityTag(ActivityTag* s); 4281 4282 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4283 4284 bool hasWrongDayOrHour(Rules& r); 4285 bool canRepairWrongDayOrHour(Rules& r); 4286 bool repairWrongDayOrHour(Rules& r); 4287 }; 4288 4289 class ConstraintStudentsMaxGapsPerDay: public TimeConstraint{ 4290 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxGapsPerDay) 4291 4292 public: 4293 int maxGaps; 4294 4295 ConstraintStudentsMaxGapsPerDay(); 4296 4297 ConstraintStudentsMaxGapsPerDay(double wp, int mg); 4298 4299 bool computeInternalStructure(QWidget* parent, Rules& r); 4300 4301 bool hasInactiveActivities(Rules& r); 4302 4303 QString getXmlDescription(Rules& r); 4304 4305 QString getDescription(Rules& r); 4306 4307 QString getDetailedDescription(Rules& r); 4308 4309 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4310 4311 bool isRelatedToActivity(Rules& r, Activity* a); 4312 4313 bool isRelatedToTeacher(Teacher* t); 4314 4315 bool isRelatedToSubject(Subject* s); 4316 4317 bool isRelatedToActivityTag(ActivityTag* s); 4318 4319 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4320 4321 bool hasWrongDayOrHour(Rules& r); 4322 bool canRepairWrongDayOrHour(Rules& r); 4323 bool repairWrongDayOrHour(Rules& r); 4324 }; 4325 4326 class ConstraintStudentsSetMaxGapsPerDay: public TimeConstraint{ 4327 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxGapsPerDay) 4328 4329 public: 4330 int maxGaps; 4331 4332 /** 4333 The name of the students set for this constraint 4334 */ 4335 QString students; 4336 4337 //internal redundant data 4338 4339 /** 4340 The number of subgroups 4341 */ 4342 //int nSubgroups; 4343 4344 /** 4345 The subgroups 4346 */ 4347 QList<int> iSubgroupsList; 4348 4349 ConstraintStudentsSetMaxGapsPerDay(); 4350 4351 ConstraintStudentsSetMaxGapsPerDay(double wp, int mg, const QString& st); 4352 4353 bool computeInternalStructure(QWidget* parent, Rules& r); 4354 4355 bool hasInactiveActivities(Rules& r); 4356 4357 QString getXmlDescription(Rules& r); 4358 4359 QString getDescription(Rules& r); 4360 4361 QString getDetailedDescription(Rules& r); 4362 4363 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4364 4365 bool isRelatedToActivity(Rules& r, Activity* a); 4366 4367 bool isRelatedToTeacher(Teacher* t); 4368 4369 bool isRelatedToSubject(Subject* s); 4370 4371 bool isRelatedToActivityTag(ActivityTag* s); 4372 4373 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4374 4375 bool hasWrongDayOrHour(Rules& r); 4376 bool canRepairWrongDayOrHour(Rules& r); 4377 bool repairWrongDayOrHour(Rules& r); 4378 }; 4379 4380 class ConstraintActivitiesOccupyMaxTimeSlotsFromSelection: public TimeConstraint{ 4381 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesOccupyMaxTimeSlotsFromSelection) 4382 4383 public: 4384 QList<int> activitiesIds; 4385 4386 QList<int> selectedDays; 4387 QList<int> selectedHours; 4388 4389 int maxOccupiedTimeSlots; 4390 4391 //internal variables 4392 QList<int> _activitiesIndices; 4393 4394 ConstraintActivitiesOccupyMaxTimeSlotsFromSelection(); 4395 4396 ConstraintActivitiesOccupyMaxTimeSlotsFromSelection(double wp, QList<int> a_L, QList<int> d_L, QList<int> h_L, int max_slots); 4397 4398 bool computeInternalStructure(QWidget* parent, Rules& r); 4399 4400 bool hasInactiveActivities(Rules& r); 4401 4402 QString getXmlDescription(Rules& r); 4403 4404 QString getDescription(Rules& r); 4405 4406 QString getDetailedDescription(Rules& r); 4407 4408 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4409 4410 void removeUseless(Rules& r); 4411 4412 bool isRelatedToActivity(Rules& r, Activity* a); 4413 4414 bool isRelatedToTeacher(Teacher* t); 4415 4416 bool isRelatedToSubject(Subject* s); 4417 4418 bool isRelatedToActivityTag(ActivityTag* s); 4419 4420 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4421 4422 bool hasWrongDayOrHour(Rules& r); 4423 bool canRepairWrongDayOrHour(Rules& r); 4424 bool repairWrongDayOrHour(Rules& r); 4425 }; 4426 4427 class ConstraintActivitiesOccupyMinTimeSlotsFromSelection: public TimeConstraint{ 4428 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesOccupyMinTimeSlotsFromSelection) 4429 4430 public: 4431 QList<int> activitiesIds; 4432 4433 QList<int> selectedDays; 4434 QList<int> selectedHours; 4435 4436 int minOccupiedTimeSlots; 4437 4438 //internal variables 4439 QList<int> _activitiesIndices; 4440 4441 ConstraintActivitiesOccupyMinTimeSlotsFromSelection(); 4442 4443 ConstraintActivitiesOccupyMinTimeSlotsFromSelection(double wp, QList<int> a_L, QList<int> d_L, QList<int> h_L, int min_slots); 4444 4445 bool computeInternalStructure(QWidget* parent, Rules& r); 4446 4447 bool hasInactiveActivities(Rules& r); 4448 4449 QString getXmlDescription(Rules& r); 4450 4451 QString getDescription(Rules& r); 4452 4453 QString getDetailedDescription(Rules& r); 4454 4455 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4456 4457 void removeUseless(Rules& r); 4458 4459 bool isRelatedToActivity(Rules& r, Activity* a); 4460 4461 bool isRelatedToTeacher(Teacher* t); 4462 4463 bool isRelatedToSubject(Subject* s); 4464 4465 bool isRelatedToActivityTag(ActivityTag* s); 4466 4467 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4468 4469 bool hasWrongDayOrHour(Rules& r); 4470 bool canRepairWrongDayOrHour(Rules& r); 4471 bool repairWrongDayOrHour(Rules& r); 4472 }; 4473 4474 class ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots: public TimeConstraint{ 4475 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots) 4476 4477 public: 4478 QList<int> activitiesIds; 4479 4480 QList<int> selectedDays; 4481 QList<int> selectedHours; 4482 4483 int maxSimultaneous; 4484 4485 //internal variables 4486 QList<int> _activitiesIndices; 4487 4488 ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots(); 4489 4490 ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots(double wp, QList<int> a_L, QList<int> d_L, QList<int> h_L, int max_simultaneous); 4491 4492 bool computeInternalStructure(QWidget* parent, Rules& r); 4493 4494 bool hasInactiveActivities(Rules& r); 4495 4496 QString getXmlDescription(Rules& r); 4497 4498 QString getDescription(Rules& r); 4499 4500 QString getDetailedDescription(Rules& r); 4501 4502 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4503 4504 void removeUseless(Rules& r); 4505 4506 bool isRelatedToActivity(Rules& r, Activity* a); 4507 4508 bool isRelatedToTeacher(Teacher* t); 4509 4510 bool isRelatedToSubject(Subject* s); 4511 4512 bool isRelatedToActivityTag(ActivityTag* s); 4513 4514 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4515 4516 bool hasWrongDayOrHour(Rules& r); 4517 bool canRepairWrongDayOrHour(Rules& r); 4518 bool repairWrongDayOrHour(Rules& r); 4519 }; 4520 4521 class ConstraintActivitiesMinSimultaneousInSelectedTimeSlots: public TimeConstraint{ 4522 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesMinSimultaneousInSelectedTimeSlots) 4523 4524 public: 4525 QList<int> activitiesIds; 4526 4527 QList<int> selectedDays; 4528 QList<int> selectedHours; 4529 4530 int minSimultaneous; 4531 4532 bool allowEmptySlots; 4533 4534 //internal variables 4535 QList<int> _activitiesIndices; 4536 4537 ConstraintActivitiesMinSimultaneousInSelectedTimeSlots(); 4538 4539 ConstraintActivitiesMinSimultaneousInSelectedTimeSlots(double wp, QList<int> a_L, QList<int> d_L, QList<int> h_L, int min_simultaneous, bool allow_empty_slots); 4540 4541 bool computeInternalStructure(QWidget* parent, Rules& r); 4542 4543 bool hasInactiveActivities(Rules& r); 4544 4545 QString getXmlDescription(Rules& r); 4546 4547 QString getDescription(Rules& r); 4548 4549 QString getDetailedDescription(Rules& r); 4550 4551 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4552 4553 void removeUseless(Rules& r); 4554 4555 bool isRelatedToActivity(Rules& r, Activity* a); 4556 4557 bool isRelatedToTeacher(Teacher* t); 4558 4559 bool isRelatedToSubject(Subject* s); 4560 4561 bool isRelatedToActivityTag(ActivityTag* s); 4562 4563 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4564 4565 bool hasWrongDayOrHour(Rules& r); 4566 bool canRepairWrongDayOrHour(Rules& r); 4567 bool repairWrongDayOrHour(Rules& r); 4568 }; 4569 4570 class ConstraintMaxTotalActivitiesFromSetInSelectedTimeSlots: public TimeConstraint{ 4571 Q_DECLARE_TR_FUNCTIONS(ConstraintMaxTotalActivitiesFromSetInSelectedTimeSlots) 4572 4573 public: 4574 QList<int> activitiesIds; 4575 4576 QList<int> selectedDays; 4577 QList<int> selectedHours; 4578 4579 int maxActivities; 4580 4581 //internal variables 4582 QList<int> _activitiesIndices; 4583 4584 ConstraintMaxTotalActivitiesFromSetInSelectedTimeSlots(); 4585 4586 ConstraintMaxTotalActivitiesFromSetInSelectedTimeSlots(double wp, QList<int> a_L, QList<int> d_L, QList<int> h_L, int max_activities); 4587 4588 bool computeInternalStructure(QWidget* parent, Rules& r); 4589 4590 bool hasInactiveActivities(Rules& r); 4591 4592 QString getXmlDescription(Rules& r); 4593 4594 QString getDescription(Rules& r); 4595 4596 QString getDetailedDescription(Rules& r); 4597 4598 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4599 4600 void removeUseless(Rules& r); 4601 4602 bool isRelatedToActivity(Rules& r, Activity* a); 4603 4604 bool isRelatedToTeacher(Teacher* t); 4605 4606 bool isRelatedToSubject(Subject* s); 4607 4608 bool isRelatedToActivityTag(ActivityTag* s); 4609 4610 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4611 4612 bool hasWrongDayOrHour(Rules& r); 4613 bool canRepairWrongDayOrHour(Rules& r); 4614 bool repairWrongDayOrHour(Rules& r); 4615 }; 4616 4617 class ConstraintActivitiesMaxInATerm: public TimeConstraint{ 4618 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesMaxInATerm) 4619 4620 public: 4621 QList<int> activitiesIds; 4622 4623 int maxActivitiesInATerm; 4624 4625 //internal variables 4626 QList<int> _activitiesIndices; 4627 4628 ConstraintActivitiesMaxInATerm(); 4629 4630 ConstraintActivitiesMaxInATerm(double wp, QList<int> a_L, int max_acts); 4631 4632 bool computeInternalStructure(QWidget* parent, Rules& r); 4633 4634 bool hasInactiveActivities(Rules& r); 4635 4636 QString getXmlDescription(Rules& r); 4637 4638 QString getDescription(Rules& r); 4639 4640 QString getDetailedDescription(Rules& r); 4641 4642 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4643 4644 void removeUseless(Rules& r); 4645 4646 bool isRelatedToActivity(Rules& r, Activity* a); 4647 4648 bool isRelatedToTeacher(Teacher* t); 4649 4650 bool isRelatedToSubject(Subject* s); 4651 4652 bool isRelatedToActivityTag(ActivityTag* s); 4653 4654 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4655 4656 bool hasWrongDayOrHour(Rules& r); 4657 bool canRepairWrongDayOrHour(Rules& r); 4658 bool repairWrongDayOrHour(Rules& r); 4659 }; 4660 4661 class ConstraintActivitiesOccupyMaxTerms: public TimeConstraint{ 4662 Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesOccupyMaxTerms) 4663 4664 public: 4665 QList<int> activitiesIds; 4666 4667 int maxOccupiedTerms; 4668 4669 //internal variables 4670 QList<int> _activitiesIndices; 4671 4672 ConstraintActivitiesOccupyMaxTerms(); 4673 4674 ConstraintActivitiesOccupyMaxTerms(double wp, QList<int> a_L, int max_occupied); 4675 4676 bool computeInternalStructure(QWidget* parent, Rules& r); 4677 4678 bool hasInactiveActivities(Rules& r); 4679 4680 QString getXmlDescription(Rules& r); 4681 4682 QString getDescription(Rules& r); 4683 4684 QString getDetailedDescription(Rules& r); 4685 4686 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4687 4688 void removeUseless(Rules& r); 4689 4690 bool isRelatedToActivity(Rules& r, Activity* a); 4691 4692 bool isRelatedToTeacher(Teacher* t); 4693 4694 bool isRelatedToSubject(Subject* s); 4695 4696 bool isRelatedToActivityTag(ActivityTag* s); 4697 4698 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4699 4700 bool hasWrongDayOrHour(Rules& r); 4701 bool canRepairWrongDayOrHour(Rules& r); 4702 bool repairWrongDayOrHour(Rules& r); 4703 }; 4704 4705 class ConstraintStudentsSetMaxDaysPerWeek: public TimeConstraint{ 4706 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxDaysPerWeek) 4707 4708 public: 4709 /** 4710 The number of maximum allowed working days per week 4711 */ 4712 int maxDaysPerWeek; 4713 4714 /** 4715 The name of the students set for this constraint 4716 */ 4717 QString students; 4718 4719 //internal redundant data 4720 4721 /** 4722 The number of subgroups 4723 */ 4724 //int nSubgroups; 4725 4726 /** 4727 The subgroups 4728 */ 4729 QList<int> iSubgroupsList; 4730 4731 ConstraintStudentsSetMaxDaysPerWeek(); 4732 4733 ConstraintStudentsSetMaxDaysPerWeek(double wp, int maxnd, const QString& sn); 4734 4735 bool computeInternalStructure(QWidget* parent, Rules& r); 4736 4737 bool hasInactiveActivities(Rules& r); 4738 4739 QString getXmlDescription(Rules& r); 4740 4741 QString getDescription(Rules& r); 4742 4743 QString getDetailedDescription(Rules& r); 4744 4745 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4746 4747 bool isRelatedToActivity(Rules& r, Activity* a); 4748 4749 bool isRelatedToTeacher(Teacher* t); 4750 4751 bool isRelatedToSubject(Subject* s); 4752 4753 bool isRelatedToActivityTag(ActivityTag* s); 4754 4755 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4756 4757 bool hasWrongDayOrHour(Rules& r); 4758 bool canRepairWrongDayOrHour(Rules& r); 4759 bool repairWrongDayOrHour(Rules& r); 4760 }; 4761 4762 class ConstraintStudentsMaxDaysPerWeek: public TimeConstraint{ 4763 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxDaysPerWeek) 4764 4765 public: 4766 /** 4767 The number of maximum allowed working days per week 4768 */ 4769 int maxDaysPerWeek; 4770 4771 ConstraintStudentsMaxDaysPerWeek(); 4772 4773 ConstraintStudentsMaxDaysPerWeek(double wp, int maxnd); 4774 4775 bool computeInternalStructure(QWidget* parent, Rules& r); 4776 4777 bool hasInactiveActivities(Rules& r); 4778 4779 QString getXmlDescription(Rules& r); 4780 4781 QString getDescription(Rules& r); 4782 4783 QString getDetailedDescription(Rules& r); 4784 4785 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4786 4787 bool isRelatedToActivity(Rules& r, Activity* a); 4788 4789 bool isRelatedToTeacher(Teacher* t); 4790 4791 bool isRelatedToSubject(Subject* s); 4792 4793 bool isRelatedToActivityTag(ActivityTag* s); 4794 4795 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4796 4797 bool hasWrongDayOrHour(Rules& r); 4798 bool canRepairWrongDayOrHour(Rules& r); 4799 bool repairWrongDayOrHour(Rules& r); 4800 }; 4801 4802 class ConstraintTeacherMaxSpanPerDay: public TimeConstraint{ 4803 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxSpanPerDay) 4804 4805 public: 4806 /** 4807 The maximum span daily 4808 */ 4809 int maxSpanPerDay; 4810 4811 bool allowOneDayExceptionPlusOne; 4812 4813 QString teacherName; 4814 4815 int teacher_ID; 4816 4817 ConstraintTeacherMaxSpanPerDay(); 4818 4819 ConstraintTeacherMaxSpanPerDay(double wp, int maxspan, bool except, const QString& teacher); 4820 4821 QString getXmlDescription(Rules& r); 4822 4823 bool computeInternalStructure(QWidget* parent, Rules& r); 4824 4825 bool hasInactiveActivities(Rules& r); 4826 4827 QString getDescription(Rules& r); 4828 4829 QString getDetailedDescription(Rules& r); 4830 4831 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4832 4833 bool isRelatedToActivity(Rules& r, Activity* a); 4834 4835 bool isRelatedToTeacher(Teacher* t); 4836 4837 bool isRelatedToSubject(Subject* s); 4838 4839 bool isRelatedToActivityTag(ActivityTag* s); 4840 4841 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4842 4843 bool hasWrongDayOrHour(Rules& r); 4844 bool canRepairWrongDayOrHour(Rules& r); 4845 bool repairWrongDayOrHour(Rules& r); 4846 }; 4847 4848 class ConstraintTeachersMaxSpanPerDay: public TimeConstraint{ 4849 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxSpanPerDay) 4850 4851 public: 4852 /** 4853 The maximum span daily 4854 */ 4855 int maxSpanPerDay; 4856 4857 bool allowOneDayExceptionPlusOne; 4858 4859 ConstraintTeachersMaxSpanPerDay(); 4860 4861 ConstraintTeachersMaxSpanPerDay(double wp, int maxspan, bool except); 4862 4863 QString getXmlDescription(Rules& r); 4864 4865 bool computeInternalStructure(QWidget* parent, Rules& r); 4866 4867 bool hasInactiveActivities(Rules& r); 4868 4869 QString getDescription(Rules& r); 4870 4871 QString getDetailedDescription(Rules& r); 4872 4873 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4874 4875 bool isRelatedToActivity(Rules& r, Activity* a); 4876 4877 bool isRelatedToTeacher(Teacher* t); 4878 4879 bool isRelatedToSubject(Subject* s); 4880 4881 bool isRelatedToActivityTag(ActivityTag* s); 4882 4883 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4884 4885 bool hasWrongDayOrHour(Rules& r); 4886 bool canRepairWrongDayOrHour(Rules& r); 4887 bool repairWrongDayOrHour(Rules& r); 4888 }; 4889 4890 class ConstraintTeacherMinRestingHours: public TimeConstraint{ 4891 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinRestingHours) 4892 4893 public: 4894 int minRestingHours; 4895 4896 bool circular; 4897 4898 QString teacherName; 4899 4900 int teacher_ID; 4901 4902 ConstraintTeacherMinRestingHours(); 4903 4904 ConstraintTeacherMinRestingHours(double wp, int minrestinghours, bool circ, const QString& teacher); 4905 4906 QString getXmlDescription(Rules& r); 4907 4908 bool computeInternalStructure(QWidget* parent, Rules& r); 4909 4910 bool hasInactiveActivities(Rules& r); 4911 4912 QString getDescription(Rules& r); 4913 4914 QString getDetailedDescription(Rules& r); 4915 4916 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4917 4918 bool isRelatedToActivity(Rules& r, Activity* a); 4919 4920 bool isRelatedToTeacher(Teacher* t); 4921 4922 bool isRelatedToSubject(Subject* s); 4923 4924 bool isRelatedToActivityTag(ActivityTag* s); 4925 4926 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4927 4928 bool hasWrongDayOrHour(Rules& r); 4929 bool canRepairWrongDayOrHour(Rules& r); 4930 bool repairWrongDayOrHour(Rules& r); 4931 }; 4932 4933 class ConstraintTeachersMinRestingHours: public TimeConstraint{ 4934 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinRestingHours) 4935 4936 public: 4937 int minRestingHours; 4938 4939 bool circular; 4940 4941 ConstraintTeachersMinRestingHours(); 4942 4943 ConstraintTeachersMinRestingHours(double wp, int minrestinghours, bool circ); 4944 4945 QString getXmlDescription(Rules& r); 4946 4947 bool computeInternalStructure(QWidget* parent, Rules& r); 4948 4949 bool hasInactiveActivities(Rules& r); 4950 4951 QString getDescription(Rules& r); 4952 4953 QString getDetailedDescription(Rules& r); 4954 4955 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 4956 4957 bool isRelatedToActivity(Rules& r, Activity* a); 4958 4959 bool isRelatedToTeacher(Teacher* t); 4960 4961 bool isRelatedToSubject(Subject* s); 4962 4963 bool isRelatedToActivityTag(ActivityTag* s); 4964 4965 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 4966 4967 bool hasWrongDayOrHour(Rules& r); 4968 bool canRepairWrongDayOrHour(Rules& r); 4969 bool repairWrongDayOrHour(Rules& r); 4970 }; 4971 4972 class ConstraintStudentsSetMaxSpanPerDay: public TimeConstraint{ 4973 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxSpanPerDay) 4974 4975 public: 4976 int maxSpanPerDay; 4977 4978 /** 4979 The name of the students set for this constraint 4980 */ 4981 QString students; 4982 4983 //internal redundant data 4984 4985 /** 4986 The number of subgroups 4987 */ 4988 //int nSubgroups; 4989 4990 /** 4991 The subgroups 4992 */ 4993 QList<int> iSubgroupsList; 4994 4995 ConstraintStudentsSetMaxSpanPerDay(); 4996 4997 ConstraintStudentsSetMaxSpanPerDay(double wp, int maxspan, const QString& sn); 4998 4999 bool computeInternalStructure(QWidget* parent, Rules& r); 5000 5001 bool hasInactiveActivities(Rules& r); 5002 5003 QString getXmlDescription(Rules& r); 5004 5005 QString getDescription(Rules& r); 5006 5007 QString getDetailedDescription(Rules& r); 5008 5009 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 5010 5011 bool isRelatedToActivity(Rules& r, Activity* a); 5012 5013 bool isRelatedToTeacher(Teacher* t); 5014 5015 bool isRelatedToSubject(Subject* s); 5016 5017 bool isRelatedToActivityTag(ActivityTag* s); 5018 5019 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5020 5021 bool hasWrongDayOrHour(Rules& r); 5022 bool canRepairWrongDayOrHour(Rules& r); 5023 bool repairWrongDayOrHour(Rules& r); 5024 }; 5025 5026 class ConstraintStudentsMaxSpanPerDay: public TimeConstraint{ 5027 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxSpanPerDay) 5028 5029 public: 5030 int maxSpanPerDay; 5031 5032 ConstraintStudentsMaxSpanPerDay(); 5033 5034 ConstraintStudentsMaxSpanPerDay(double wp, int maxspan); 5035 5036 bool computeInternalStructure(QWidget* parent, Rules& r); 5037 5038 bool hasInactiveActivities(Rules& r); 5039 5040 QString getXmlDescription(Rules& r); 5041 5042 QString getDescription(Rules& r); 5043 5044 QString getDetailedDescription(Rules& r); 5045 5046 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 5047 5048 bool isRelatedToActivity(Rules& r, Activity* a); 5049 5050 bool isRelatedToTeacher(Teacher* t); 5051 5052 bool isRelatedToSubject(Subject* s); 5053 5054 bool isRelatedToActivityTag(ActivityTag* s); 5055 5056 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5057 5058 bool hasWrongDayOrHour(Rules& r); 5059 bool canRepairWrongDayOrHour(Rules& r); 5060 bool repairWrongDayOrHour(Rules& r); 5061 }; 5062 5063 class ConstraintStudentsSetMinRestingHours: public TimeConstraint{ 5064 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinRestingHours) 5065 5066 public: 5067 int minRestingHours; 5068 5069 bool circular; 5070 5071 /** 5072 The name of the students set for this constraint 5073 */ 5074 QString students; 5075 5076 //internal redundant data 5077 5078 /** 5079 The number of subgroups 5080 */ 5081 //int nSubgroups; 5082 5083 /** 5084 The subgroups 5085 */ 5086 QList<int> iSubgroupsList; 5087 5088 ConstraintStudentsSetMinRestingHours(); 5089 5090 ConstraintStudentsSetMinRestingHours(double wp, int minrestinghours, bool circ, const QString& sn); 5091 5092 bool computeInternalStructure(QWidget* parent, Rules& r); 5093 5094 bool hasInactiveActivities(Rules& r); 5095 5096 QString getXmlDescription(Rules& r); 5097 5098 QString getDescription(Rules& r); 5099 5100 QString getDetailedDescription(Rules& r); 5101 5102 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 5103 5104 bool isRelatedToActivity(Rules& r, Activity* a); 5105 5106 bool isRelatedToTeacher(Teacher* t); 5107 5108 bool isRelatedToSubject(Subject* s); 5109 5110 bool isRelatedToActivityTag(ActivityTag* s); 5111 5112 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5113 5114 bool hasWrongDayOrHour(Rules& r); 5115 bool canRepairWrongDayOrHour(Rules& r); 5116 bool repairWrongDayOrHour(Rules& r); 5117 }; 5118 5119 class ConstraintStudentsMinRestingHours: public TimeConstraint{ 5120 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinRestingHours) 5121 5122 public: 5123 int minRestingHours; 5124 5125 bool circular; 5126 5127 ConstraintStudentsMinRestingHours(); 5128 5129 ConstraintStudentsMinRestingHours(double wp, int minrestinghours, bool circ); 5130 5131 bool computeInternalStructure(QWidget* parent, Rules& r); 5132 5133 bool hasInactiveActivities(Rules& r); 5134 5135 QString getXmlDescription(Rules& r); 5136 5137 QString getDescription(Rules& r); 5138 5139 QString getDetailedDescription(Rules& r); 5140 5141 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 5142 5143 bool isRelatedToActivity(Rules& r, Activity* a); 5144 5145 bool isRelatedToTeacher(Teacher* t); 5146 5147 bool isRelatedToSubject(Subject* s); 5148 5149 bool isRelatedToActivityTag(ActivityTag* s); 5150 5151 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5152 5153 bool hasWrongDayOrHour(Rules& r); 5154 bool canRepairWrongDayOrHour(Rules& r); 5155 bool repairWrongDayOrHour(Rules& r); 5156 }; 5157 5158 class ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags: public TimeConstraint{ 5159 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags) 5160 5161 public: 5162 int minGaps; 5163 5164 QString students; 5165 5166 QString firstActivityTag; 5167 QString secondActivityTag; 5168 5169 //internal variables 5170 5171 QList<int> canonicalSubgroupsList; 5172 5173 int _firstActivityTagIndex; 5174 int _secondActivityTagIndex; 5175 5176 ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags(); 5177 5178 ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags(double wp, const QString& _students, int _minGaps, const QString& _firstActivityTag, const QString& _secondActivityTag); 5179 5180 bool computeInternalStructure(QWidget* parent, Rules& r); 5181 5182 bool hasInactiveActivities(Rules& r); 5183 5184 QString getXmlDescription(Rules& r); 5185 5186 QString getDescription(Rules& r); 5187 5188 QString getDetailedDescription(Rules& r); 5189 5190 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 5191 5192 bool isRelatedToActivity(Rules& r, Activity* a); 5193 5194 bool isRelatedToTeacher(Teacher* t); 5195 5196 bool isRelatedToSubject(Subject* s); 5197 5198 bool isRelatedToActivityTag(ActivityTag* s); 5199 5200 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5201 5202 bool hasWrongDayOrHour(Rules& r); 5203 bool canRepairWrongDayOrHour(Rules& r); 5204 bool repairWrongDayOrHour(Rules& r); 5205 }; 5206 5207 class ConstraintStudentsMinGapsBetweenOrderedPairOfActivityTags: public TimeConstraint{ 5208 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinGapsBetweenOrderedPairOfActivityTags) 5209 5210 public: 5211 int minGaps; 5212 5213 QString firstActivityTag; 5214 QString secondActivityTag; 5215 5216 //internal variables 5217 5218 QList<int> canonicalSubgroupsList; 5219 5220 int _firstActivityTagIndex; 5221 int _secondActivityTagIndex; 5222 5223 ConstraintStudentsMinGapsBetweenOrderedPairOfActivityTags(); 5224 5225 ConstraintStudentsMinGapsBetweenOrderedPairOfActivityTags(double wp, int _minGaps, const QString& _firstActivityTag, const QString& _secondActivityTag); 5226 5227 bool computeInternalStructure(QWidget* parent, Rules& r); 5228 5229 bool hasInactiveActivities(Rules& r); 5230 5231 QString getXmlDescription(Rules& r); 5232 5233 QString getDescription(Rules& r); 5234 5235 QString getDetailedDescription(Rules& r); 5236 5237 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 5238 5239 bool isRelatedToActivity(Rules& r, Activity* a); 5240 5241 bool isRelatedToTeacher(Teacher* t); 5242 5243 bool isRelatedToSubject(Subject* s); 5244 5245 bool isRelatedToActivityTag(ActivityTag* s); 5246 5247 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5248 5249 bool hasWrongDayOrHour(Rules& r); 5250 bool canRepairWrongDayOrHour(Rules& r); 5251 bool repairWrongDayOrHour(Rules& r); 5252 }; 5253 5254 class ConstraintTeacherMinGapsBetweenOrderedPairOfActivityTags: public TimeConstraint{ 5255 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinGapsBetweenOrderedPairOfActivityTags) 5256 5257 public: 5258 int minGaps; 5259 5260 QString teacher; 5261 5262 QString firstActivityTag; 5263 QString secondActivityTag; 5264 5265 //internal variables 5266 5267 QList<int> canonicalTeachersList; 5268 5269 int _firstActivityTagIndex; 5270 int _secondActivityTagIndex; 5271 5272 ConstraintTeacherMinGapsBetweenOrderedPairOfActivityTags(); 5273 5274 ConstraintTeacherMinGapsBetweenOrderedPairOfActivityTags(double wp, const QString& _teacher, int _minGaps, const QString& _firstActivityTag, const QString& _secondActivityTag); 5275 5276 bool computeInternalStructure(QWidget* parent, Rules& r); 5277 5278 bool hasInactiveActivities(Rules& r); 5279 5280 QString getXmlDescription(Rules& r); 5281 5282 QString getDescription(Rules& r); 5283 5284 QString getDetailedDescription(Rules& r); 5285 5286 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 5287 5288 bool isRelatedToActivity(Rules& r, Activity* a); 5289 5290 bool isRelatedToTeacher(Teacher* t); 5291 5292 bool isRelatedToSubject(Subject* s); 5293 5294 bool isRelatedToActivityTag(ActivityTag* s); 5295 5296 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5297 5298 bool hasWrongDayOrHour(Rules& r); 5299 bool canRepairWrongDayOrHour(Rules& r); 5300 bool repairWrongDayOrHour(Rules& r); 5301 }; 5302 5303 class ConstraintTeachersMinGapsBetweenOrderedPairOfActivityTags: public TimeConstraint{ 5304 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinGapsBetweenOrderedPairOfActivityTags) 5305 5306 public: 5307 int minGaps; 5308 5309 QString firstActivityTag; 5310 QString secondActivityTag; 5311 5312 //internal variables 5313 5314 QList<int> canonicalTeachersList; 5315 5316 int _firstActivityTagIndex; 5317 int _secondActivityTagIndex; 5318 5319 ConstraintTeachersMinGapsBetweenOrderedPairOfActivityTags(); 5320 5321 ConstraintTeachersMinGapsBetweenOrderedPairOfActivityTags(double wp, int _minGaps, const QString& _firstActivityTag, const QString& _secondActivityTag); 5322 5323 bool computeInternalStructure(QWidget* parent, Rules& r); 5324 5325 bool hasInactiveActivities(Rules& r); 5326 5327 QString getXmlDescription(Rules& r); 5328 5329 QString getDescription(Rules& r); 5330 5331 QString getDetailedDescription(Rules& r); 5332 5333 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 5334 5335 bool isRelatedToActivity(Rules& r, Activity* a); 5336 5337 bool isRelatedToTeacher(Teacher* t); 5338 5339 bool isRelatedToSubject(Subject* s); 5340 5341 bool isRelatedToActivityTag(ActivityTag* s); 5342 5343 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5344 5345 bool hasWrongDayOrHour(Rules& r); 5346 bool canRepairWrongDayOrHour(Rules& r); 5347 bool repairWrongDayOrHour(Rules& r); 5348 }; 5349 5350 //Begin for mornings-afternoons 5351 /** 5352 This is a constraint, aimed at obtaining timetables 5353 which do not allow more than X hours in a day for any teacher 5354 */ 5355 class ConstraintTeachersMaxHoursDailyRealDays: public TimeConstraint{ 5356 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxHoursDailyRealDays) 5357 5358 public: 5359 /** 5360 The maximum hours daily 5361 */ 5362 int maxHoursDaily; 5363 5364 ConstraintTeachersMaxHoursDailyRealDays(); 5365 5366 ConstraintTeachersMaxHoursDailyRealDays(double wp, int maxhours); 5367 5368 QString getXmlDescription(Rules& r); 5369 5370 bool computeInternalStructure(QWidget* parent, Rules& r); 5371 5372 bool hasInactiveActivities(Rules& r); 5373 5374 QString getDescription(Rules& r); 5375 5376 QString getDetailedDescription(Rules& r); 5377 5378 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5379 5380 bool isRelatedToActivity(Rules& r, Activity* a); 5381 5382 bool isRelatedToTeacher(Teacher* t); 5383 5384 bool isRelatedToSubject(Subject* s); 5385 5386 bool isRelatedToActivityTag(ActivityTag* s); 5387 5388 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5389 5390 bool hasWrongDayOrHour(Rules& r); 5391 bool canRepairWrongDayOrHour(Rules& r); 5392 bool repairWrongDayOrHour(Rules& r); 5393 }; 5394 5395 class ConstraintTeacherMaxHoursDailyRealDays: public TimeConstraint{ 5396 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxHoursDailyRealDays) 5397 5398 public: 5399 /** 5400 The maximum hours daily 5401 */ 5402 int maxHoursDaily; 5403 5404 QString teacherName; 5405 5406 int teacher_ID; 5407 5408 ConstraintTeacherMaxHoursDailyRealDays(); 5409 5410 ConstraintTeacherMaxHoursDailyRealDays(double wp, int maxhours, const QString& teacher); 5411 5412 QString getXmlDescription(Rules& r); 5413 5414 bool computeInternalStructure(QWidget* parent, Rules& r); 5415 5416 bool hasInactiveActivities(Rules& r); 5417 5418 QString getDescription(Rules& r); 5419 5420 QString getDetailedDescription(Rules& r); 5421 5422 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5423 5424 bool isRelatedToActivity(Rules& r, Activity* a); 5425 5426 bool isRelatedToTeacher(Teacher* t); 5427 5428 bool isRelatedToSubject(Subject* s); 5429 5430 bool isRelatedToActivityTag(ActivityTag* s); 5431 5432 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5433 5434 bool hasWrongDayOrHour(Rules& r); 5435 bool canRepairWrongDayOrHour(Rules& r); 5436 bool repairWrongDayOrHour(Rules& r); 5437 }; 5438 5439 /** 5440 This is a constraint. 5441 The resulting timetable must respect the requirement 5442 that this teacher must not have too much working 5443 days per week. 5444 */ 5445 class ConstraintTeacherMaxRealDaysPerWeek: public TimeConstraint{ 5446 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxRealDaysPerWeek) 5447 5448 public: 5449 /** 5450 The number of maximum allowed working days per week (-1 for don't care) 5451 */ 5452 int maxDaysPerWeek; 5453 5454 /** 5455 The teacher's name 5456 */ 5457 QString teacherName; 5458 5459 /** 5460 The teacher's id, or index in the rules 5461 */ 5462 int teacher_ID; 5463 5464 ConstraintTeacherMaxRealDaysPerWeek(); 5465 5466 ConstraintTeacherMaxRealDaysPerWeek(double wp, int maxnd, QString t); 5467 5468 bool computeInternalStructure(QWidget* parent, Rules& r); 5469 5470 bool hasInactiveActivities(Rules& r); 5471 5472 QString getXmlDescription(Rules& r); 5473 5474 QString getDescription(Rules& r); 5475 5476 QString getDetailedDescription(Rules& r); 5477 5478 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5479 5480 bool isRelatedToActivity(Rules& r, Activity* a); 5481 5482 bool isRelatedToTeacher(Teacher* t); 5483 5484 bool isRelatedToSubject(Subject* s); 5485 5486 bool isRelatedToActivityTag(ActivityTag* s); 5487 5488 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5489 5490 bool hasWrongDayOrHour(Rules& r); 5491 bool canRepairWrongDayOrHour(Rules& r); 5492 bool repairWrongDayOrHour(Rules& r); 5493 }; 5494 5495 class ConstraintTeachersMaxRealDaysPerWeek: public TimeConstraint{ 5496 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxRealDaysPerWeek) 5497 5498 public: 5499 /** 5500 The number of maximum allowed working days per week (-1 for don't care) 5501 */ 5502 int maxDaysPerWeek; 5503 5504 ConstraintTeachersMaxRealDaysPerWeek(); 5505 5506 ConstraintTeachersMaxRealDaysPerWeek(double wp, int maxnd); 5507 5508 bool computeInternalStructure(QWidget* parent, Rules& r); 5509 5510 bool hasInactiveActivities(Rules& r); 5511 5512 QString getXmlDescription(Rules& r); 5513 5514 QString getDescription(Rules& r); 5515 5516 QString getDetailedDescription(Rules& r); 5517 5518 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5519 5520 bool isRelatedToActivity(Rules& r, Activity* a); 5521 5522 bool isRelatedToTeacher(Teacher* t); 5523 5524 bool isRelatedToSubject(Subject* s); 5525 5526 bool isRelatedToActivityTag(ActivityTag* s); 5527 5528 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5529 5530 bool hasWrongDayOrHour(Rules& r); 5531 bool canRepairWrongDayOrHour(Rules& r); 5532 bool repairWrongDayOrHour(Rules& r); 5533 }; 5534 5535 class ConstraintTeacherMinRealDaysPerWeek: public TimeConstraint{ 5536 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinRealDaysPerWeek) 5537 5538 public: 5539 int minDaysPerWeek; 5540 5541 /** 5542 The teacher's name 5543 */ 5544 QString teacherName; 5545 5546 /** 5547 The teacher's id, or index in the rules 5548 */ 5549 int teacher_ID; 5550 5551 ConstraintTeacherMinRealDaysPerWeek(); 5552 5553 ConstraintTeacherMinRealDaysPerWeek(double wp, int mindays, const QString& t); 5554 5555 bool computeInternalStructure(QWidget* parent, Rules& r); 5556 5557 bool hasInactiveActivities(Rules& r); 5558 5559 QString getXmlDescription(Rules& r); 5560 5561 QString getDescription(Rules& r); 5562 5563 QString getDetailedDescription(Rules& r); 5564 5565 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5566 5567 bool isRelatedToActivity(Rules& r, Activity* a); 5568 5569 bool isRelatedToTeacher(Teacher* t); 5570 5571 bool isRelatedToSubject(Subject* s); 5572 5573 bool isRelatedToActivityTag(ActivityTag* s); 5574 5575 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5576 5577 bool hasWrongDayOrHour(Rules& r); 5578 bool canRepairWrongDayOrHour(Rules& r); 5579 bool repairWrongDayOrHour(Rules& r); 5580 }; 5581 5582 class ConstraintTeachersMinRealDaysPerWeek: public TimeConstraint{ 5583 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinRealDaysPerWeek) 5584 5585 public: 5586 int minDaysPerWeek; 5587 5588 ConstraintTeachersMinRealDaysPerWeek(); 5589 5590 ConstraintTeachersMinRealDaysPerWeek(double wp, int mindays); 5591 5592 bool computeInternalStructure(QWidget* parent, Rules& r); 5593 5594 bool hasInactiveActivities(Rules& r); 5595 5596 QString getXmlDescription(Rules& r); 5597 5598 QString getDescription(Rules& r); 5599 5600 QString getDetailedDescription(Rules& r); 5601 5602 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5603 5604 bool isRelatedToActivity(Rules& r, Activity* a); 5605 5606 bool isRelatedToTeacher(Teacher* t); 5607 5608 bool isRelatedToSubject(Subject* s); 5609 5610 bool isRelatedToActivityTag(ActivityTag* s); 5611 5612 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5613 5614 bool hasWrongDayOrHour(Rules& r); 5615 bool canRepairWrongDayOrHour(Rules& r); 5616 bool repairWrongDayOrHour(Rules& r); 5617 }; 5618 5619 class ConstraintTeachersMaxGapsPerRealDay: public TimeConstraint{ 5620 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerRealDay) 5621 5622 public: 5623 int maxGaps; 5624 5625 bool allowOneDayExceptionPlusOne; 5626 5627 ConstraintTeachersMaxGapsPerRealDay(); 5628 5629 ConstraintTeachersMaxGapsPerRealDay(double wp, int maxGaps, bool except); 5630 5631 bool computeInternalStructure(QWidget* parent, Rules& r); 5632 5633 bool hasInactiveActivities(Rules& r); 5634 5635 QString getXmlDescription(Rules& r); 5636 5637 QString getDescription(Rules& r); 5638 5639 QString getDetailedDescription(Rules& r); 5640 5641 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5642 5643 bool isRelatedToActivity(Rules& r, Activity* a); 5644 5645 bool isRelatedToTeacher(Teacher* t); 5646 5647 bool isRelatedToSubject(Subject* s); 5648 5649 bool isRelatedToActivityTag(ActivityTag* s); 5650 5651 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5652 5653 bool hasWrongDayOrHour(Rules& r); 5654 bool canRepairWrongDayOrHour(Rules& r); 5655 bool repairWrongDayOrHour(Rules& r); 5656 }; 5657 5658 class ConstraintTeacherMaxGapsPerRealDay: public TimeConstraint{ 5659 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerRealDay) 5660 5661 public: 5662 int maxGaps; 5663 5664 bool allowOneDayExceptionPlusOne; 5665 5666 QString teacherName; 5667 5668 int teacherIndex; 5669 5670 ConstraintTeacherMaxGapsPerRealDay(); 5671 5672 ConstraintTeacherMaxGapsPerRealDay(double wp, QString tn, int maxGaps, bool except); 5673 5674 bool computeInternalStructure(QWidget* parent, Rules& r); 5675 5676 bool hasInactiveActivities(Rules& r); 5677 5678 QString getXmlDescription(Rules& r); 5679 5680 QString getDescription(Rules& r); 5681 5682 QString getDetailedDescription(Rules& r); 5683 5684 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5685 5686 bool isRelatedToActivity(Rules& r, Activity* a); 5687 5688 bool isRelatedToTeacher(Teacher* t); 5689 5690 bool isRelatedToSubject(Subject* s); 5691 5692 bool isRelatedToActivityTag(ActivityTag* s); 5693 5694 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5695 5696 bool hasWrongDayOrHour(Rules& r); 5697 bool canRepairWrongDayOrHour(Rules& r); 5698 bool repairWrongDayOrHour(Rules& r); 5699 }; 5700 5701 class ConstraintStudentsMaxHoursDailyRealDays: public TimeConstraint{ 5702 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxHoursDailyRealDays) 5703 5704 public: 5705 int maxHoursDaily; 5706 5707 ConstraintStudentsMaxHoursDailyRealDays(); 5708 5709 ConstraintStudentsMaxHoursDailyRealDays(double wp, int maxnh); 5710 5711 bool computeInternalStructure(QWidget* parent, Rules& r); 5712 5713 bool hasInactiveActivities(Rules& r); 5714 5715 QString getXmlDescription(Rules& r); 5716 5717 QString getDescription(Rules& r); 5718 5719 QString getDetailedDescription(Rules& r); 5720 5721 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5722 5723 bool isRelatedToActivity(Rules& r, Activity* a); 5724 5725 bool isRelatedToTeacher(Teacher* t); 5726 5727 bool isRelatedToSubject(Subject* s); 5728 5729 bool isRelatedToActivityTag(ActivityTag* s); 5730 5731 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5732 5733 bool hasWrongDayOrHour(Rules& r); 5734 bool canRepairWrongDayOrHour(Rules& r); 5735 bool repairWrongDayOrHour(Rules& r); 5736 }; 5737 5738 class ConstraintStudentsSetMaxHoursDailyRealDays: public TimeConstraint{ 5739 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxHoursDailyRealDays) 5740 5741 public: 5742 int maxHoursDaily; 5743 5744 /** 5745 The students set name 5746 */ 5747 QString students; 5748 5749 //internal variables 5750 5751 /** 5752 The number of subgroups 5753 */ 5754 //int nSubgroups; 5755 5756 /** 5757 The subgroups 5758 */ 5759 //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; 5760 QList<int> iSubgroupsList; 5761 5762 ConstraintStudentsSetMaxHoursDailyRealDays(); 5763 5764 ConstraintStudentsSetMaxHoursDailyRealDays(double wp, int maxnh, QString s); 5765 5766 bool computeInternalStructure(QWidget* parent, Rules& r); 5767 5768 bool hasInactiveActivities(Rules& r); 5769 5770 QString getXmlDescription(Rules& r); 5771 5772 QString getDescription(Rules& r); 5773 5774 QString getDetailedDescription(Rules& r); 5775 5776 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5777 5778 bool isRelatedToActivity(Rules& r, Activity* a); 5779 5780 bool isRelatedToTeacher(Teacher* t); 5781 5782 bool isRelatedToSubject(Subject* s); 5783 5784 bool isRelatedToActivityTag(ActivityTag* s); 5785 5786 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5787 5788 bool hasWrongDayOrHour(Rules& r); 5789 bool canRepairWrongDayOrHour(Rules& r); 5790 bool repairWrongDayOrHour(Rules& r); 5791 }; 5792 5793 class ConstraintTeachersMinHoursPerMorning: public TimeConstraint{ 5794 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinHoursPerMorning) 5795 5796 public: 5797 /** 5798 The minimum hours per morning 5799 */ 5800 int minHoursPerMorning; 5801 5802 bool allowEmptyMornings; 5803 5804 ConstraintTeachersMinHoursPerMorning(); 5805 5806 ConstraintTeachersMinHoursPerMorning(double wp, int minhours, bool _allowEmptyMornings); 5807 5808 QString getXmlDescription(Rules& r); 5809 5810 bool computeInternalStructure(QWidget* parent, Rules& r); 5811 5812 bool hasInactiveActivities(Rules& r); 5813 5814 QString getDescription(Rules& r); 5815 5816 QString getDetailedDescription(Rules& r); 5817 5818 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5819 5820 bool isRelatedToActivity(Rules& r, Activity* a); 5821 5822 bool isRelatedToTeacher(Teacher* t); 5823 5824 bool isRelatedToSubject(Subject* s); 5825 5826 bool isRelatedToActivityTag(ActivityTag* s); 5827 5828 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5829 5830 bool hasWrongDayOrHour(Rules& r); 5831 bool canRepairWrongDayOrHour(Rules& r); 5832 bool repairWrongDayOrHour(Rules& r); 5833 }; 5834 5835 class ConstraintTeacherMinHoursPerMorning: public TimeConstraint{ 5836 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinHoursPerMorning) 5837 5838 public: 5839 /** 5840 The minimum hours per morning 5841 */ 5842 int minHoursPerMorning; 5843 5844 QString teacherName; 5845 5846 int teacher_ID; 5847 5848 bool allowEmptyMornings; 5849 5850 ConstraintTeacherMinHoursPerMorning(); 5851 5852 ConstraintTeacherMinHoursPerMorning(double wp, int minhours, const QString& teacher, bool _allowEmptyMornings); 5853 5854 QString getXmlDescription(Rules& r); 5855 5856 bool computeInternalStructure(QWidget* parent, Rules& r); 5857 5858 bool hasInactiveActivities(Rules& r); 5859 5860 QString getDescription(Rules& r); 5861 5862 QString getDetailedDescription(Rules& r); 5863 5864 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5865 5866 bool isRelatedToActivity(Rules& r, Activity* a); 5867 5868 bool isRelatedToTeacher(Teacher* t); 5869 5870 bool isRelatedToSubject(Subject* s); 5871 5872 bool isRelatedToActivityTag(ActivityTag* s); 5873 5874 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5875 5876 bool hasWrongDayOrHour(Rules& r); 5877 bool canRepairWrongDayOrHour(Rules& r); 5878 bool repairWrongDayOrHour(Rules& r); 5879 }; 5880 5881 class ConstraintTeachersMinHoursDailyRealDays: public TimeConstraint{ 5882 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinHoursDailyRealDays) 5883 5884 public: 5885 /** 5886 The minimum hours daily 5887 */ 5888 int minHoursDaily; 5889 5890 bool allowEmptyDays; 5891 5892 ConstraintTeachersMinHoursDailyRealDays(); 5893 5894 ConstraintTeachersMinHoursDailyRealDays(double wp, int minhours, bool _allowEmptyDays); 5895 5896 QString getXmlDescription(Rules& r); 5897 5898 bool computeInternalStructure(QWidget* parent, Rules& r); 5899 5900 bool hasInactiveActivities(Rules& r); 5901 5902 QString getDescription(Rules& r); 5903 5904 QString getDetailedDescription(Rules& r); 5905 5906 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5907 5908 bool isRelatedToActivity(Rules& r, Activity* a); 5909 5910 bool isRelatedToTeacher(Teacher* t); 5911 5912 bool isRelatedToSubject(Subject* s); 5913 5914 bool isRelatedToActivityTag(ActivityTag* s); 5915 5916 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5917 5918 bool hasWrongDayOrHour(Rules& r); 5919 bool canRepairWrongDayOrHour(Rules& r); 5920 bool repairWrongDayOrHour(Rules& r); 5921 }; 5922 5923 class ConstraintTeacherMinHoursDailyRealDays: public TimeConstraint{ 5924 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinHoursDailyRealDays) 5925 5926 public: 5927 /** 5928 The minimum hours daily 5929 */ 5930 int minHoursDaily; 5931 5932 QString teacherName; 5933 5934 int teacher_ID; 5935 5936 bool allowEmptyDays; 5937 5938 ConstraintTeacherMinHoursDailyRealDays(); 5939 5940 ConstraintTeacherMinHoursDailyRealDays(double wp, int minhours, const QString& teacher, bool _allowEmptyDays); 5941 5942 QString getXmlDescription(Rules& r); 5943 5944 bool computeInternalStructure(QWidget* parent, Rules& r); 5945 5946 bool hasInactiveActivities(Rules& r); 5947 5948 QString getDescription(Rules& r); 5949 5950 QString getDetailedDescription(Rules& r); 5951 5952 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 5953 5954 bool isRelatedToActivity(Rules& r, Activity* a); 5955 5956 bool isRelatedToTeacher(Teacher* t); 5957 5958 bool isRelatedToSubject(Subject* s); 5959 5960 bool isRelatedToActivityTag(ActivityTag* s); 5961 5962 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 5963 5964 bool hasWrongDayOrHour(Rules& r); 5965 bool canRepairWrongDayOrHour(Rules& r); 5966 bool repairWrongDayOrHour(Rules& r); 5967 }; 5968 5969 5970 //morning 5971 class ConstraintTeacherMorningIntervalMaxDaysPerWeek: public TimeConstraint{ 5972 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMorningIntervalMaxDaysPerWeek) 5973 5974 public: 5975 /** 5976 The number of maximum allowed working days per week (mornings) 5977 */ 5978 int maxDaysPerWeek; 5979 5980 int startHour; 5981 5982 int endHour; //might be = to gt.rules.nHoursPerDay 5983 5984 /** 5985 The teacher's name 5986 */ 5987 QString teacherName; 5988 5989 /** 5990 The teacher's id, or index in the rules 5991 */ 5992 int teacher_ID; 5993 5994 ConstraintTeacherMorningIntervalMaxDaysPerWeek(); 5995 5996 ConstraintTeacherMorningIntervalMaxDaysPerWeek(double wp, int maxnd, QString tn, int sh, int eh); 5997 5998 bool computeInternalStructure(QWidget* parent, Rules& r); 5999 6000 bool hasInactiveActivities(Rules& r); 6001 6002 QString getXmlDescription(Rules& r); 6003 6004 QString getDescription(Rules& r); 6005 6006 QString getDetailedDescription(Rules& r); 6007 6008 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6009 6010 bool isRelatedToActivity(Rules& r, Activity* a); 6011 6012 bool isRelatedToTeacher(Teacher* t); 6013 6014 bool isRelatedToSubject(Subject* s); 6015 6016 bool isRelatedToActivityTag(ActivityTag* s); 6017 6018 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6019 6020 bool hasWrongDayOrHour(Rules& r); 6021 bool canRepairWrongDayOrHour(Rules& r); 6022 bool repairWrongDayOrHour(Rules& r); 6023 }; 6024 6025 class ConstraintTeachersMorningIntervalMaxDaysPerWeek: public TimeConstraint{ 6026 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMorningIntervalMaxDaysPerWeek) 6027 6028 public: 6029 /** 6030 The number of maximum allowed working days per week (mornings) 6031 */ 6032 int maxDaysPerWeek; 6033 6034 int startHour; 6035 6036 int endHour; //might be = to gt.rules.nHoursPerDay 6037 6038 ConstraintTeachersMorningIntervalMaxDaysPerWeek(); 6039 6040 ConstraintTeachersMorningIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh); 6041 6042 bool computeInternalStructure(QWidget* parent, Rules& r); 6043 6044 bool hasInactiveActivities(Rules& r); 6045 6046 QString getXmlDescription(Rules& r); 6047 6048 QString getDescription(Rules& r); 6049 6050 QString getDetailedDescription(Rules& r); 6051 6052 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6053 6054 bool isRelatedToActivity(Rules& r, Activity* a); 6055 6056 bool isRelatedToTeacher(Teacher* t); 6057 6058 bool isRelatedToSubject(Subject* s); 6059 6060 bool isRelatedToActivityTag(ActivityTag* s); 6061 6062 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6063 6064 bool hasWrongDayOrHour(Rules& r); 6065 bool canRepairWrongDayOrHour(Rules& r); 6066 bool repairWrongDayOrHour(Rules& r); 6067 }; 6068 6069 //afternoon 6070 class ConstraintTeacherAfternoonIntervalMaxDaysPerWeek: public TimeConstraint{ 6071 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherIntervalMaxDaysPerWeek) 6072 6073 public: 6074 /** 6075 The number of maximum allowed working days per week (afternoons) 6076 */ 6077 int maxDaysPerWeek; 6078 6079 int startHour; 6080 6081 int endHour; //might be = to gt.rules.nHoursPerDay 6082 6083 /** 6084 The teacher's name 6085 */ 6086 QString teacherName; 6087 6088 /** 6089 The teacher's id, or index in the rules 6090 */ 6091 int teacher_ID; 6092 6093 ConstraintTeacherAfternoonIntervalMaxDaysPerWeek(); 6094 6095 ConstraintTeacherAfternoonIntervalMaxDaysPerWeek(double wp, int maxnd, QString tn, int sh, int eh); 6096 6097 bool computeInternalStructure(QWidget* parent, Rules& r); 6098 6099 bool hasInactiveActivities(Rules& r); 6100 6101 QString getXmlDescription(Rules& r); 6102 6103 QString getDescription(Rules& r); 6104 6105 QString getDetailedDescription(Rules& r); 6106 6107 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6108 6109 bool isRelatedToActivity(Rules& r, Activity* a); 6110 6111 bool isRelatedToTeacher(Teacher* t); 6112 6113 bool isRelatedToSubject(Subject* s); 6114 6115 bool isRelatedToActivityTag(ActivityTag* s); 6116 6117 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6118 6119 bool hasWrongDayOrHour(Rules& r); 6120 bool canRepairWrongDayOrHour(Rules& r); 6121 bool repairWrongDayOrHour(Rules& r); 6122 }; 6123 6124 class ConstraintTeachersAfternoonIntervalMaxDaysPerWeek: public TimeConstraint{ 6125 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersIntervalMaxDaysPerWeek) 6126 6127 public: 6128 /** 6129 The number of maximum allowed working days per week (afternoons) 6130 */ 6131 int maxDaysPerWeek; 6132 6133 int startHour; 6134 6135 int endHour; //might be = to gt.rules.nHoursPerDay 6136 6137 ConstraintTeachersAfternoonIntervalMaxDaysPerWeek(); 6138 6139 ConstraintTeachersAfternoonIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh); 6140 6141 bool computeInternalStructure(QWidget* parent, Rules& r); 6142 6143 bool hasInactiveActivities(Rules& r); 6144 6145 QString getXmlDescription(Rules& r); 6146 6147 QString getDescription(Rules& r); 6148 6149 QString getDetailedDescription(Rules& r); 6150 6151 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6152 6153 bool isRelatedToActivity(Rules& r, Activity* a); 6154 6155 bool isRelatedToTeacher(Teacher* t); 6156 6157 bool isRelatedToSubject(Subject* s); 6158 6159 bool isRelatedToActivityTag(ActivityTag* s); 6160 6161 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6162 6163 bool hasWrongDayOrHour(Rules& r); 6164 bool canRepairWrongDayOrHour(Rules& r); 6165 bool repairWrongDayOrHour(Rules& r); 6166 }; 6167 6168 class ConstraintTeachersActivityTagMaxHoursDailyRealDays: public TimeConstraint{ 6169 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMaxHoursDailyRealDays) 6170 6171 public: 6172 /** 6173 The maximum hours daily 6174 */ 6175 int maxHoursDaily; 6176 6177 QString activityTagName; 6178 6179 int activityTagIndex; 6180 6181 QList<int> canonicalTeachersList; 6182 6183 ConstraintTeachersActivityTagMaxHoursDailyRealDays(); 6184 6185 ConstraintTeachersActivityTagMaxHoursDailyRealDays(double wp, int maxhours, const QString& activityTag); 6186 6187 QString getXmlDescription(Rules& r); 6188 6189 bool computeInternalStructure(QWidget* parent, Rules& r); 6190 6191 bool hasInactiveActivities(Rules& r); 6192 6193 QString getDescription(Rules& r); 6194 6195 QString getDetailedDescription(Rules& r); 6196 6197 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6198 6199 bool isRelatedToActivity(Rules& r, Activity* a); 6200 6201 bool isRelatedToTeacher(Teacher* t); 6202 6203 bool isRelatedToSubject(Subject* s); 6204 6205 bool isRelatedToActivityTag(ActivityTag* s); 6206 6207 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6208 6209 bool hasWrongDayOrHour(Rules& r); 6210 bool canRepairWrongDayOrHour(Rules& r); 6211 bool repairWrongDayOrHour(Rules& r); 6212 }; 6213 6214 class ConstraintTeacherActivityTagMaxHoursDailyRealDays: public TimeConstraint{ 6215 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMaxHoursDailyRealDays) 6216 6217 public: 6218 /** 6219 The maximum hours daily 6220 */ 6221 int maxHoursDaily; 6222 6223 QString teacherName; 6224 6225 QString activityTagName; 6226 6227 int teacher_ID; 6228 6229 int activityTagIndex; 6230 6231 QList<int> canonicalTeachersList; 6232 6233 ConstraintTeacherActivityTagMaxHoursDailyRealDays(); 6234 6235 ConstraintTeacherActivityTagMaxHoursDailyRealDays(double wp, int maxhours, const QString& teacher, const QString& activityTag); 6236 6237 QString getXmlDescription(Rules& r); 6238 6239 bool computeInternalStructure(QWidget* parent, Rules& r); 6240 6241 bool hasInactiveActivities(Rules& r); 6242 6243 QString getDescription(Rules& r); 6244 6245 QString getDetailedDescription(Rules& r); 6246 6247 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6248 6249 bool isRelatedToActivity(Rules& r, Activity* a); 6250 6251 bool isRelatedToTeacher(Teacher* t); 6252 6253 bool isRelatedToSubject(Subject* s); 6254 6255 bool isRelatedToActivityTag(ActivityTag* s); 6256 6257 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6258 6259 bool hasWrongDayOrHour(Rules& r); 6260 bool canRepairWrongDayOrHour(Rules& r); 6261 bool repairWrongDayOrHour(Rules& r); 6262 }; 6263 6264 class ConstraintStudentsActivityTagMaxHoursDailyRealDays: public TimeConstraint{ 6265 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMaxHoursDailyRealDays) 6266 6267 public: 6268 int maxHoursDaily; 6269 6270 QString activityTagName; 6271 6272 int activityTagIndex; 6273 6274 QList<int> canonicalSubgroupsList; 6275 6276 ConstraintStudentsActivityTagMaxHoursDailyRealDays(); 6277 6278 ConstraintStudentsActivityTagMaxHoursDailyRealDays(double wp, int maxnh, const QString& activityTag); 6279 6280 bool computeInternalStructure(QWidget* parent, Rules& r); 6281 6282 bool hasInactiveActivities(Rules& r); 6283 6284 QString getXmlDescription(Rules& r); 6285 6286 QString getDescription(Rules& r); 6287 6288 QString getDetailedDescription(Rules& r); 6289 6290 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6291 6292 bool isRelatedToActivity(Rules& r, Activity* a); 6293 6294 bool isRelatedToTeacher(Teacher* t); 6295 6296 bool isRelatedToSubject(Subject* s); 6297 6298 bool isRelatedToActivityTag(ActivityTag* s); 6299 6300 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6301 6302 bool hasWrongDayOrHour(Rules& r); 6303 bool canRepairWrongDayOrHour(Rules& r); 6304 bool repairWrongDayOrHour(Rules& r); 6305 }; 6306 6307 class ConstraintStudentsSetActivityTagMaxHoursDailyRealDays: public TimeConstraint{ 6308 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMaxHoursDailyRealDays) 6309 6310 public: 6311 int maxHoursDaily; 6312 6313 /** 6314 The students set name 6315 */ 6316 QString students; 6317 6318 QString activityTagName; 6319 6320 //internal variables 6321 6322 int activityTagIndex; 6323 6324 /** 6325 The number of subgroups 6326 */ 6327 //int nSubgroups; 6328 6329 /** 6330 The subgroups 6331 */ 6332 //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; 6333 QList<int> iSubgroupsList; 6334 6335 QList<int> canonicalSubgroupsList; 6336 6337 ConstraintStudentsSetActivityTagMaxHoursDailyRealDays(); 6338 6339 ConstraintStudentsSetActivityTagMaxHoursDailyRealDays(double wp, int maxnh, const QString& s, const QString& activityTag); 6340 6341 bool computeInternalStructure(QWidget* parent, Rules& r); 6342 6343 bool hasInactiveActivities(Rules& r); 6344 6345 QString getXmlDescription(Rules& r); 6346 6347 QString getDescription(Rules& r); 6348 6349 QString getDetailedDescription(Rules& r); 6350 6351 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6352 6353 bool isRelatedToActivity(Rules& r, Activity* a); 6354 6355 bool isRelatedToTeacher(Teacher* t); 6356 6357 bool isRelatedToSubject(Subject* s); 6358 6359 bool isRelatedToActivityTag(ActivityTag* s); 6360 6361 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6362 6363 bool hasWrongDayOrHour(Rules& r); 6364 bool canRepairWrongDayOrHour(Rules& r); 6365 bool repairWrongDayOrHour(Rules& r); 6366 }; 6367 6368 class ConstraintStudentsMaxGapsPerRealDay: public TimeConstraint{ 6369 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxGapsPerRealDay) 6370 6371 public: 6372 int maxGaps; 6373 6374 ConstraintStudentsMaxGapsPerRealDay(); 6375 6376 ConstraintStudentsMaxGapsPerRealDay(double wp, int mg); 6377 6378 bool computeInternalStructure(QWidget* parent, Rules& r); 6379 6380 bool hasInactiveActivities(Rules& r); 6381 6382 QString getXmlDescription(Rules& r); 6383 6384 QString getDescription(Rules& r); 6385 6386 QString getDetailedDescription(Rules& r); 6387 6388 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6389 6390 bool isRelatedToActivity(Rules& r, Activity* a); 6391 6392 bool isRelatedToTeacher(Teacher* t); 6393 6394 bool isRelatedToSubject(Subject* s); 6395 6396 bool isRelatedToActivityTag(ActivityTag* s); 6397 6398 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6399 6400 bool hasWrongDayOrHour(Rules& r); 6401 bool canRepairWrongDayOrHour(Rules& r); 6402 bool repairWrongDayOrHour(Rules& r); 6403 }; 6404 6405 class ConstraintStudentsSetMaxGapsPerRealDay: public TimeConstraint{ 6406 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxGapsPerRealDay) 6407 6408 public: 6409 int maxGaps; 6410 6411 /** 6412 The name of the students set for this constraint 6413 */ 6414 QString students; 6415 6416 //internal redundant data 6417 6418 /** 6419 The number of subgroups 6420 */ 6421 //int nSubgroups; 6422 6423 /** 6424 The subgroups 6425 */ 6426 QList<int> iSubgroupsList; 6427 6428 ConstraintStudentsSetMaxGapsPerRealDay(); 6429 6430 ConstraintStudentsSetMaxGapsPerRealDay(double wp, int mg, const QString& st ); 6431 6432 bool computeInternalStructure(QWidget* parent, Rules& r); 6433 6434 bool hasInactiveActivities(Rules& r); 6435 6436 QString getXmlDescription(Rules& r); 6437 6438 QString getDescription(Rules& r); 6439 6440 QString getDetailedDescription(Rules& r); 6441 6442 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6443 6444 bool isRelatedToActivity(Rules& r, Activity* a); 6445 6446 bool isRelatedToTeacher(Teacher* t); 6447 6448 bool isRelatedToSubject(Subject* s); 6449 6450 bool isRelatedToActivityTag(ActivityTag* s); 6451 6452 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6453 6454 bool hasWrongDayOrHour(Rules& r); 6455 bool canRepairWrongDayOrHour(Rules& r); 6456 bool repairWrongDayOrHour(Rules& r); 6457 }; 6458 6459 class ConstraintStudentsSetMaxRealDaysPerWeek: public TimeConstraint{ 6460 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxRealDaysPerWeek) 6461 6462 public: 6463 /** 6464 The number of maximum allowed working days per week 6465 */ 6466 int maxDaysPerWeek; 6467 6468 /** 6469 The name of the students set for this constraint 6470 */ 6471 QString students; 6472 6473 //internal redundant data 6474 6475 /** 6476 The number of subgroups 6477 */ 6478 //int nSubgroups; 6479 6480 /** 6481 The subgroups 6482 */ 6483 QList<int> iSubgroupsList; 6484 6485 ConstraintStudentsSetMaxRealDaysPerWeek(); 6486 6487 ConstraintStudentsSetMaxRealDaysPerWeek(double wp, int maxnd, QString sn); 6488 6489 bool computeInternalStructure(QWidget* parent, Rules& r); 6490 6491 bool hasInactiveActivities(Rules& r); 6492 6493 QString getXmlDescription(Rules& r); 6494 6495 QString getDescription(Rules& r); 6496 6497 QString getDetailedDescription(Rules& r); 6498 6499 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6500 6501 bool isRelatedToActivity(Rules& r, Activity* a); 6502 6503 bool isRelatedToTeacher(Teacher* t); 6504 6505 bool isRelatedToSubject(Subject* s); 6506 6507 bool isRelatedToActivityTag(ActivityTag* s); 6508 6509 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6510 6511 bool hasWrongDayOrHour(Rules& r); 6512 bool canRepairWrongDayOrHour(Rules& r); 6513 bool repairWrongDayOrHour(Rules& r); 6514 }; 6515 6516 class ConstraintStudentsMaxRealDaysPerWeek: public TimeConstraint{ 6517 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxRealDaysPerWeek) 6518 6519 public: 6520 /** 6521 The number of maximum allowed working days per week 6522 */ 6523 int maxDaysPerWeek; 6524 6525 ConstraintStudentsMaxRealDaysPerWeek(); 6526 6527 ConstraintStudentsMaxRealDaysPerWeek(double wp, int maxnd); 6528 6529 bool computeInternalStructure(QWidget* parent, Rules& r); 6530 6531 bool hasInactiveActivities(Rules& r); 6532 6533 QString getXmlDescription(Rules& r); 6534 6535 QString getDescription(Rules& r); 6536 6537 QString getDetailedDescription(Rules& r); 6538 6539 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6540 6541 bool isRelatedToActivity(Rules& r, Activity* a); 6542 6543 bool isRelatedToTeacher(Teacher* t); 6544 6545 bool isRelatedToSubject(Subject* s); 6546 6547 bool isRelatedToActivityTag(ActivityTag* s); 6548 6549 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6550 6551 bool hasWrongDayOrHour(Rules& r); 6552 bool canRepairWrongDayOrHour(Rules& r); 6553 bool repairWrongDayOrHour(Rules& r); 6554 }; 6555 6556 class ConstraintTeacherMaxSpanPerRealDay: public TimeConstraint{ 6557 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxSpanPerRealDay) 6558 6559 public: 6560 /** 6561 The maximum span daily 6562 */ 6563 int maxSpanPerDay; 6564 6565 bool allowOneDayExceptionPlusOne; 6566 6567 QString teacherName; 6568 6569 int teacher_ID; 6570 6571 ConstraintTeacherMaxSpanPerRealDay(); 6572 6573 ConstraintTeacherMaxSpanPerRealDay(double wp, int maxspan, bool except, const QString& teacher); 6574 6575 QString getXmlDescription(Rules& r); 6576 6577 bool computeInternalStructure(QWidget* parent, Rules& r); 6578 6579 bool hasInactiveActivities(Rules& r); 6580 6581 QString getDescription(Rules& r); 6582 6583 QString getDetailedDescription(Rules& r); 6584 6585 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 6586 6587 bool isRelatedToActivity(Rules& r, Activity* a); 6588 6589 bool isRelatedToTeacher(Teacher* t); 6590 6591 bool isRelatedToSubject(Subject* s); 6592 6593 bool isRelatedToActivityTag(ActivityTag* s); 6594 6595 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6596 6597 bool hasWrongDayOrHour(Rules& r); 6598 bool canRepairWrongDayOrHour(Rules& r); 6599 bool repairWrongDayOrHour(Rules& r); 6600 }; 6601 6602 class ConstraintTeachersMaxSpanPerRealDay: public TimeConstraint{ 6603 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxSpanPerRealDay) 6604 6605 public: 6606 /** 6607 The maximum span daily 6608 */ 6609 int maxSpanPerDay; 6610 6611 bool allowOneDayExceptionPlusOne; 6612 6613 ConstraintTeachersMaxSpanPerRealDay(); 6614 6615 ConstraintTeachersMaxSpanPerRealDay(double wp, int maxspan, bool except); 6616 6617 QString getXmlDescription(Rules& r); 6618 6619 bool computeInternalStructure(QWidget* parent, Rules& r); 6620 6621 bool hasInactiveActivities(Rules& r); 6622 6623 QString getDescription(Rules& r); 6624 6625 QString getDetailedDescription(Rules& r); 6626 6627 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 6628 6629 bool isRelatedToActivity(Rules& r, Activity* a); 6630 6631 bool isRelatedToTeacher(Teacher* t); 6632 6633 bool isRelatedToSubject(Subject* s); 6634 6635 bool isRelatedToActivityTag(ActivityTag* s); 6636 6637 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6638 6639 bool hasWrongDayOrHour(Rules& r); 6640 bool canRepairWrongDayOrHour(Rules& r); 6641 bool repairWrongDayOrHour(Rules& r); 6642 }; 6643 6644 class ConstraintStudentsSetMaxSpanPerRealDay: public TimeConstraint{ 6645 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxSpanPerRealDay) 6646 6647 public: 6648 int maxSpanPerDay; 6649 6650 /** 6651 The name of the students set for this constraint 6652 */ 6653 QString students; 6654 6655 //internal redundant data 6656 6657 /** 6658 The number of subgroups 6659 */ 6660 //int nSubgroups; 6661 6662 /** 6663 The subgroups 6664 */ 6665 QList<int> iSubgroupsList; 6666 6667 ConstraintStudentsSetMaxSpanPerRealDay(); 6668 6669 ConstraintStudentsSetMaxSpanPerRealDay(double wp, int maxspan, const QString& sn); 6670 6671 bool computeInternalStructure(QWidget* parent, Rules& r); 6672 6673 bool hasInactiveActivities(Rules& r); 6674 6675 QString getXmlDescription(Rules& r); 6676 6677 QString getDescription(Rules& r); 6678 6679 QString getDetailedDescription(Rules& r); 6680 6681 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 6682 6683 bool isRelatedToActivity(Rules& r, Activity* a); 6684 6685 bool isRelatedToTeacher(Teacher* t); 6686 6687 bool isRelatedToSubject(Subject* s); 6688 6689 bool isRelatedToActivityTag(ActivityTag* s); 6690 6691 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6692 6693 bool hasWrongDayOrHour(Rules& r); 6694 bool canRepairWrongDayOrHour(Rules& r); 6695 bool repairWrongDayOrHour(Rules& r); 6696 }; 6697 6698 class ConstraintStudentsMaxSpanPerRealDay: public TimeConstraint{ 6699 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxSpanPerRealDay) 6700 6701 public: 6702 int maxSpanPerDay; 6703 6704 ConstraintStudentsMaxSpanPerRealDay(); 6705 6706 ConstraintStudentsMaxSpanPerRealDay(double wp, int maxspan); 6707 6708 bool computeInternalStructure(QWidget* parent, Rules& r); 6709 6710 bool hasInactiveActivities(Rules& r); 6711 6712 QString getXmlDescription(Rules& r); 6713 6714 QString getDescription(Rules& r); 6715 6716 QString getDetailedDescription(Rules& r); 6717 6718 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 6719 6720 bool isRelatedToActivity(Rules& r, Activity* a); 6721 6722 bool isRelatedToTeacher(Teacher* t); 6723 6724 bool isRelatedToSubject(Subject* s); 6725 6726 bool isRelatedToActivityTag(ActivityTag* s); 6727 6728 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6729 6730 bool hasWrongDayOrHour(Rules& r); 6731 bool canRepairWrongDayOrHour(Rules& r); 6732 bool repairWrongDayOrHour(Rules& r); 6733 }; 6734 6735 class ConstraintTeacherMaxAfternoonsPerWeek: public TimeConstraint{ 6736 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxAfternoonsPerWeek) 6737 6738 public: 6739 /** 6740 The number of maximum allowed working days per week (-1 for don't care) 6741 */ 6742 int maxAfternoonsPerWeek; 6743 6744 /** 6745 The teacher's name 6746 */ 6747 QString teacherName; 6748 6749 /** 6750 The teacher's id, or index in the rules 6751 */ 6752 int teacher_ID; 6753 6754 ConstraintTeacherMaxAfternoonsPerWeek(); 6755 6756 ConstraintTeacherMaxAfternoonsPerWeek(double wp, int maxnd, QString t); 6757 6758 bool computeInternalStructure(QWidget* parent, Rules& r); 6759 6760 bool hasInactiveActivities(Rules& r); 6761 6762 QString getXmlDescription(Rules& r); 6763 6764 QString getDescription(Rules& r); 6765 6766 QString getDetailedDescription(Rules& r); 6767 6768 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6769 6770 bool isRelatedToActivity(Rules& r, Activity* a); 6771 6772 bool isRelatedToTeacher(Teacher* t); 6773 6774 bool isRelatedToSubject(Subject* s); 6775 6776 bool isRelatedToActivityTag(ActivityTag* s); 6777 6778 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6779 6780 bool hasWrongDayOrHour(Rules& r); 6781 bool canRepairWrongDayOrHour(Rules& r); 6782 bool repairWrongDayOrHour(Rules& r); 6783 }; 6784 6785 class ConstraintTeachersMaxAfternoonsPerWeek: public TimeConstraint{ 6786 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxAfternoonsPerWeek) 6787 6788 public: 6789 /** 6790 The number of maximum allowed working days per week (-1 for don't care) 6791 */ 6792 int maxAfternoonsPerWeek; 6793 6794 ConstraintTeachersMaxAfternoonsPerWeek(); 6795 6796 ConstraintTeachersMaxAfternoonsPerWeek(double wp, int maxnd); 6797 6798 bool computeInternalStructure(QWidget* parent, Rules& r); 6799 6800 bool hasInactiveActivities(Rules& r); 6801 6802 QString getXmlDescription(Rules& r); 6803 6804 QString getDescription(Rules& r); 6805 6806 QString getDetailedDescription(Rules& r); 6807 6808 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6809 6810 bool isRelatedToActivity(Rules& r, Activity* a); 6811 6812 bool isRelatedToTeacher(Teacher* t); 6813 6814 bool isRelatedToSubject(Subject* s); 6815 6816 bool isRelatedToActivityTag(ActivityTag* s); 6817 6818 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6819 6820 bool hasWrongDayOrHour(Rules& r); 6821 bool canRepairWrongDayOrHour(Rules& r); 6822 bool repairWrongDayOrHour(Rules& r); 6823 }; 6824 6825 class ConstraintTeacherMaxMorningsPerWeek: public TimeConstraint{ 6826 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxMorningsPerWeek) 6827 6828 public: 6829 /** 6830 The number of maximum allowed working days per week (-1 for don't care) 6831 */ 6832 int maxMorningsPerWeek; 6833 6834 /** 6835 The teacher's name 6836 */ 6837 QString teacherName; 6838 6839 /** 6840 The teacher's id, or index in the rules 6841 */ 6842 int teacher_ID; 6843 6844 ConstraintTeacherMaxMorningsPerWeek(); 6845 6846 ConstraintTeacherMaxMorningsPerWeek(double wp, int maxnd, QString t); 6847 6848 bool computeInternalStructure(QWidget* parent, Rules& r); 6849 6850 bool hasInactiveActivities(Rules& r); 6851 6852 QString getXmlDescription(Rules& r); 6853 6854 QString getDescription(Rules& r); 6855 6856 QString getDetailedDescription(Rules& r); 6857 6858 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6859 6860 bool isRelatedToActivity(Rules& r, Activity* a); 6861 6862 bool isRelatedToTeacher(Teacher* t); 6863 6864 bool isRelatedToSubject(Subject* s); 6865 6866 bool isRelatedToActivityTag(ActivityTag* s); 6867 6868 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6869 6870 bool hasWrongDayOrHour(Rules& r); 6871 bool canRepairWrongDayOrHour(Rules& r); 6872 bool repairWrongDayOrHour(Rules& r); 6873 }; 6874 6875 class ConstraintTeachersMaxMorningsPerWeek: public TimeConstraint{ 6876 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxMorningsPerWeek) 6877 6878 public: 6879 /** 6880 The number of maximum allowed working days per week (-1 for don't care) 6881 */ 6882 int maxMorningsPerWeek; 6883 6884 ConstraintTeachersMaxMorningsPerWeek(); 6885 6886 ConstraintTeachersMaxMorningsPerWeek(double wp, int maxnd); 6887 6888 bool computeInternalStructure(QWidget* parent, Rules& r); 6889 6890 bool hasInactiveActivities(Rules& r); 6891 6892 QString getXmlDescription(Rules& r); 6893 6894 QString getDescription(Rules& r); 6895 6896 QString getDetailedDescription(Rules& r); 6897 6898 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6899 6900 bool isRelatedToActivity(Rules& r, Activity* a); 6901 6902 bool isRelatedToTeacher(Teacher* t); 6903 6904 bool isRelatedToSubject(Subject* s); 6905 6906 bool isRelatedToActivityTag(ActivityTag* s); 6907 6908 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6909 6910 bool hasWrongDayOrHour(Rules& r); 6911 bool canRepairWrongDayOrHour(Rules& r); 6912 bool repairWrongDayOrHour(Rules& r); 6913 }; 6914 6915 class ConstraintTeacherMaxTwoActivityTagsPerDayFromN1N2N3: public TimeConstraint{ 6916 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxTwoActivityTagsPerDayFromN1N2N3) 6917 6918 public: 6919 6920 /** 6921 The teacher's name 6922 */ 6923 QString teacherName; 6924 6925 /** 6926 The teacher's id, or index in the rules 6927 */ 6928 int teacher_ID; 6929 6930 ConstraintTeacherMaxTwoActivityTagsPerDayFromN1N2N3(); 6931 6932 ConstraintTeacherMaxTwoActivityTagsPerDayFromN1N2N3(double wp, QString t); 6933 6934 bool computeInternalStructure(QWidget* parent, Rules& r); 6935 6936 bool hasInactiveActivities(Rules& r); 6937 6938 QString getXmlDescription(Rules& r); 6939 6940 QString getDescription(Rules& r); 6941 6942 QString getDetailedDescription(Rules& r); 6943 6944 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6945 6946 bool isRelatedToActivity(Rules& r, Activity* a); 6947 6948 bool isRelatedToTeacher(Teacher* t); 6949 6950 bool isRelatedToSubject(Subject* s); 6951 6952 bool isRelatedToActivityTag(ActivityTag* s); 6953 6954 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6955 6956 bool hasWrongDayOrHour(Rules& r); 6957 bool canRepairWrongDayOrHour(Rules& r); 6958 bool repairWrongDayOrHour(Rules& r); 6959 }; 6960 6961 class ConstraintTeachersMaxTwoActivityTagsPerDayFromN1N2N3: public TimeConstraint{ 6962 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxTwoActivityTagsPerDayFromN1N2N3) 6963 6964 public: 6965 6966 ConstraintTeachersMaxTwoActivityTagsPerDayFromN1N2N3(); 6967 6968 ConstraintTeachersMaxTwoActivityTagsPerDayFromN1N2N3(double wp); 6969 6970 bool computeInternalStructure(QWidget* parent, Rules& r); 6971 6972 bool hasInactiveActivities(Rules& r); 6973 6974 QString getXmlDescription(Rules& r); 6975 6976 QString getDescription(Rules& r); 6977 6978 QString getDetailedDescription(Rules& r); 6979 6980 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 6981 6982 bool isRelatedToActivity(Rules& r, Activity* a); 6983 6984 bool isRelatedToTeacher(Teacher* t); 6985 6986 bool isRelatedToSubject(Subject* s); 6987 6988 bool isRelatedToActivityTag(ActivityTag* s); 6989 6990 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 6991 6992 bool hasWrongDayOrHour(Rules& r); 6993 bool canRepairWrongDayOrHour(Rules& r); 6994 bool repairWrongDayOrHour(Rules& r); 6995 }; 6996 6997 6998 class ConstraintTeacherMinMorningsPerWeek: public TimeConstraint{ 6999 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinMorningsPerWeek) 7000 7001 public: 7002 int minMorningsPerWeek; 7003 7004 /** 7005 The teacher's name 7006 */ 7007 QString teacherName; 7008 7009 /** 7010 The teacher's id, or index in the rules 7011 */ 7012 int teacher_ID; 7013 7014 ConstraintTeacherMinMorningsPerWeek(); 7015 7016 ConstraintTeacherMinMorningsPerWeek(double wp, int minmornings, const QString& t); 7017 7018 bool computeInternalStructure(QWidget* parent, Rules& r); 7019 7020 bool hasInactiveActivities(Rules& r); 7021 7022 QString getXmlDescription(Rules& r); 7023 7024 QString getDescription(Rules& r); 7025 7026 QString getDetailedDescription(Rules& r); 7027 7028 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7029 7030 bool isRelatedToActivity(Rules& r, Activity* a); 7031 7032 bool isRelatedToTeacher(Teacher* t); 7033 7034 bool isRelatedToSubject(Subject* s); 7035 7036 bool isRelatedToActivityTag(ActivityTag* s); 7037 7038 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7039 7040 bool hasWrongDayOrHour(Rules& r); 7041 bool canRepairWrongDayOrHour(Rules& r); 7042 bool repairWrongDayOrHour(Rules& r); 7043 }; 7044 7045 class ConstraintTeachersMinMorningsPerWeek: public TimeConstraint{ 7046 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinMorningsPerWeek) 7047 7048 public: 7049 int minMorningsPerWeek; 7050 7051 ConstraintTeachersMinMorningsPerWeek(); 7052 7053 ConstraintTeachersMinMorningsPerWeek(double wp, int minmornings); 7054 7055 bool computeInternalStructure(QWidget* parent, Rules& r); 7056 7057 bool hasInactiveActivities(Rules& r); 7058 7059 QString getXmlDescription(Rules& r); 7060 7061 QString getDescription(Rules& r); 7062 7063 QString getDetailedDescription(Rules& r); 7064 7065 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7066 7067 bool isRelatedToActivity(Rules& r, Activity* a); 7068 7069 bool isRelatedToTeacher(Teacher* t); 7070 7071 bool isRelatedToSubject(Subject* s); 7072 7073 bool isRelatedToActivityTag(ActivityTag* s); 7074 7075 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7076 7077 bool hasWrongDayOrHour(Rules& r); 7078 bool canRepairWrongDayOrHour(Rules& r); 7079 bool repairWrongDayOrHour(Rules& r); 7080 }; 7081 7082 class ConstraintTeacherMinAfternoonsPerWeek: public TimeConstraint{ 7083 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinAfternoonsPerWeek) 7084 7085 public: 7086 int minAfternoonsPerWeek; 7087 7088 /** 7089 The teacher's name 7090 */ 7091 QString teacherName; 7092 7093 /** 7094 The teacher's id, or index in the rules 7095 */ 7096 int teacher_ID; 7097 7098 ConstraintTeacherMinAfternoonsPerWeek(); 7099 7100 ConstraintTeacherMinAfternoonsPerWeek(double wp, int minafternoons, const QString& t); 7101 7102 bool computeInternalStructure(QWidget* parent, Rules& r); 7103 7104 bool hasInactiveActivities(Rules& r); 7105 7106 QString getXmlDescription(Rules& r); 7107 7108 QString getDescription(Rules& r); 7109 7110 QString getDetailedDescription(Rules& r); 7111 7112 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7113 7114 bool isRelatedToActivity(Rules& r, Activity* a); 7115 7116 bool isRelatedToTeacher(Teacher* t); 7117 7118 bool isRelatedToSubject(Subject* s); 7119 7120 bool isRelatedToActivityTag(ActivityTag* s); 7121 7122 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7123 7124 bool hasWrongDayOrHour(Rules& r); 7125 bool canRepairWrongDayOrHour(Rules& r); 7126 bool repairWrongDayOrHour(Rules& r); 7127 }; 7128 7129 class ConstraintTeachersMinAfternoonsPerWeek: public TimeConstraint{ 7130 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinAfternoonsPerWeek) 7131 7132 public: 7133 int minAfternoonsPerWeek; 7134 7135 ConstraintTeachersMinAfternoonsPerWeek(); 7136 7137 ConstraintTeachersMinAfternoonsPerWeek(double wp, int minafternoons); 7138 7139 bool computeInternalStructure(QWidget* parent, Rules& r); 7140 7141 bool hasInactiveActivities(Rules& r); 7142 7143 QString getXmlDescription(Rules& r); 7144 7145 QString getDescription(Rules& r); 7146 7147 QString getDetailedDescription(Rules& r); 7148 7149 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7150 7151 bool isRelatedToActivity(Rules& r, Activity* a); 7152 7153 bool isRelatedToTeacher(Teacher* t); 7154 7155 bool isRelatedToSubject(Subject* s); 7156 7157 bool isRelatedToActivityTag(ActivityTag* s); 7158 7159 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7160 7161 bool hasWrongDayOrHour(Rules& r); 7162 bool canRepairWrongDayOrHour(Rules& r); 7163 bool repairWrongDayOrHour(Rules& r); 7164 }; 7165 7166 class ConstraintTeacherMaxTwoConsecutiveMornings: public TimeConstraint{ 7167 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxTwoConsecutiveMornings) 7168 7169 public: 7170 /** 7171 The teacher's name 7172 */ 7173 QString teacherName; 7174 7175 /** 7176 The teacher's id, or index in the rules 7177 */ 7178 int teacher_ID; 7179 7180 ConstraintTeacherMaxTwoConsecutiveMornings(); 7181 7182 ConstraintTeacherMaxTwoConsecutiveMornings(double wp, QString t); 7183 7184 bool computeInternalStructure(QWidget* parent, Rules& r); 7185 7186 bool hasInactiveActivities(Rules& r); 7187 7188 QString getXmlDescription(Rules& r); 7189 7190 QString getDescription(Rules& r); 7191 7192 QString getDetailedDescription(Rules& r); 7193 7194 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7195 7196 bool isRelatedToActivity(Rules& r, Activity* a); 7197 7198 bool isRelatedToTeacher(Teacher* t); 7199 7200 bool isRelatedToSubject(Subject* s); 7201 7202 bool isRelatedToActivityTag(ActivityTag* s); 7203 7204 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7205 7206 bool hasWrongDayOrHour(Rules& r); 7207 bool canRepairWrongDayOrHour(Rules& r); 7208 bool repairWrongDayOrHour(Rules& r); 7209 }; 7210 7211 class ConstraintTeachersMaxTwoConsecutiveMornings: public TimeConstraint{ 7212 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxTwoConsecutiveMornings) 7213 7214 public: 7215 ConstraintTeachersMaxTwoConsecutiveMornings(); 7216 7217 ConstraintTeachersMaxTwoConsecutiveMornings(double wp); 7218 7219 bool computeInternalStructure(QWidget* parent, Rules& r); 7220 7221 bool hasInactiveActivities(Rules& r); 7222 7223 QString getXmlDescription(Rules& r); 7224 7225 QString getDescription(Rules& r); 7226 7227 QString getDetailedDescription(Rules& r); 7228 7229 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7230 7231 bool isRelatedToActivity(Rules& r, Activity* a); 7232 7233 bool isRelatedToTeacher(Teacher* t); 7234 7235 bool isRelatedToSubject(Subject* s); 7236 7237 bool isRelatedToActivityTag(ActivityTag* s); 7238 7239 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7240 7241 bool hasWrongDayOrHour(Rules& r); 7242 bool canRepairWrongDayOrHour(Rules& r); 7243 bool repairWrongDayOrHour(Rules& r); 7244 }; 7245 7246 class ConstraintTeacherMaxTwoConsecutiveAfternoons: public TimeConstraint{ 7247 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxTwoConsecutiveAfternoons) 7248 7249 public: 7250 /** 7251 The teacher's name 7252 */ 7253 QString teacherName; 7254 7255 /** 7256 The teacher's id, or index in the rules 7257 */ 7258 int teacher_ID; 7259 7260 ConstraintTeacherMaxTwoConsecutiveAfternoons(); 7261 7262 ConstraintTeacherMaxTwoConsecutiveAfternoons(double wp, QString t); 7263 7264 bool computeInternalStructure(QWidget* parent, Rules& r); 7265 7266 bool hasInactiveActivities(Rules& r); 7267 7268 QString getXmlDescription(Rules& r); 7269 7270 QString getDescription(Rules& r); 7271 7272 QString getDetailedDescription(Rules& r); 7273 7274 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7275 7276 bool isRelatedToActivity(Rules& r, Activity* a); 7277 7278 bool isRelatedToTeacher(Teacher* t); 7279 7280 bool isRelatedToSubject(Subject* s); 7281 7282 bool isRelatedToActivityTag(ActivityTag* s); 7283 7284 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7285 7286 bool hasWrongDayOrHour(Rules& r); 7287 bool canRepairWrongDayOrHour(Rules& r); 7288 bool repairWrongDayOrHour(Rules& r); 7289 }; 7290 7291 class ConstraintTeachersMaxTwoConsecutiveAfternoons: public TimeConstraint{ 7292 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxTwoConsecutiveAfternoons) 7293 7294 public: 7295 ConstraintTeachersMaxTwoConsecutiveAfternoons(); 7296 7297 ConstraintTeachersMaxTwoConsecutiveAfternoons(double wp); 7298 7299 bool computeInternalStructure(QWidget* parent, Rules& r); 7300 7301 bool hasInactiveActivities(Rules& r); 7302 7303 QString getXmlDescription(Rules& r); 7304 7305 QString getDescription(Rules& r); 7306 7307 QString getDetailedDescription(Rules& r); 7308 7309 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7310 7311 bool isRelatedToActivity(Rules& r, Activity* a); 7312 7313 bool isRelatedToTeacher(Teacher* t); 7314 7315 bool isRelatedToSubject(Subject* s); 7316 7317 bool isRelatedToActivityTag(ActivityTag* s); 7318 7319 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7320 7321 bool hasWrongDayOrHour(Rules& r); 7322 bool canRepairWrongDayOrHour(Rules& r); 7323 bool repairWrongDayOrHour(Rules& r); 7324 }; 7325 7326 class ConstraintTeachersAfternoonsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ 7327 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersAfternoonsEarlyMaxBeginningsAtSecondHour) 7328 7329 public: 7330 7331 int maxBeginningsAtSecondHour; 7332 7333 ConstraintTeachersAfternoonsEarlyMaxBeginningsAtSecondHour(); 7334 7335 ConstraintTeachersAfternoonsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH); 7336 7337 bool computeInternalStructure(QWidget* parent, Rules& r); 7338 7339 bool hasInactiveActivities(Rules& r); 7340 7341 QString getXmlDescription(Rules& r); 7342 7343 QString getDescription(Rules& r); 7344 7345 QString getDetailedDescription(Rules& r); 7346 7347 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7348 7349 bool isRelatedToActivity(Rules& r, Activity* a); 7350 7351 bool isRelatedToTeacher(Teacher* t); 7352 7353 bool isRelatedToSubject(Subject* s); 7354 7355 bool isRelatedToActivityTag(ActivityTag* s); 7356 7357 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7358 7359 bool hasWrongDayOrHour(Rules& r); 7360 bool canRepairWrongDayOrHour(Rules& r); 7361 bool repairWrongDayOrHour(Rules& r); 7362 }; 7363 7364 class ConstraintTeacherAfternoonsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ 7365 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherAfternoonsEarlyMaxBeginningsAtSecondHour) 7366 7367 public: 7368 int maxBeginningsAtSecondHour; 7369 7370 QString teacherName; 7371 7372 //internal 7373 int teacherIndex; 7374 7375 ConstraintTeacherAfternoonsEarlyMaxBeginningsAtSecondHour(); 7376 7377 ConstraintTeacherAfternoonsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH, const QString& teacher); 7378 7379 bool computeInternalStructure(QWidget* parent, Rules& r); 7380 7381 bool hasInactiveActivities(Rules& r); 7382 7383 QString getXmlDescription(Rules& r); 7384 7385 QString getDescription(Rules& r); 7386 7387 QString getDetailedDescription(Rules& r); 7388 7389 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7390 7391 bool isRelatedToActivity(Rules& r, Activity* a); 7392 7393 bool isRelatedToTeacher(Teacher* t); 7394 7395 bool isRelatedToSubject(Subject* s); 7396 7397 bool isRelatedToActivityTag(ActivityTag* s); 7398 7399 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7400 7401 bool hasWrongDayOrHour(Rules& r); 7402 bool canRepairWrongDayOrHour(Rules& r); 7403 bool repairWrongDayOrHour(Rules& r); 7404 }; 7405 7406 class ConstraintTeachersMorningsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ 7407 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMorningsEarlyMaxBeginningsAtSecondHour) 7408 7409 public: 7410 7411 int maxBeginningsAtSecondHour; 7412 7413 ConstraintTeachersMorningsEarlyMaxBeginningsAtSecondHour(); 7414 7415 ConstraintTeachersMorningsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH); 7416 7417 bool computeInternalStructure(QWidget* parent, Rules& r); 7418 7419 bool hasInactiveActivities(Rules& r); 7420 7421 QString getXmlDescription(Rules& r); 7422 7423 QString getDescription(Rules& r); 7424 7425 QString getDetailedDescription(Rules& r); 7426 7427 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7428 7429 bool isRelatedToActivity(Rules& r, Activity* a); 7430 7431 bool isRelatedToTeacher(Teacher* t); 7432 7433 bool isRelatedToSubject(Subject* s); 7434 7435 bool isRelatedToActivityTag(ActivityTag* s); 7436 7437 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7438 7439 bool hasWrongDayOrHour(Rules& r); 7440 bool canRepairWrongDayOrHour(Rules& r); 7441 bool repairWrongDayOrHour(Rules& r); 7442 }; 7443 7444 class ConstraintTeacherMorningsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ 7445 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMorningsEarlyMaxBeginningsAtSecondHour) 7446 7447 public: 7448 int maxBeginningsAtSecondHour; 7449 7450 QString teacherName; 7451 7452 //internal 7453 int teacherIndex; 7454 7455 ConstraintTeacherMorningsEarlyMaxBeginningsAtSecondHour(); 7456 7457 ConstraintTeacherMorningsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH, const QString& teacher); 7458 7459 bool computeInternalStructure(QWidget* parent, Rules& r); 7460 7461 bool hasInactiveActivities(Rules& r); 7462 7463 QString getXmlDescription(Rules& r); 7464 7465 QString getDescription(Rules& r); 7466 7467 QString getDetailedDescription(Rules& r); 7468 7469 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7470 7471 bool isRelatedToActivity(Rules& r, Activity* a); 7472 7473 bool isRelatedToTeacher(Teacher* t); 7474 7475 bool isRelatedToSubject(Subject* s); 7476 7477 bool isRelatedToActivityTag(ActivityTag* s); 7478 7479 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7480 7481 bool hasWrongDayOrHour(Rules& r); 7482 bool canRepairWrongDayOrHour(Rules& r); 7483 bool repairWrongDayOrHour(Rules& r); 7484 }; 7485 7486 //2020-06-14 7487 class ConstraintStudentsMinHoursPerMorning: public TimeConstraint{ 7488 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinHoursPerMorning) 7489 7490 public: 7491 int minHoursPerMorning; 7492 7493 bool allowEmptyMornings; 7494 7495 ConstraintStudentsMinHoursPerMorning(); 7496 7497 ConstraintStudentsMinHoursPerMorning(double wp, int minnh, bool _allowEmptyMornings); 7498 7499 bool computeInternalStructure(QWidget* parent, Rules& r); 7500 7501 bool hasInactiveActivities(Rules& r); 7502 7503 QString getXmlDescription(Rules& r); 7504 7505 QString getDescription(Rules& r); 7506 7507 QString getDetailedDescription(Rules& r); 7508 7509 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7510 7511 bool isRelatedToActivity(Rules& r, Activity* a); 7512 7513 bool isRelatedToTeacher(Teacher* t); 7514 7515 bool isRelatedToSubject(Subject* s); 7516 7517 bool isRelatedToActivityTag(ActivityTag* s); 7518 7519 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7520 7521 bool hasWrongDayOrHour(Rules& r); 7522 bool canRepairWrongDayOrHour(Rules& r); 7523 bool repairWrongDayOrHour(Rules& r); 7524 }; 7525 7526 class ConstraintStudentsSetMinHoursPerMorning: public TimeConstraint{ 7527 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinHoursPerMorning) 7528 7529 public: 7530 int minHoursPerMorning; 7531 7532 /** 7533 The students set name 7534 */ 7535 QString students; 7536 7537 bool allowEmptyMornings; 7538 7539 //internal variables 7540 7541 /** 7542 The number of subgroups 7543 */ 7544 //int nSubgroups; 7545 7546 /** 7547 The subgroups 7548 */ 7549 //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; 7550 QList<int> iSubgroupsList; 7551 7552 ConstraintStudentsSetMinHoursPerMorning(); 7553 7554 ConstraintStudentsSetMinHoursPerMorning(double wp, int minnh, QString s, bool _allowEmptyMornings); 7555 7556 bool computeInternalStructure(QWidget* parent, Rules& r); 7557 7558 bool hasInactiveActivities(Rules& r); 7559 7560 QString getXmlDescription(Rules& r); 7561 7562 QString getDescription(Rules& r); 7563 7564 QString getDetailedDescription(Rules& r); 7565 7566 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7567 7568 bool isRelatedToActivity(Rules& r, Activity* a); 7569 7570 bool isRelatedToTeacher(Teacher* t); 7571 7572 bool isRelatedToSubject(Subject* s); 7573 7574 bool isRelatedToActivityTag(ActivityTag* s); 7575 7576 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7577 7578 bool hasWrongDayOrHour(Rules& r); 7579 bool canRepairWrongDayOrHour(Rules& r); 7580 bool repairWrongDayOrHour(Rules& r); 7581 }; 7582 7583 class ConstraintTeacherMaxZeroGapsPerAfternoon: public TimeConstraint{ 7584 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxZeroGapsPerAfternoon) 7585 7586 public: 7587 QString teacherName; 7588 7589 int teacherIndex; 7590 7591 ConstraintTeacherMaxZeroGapsPerAfternoon(); 7592 7593 ConstraintTeacherMaxZeroGapsPerAfternoon(double wp, QString tn); 7594 7595 bool computeInternalStructure(QWidget* parent, Rules& r); 7596 7597 bool hasInactiveActivities(Rules& r); 7598 7599 QString getXmlDescription(Rules& r); 7600 7601 QString getDescription(Rules& r); 7602 7603 QString getDetailedDescription(Rules& r); 7604 7605 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7606 7607 bool isRelatedToActivity(Rules& r, Activity* a); 7608 7609 bool isRelatedToTeacher(Teacher* t); 7610 7611 bool isRelatedToSubject(Subject* s); 7612 7613 bool isRelatedToActivityTag(ActivityTag* s); 7614 7615 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7616 7617 bool hasWrongDayOrHour(Rules& r); 7618 bool canRepairWrongDayOrHour(Rules& r); 7619 bool repairWrongDayOrHour(Rules& r); 7620 }; 7621 7622 class ConstraintTeachersMaxZeroGapsPerAfternoon: public TimeConstraint{ 7623 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxZeroGapsPerAfternoon) 7624 7625 public: 7626 ConstraintTeachersMaxZeroGapsPerAfternoon(); 7627 7628 ConstraintTeachersMaxZeroGapsPerAfternoon(double wp); 7629 7630 bool computeInternalStructure(QWidget* parent, Rules& r); 7631 7632 bool hasInactiveActivities(Rules& r); 7633 7634 QString getXmlDescription(Rules& r); 7635 7636 QString getDescription(Rules& r); 7637 7638 QString getDetailedDescription(Rules& r); 7639 7640 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7641 7642 bool isRelatedToActivity(Rules& r, Activity* a); 7643 7644 bool isRelatedToTeacher(Teacher* t); 7645 7646 bool isRelatedToSubject(Subject* s); 7647 7648 bool isRelatedToActivityTag(ActivityTag* s); 7649 7650 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7651 7652 bool hasWrongDayOrHour(Rules& r); 7653 bool canRepairWrongDayOrHour(Rules& r); 7654 bool repairWrongDayOrHour(Rules& r); 7655 }; 7656 7657 //2020-06-25 7658 class ConstraintStudentsMaxAfternoonsPerWeek: public TimeConstraint{ 7659 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxAfternoonsPerWeek) 7660 7661 public: 7662 int maxAfternoonsPerWeek; 7663 7664 ConstraintStudentsMaxAfternoonsPerWeek(); 7665 7666 ConstraintStudentsMaxAfternoonsPerWeek(double wp, int maxnd); 7667 7668 bool computeInternalStructure(QWidget* parent, Rules& r); 7669 7670 bool hasInactiveActivities(Rules& r); 7671 7672 QString getXmlDescription(Rules& r); 7673 7674 QString getDescription(Rules& r); 7675 7676 QString getDetailedDescription(Rules& r); 7677 7678 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7679 7680 bool isRelatedToActivity(Rules& r, Activity* a); 7681 7682 bool isRelatedToTeacher(Teacher* t); 7683 7684 bool isRelatedToSubject(Subject* s); 7685 7686 bool isRelatedToActivityTag(ActivityTag* s); 7687 7688 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7689 7690 bool hasWrongDayOrHour(Rules& r); 7691 bool canRepairWrongDayOrHour(Rules& r); 7692 bool repairWrongDayOrHour(Rules& r); 7693 }; 7694 7695 class ConstraintStudentsSetMaxAfternoonsPerWeek: public TimeConstraint{ 7696 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxAfternoonsPerWeek) 7697 7698 public: 7699 int maxAfternoonsPerWeek; 7700 7701 QString students; 7702 7703 QList<int> iSubgroupsList; 7704 7705 ConstraintStudentsSetMaxAfternoonsPerWeek(); 7706 7707 ConstraintStudentsSetMaxAfternoonsPerWeek(double wp, int maxnd, const QString& sn); 7708 7709 bool computeInternalStructure(QWidget* parent, Rules& r); 7710 7711 bool hasInactiveActivities(Rules& r); 7712 7713 QString getXmlDescription(Rules& r); 7714 7715 QString getDescription(Rules& r); 7716 7717 QString getDetailedDescription(Rules& r); 7718 7719 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7720 7721 bool isRelatedToActivity(Rules& r, Activity* a); 7722 7723 bool isRelatedToTeacher(Teacher* t); 7724 7725 bool isRelatedToSubject(Subject* s); 7726 7727 bool isRelatedToActivityTag(ActivityTag* s); 7728 7729 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7730 7731 bool hasWrongDayOrHour(Rules& r); 7732 bool canRepairWrongDayOrHour(Rules& r); 7733 bool repairWrongDayOrHour(Rules& r); 7734 }; 7735 7736 class ConstraintStudentsMaxMorningsPerWeek: public TimeConstraint{ 7737 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxMorningsPerWeek) 7738 7739 public: 7740 int maxMorningsPerWeek; 7741 7742 ConstraintStudentsMaxMorningsPerWeek(); 7743 7744 ConstraintStudentsMaxMorningsPerWeek(double wp, int maxnd); 7745 7746 bool computeInternalStructure(QWidget* parent, Rules& r); 7747 7748 bool hasInactiveActivities(Rules& r); 7749 7750 QString getXmlDescription(Rules& r); 7751 7752 QString getDescription(Rules& r); 7753 7754 QString getDetailedDescription(Rules& r); 7755 7756 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7757 7758 bool isRelatedToActivity(Rules& r, Activity* a); 7759 7760 bool isRelatedToTeacher(Teacher* t); 7761 7762 bool isRelatedToSubject(Subject* s); 7763 7764 bool isRelatedToActivityTag(ActivityTag* s); 7765 7766 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7767 7768 bool hasWrongDayOrHour(Rules& r); 7769 bool canRepairWrongDayOrHour(Rules& r); 7770 bool repairWrongDayOrHour(Rules& r); 7771 }; 7772 7773 class ConstraintStudentsSetMaxMorningsPerWeek: public TimeConstraint{ 7774 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxMorningsPerWeek) 7775 7776 public: 7777 int maxMorningsPerWeek; 7778 7779 QString students; 7780 7781 QList<int> iSubgroupsList; 7782 7783 ConstraintStudentsSetMaxMorningsPerWeek(); 7784 7785 ConstraintStudentsSetMaxMorningsPerWeek(double wp, int maxnd, const QString& sn); 7786 7787 bool computeInternalStructure(QWidget* parent, Rules& r); 7788 7789 bool hasInactiveActivities(Rules& r); 7790 7791 QString getXmlDescription(Rules& r); 7792 7793 QString getDescription(Rules& r); 7794 7795 QString getDetailedDescription(Rules& r); 7796 7797 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7798 7799 bool isRelatedToActivity(Rules& r, Activity* a); 7800 7801 bool isRelatedToTeacher(Teacher* t); 7802 7803 bool isRelatedToSubject(Subject* s); 7804 7805 bool isRelatedToActivityTag(ActivityTag* s); 7806 7807 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7808 7809 bool hasWrongDayOrHour(Rules& r); 7810 bool canRepairWrongDayOrHour(Rules& r); 7811 bool repairWrongDayOrHour(Rules& r); 7812 }; 7813 7814 //2020-06-26 7815 class ConstraintStudentsMinAfternoonsPerWeek: public TimeConstraint{ 7816 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinAfternoonsPerWeek) 7817 7818 public: 7819 int minAfternoonsPerWeek; 7820 7821 ConstraintStudentsMinAfternoonsPerWeek(); 7822 7823 ConstraintStudentsMinAfternoonsPerWeek(double wp, int minnd); 7824 7825 bool computeInternalStructure(QWidget* parent, Rules& r); 7826 7827 bool hasInactiveActivities(Rules& r); 7828 7829 QString getXmlDescription(Rules& r); 7830 7831 QString getDescription(Rules& r); 7832 7833 QString getDetailedDescription(Rules& r); 7834 7835 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7836 7837 bool isRelatedToActivity(Rules& r, Activity* a); 7838 7839 bool isRelatedToTeacher(Teacher* t); 7840 7841 bool isRelatedToSubject(Subject* s); 7842 7843 bool isRelatedToActivityTag(ActivityTag* s); 7844 7845 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7846 7847 bool hasWrongDayOrHour(Rules& r); 7848 bool canRepairWrongDayOrHour(Rules& r); 7849 bool repairWrongDayOrHour(Rules& r); 7850 }; 7851 7852 class ConstraintStudentsSetMinAfternoonsPerWeek: public TimeConstraint{ 7853 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinAfternoonsPerWeek) 7854 7855 public: 7856 int minAfternoonsPerWeek; 7857 7858 QString students; 7859 7860 QList<int> iSubgroupsList; 7861 7862 ConstraintStudentsSetMinAfternoonsPerWeek(); 7863 7864 ConstraintStudentsSetMinAfternoonsPerWeek(double wp, int minnd, const QString& sn); 7865 7866 bool computeInternalStructure(QWidget* parent, Rules& r); 7867 7868 bool hasInactiveActivities(Rules& r); 7869 7870 QString getXmlDescription(Rules& r); 7871 7872 QString getDescription(Rules& r); 7873 7874 QString getDetailedDescription(Rules& r); 7875 7876 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7877 7878 bool isRelatedToActivity(Rules& r, Activity* a); 7879 7880 bool isRelatedToTeacher(Teacher* t); 7881 7882 bool isRelatedToSubject(Subject* s); 7883 7884 bool isRelatedToActivityTag(ActivityTag* s); 7885 7886 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7887 7888 bool hasWrongDayOrHour(Rules& r); 7889 bool canRepairWrongDayOrHour(Rules& r); 7890 bool repairWrongDayOrHour(Rules& r); 7891 }; 7892 7893 class ConstraintStudentsMinMorningsPerWeek: public TimeConstraint{ 7894 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinMorningsPerWeek) 7895 7896 public: 7897 int minMorningsPerWeek; 7898 7899 ConstraintStudentsMinMorningsPerWeek(); 7900 7901 ConstraintStudentsMinMorningsPerWeek(double wp, int minnd); 7902 7903 bool computeInternalStructure(QWidget* parent, Rules& r); 7904 7905 bool hasInactiveActivities(Rules& r); 7906 7907 QString getXmlDescription(Rules& r); 7908 7909 QString getDescription(Rules& r); 7910 7911 QString getDetailedDescription(Rules& r); 7912 7913 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7914 7915 bool isRelatedToActivity(Rules& r, Activity* a); 7916 7917 bool isRelatedToTeacher(Teacher* t); 7918 7919 bool isRelatedToSubject(Subject* s); 7920 7921 bool isRelatedToActivityTag(ActivityTag* s); 7922 7923 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7924 7925 bool hasWrongDayOrHour(Rules& r); 7926 bool canRepairWrongDayOrHour(Rules& r); 7927 bool repairWrongDayOrHour(Rules& r); 7928 }; 7929 7930 class ConstraintStudentsSetMinMorningsPerWeek: public TimeConstraint{ 7931 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinMorningsPerWeek) 7932 7933 public: 7934 int minMorningsPerWeek; 7935 7936 QString students; 7937 7938 QList<int> iSubgroupsList; 7939 7940 ConstraintStudentsSetMinMorningsPerWeek(); 7941 7942 ConstraintStudentsSetMinMorningsPerWeek(double wp, int minnd, const QString& sn); 7943 7944 bool computeInternalStructure(QWidget* parent, Rules& r); 7945 7946 bool hasInactiveActivities(Rules& r); 7947 7948 QString getXmlDescription(Rules& r); 7949 7950 QString getDescription(Rules& r); 7951 7952 QString getDetailedDescription(Rules& r); 7953 7954 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 7955 7956 bool isRelatedToActivity(Rules& r, Activity* a); 7957 7958 bool isRelatedToTeacher(Teacher* t); 7959 7960 bool isRelatedToSubject(Subject* s); 7961 7962 bool isRelatedToActivityTag(ActivityTag* s); 7963 7964 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 7965 7966 bool hasWrongDayOrHour(Rules& r); 7967 bool canRepairWrongDayOrHour(Rules& r); 7968 bool repairWrongDayOrHour(Rules& r); 7969 }; 7970 7971 //2020-06-26 7972 class ConstraintStudentsSetMorningIntervalMaxDaysPerWeek: public TimeConstraint{ 7973 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetIntervalMaxDaysPerWeek) 7974 7975 public: 7976 /** 7977 The number of maximum allowed working days per week 7978 */ 7979 int maxDaysPerWeek; 7980 7981 int startHour; 7982 7983 int endHour; //might be = to gt.rules.nHoursPerDay 7984 7985 /** 7986 The name of the students set for this constraint 7987 */ 7988 QString students; 7989 7990 //internal redundant data 7991 7992 /** 7993 The number of subgroups 7994 */ 7995 //int nSubgroups; 7996 7997 /** 7998 The subgroups 7999 */ 8000 QList<int> iSubgroupsList; 8001 8002 ConstraintStudentsSetMorningIntervalMaxDaysPerWeek(); 8003 8004 ConstraintStudentsSetMorningIntervalMaxDaysPerWeek(double wp, int maxnd, QString sn, int sh, int eh); 8005 8006 bool computeInternalStructure(QWidget* parent, Rules& r); 8007 8008 bool hasInactiveActivities(Rules& r); 8009 8010 QString getXmlDescription(Rules& r); 8011 8012 QString getDescription(Rules& r); 8013 8014 QString getDetailedDescription(Rules& r); 8015 8016 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8017 8018 bool isRelatedToActivity(Rules& r, Activity* a); 8019 8020 bool isRelatedToTeacher(Teacher* t); 8021 8022 bool isRelatedToSubject(Subject* s); 8023 8024 bool isRelatedToActivityTag(ActivityTag* s); 8025 8026 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8027 8028 bool hasWrongDayOrHour(Rules& r); 8029 bool canRepairWrongDayOrHour(Rules& r); 8030 bool repairWrongDayOrHour(Rules& r); 8031 }; 8032 8033 class ConstraintStudentsMorningIntervalMaxDaysPerWeek: public TimeConstraint{ 8034 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsIntervalMaxDaysPerWeek) 8035 8036 public: 8037 /** 8038 The number of maximum allowed working days per week 8039 */ 8040 int maxDaysPerWeek; 8041 8042 int startHour; 8043 8044 int endHour; //might be = to gt.rules.nHoursPerDay 8045 8046 8047 ConstraintStudentsMorningIntervalMaxDaysPerWeek(); 8048 8049 ConstraintStudentsMorningIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh); 8050 8051 bool computeInternalStructure(QWidget* parent, Rules& r); 8052 8053 bool hasInactiveActivities(Rules& r); 8054 8055 QString getXmlDescription(Rules& r); 8056 8057 QString getDescription(Rules& r); 8058 8059 QString getDetailedDescription(Rules& r); 8060 8061 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8062 8063 bool isRelatedToActivity(Rules& r, Activity* a); 8064 8065 bool isRelatedToTeacher(Teacher* t); 8066 8067 bool isRelatedToSubject(Subject* s); 8068 8069 bool isRelatedToActivityTag(ActivityTag* s); 8070 8071 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8072 8073 bool hasWrongDayOrHour(Rules& r); 8074 bool canRepairWrongDayOrHour(Rules& r); 8075 bool repairWrongDayOrHour(Rules& r); 8076 }; 8077 8078 class ConstraintStudentsSetAfternoonIntervalMaxDaysPerWeek: public TimeConstraint{ 8079 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetIntervalMaxDaysPerWeek) 8080 8081 public: 8082 /** 8083 The number of maximum allowed working days per week 8084 */ 8085 int maxDaysPerWeek; 8086 8087 int startHour; 8088 8089 int endHour; //might be = to gt.rules.nHoursPerDay 8090 8091 /** 8092 The name of the students set for this constraint 8093 */ 8094 QString students; 8095 8096 //internal redundant data 8097 8098 /** 8099 The number of subgroups 8100 */ 8101 //int nSubgroups; 8102 8103 /** 8104 The subgroups 8105 */ 8106 QList<int> iSubgroupsList; 8107 8108 ConstraintStudentsSetAfternoonIntervalMaxDaysPerWeek(); 8109 8110 ConstraintStudentsSetAfternoonIntervalMaxDaysPerWeek(double wp, int maxnd, QString sn, int sh, int eh); 8111 8112 bool computeInternalStructure(QWidget* parent, Rules& r); 8113 8114 bool hasInactiveActivities(Rules& r); 8115 8116 QString getXmlDescription(Rules& r); 8117 8118 QString getDescription(Rules& r); 8119 8120 QString getDetailedDescription(Rules& r); 8121 8122 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8123 8124 bool isRelatedToActivity(Rules& r, Activity* a); 8125 8126 bool isRelatedToTeacher(Teacher* t); 8127 8128 bool isRelatedToSubject(Subject* s); 8129 8130 bool isRelatedToActivityTag(ActivityTag* s); 8131 8132 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8133 8134 bool hasWrongDayOrHour(Rules& r); 8135 bool canRepairWrongDayOrHour(Rules& r); 8136 bool repairWrongDayOrHour(Rules& r); 8137 }; 8138 8139 class ConstraintStudentsAfternoonIntervalMaxDaysPerWeek: public TimeConstraint{ 8140 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsIntervalMaxDaysPerWeek) 8141 8142 public: 8143 /** 8144 The number of maximum allowed working days per week 8145 */ 8146 int maxDaysPerWeek; 8147 8148 int startHour; 8149 8150 int endHour; //might be = to gt.rules.nHoursPerDay 8151 8152 8153 ConstraintStudentsAfternoonIntervalMaxDaysPerWeek(); 8154 8155 ConstraintStudentsAfternoonIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh); 8156 8157 bool computeInternalStructure(QWidget* parent, Rules& r); 8158 8159 bool hasInactiveActivities(Rules& r); 8160 8161 QString getXmlDescription(Rules& r); 8162 8163 QString getDescription(Rules& r); 8164 8165 QString getDetailedDescription(Rules& r); 8166 8167 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8168 8169 bool isRelatedToActivity(Rules& r, Activity* a); 8170 8171 bool isRelatedToTeacher(Teacher* t); 8172 8173 bool isRelatedToSubject(Subject* s); 8174 8175 bool isRelatedToActivityTag(ActivityTag* s); 8176 8177 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8178 8179 bool hasWrongDayOrHour(Rules& r); 8180 bool canRepairWrongDayOrHour(Rules& r); 8181 bool repairWrongDayOrHour(Rules& r); 8182 }; 8183 8184 //2020-06-28 8185 class ConstraintTeacherMaxHoursPerAllAfternoons: public TimeConstraint{ 8186 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxHoursPerAllAfternoons) 8187 8188 public: 8189 int maxHoursPerAllAfternoons; 8190 8191 QString teacherName; 8192 8193 int teacher_ID; 8194 8195 ConstraintTeacherMaxHoursPerAllAfternoons(); 8196 8197 ConstraintTeacherMaxHoursPerAllAfternoons(double wp, int maxhours, const QString& teacher); 8198 8199 QString getXmlDescription(Rules& r); 8200 8201 bool computeInternalStructure(QWidget* parent, Rules& r); 8202 8203 bool hasInactiveActivities(Rules& r); 8204 8205 QString getDescription(Rules& r); 8206 8207 QString getDetailedDescription(Rules& r); 8208 8209 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8210 8211 bool isRelatedToActivity(Rules& r, Activity* a); 8212 8213 bool isRelatedToTeacher(Teacher* t); 8214 8215 bool isRelatedToSubject(Subject* s); 8216 8217 bool isRelatedToActivityTag(ActivityTag* s); 8218 8219 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8220 8221 bool hasWrongDayOrHour(Rules& r); 8222 bool canRepairWrongDayOrHour(Rules& r); 8223 bool repairWrongDayOrHour(Rules& r); 8224 }; 8225 8226 class ConstraintTeachersMaxHoursPerAllAfternoons: public TimeConstraint{ 8227 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxHoursPerAllAfternoons) 8228 8229 public: 8230 int maxHoursPerAllAfternoons; 8231 8232 ConstraintTeachersMaxHoursPerAllAfternoons(); 8233 8234 ConstraintTeachersMaxHoursPerAllAfternoons(double wp, int maxhours); 8235 8236 QString getXmlDescription(Rules& r); 8237 8238 bool computeInternalStructure(QWidget* parent, Rules& r); 8239 8240 bool hasInactiveActivities(Rules& r); 8241 8242 QString getDescription(Rules& r); 8243 8244 QString getDetailedDescription(Rules& r); 8245 8246 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8247 8248 bool isRelatedToActivity(Rules& r, Activity* a); 8249 8250 bool isRelatedToTeacher(Teacher* t); 8251 8252 bool isRelatedToSubject(Subject* s); 8253 8254 bool isRelatedToActivityTag(ActivityTag* s); 8255 8256 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8257 8258 bool hasWrongDayOrHour(Rules& r); 8259 bool canRepairWrongDayOrHour(Rules& r); 8260 bool repairWrongDayOrHour(Rules& r); 8261 }; 8262 8263 //2020-06-28 8264 class ConstraintStudentsSetMaxHoursPerAllAfternoons: public TimeConstraint{ 8265 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxHoursPerAllAfternoons) 8266 8267 public: 8268 int maxHoursPerAllAfternoons; 8269 8270 QString students; 8271 8272 QList<int> iSubgroupsList; 8273 8274 ConstraintStudentsSetMaxHoursPerAllAfternoons(); 8275 8276 ConstraintStudentsSetMaxHoursPerAllAfternoons(double wp, int maxhours, const QString& st); 8277 8278 QString getXmlDescription(Rules& r); 8279 8280 bool computeInternalStructure(QWidget* parent, Rules& r); 8281 8282 bool hasInactiveActivities(Rules& r); 8283 8284 QString getDescription(Rules& r); 8285 8286 QString getDetailedDescription(Rules& r); 8287 8288 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8289 8290 bool isRelatedToActivity(Rules& r, Activity* a); 8291 8292 bool isRelatedToTeacher(Teacher* t); 8293 8294 bool isRelatedToSubject(Subject* s); 8295 8296 bool isRelatedToActivityTag(ActivityTag* s); 8297 8298 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8299 8300 bool hasWrongDayOrHour(Rules& r); 8301 bool canRepairWrongDayOrHour(Rules& r); 8302 bool repairWrongDayOrHour(Rules& r); 8303 }; 8304 8305 class ConstraintStudentsMaxHoursPerAllAfternoons: public TimeConstraint{ 8306 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxHoursPerAllAfternoons) 8307 8308 public: 8309 int maxHoursPerAllAfternoons; 8310 8311 ConstraintStudentsMaxHoursPerAllAfternoons(); 8312 8313 ConstraintStudentsMaxHoursPerAllAfternoons(double wp, int maxhours); 8314 8315 QString getXmlDescription(Rules& r); 8316 8317 bool computeInternalStructure(QWidget* parent, Rules& r); 8318 8319 bool hasInactiveActivities(Rules& r); 8320 8321 QString getDescription(Rules& r); 8322 8323 QString getDetailedDescription(Rules& r); 8324 8325 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8326 8327 bool isRelatedToActivity(Rules& r, Activity* a); 8328 8329 bool isRelatedToTeacher(Teacher* t); 8330 8331 bool isRelatedToSubject(Subject* s); 8332 8333 bool isRelatedToActivityTag(ActivityTag* s); 8334 8335 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8336 8337 bool hasWrongDayOrHour(Rules& r); 8338 bool canRepairWrongDayOrHour(Rules& r); 8339 bool repairWrongDayOrHour(Rules& r); 8340 }; 8341 8342 class ConstraintTeacherMinRestingHoursBetweenMorningAndAfternoon: public TimeConstraint{ 8343 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinRestingHoursBetweenMorningAndAfternoon) 8344 8345 public: 8346 int minRestingHours; 8347 8348 QString teacherName; 8349 8350 int teacher_ID; 8351 8352 ConstraintTeacherMinRestingHoursBetweenMorningAndAfternoon(); 8353 8354 ConstraintTeacherMinRestingHoursBetweenMorningAndAfternoon(double wp, int minrestinghours, const QString& teacher); 8355 8356 QString getXmlDescription(Rules& r); 8357 8358 bool computeInternalStructure(QWidget* parent, Rules& r); 8359 8360 bool hasInactiveActivities(Rules& r); 8361 8362 QString getDescription(Rules& r); 8363 8364 QString getDetailedDescription(Rules& r); 8365 8366 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 8367 8368 bool isRelatedToActivity(Rules& r, Activity* a); 8369 8370 bool isRelatedToTeacher(Teacher* t); 8371 8372 bool isRelatedToSubject(Subject* s); 8373 8374 bool isRelatedToActivityTag(ActivityTag* s); 8375 8376 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8377 8378 bool hasWrongDayOrHour(Rules& r); 8379 bool canRepairWrongDayOrHour(Rules& r); 8380 bool repairWrongDayOrHour(Rules& r); 8381 }; 8382 8383 class ConstraintTeachersMinRestingHoursBetweenMorningAndAfternoon: public TimeConstraint{ 8384 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinRestingHoursBetweenMorningAndAfternoon) 8385 8386 public: 8387 int minRestingHours; 8388 8389 ConstraintTeachersMinRestingHoursBetweenMorningAndAfternoon(); 8390 8391 ConstraintTeachersMinRestingHoursBetweenMorningAndAfternoon(double wp, int minrestinghours); 8392 8393 QString getXmlDescription(Rules& r); 8394 8395 bool computeInternalStructure(QWidget* parent, Rules& r); 8396 8397 bool hasInactiveActivities(Rules& r); 8398 8399 QString getDescription(Rules& r); 8400 8401 QString getDetailedDescription(Rules& r); 8402 8403 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 8404 8405 bool isRelatedToActivity(Rules& r, Activity* a); 8406 8407 bool isRelatedToTeacher(Teacher* t); 8408 8409 bool isRelatedToSubject(Subject* s); 8410 8411 bool isRelatedToActivityTag(ActivityTag* s); 8412 8413 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8414 8415 bool hasWrongDayOrHour(Rules& r); 8416 bool canRepairWrongDayOrHour(Rules& r); 8417 bool repairWrongDayOrHour(Rules& r); 8418 }; 8419 8420 class ConstraintStudentsSetMinRestingHoursBetweenMorningAndAfternoon: public TimeConstraint{ 8421 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinRestingHoursBetweenMorningAndAfternoon) 8422 8423 public: 8424 int minRestingHours; 8425 8426 /** 8427 The name of the students set for this constraint 8428 */ 8429 QString students; 8430 8431 //internal redundant data 8432 8433 /** 8434 The number of subgroups 8435 */ 8436 //int nSubgroups; 8437 8438 /** 8439 The subgroups 8440 */ 8441 QList<int> iSubgroupsList; 8442 8443 ConstraintStudentsSetMinRestingHoursBetweenMorningAndAfternoon(); 8444 8445 ConstraintStudentsSetMinRestingHoursBetweenMorningAndAfternoon(double wp, int minrestinghours, const QString& sn); 8446 8447 bool computeInternalStructure(QWidget* parent, Rules& r); 8448 8449 bool hasInactiveActivities(Rules& r); 8450 8451 QString getXmlDescription(Rules& r); 8452 8453 QString getDescription(Rules& r); 8454 8455 QString getDetailedDescription(Rules& r); 8456 8457 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 8458 8459 bool isRelatedToActivity(Rules& r, Activity* a); 8460 8461 bool isRelatedToTeacher(Teacher* t); 8462 8463 bool isRelatedToSubject(Subject* s); 8464 8465 bool isRelatedToActivityTag(ActivityTag* s); 8466 8467 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8468 8469 bool hasWrongDayOrHour(Rules& r); 8470 bool canRepairWrongDayOrHour(Rules& r); 8471 bool repairWrongDayOrHour(Rules& r); 8472 }; 8473 8474 class ConstraintStudentsMinRestingHoursBetweenMorningAndAfternoon: public TimeConstraint{ 8475 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinRestingHoursBetweenMorningAndAfternoon) 8476 8477 public: 8478 int minRestingHours; 8479 8480 ConstraintStudentsMinRestingHoursBetweenMorningAndAfternoon(); 8481 8482 ConstraintStudentsMinRestingHoursBetweenMorningAndAfternoon(double wp, int minrestinghours); 8483 8484 bool computeInternalStructure(QWidget* parent, Rules& r); 8485 8486 bool hasInactiveActivities(Rules& r); 8487 8488 QString getXmlDescription(Rules& r); 8489 8490 QString getDescription(Rules& r); 8491 8492 QString getDetailedDescription(Rules& r); 8493 8494 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 8495 8496 bool isRelatedToActivity(Rules& r, Activity* a); 8497 8498 bool isRelatedToTeacher(Teacher* t); 8499 8500 bool isRelatedToSubject(Subject* s); 8501 8502 bool isRelatedToActivityTag(ActivityTag* s); 8503 8504 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8505 8506 bool hasWrongDayOrHour(Rules& r); 8507 bool canRepairWrongDayOrHour(Rules& r); 8508 bool repairWrongDayOrHour(Rules& r); 8509 }; 8510 8511 class ConstraintStudentsAfternoonsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ 8512 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsAfternoonsEarlyMaxBeginningsAtSecondHour) 8513 8514 public: 8515 8516 int maxBeginningsAtSecondHour; 8517 8518 ConstraintStudentsAfternoonsEarlyMaxBeginningsAtSecondHour(); 8519 8520 ConstraintStudentsAfternoonsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH); 8521 8522 bool computeInternalStructure(QWidget* parent, Rules& r); 8523 8524 bool hasInactiveActivities(Rules& r); 8525 8526 QString getXmlDescription(Rules& r); 8527 8528 QString getDescription(Rules& r); 8529 8530 QString getDetailedDescription(Rules& r); 8531 8532 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8533 8534 bool isRelatedToActivity(Rules& r, Activity* a); 8535 8536 bool isRelatedToTeacher(Teacher* t); 8537 8538 bool isRelatedToSubject(Subject* s); 8539 8540 bool isRelatedToActivityTag(ActivityTag* s); 8541 8542 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8543 8544 bool hasWrongDayOrHour(Rules& r); 8545 bool canRepairWrongDayOrHour(Rules& r); 8546 bool repairWrongDayOrHour(Rules& r); 8547 }; 8548 8549 class ConstraintStudentsSetAfternoonsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ 8550 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetAfternoonsEarlyMaxBeginningsAtSecondHour) 8551 8552 public: 8553 int maxBeginningsAtSecondHour; 8554 8555 /** 8556 The name of the students 8557 */ 8558 QString students; 8559 8560 /** 8561 The number of subgroups involved in this constraint 8562 */ 8563 //int nSubgroups; 8564 8565 /** 8566 The subgroups involved in this constraint 8567 */ 8568 //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; 8569 QList<int> iSubgroupsList; 8570 8571 ConstraintStudentsSetAfternoonsEarlyMaxBeginningsAtSecondHour(); 8572 8573 ConstraintStudentsSetAfternoonsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH, const QString& students); 8574 8575 bool computeInternalStructure(QWidget* parent, Rules& r); 8576 8577 bool hasInactiveActivities(Rules& r); 8578 8579 QString getXmlDescription(Rules& r); 8580 8581 QString getDescription(Rules& r); 8582 8583 QString getDetailedDescription(Rules& r); 8584 8585 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8586 8587 bool isRelatedToActivity(Rules& r, Activity* a); 8588 8589 bool isRelatedToTeacher(Teacher* t); 8590 8591 bool isRelatedToSubject(Subject* s); 8592 8593 bool isRelatedToActivityTag(ActivityTag* s); 8594 8595 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8596 8597 bool hasWrongDayOrHour(Rules& r); 8598 bool canRepairWrongDayOrHour(Rules& r); 8599 bool repairWrongDayOrHour(Rules& r); 8600 }; 8601 8602 class ConstraintStudentsMorningsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ 8603 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMorningsEarlyMaxBeginningsAtSecondHour) 8604 8605 public: 8606 8607 int maxBeginningsAtSecondHour; 8608 8609 ConstraintStudentsMorningsEarlyMaxBeginningsAtSecondHour(); 8610 8611 ConstraintStudentsMorningsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH); 8612 8613 bool computeInternalStructure(QWidget* parent, Rules& r); 8614 8615 bool hasInactiveActivities(Rules& r); 8616 8617 QString getXmlDescription(Rules& r); 8618 8619 QString getDescription(Rules& r); 8620 8621 QString getDetailedDescription(Rules& r); 8622 8623 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8624 8625 bool isRelatedToActivity(Rules& r, Activity* a); 8626 8627 bool isRelatedToTeacher(Teacher* t); 8628 8629 bool isRelatedToSubject(Subject* s); 8630 8631 bool isRelatedToActivityTag(ActivityTag* s); 8632 8633 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8634 8635 bool hasWrongDayOrHour(Rules& r); 8636 bool canRepairWrongDayOrHour(Rules& r); 8637 bool repairWrongDayOrHour(Rules& r); 8638 }; 8639 8640 class ConstraintStudentsSetMorningsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ 8641 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMorningsEarlyMaxBeginningsAtSecondHour) 8642 8643 public: 8644 int maxBeginningsAtSecondHour; 8645 8646 /** 8647 The name of the students 8648 */ 8649 QString students; 8650 8651 /** 8652 The number of subgroups involved in this constraint 8653 */ 8654 //int nSubgroups; 8655 8656 /** 8657 The subgroups involved in this constraint 8658 */ 8659 //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; 8660 QList<int> iSubgroupsList; 8661 8662 ConstraintStudentsSetMorningsEarlyMaxBeginningsAtSecondHour(); 8663 8664 ConstraintStudentsSetMorningsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH, const QString& students); 8665 8666 bool computeInternalStructure(QWidget* parent, Rules& r); 8667 8668 bool hasInactiveActivities(Rules& r); 8669 8670 QString getXmlDescription(Rules& r); 8671 8672 QString getDescription(Rules& r); 8673 8674 QString getDetailedDescription(Rules& r); 8675 8676 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8677 8678 bool isRelatedToActivity(Rules& r, Activity* a); 8679 8680 bool isRelatedToTeacher(Teacher* t); 8681 8682 bool isRelatedToSubject(Subject* s); 8683 8684 bool isRelatedToActivityTag(ActivityTag* s); 8685 8686 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8687 8688 bool hasWrongDayOrHour(Rules& r); 8689 bool canRepairWrongDayOrHour(Rules& r); 8690 bool repairWrongDayOrHour(Rules& r); 8691 }; 8692 8693 //2020-07-29 8694 class ConstraintTeachersMaxGapsPerWeekForRealDays: public TimeConstraint{ 8695 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerWeekForRealDays) 8696 8697 public: 8698 int maxGaps; 8699 8700 ConstraintTeachersMaxGapsPerWeekForRealDays(); 8701 8702 ConstraintTeachersMaxGapsPerWeekForRealDays(double wp, int maxGaps); 8703 8704 bool computeInternalStructure(QWidget* parent, Rules& r); 8705 8706 bool hasInactiveActivities(Rules& r); 8707 8708 QString getXmlDescription(Rules& r); 8709 8710 QString getDescription(Rules& r); 8711 8712 QString getDetailedDescription(Rules& r); 8713 8714 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8715 8716 bool isRelatedToActivity(Rules& r, Activity* a); 8717 8718 bool isRelatedToTeacher(Teacher* t); 8719 8720 bool isRelatedToSubject(Subject* s); 8721 8722 bool isRelatedToActivityTag(ActivityTag* s); 8723 8724 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8725 8726 bool hasWrongDayOrHour(Rules& r); 8727 bool canRepairWrongDayOrHour(Rules& r); 8728 bool repairWrongDayOrHour(Rules& r); 8729 }; 8730 8731 class ConstraintTeacherMaxGapsPerWeekForRealDays: public TimeConstraint{ 8732 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerWeekForRealDays) 8733 8734 public: 8735 int maxGaps; 8736 8737 QString teacherName; 8738 8739 int teacherIndex; 8740 8741 ConstraintTeacherMaxGapsPerWeekForRealDays(); 8742 8743 ConstraintTeacherMaxGapsPerWeekForRealDays(double wp, QString tn, int maxGaps); 8744 8745 bool computeInternalStructure(QWidget* parent, Rules& r); 8746 8747 bool hasInactiveActivities(Rules& r); 8748 8749 QString getXmlDescription(Rules& r); 8750 8751 QString getDescription(Rules& r); 8752 8753 QString getDetailedDescription(Rules& r); 8754 8755 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8756 8757 bool isRelatedToActivity(Rules& r, Activity* a); 8758 8759 bool isRelatedToTeacher(Teacher* t); 8760 8761 bool isRelatedToSubject(Subject* s); 8762 8763 bool isRelatedToActivityTag(ActivityTag* s); 8764 8765 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8766 8767 bool hasWrongDayOrHour(Rules& r); 8768 bool canRepairWrongDayOrHour(Rules& r); 8769 bool repairWrongDayOrHour(Rules& r); 8770 }; 8771 8772 class ConstraintStudentsMaxGapsPerWeekForRealDays: public TimeConstraint{ 8773 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxGapsPerWeekForRealDays) 8774 8775 public: 8776 int maxGaps; 8777 8778 ConstraintStudentsMaxGapsPerWeekForRealDays(); 8779 8780 ConstraintStudentsMaxGapsPerWeekForRealDays(double wp, int mg); 8781 8782 bool computeInternalStructure(QWidget* parent, Rules& r); 8783 8784 bool hasInactiveActivities(Rules& r); 8785 8786 QString getXmlDescription(Rules& r); 8787 8788 QString getDescription(Rules& r); 8789 8790 QString getDetailedDescription(Rules& r); 8791 8792 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8793 8794 bool isRelatedToActivity(Rules& r, Activity* a); 8795 8796 bool isRelatedToTeacher(Teacher* t); 8797 8798 bool isRelatedToSubject(Subject* s); 8799 8800 bool isRelatedToActivityTag(ActivityTag* s); 8801 8802 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8803 8804 bool hasWrongDayOrHour(Rules& r); 8805 bool canRepairWrongDayOrHour(Rules& r); 8806 bool repairWrongDayOrHour(Rules& r); 8807 }; 8808 8809 class ConstraintStudentsSetMaxGapsPerWeekForRealDays: public TimeConstraint{ 8810 Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxGapsPerWeekForRealDays) 8811 8812 public: 8813 int maxGaps; 8814 8815 /** 8816 The name of the students set for this constraint 8817 */ 8818 QString students; 8819 8820 //internal redundant data 8821 8822 /** 8823 The number of subgroups 8824 */ 8825 //int nSubgroups; 8826 8827 /** 8828 The subgroups 8829 */ 8830 QList<int> iSubgroupsList; 8831 8832 ConstraintStudentsSetMaxGapsPerWeekForRealDays(); 8833 8834 ConstraintStudentsSetMaxGapsPerWeekForRealDays(double wp, int mg, const QString& st ); 8835 8836 bool computeInternalStructure(QWidget* parent, Rules& r); 8837 8838 bool hasInactiveActivities(Rules& r); 8839 8840 QString getXmlDescription(Rules& r); 8841 8842 QString getDescription(Rules& r); 8843 8844 QString getDetailedDescription(Rules& r); 8845 8846 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, FakeString* conflictsString=nullptr); 8847 8848 bool isRelatedToActivity(Rules& r, Activity* a); 8849 8850 bool isRelatedToTeacher(Teacher* t); 8851 8852 bool isRelatedToSubject(Subject* s); 8853 8854 bool isRelatedToActivityTag(ActivityTag* s); 8855 8856 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8857 8858 bool hasWrongDayOrHour(Rules& r); 8859 bool canRepairWrongDayOrHour(Rules& r); 8860 bool repairWrongDayOrHour(Rules& r); 8861 }; 8862 //End for mornings-afternoons 8863 8864 //Begin mornings-afternoons 2021-09-26 8865 class ConstraintTeacherMaxThreeConsecutiveDays: public TimeConstraint{ 8866 Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxThreeConsecutiveDays) 8867 8868 public: 8869 /** 8870 The teacher's name 8871 */ 8872 QString teacherName; 8873 8874 /** 8875 The teacher's id, or index in the rules 8876 */ 8877 int teacher_ID; 8878 8879 bool allowAMAMException; //AMAM=afternoon morning afternoon morning. 8880 8881 ConstraintTeacherMaxThreeConsecutiveDays(); 8882 8883 ConstraintTeacherMaxThreeConsecutiveDays(double wp, bool ae, const QString& tn); 8884 8885 bool computeInternalStructure(QWidget* parent, Rules& r); 8886 8887 bool hasInactiveActivities(Rules& r); 8888 8889 QString getXmlDescription(Rules& r); 8890 8891 QString getDescription(Rules& r); 8892 8893 QString getDetailedDescription(Rules& r); 8894 8895 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 8896 8897 bool isRelatedToActivity(Rules& r, Activity* a); 8898 8899 bool isRelatedToTeacher(Teacher* t); 8900 8901 bool isRelatedToSubject(Subject* s); 8902 8903 bool isRelatedToActivityTag(ActivityTag* s); 8904 8905 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8906 8907 bool hasWrongDayOrHour(Rules& r); 8908 bool canRepairWrongDayOrHour(Rules& r); 8909 bool repairWrongDayOrHour(Rules& r); 8910 }; 8911 class ConstraintTeachersMaxThreeConsecutiveDays: public TimeConstraint{ 8912 Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxThreeConsecutiveDays) 8913 8914 public: 8915 bool allowAMAMException; //AMAM=afternoon morning afternoon morning. 8916 8917 ConstraintTeachersMaxThreeConsecutiveDays(); 8918 8919 ConstraintTeachersMaxThreeConsecutiveDays(double wp, bool ae); 8920 8921 bool computeInternalStructure(QWidget* parent, Rules& r); 8922 8923 bool hasInactiveActivities(Rules& r); 8924 8925 QString getXmlDescription(Rules& r); 8926 8927 QString getDescription(Rules& r); 8928 8929 QString getDetailedDescription(Rules& r); 8930 8931 double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr); 8932 8933 bool isRelatedToActivity(Rules& r, Activity* a); 8934 8935 bool isRelatedToTeacher(Teacher* t); 8936 8937 bool isRelatedToSubject(Subject* s); 8938 8939 bool isRelatedToActivityTag(ActivityTag* s); 8940 8941 bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); 8942 8943 bool hasWrongDayOrHour(Rules& r); 8944 bool canRepairWrongDayOrHour(Rules& r); 8945 bool repairWrongDayOrHour(Rules& r); 8946 }; 8947 //End mornings-afternoons 2021-09-26 8948 8949 #endif 8950