1 /*
2 File spaceconstraint.h
3 */
4 
5 /***************************************************************************
6                           spaceconstraint.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 SPACECONSTRAINT_H
23 #define SPACECONSTRAINT_H
24 
25 #include <QCoreApplication>
26 
27 #include "timetable_defs.h"
28 
29 #include <QString>
30 #include <QList>
31 #include <QStringList>
32 #include <QSet>
33 
34 class Rules;
35 class SpaceConstraint;
36 class Activity;
37 class Teacher;
38 class Subject;
39 class ActivityTag;
40 class StudentsSet;
41 class Building;
42 class Room;
43 class Solution;
44 
45 class FakeString;
46 
47 class QWidget;
48 
49 typedef QList<SpaceConstraint*> SpaceConstraintsList;
50 
51 const int CONSTRAINT_GENERIC_SPACE										=1000; //time constraints are beginning from 1
52 
53 const int CONSTRAINT_BASIC_COMPULSORY_SPACE								=1001; //space constraints from 1001
54 const int CONSTRAINT_ROOM_NOT_AVAILABLE_TIMES							=1002;
55 
56 const int CONSTRAINT_ACTIVITY_PREFERRED_ROOM							=1003;
57 const int CONSTRAINT_ACTIVITY_PREFERRED_ROOMS							=1004;
58 
59 const int CONSTRAINT_STUDENTS_SET_HOME_ROOM								=1005;
60 const int CONSTRAINT_STUDENTS_SET_HOME_ROOMS							=1006;
61 
62 const int CONSTRAINT_TEACHER_HOME_ROOM									=1007;
63 const int CONSTRAINT_TEACHER_HOME_ROOMS									=1008;
64 
65 const int CONSTRAINT_SUBJECT_PREFERRED_ROOM								=1009;
66 const int CONSTRAINT_SUBJECT_PREFERRED_ROOMS							=1010;
67 const int CONSTRAINT_SUBJECT_ACTIVITY_TAG_PREFERRED_ROOM				=1011;
68 const int CONSTRAINT_SUBJECT_ACTIVITY_TAG_PREFERRED_ROOMS				=1012;
69 
70 const int CONSTRAINT_STUDENTS_MAX_BUILDING_CHANGES_PER_DAY				=1013;
71 const int CONSTRAINT_STUDENTS_SET_MAX_BUILDING_CHANGES_PER_DAY			=1014;
72 const int CONSTRAINT_STUDENTS_MAX_BUILDING_CHANGES_PER_WEEK				=1015;
73 const int CONSTRAINT_STUDENTS_SET_MAX_BUILDING_CHANGES_PER_WEEK			=1016;
74 const int CONSTRAINT_STUDENTS_MIN_GAPS_BETWEEN_BUILDING_CHANGES			=1017;
75 const int CONSTRAINT_STUDENTS_SET_MIN_GAPS_BETWEEN_BUILDING_CHANGES		=1018;
76 
77 const int CONSTRAINT_TEACHERS_MAX_BUILDING_CHANGES_PER_DAY				=1019;
78 const int CONSTRAINT_TEACHER_MAX_BUILDING_CHANGES_PER_DAY				=1020;
79 const int CONSTRAINT_TEACHERS_MAX_BUILDING_CHANGES_PER_WEEK				=1021;
80 const int CONSTRAINT_TEACHER_MAX_BUILDING_CHANGES_PER_WEEK				=1022;
81 const int CONSTRAINT_TEACHERS_MIN_GAPS_BETWEEN_BUILDING_CHANGES			=1023;
82 const int CONSTRAINT_TEACHER_MIN_GAPS_BETWEEN_BUILDING_CHANGES			=1024;
83 
84 const int CONSTRAINT_ACTIVITY_TAG_PREFERRED_ROOM						=1025;
85 const int CONSTRAINT_ACTIVITY_TAG_PREFERRED_ROOMS						=1026;
86 
87 const int CONSTRAINT_ACTIVITIES_OCCUPY_MAX_DIFFERENT_ROOMS				=1027;
88 const int CONSTRAINT_ACTIVITIES_SAME_ROOM_IF_CONSECUTIVE				=1028;
89 
90 //2019-11-14
91 const int CONSTRAINT_STUDENTS_MAX_ROOM_CHANGES_PER_DAY					=1029;
92 const int CONSTRAINT_STUDENTS_SET_MAX_ROOM_CHANGES_PER_DAY				=1030;
93 const int CONSTRAINT_STUDENTS_MAX_ROOM_CHANGES_PER_WEEK					=1031;
94 const int CONSTRAINT_STUDENTS_SET_MAX_ROOM_CHANGES_PER_WEEK				=1032;
95 const int CONSTRAINT_STUDENTS_MIN_GAPS_BETWEEN_ROOM_CHANGES				=1033;
96 const int CONSTRAINT_STUDENTS_SET_MIN_GAPS_BETWEEN_ROOM_CHANGES			=1034;
97 
98 const int CONSTRAINT_TEACHERS_MAX_ROOM_CHANGES_PER_DAY					=1035;
99 const int CONSTRAINT_TEACHER_MAX_ROOM_CHANGES_PER_DAY					=1036;
100 const int CONSTRAINT_TEACHERS_MAX_ROOM_CHANGES_PER_WEEK					=1037;
101 const int CONSTRAINT_TEACHER_MAX_ROOM_CHANGES_PER_WEEK					=1038;
102 const int CONSTRAINT_TEACHERS_MIN_GAPS_BETWEEN_ROOM_CHANGES				=1039;
103 const int CONSTRAINT_TEACHER_MIN_GAPS_BETWEEN_ROOM_CHANGES				=1040;
104 
105 const int CONSTRAINT_TEACHER_ROOM_NOT_AVAILABLE_TIMES					=1041;
106 
107 //For mornings-afternoons
108 const int CONSTRAINT_STUDENTS_MAX_ROOM_CHANGES_PER_REAL_DAY				=1042;
109 const int CONSTRAINT_STUDENTS_SET_MAX_ROOM_CHANGES_PER_REAL_DAY			=1043;
110 const int CONSTRAINT_TEACHERS_MAX_ROOM_CHANGES_PER_REAL_DAY				=1044;
111 const int CONSTRAINT_TEACHER_MAX_ROOM_CHANGES_PER_REAL_DAY				=1045;
112 
113 /**
114 This class represents a space constraint
115 */
116 class SpaceConstraint{
117 	Q_DECLARE_TR_FUNCTIONS(SpaceConstraint)
118 
119 public:
120 	/**
121 	The weight (percentage) of this constraint
122 	*/
123 	double weightPercentage;
124 
125 	bool active;
126 
127 	QString comments;
128 
129 	/**
130 	Specifies the type of this constraint (using the above constants).
131 	*/
132 	int type;
133 
134 	/**
135 	Dummy constructor - needed for the static array of constraints.
136 	Use of this function must be avoided.
137 	*/
138 	SpaceConstraint();
139 
140 	virtual ~SpaceConstraint()=0;
141 
142 	/**
143 	DEPRECATED COMMENT BELOW:
144 	Constructor - please note that the maximum allowed weight is 100.0
145 	The reason: unallocated activities must have very big conflict weight,
146 	and any other constraints must have much more lower weight,
147 	so that the timetable can evolve when starting with uninitialized activities
148 	*/
149 	SpaceConstraint(double wp);
150 
151 	bool canBeUsedInOfficialMode();
152 	bool canBeUsedInMorningsAfternoonsMode();
153 	bool canBeUsedInBlockPlanningMode();
154 	bool canBeUsedInTermsMode();
155 
156 	/**
157 	The function that calculates the fitness of a solution, according to this
158 	constraint. We need the solution to compute this fitness factor.
159 	We need also the allocation of the activities on days and hours.
160 	If conflictsString!=nullptr, it will be initialized with a text explaining
161 	where this constraint is broken.
162 	*/
163 	virtual double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr)=0;
164 
165 	/**
166 	Returns an XML description of this constraint
167 	*/
168 	virtual QString getXmlDescription(Rules& r)=0;
169 
170 	/**
171 	Computes the internal structure for this constraint
172 	*/
173 	virtual bool computeInternalStructure(QWidget* parent, Rules& r)=0;
174 
175 	virtual bool hasInactiveActivities(Rules& r)=0;
176 
177 	/**
178 	Returns a small description string for this constraint
179 	*/
180 	virtual QString getDescription(Rules& r)=0;
181 
182 	/**
183 	Returns a detailed description string for this constraint
184 	*/
185 	virtual QString getDetailedDescription(Rules& r)=0;
186 
187 	/**
188 	Returns true if this constraint is related to this activity
189 	*/
190 	virtual bool isRelatedToActivity(Activity* a)=0;
191 
192 	/**
193 	Returns true if this constraint is related to this teacher
194 	*/
195 	virtual bool isRelatedToTeacher(Teacher* t)=0;
196 
197 	/**
198 	Returns true if this constraint is related to this subject
199 	*/
200 	virtual bool isRelatedToSubject(Subject* s)=0;
201 
202 	/**
203 	Returns true if this constraint is related to this activity tag
204 	*/
205 	virtual bool isRelatedToActivityTag(ActivityTag* s)=0;
206 
207 	/**
208 	Returns true if this constraint is related to this students set
209 	*/
210 	virtual bool isRelatedToStudentsSet(Rules& r, StudentsSet* s)=0;
211 
212 	/**
213 	Returns true if this constraint is related to this room
214 	*/
215 	virtual bool isRelatedToRoom(Room* r)=0;
216 
217 	virtual bool hasWrongDayOrHour(Rules& r)=0;
218 	virtual bool canRepairWrongDayOrHour(Rules& r)=0;
219 	virtual bool repairWrongDayOrHour(Rules& r)=0;
220 };
221 
222 /**
223 This class comprises all the basic compulsory constraints (constraints
224 which must be fulfilled for any timetable) - the space allocation part
225 */
226 class ConstraintBasicCompulsorySpace: public SpaceConstraint{
227 	Q_DECLARE_TR_FUNCTIONS(ConstraintBasicCompulsorySpace)
228 
229 public:
230 	ConstraintBasicCompulsorySpace();
231 
232 	ConstraintBasicCompulsorySpace(double wp);
233 
234 	bool computeInternalStructure(QWidget* parent, Rules& r);
235 
236 	bool hasInactiveActivities(Rules& r);
237 
238 	QString getXmlDescription(Rules& r);
239 
240 	QString getDescription(Rules& r);
241 
242 	QString getDetailedDescription(Rules& r);
243 
244 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
245 
246 	bool isRelatedToActivity(Activity* a);
247 
248 	bool isRelatedToTeacher(Teacher* t);
249 
250 	bool isRelatedToSubject(Subject* s);
251 
252 	bool isRelatedToActivityTag(ActivityTag* s);
253 
254 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
255 
256 	bool isRelatedToRoom(Room* r);
257 
258 	bool hasWrongDayOrHour(Rules& r);
259 	bool canRepairWrongDayOrHour(Rules& r);
260 	bool repairWrongDayOrHour(Rules& r);
261 };
262 
263 class ConstraintRoomNotAvailableTimes: public SpaceConstraint{
264 	Q_DECLARE_TR_FUNCTIONS(ConstraintRoomNotAvailableTimes)
265 
266 public:
267 
268 	QList<int> days;
269 	QList<int> hours;
270 
271 	/**
272 	The room's name
273 	*/
274 	QString room;
275 
276 	/**
277 	The room's id, or index in the rules
278 	*/
279 	int room_ID;
280 
281 	ConstraintRoomNotAvailableTimes();
282 
283 	ConstraintRoomNotAvailableTimes(double wp, const QString& rn, QList<int> d, QList<int> h);
284 
285 	bool computeInternalStructure(QWidget* parent, Rules& r);
286 
287 	bool hasInactiveActivities(Rules& r);
288 
289 	QString getXmlDescription(Rules& r);
290 
291 	QString getDescription(Rules& r);
292 
293 	QString getDetailedDescription(Rules& r);
294 
295 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
296 
297 	bool isRelatedToActivity(Activity* a);
298 
299 	bool isRelatedToTeacher(Teacher* t);
300 
301 	bool isRelatedToSubject(Subject* s);
302 
303 	bool isRelatedToActivityTag(ActivityTag* s);
304 
305 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
306 
307 	bool isRelatedToRoom(Room* r);
308 
309 	bool hasWrongDayOrHour(Rules& r);
310 	bool canRepairWrongDayOrHour(Rules& r);
311 	bool repairWrongDayOrHour(Rules& r);
312 };
313 
314 class ConstraintTeacherRoomNotAvailableTimes: public SpaceConstraint{
315 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherRoomNotAvailableTimes)
316 
317 public:
318 
319 	QList<int> days;
320 	QList<int> hours;
321 
322 	/**
323 	The room's name
324 	*/
325 	QString room;
326 
327 	QString teacherName;
328 
329 	/**
330 	The room's id, or index in the rules
331 	*/
332 	int room_ID;
333 
334 	int teacher_ID;
335 
336 	ConstraintTeacherRoomNotAvailableTimes();
337 
338 	ConstraintTeacherRoomNotAvailableTimes(double wp, const QString& tn, const QString& rn, QList<int> d, QList<int> h);
339 
340 	bool computeInternalStructure(QWidget* parent, Rules& r);
341 
342 	bool hasInactiveActivities(Rules& r);
343 
344 	QString getXmlDescription(Rules& r);
345 
346 	QString getDescription(Rules& r);
347 
348 	QString getDetailedDescription(Rules& r);
349 
350 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
351 
352 	bool isRelatedToActivity(Activity* a);
353 
354 	bool isRelatedToTeacher(Teacher* t);
355 
356 	bool isRelatedToSubject(Subject* s);
357 
358 	bool isRelatedToActivityTag(ActivityTag* s);
359 
360 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
361 
362 	bool isRelatedToRoom(Room* r);
363 
364 	bool hasWrongDayOrHour(Rules& r);
365 	bool canRepairWrongDayOrHour(Rules& r);
366 	bool repairWrongDayOrHour(Rules& r);
367 };
368 
369 /**
370 This is a constraint. Its purpose: an activity must take place in
371 the preferred room.
372 */
373 class ConstraintActivityPreferredRoom: public SpaceConstraint{
374 	Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredRoom)
375 
376 public:
377 
378 	//The activity referred to by this constraint.
379 	//This is an index in the rules internal activities list.
380 	int _activity;
381 
382 	//The index of the room
383 	int _room;
384 
385 	//----------------------------------------------------------
386 
387 	int activityId;
388 
389 	QString roomName;
390 
391 	QStringList preferredRealRoomsNames;
392 
393 	QSet<int> preferredRealRooms;
394 
395 	bool permanentlyLocked;
396 
397 	ConstraintActivityPreferredRoom();
398 
399 	ConstraintActivityPreferredRoom(double wp, int aid, const QString& room, const QStringList& realRooms, bool perm);
400 
401 	/**
402 	Comparison operator - to be sure we do not introduce duplicates
403 	*/
404 	bool operator==(ConstraintActivityPreferredRoom& c);
405 
406 	bool computeInternalStructure(QWidget* parent, Rules& r);
407 
408 	bool hasInactiveActivities(Rules& r);
409 
410 	QString getXmlDescription(Rules& r);
411 
412 	QString getDescription(Rules& r);
413 
414 	QString getDetailedDescription(Rules& r);
415 
416 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
417 
418 	bool isRelatedToActivity(Activity* a);
419 
420 	bool isRelatedToTeacher(Teacher* t);
421 
422 	bool isRelatedToSubject(Subject* s);
423 
424 	bool isRelatedToActivityTag(ActivityTag* s);
425 
426 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
427 
428 	bool isRelatedToRoom(Room* r);
429 
430 	bool hasWrongDayOrHour(Rules& r);
431 	bool canRepairWrongDayOrHour(Rules& r);
432 	bool repairWrongDayOrHour(Rules& r);
433 };
434 
435 /**
436 This is a constraint. Its purpose: an activity must take place in
437 the preferred rooms.
438 */
439 class ConstraintActivityPreferredRooms: public SpaceConstraint{
440 	Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredRooms)
441 
442 public:
443 
444 	//The activity referred to by this constraint.
445 	//This is an index in the rules internal activities list.
446 	int _activity;
447 
448 	//The indexes of the rooms
449 	QList<int> _rooms;
450 
451 	//----------------------------------------------------------
452 
453 	int activityId;
454 
455 	QStringList roomsNames;
456 
457 	ConstraintActivityPreferredRooms();
458 
459 	ConstraintActivityPreferredRooms(double wp, int aid, const QStringList& roomsList);
460 
461 	bool computeInternalStructure(QWidget* parent, Rules& r);
462 
463 	bool hasInactiveActivities(Rules& r);
464 
465 	QString getXmlDescription(Rules& r);
466 
467 	QString getDescription(Rules& r);
468 
469 	QString getDetailedDescription(Rules& r);
470 
471 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
472 
473 	bool isRelatedToActivity(Activity* a);
474 
475 	bool isRelatedToTeacher(Teacher* t);
476 
477 	bool isRelatedToSubject(Subject* s);
478 
479 	bool isRelatedToActivityTag(ActivityTag* s);
480 
481 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
482 
483 	bool isRelatedToRoom(Room* r);
484 
485 	bool hasWrongDayOrHour(Rules& r);
486 	bool canRepairWrongDayOrHour(Rules& r);
487 	bool repairWrongDayOrHour(Rules& r);
488 };
489 
490 class ConstraintStudentsSetHomeRoom: public SpaceConstraint{
491 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetHomeRoom)
492 
493 public:
494 
495 	QList<int> _activities;
496 
497 	// The index of the room
498 	int _room;
499 
500 public:
501 
502 	QString studentsName;
503 
504 	QString roomName;
505 
506 	ConstraintStudentsSetHomeRoom();
507 
508 	ConstraintStudentsSetHomeRoom(double wp, const QString& st, const QString& rm);
509 
510 	bool computeInternalStructure(QWidget* parent, Rules& r);
511 
512 	bool hasInactiveActivities(Rules& r);
513 
514 	QString getXmlDescription(Rules& r);
515 
516 	QString getDescription(Rules& r);
517 
518 	QString getDetailedDescription(Rules& r);
519 
520 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
521 
522 	bool isRelatedToActivity(Activity* a);
523 
524 	bool isRelatedToTeacher(Teacher* t);
525 
526 	bool isRelatedToSubject(Subject* s);
527 
528 	bool isRelatedToActivityTag(ActivityTag* s);
529 
530 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
531 
532 	bool isRelatedToRoom(Room* r);
533 
534 	bool hasWrongDayOrHour(Rules& r);
535 	bool canRepairWrongDayOrHour(Rules& r);
536 	bool repairWrongDayOrHour(Rules& r);
537 };
538 
539 class ConstraintStudentsSetHomeRooms: public SpaceConstraint{
540 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetHomeRooms)
541 
542 public:
543 
544 	//The list of activities referred to by this constraint.
545 	//This is a list of indices in the rules internal activities list.
546 	QList<int> _activities;
547 
548 	//The indexes of the rooms
549 	QList<int> _rooms;
550 
551 public:
552 
553 	QString studentsName;
554 
555 	QStringList roomsNames;
556 
557 	ConstraintStudentsSetHomeRooms();
558 
559 	ConstraintStudentsSetHomeRooms(double wp, const QString& st, const QStringList& rms);
560 
561 	bool computeInternalStructure(QWidget* parent, Rules& r);
562 
563 	bool hasInactiveActivities(Rules& r);
564 
565 	QString getXmlDescription(Rules& r);
566 
567 	QString getDescription(Rules& r);
568 
569 	QString getDetailedDescription(Rules& r);
570 
571 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
572 
573 	bool isRelatedToActivity(Activity* a);
574 
575 	bool isRelatedToTeacher(Teacher* t);
576 
577 	bool isRelatedToSubject(Subject* s);
578 
579 	bool isRelatedToActivityTag(ActivityTag* s);
580 
581 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
582 
583 	bool isRelatedToRoom(Room* r);
584 
585 	bool hasWrongDayOrHour(Rules& r);
586 	bool canRepairWrongDayOrHour(Rules& r);
587 	bool repairWrongDayOrHour(Rules& r);
588 };
589 
590 class ConstraintTeacherHomeRoom: public SpaceConstraint{
591 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherHomeRoom)
592 
593 public:
594 
595 	QList<int> _activities;
596 
597 	// The index of the room
598 	int _room;
599 
600 public:
601 
602 	QString teacherName;
603 
604 	QString roomName;
605 
606 	ConstraintTeacherHomeRoom();
607 
608 	ConstraintTeacherHomeRoom(double wp, const QString& tc, const QString& rm);
609 
610 	bool computeInternalStructure(QWidget* parent, Rules& r);
611 
612 	bool hasInactiveActivities(Rules& r);
613 
614 	QString getXmlDescription(Rules& r);
615 
616 	QString getDescription(Rules& r);
617 
618 	QString getDetailedDescription(Rules& r);
619 
620 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
621 
622 	bool isRelatedToActivity(Activity* a);
623 
624 	bool isRelatedToTeacher(Teacher* t);
625 
626 	bool isRelatedToSubject(Subject* s);
627 
628 	bool isRelatedToActivityTag(ActivityTag* s);
629 
630 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
631 
632 	bool isRelatedToRoom(Room* r);
633 
634 	bool hasWrongDayOrHour(Rules& r);
635 	bool canRepairWrongDayOrHour(Rules& r);
636 	bool repairWrongDayOrHour(Rules& r);
637 };
638 
639 class ConstraintTeacherHomeRooms: public SpaceConstraint{
640 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherHomeRooms)
641 
642 public:
643 
644 	//The list of activities referred to by this constraint.
645 	//This is a list of indices in the rules internal activities list.
646 	QList<int> _activities;
647 
648 	//The indexes of the rooms
649 	QList<int> _rooms;
650 
651 public:
652 
653 	QString teacherName;
654 
655 	QStringList roomsNames;
656 
657 	ConstraintTeacherHomeRooms();
658 
659 	ConstraintTeacherHomeRooms(double wp, const QString& st, const QStringList& rms);
660 
661 	bool computeInternalStructure(QWidget* parent, Rules& r);
662 
663 	bool hasInactiveActivities(Rules& r);
664 
665 	QString getXmlDescription(Rules& r);
666 
667 	QString getDescription(Rules& r);
668 
669 	QString getDetailedDescription(Rules& r);
670 
671 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
672 
673 	bool isRelatedToActivity(Activity* a);
674 
675 	bool isRelatedToTeacher(Teacher* t);
676 
677 	bool isRelatedToSubject(Subject* s);
678 
679 	bool isRelatedToActivityTag(ActivityTag* s);
680 
681 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
682 
683 	bool isRelatedToRoom(Room* r);
684 
685 	bool hasWrongDayOrHour(Rules& r);
686 	bool canRepairWrongDayOrHour(Rules& r);
687 	bool repairWrongDayOrHour(Rules& r);
688 };
689 
690 /**
691 This is a constraint. Its purpose: a subject must be taught in
692 a certain room.
693 */
694 class ConstraintSubjectPreferredRoom: public SpaceConstraint{
695 	Q_DECLARE_TR_FUNCTIONS(ConstraintSubjectPreferredRoom)
696 
697 public:
698 
699 	QList<int> _activities;
700 
701 	// The index of the room
702 	int _room;
703 
704 public:
705 
706 	QString subjectName;
707 
708 	QString roomName;
709 
710 	ConstraintSubjectPreferredRoom();
711 
712 	ConstraintSubjectPreferredRoom(double wp, const QString& subj, const QString& rm);
713 
714 	bool computeInternalStructure(QWidget* parent, Rules& r);
715 
716 	bool hasInactiveActivities(Rules& r);
717 
718 	QString getXmlDescription(Rules& r);
719 
720 	QString getDescription(Rules& r);
721 
722 	QString getDetailedDescription(Rules& r);
723 
724 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
725 
726 	bool isRelatedToActivity(Activity* a);
727 
728 	bool isRelatedToTeacher(Teacher* t);
729 
730 	bool isRelatedToSubject(Subject* s);
731 
732 	bool isRelatedToActivityTag(ActivityTag* s);
733 
734 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
735 
736 	bool isRelatedToRoom(Room* r);
737 
738 	bool hasWrongDayOrHour(Rules& r);
739 	bool canRepairWrongDayOrHour(Rules& r);
740 	bool repairWrongDayOrHour(Rules& r);
741 };
742 
743 /**
744 This is a constraint. Its purpose: a subject must be taught in
745 certain rooms.
746 */
747 class ConstraintSubjectPreferredRooms: public SpaceConstraint{
748 	Q_DECLARE_TR_FUNCTIONS(ConstraintSubjectPreferredRooms)
749 
750 public:
751 
752 	QList<int> _activities;
753 
754 	QList<int> _rooms;
755 
756 public:
757 
758 	QString subjectName;
759 
760 	QStringList roomsNames;
761 
762 	ConstraintSubjectPreferredRooms();
763 
764 	ConstraintSubjectPreferredRooms(double wp, const QString& subj, const QStringList& rms);
765 
766 	bool computeInternalStructure(QWidget* parent, Rules& r);
767 
768 	bool hasInactiveActivities(Rules& r);
769 
770 	QString getXmlDescription(Rules& r);
771 
772 	QString getDescription(Rules& r);
773 
774 	QString getDetailedDescription(Rules& r);
775 
776 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
777 
778 	bool isRelatedToActivity(Activity* a);
779 
780 	bool isRelatedToTeacher(Teacher* t);
781 
782 	bool isRelatedToSubject(Subject* s);
783 
784 	bool isRelatedToActivityTag(ActivityTag* s);
785 
786 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
787 
788 	bool isRelatedToRoom(Room* r);
789 
790 	bool hasWrongDayOrHour(Rules& r);
791 	bool canRepairWrongDayOrHour(Rules& r);
792 	bool repairWrongDayOrHour(Rules& r);
793 };
794 
795 /**
796 This is a constraint. Its purpose: a subject + an activity tag must be taught in
797 a certain room.
798 */
799 class ConstraintSubjectActivityTagPreferredRoom: public SpaceConstraint{
800 	Q_DECLARE_TR_FUNCTIONS(ConstraintSubjectActivityTagPreferredRoom)
801 
802 public:
803 
804 	QList<int> _activities;
805 
806 	// The index of the room
807 	int _room;
808 
809 public:
810 
811 	QString subjectName;
812 
813 	QString activityTagName;
814 
815 	QString roomName;
816 
817 	ConstraintSubjectActivityTagPreferredRoom();
818 
819 	ConstraintSubjectActivityTagPreferredRoom(double wp, const QString& subj, const QString& actTag, const QString& rm);
820 
821 	bool computeInternalStructure(QWidget* parent, Rules& r);
822 
823 	bool hasInactiveActivities(Rules& r);
824 
825 	QString getXmlDescription(Rules& r);
826 
827 	QString getDescription(Rules& r);
828 
829 	QString getDetailedDescription(Rules& r);
830 
831 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
832 
833 	bool isRelatedToActivity(Activity* a);
834 
835 	bool isRelatedToTeacher(Teacher* t);
836 
837 	bool isRelatedToSubject(Subject* s);
838 
839 	bool isRelatedToActivityTag(ActivityTag* s);
840 
841 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
842 
843 	bool isRelatedToRoom(Room* r);
844 
845 	bool hasWrongDayOrHour(Rules& r);
846 	bool canRepairWrongDayOrHour(Rules& r);
847 	bool repairWrongDayOrHour(Rules& r);
848 };
849 
850 /**
851 This is a constraint. Its purpose: a subject + an activity tag must be taught in
852 certain rooms.
853 */
854 class ConstraintSubjectActivityTagPreferredRooms: public SpaceConstraint{
855 	Q_DECLARE_TR_FUNCTIONS(ConstraintSubjectActivityTagPreferredRooms)
856 
857 public:
858 
859 	QList<int> _activities;
860 
861 	QList<int> _rooms;
862 
863 public:
864 
865 	QString subjectName;
866 
867 	QString activityTagName;
868 
869 	QStringList roomsNames;
870 
871 	ConstraintSubjectActivityTagPreferredRooms();
872 
873 	ConstraintSubjectActivityTagPreferredRooms(double wp, const QString& subj, const QString& actTag, const QStringList& rms);
874 
875 	bool computeInternalStructure(QWidget* parent, Rules& r);
876 
877 	bool hasInactiveActivities(Rules& r);
878 
879 	QString getXmlDescription(Rules& r);
880 
881 	QString getDescription(Rules& r);
882 
883 	QString getDetailedDescription(Rules& r);
884 
885 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
886 
887 	bool isRelatedToActivity(Activity* a);
888 
889 	bool isRelatedToTeacher(Teacher* t);
890 
891 	bool isRelatedToSubject(Subject* s);
892 
893 	bool isRelatedToActivityTag(ActivityTag* s);
894 
895 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
896 
897 	bool isRelatedToRoom(Room* r);
898 
899 	bool hasWrongDayOrHour(Rules& r);
900 	bool canRepairWrongDayOrHour(Rules& r);
901 	bool repairWrongDayOrHour(Rules& r);
902 };
903 
904 //addded on 6 apr 2009
905 class ConstraintActivityTagPreferredRoom: public SpaceConstraint{
906 	Q_DECLARE_TR_FUNCTIONS(ConstraintActivityTagPreferredRoom)
907 
908 public:
909 
910 	QList<int> _activities;
911 
912 	// The index of the room
913 	int _room;
914 
915 public:
916 
917 	QString activityTagName;
918 
919 	QString roomName;
920 
921 	ConstraintActivityTagPreferredRoom();
922 
923 	ConstraintActivityTagPreferredRoom(double wp, const QString& actTag, const QString& rm);
924 
925 	bool computeInternalStructure(QWidget* parent, Rules& r);
926 
927 	bool hasInactiveActivities(Rules& r);
928 
929 	QString getXmlDescription(Rules& r);
930 
931 	QString getDescription(Rules& r);
932 
933 	QString getDetailedDescription(Rules& r);
934 
935 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
936 
937 	bool isRelatedToActivity(Activity* a);
938 
939 	bool isRelatedToTeacher(Teacher* t);
940 
941 	bool isRelatedToSubject(Subject* s);
942 
943 	bool isRelatedToActivityTag(ActivityTag* s);
944 
945 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
946 
947 	bool isRelatedToRoom(Room* r);
948 
949 	bool hasWrongDayOrHour(Rules& r);
950 	bool canRepairWrongDayOrHour(Rules& r);
951 	bool repairWrongDayOrHour(Rules& r);
952 };
953 
954 class ConstraintActivityTagPreferredRooms: public SpaceConstraint{
955 	Q_DECLARE_TR_FUNCTIONS(ConstraintActivityTagPreferredRooms)
956 
957 public:
958 
959 	QList<int> _activities;
960 
961 	QList<int> _rooms;
962 
963 public:
964 
965 	QString activityTagName;
966 
967 	QStringList roomsNames;
968 
969 	ConstraintActivityTagPreferredRooms();
970 
971 	ConstraintActivityTagPreferredRooms(double wp, const QString& actTag, const QStringList& rms);
972 
973 	bool computeInternalStructure(QWidget* parent, Rules& r);
974 
975 	bool hasInactiveActivities(Rules& r);
976 
977 	QString getXmlDescription(Rules& r);
978 
979 	QString getDescription(Rules& r);
980 
981 	QString getDetailedDescription(Rules& r);
982 
983 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
984 
985 	bool isRelatedToActivity(Activity* a);
986 
987 	bool isRelatedToTeacher(Teacher* t);
988 
989 	bool isRelatedToSubject(Subject* s);
990 
991 	bool isRelatedToActivityTag(ActivityTag* s);
992 
993 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
994 
995 	bool isRelatedToRoom(Room* r);
996 
997 	bool hasWrongDayOrHour(Rules& r);
998 	bool canRepairWrongDayOrHour(Rules& r);
999 	bool repairWrongDayOrHour(Rules& r);
1000 };
1001 ///////
1002 
1003 class ConstraintStudentsSetMaxBuildingChangesPerDay: public SpaceConstraint{
1004 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxBuildingChangesPerDay)
1005 
1006 public:
1007 	//internal variables
1008 	QList<int> iSubgroupsList;
1009 
1010 public:
1011 
1012 	int maxBuildingChangesPerDay;
1013 
1014 	QString studentsName;
1015 
1016 	ConstraintStudentsSetMaxBuildingChangesPerDay();
1017 
1018 	ConstraintStudentsSetMaxBuildingChangesPerDay(double wp, const QString& st, int mc);
1019 
1020 	bool computeInternalStructure(QWidget* parent, Rules& r);
1021 
1022 	QString getXmlDescription(Rules& r);
1023 
1024 	bool hasInactiveActivities(Rules& r);
1025 
1026 	QString getDescription(Rules& r);
1027 
1028 	QString getDetailedDescription(Rules& r);
1029 
1030 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1031 
1032 	bool isRelatedToActivity(Activity* a);
1033 
1034 	bool isRelatedToTeacher(Teacher* t);
1035 
1036 	bool isRelatedToSubject(Subject* s);
1037 
1038 	bool isRelatedToActivityTag(ActivityTag* s);
1039 
1040 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1041 
1042 	bool isRelatedToRoom(Room* r);
1043 
1044 	bool hasWrongDayOrHour(Rules& r);
1045 	bool canRepairWrongDayOrHour(Rules& r);
1046 	bool repairWrongDayOrHour(Rules& r);
1047 };
1048 
1049 class ConstraintStudentsMaxBuildingChangesPerDay: public SpaceConstraint{
1050 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxBuildingChangesPerDay)
1051 
1052 public:
1053 
1054 	int maxBuildingChangesPerDay;
1055 
1056 	ConstraintStudentsMaxBuildingChangesPerDay();
1057 
1058 	ConstraintStudentsMaxBuildingChangesPerDay(double wp, int mc);
1059 
1060 	bool computeInternalStructure(QWidget* parent, Rules& r);
1061 
1062 	QString getXmlDescription(Rules& r);
1063 
1064 	bool hasInactiveActivities(Rules& r);
1065 
1066 	QString getDescription(Rules& r);
1067 
1068 	QString getDetailedDescription(Rules& r);
1069 
1070 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1071 
1072 	bool isRelatedToActivity(Activity* a);
1073 
1074 	bool isRelatedToTeacher(Teacher* t);
1075 
1076 	bool isRelatedToSubject(Subject* s);
1077 
1078 	bool isRelatedToActivityTag(ActivityTag* s);
1079 
1080 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1081 
1082 	bool isRelatedToRoom(Room* r);
1083 
1084 	bool hasWrongDayOrHour(Rules& r);
1085 	bool canRepairWrongDayOrHour(Rules& r);
1086 	bool repairWrongDayOrHour(Rules& r);
1087 };
1088 
1089 class ConstraintStudentsSetMaxBuildingChangesPerWeek: public SpaceConstraint{
1090 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxBuildingChangesPerWeek)
1091 
1092 public:
1093 	//internal variables
1094 	QList<int> iSubgroupsList;
1095 
1096 public:
1097 
1098 	int maxBuildingChangesPerWeek;
1099 
1100 	QString studentsName;
1101 
1102 	ConstraintStudentsSetMaxBuildingChangesPerWeek();
1103 
1104 	ConstraintStudentsSetMaxBuildingChangesPerWeek(double wp, const QString& st, int mc);
1105 
1106 	bool computeInternalStructure(QWidget* parent, Rules& r);
1107 
1108 	QString getXmlDescription(Rules& r);
1109 
1110 	bool hasInactiveActivities(Rules& r);
1111 
1112 	QString getDescription(Rules& r);
1113 
1114 	QString getDetailedDescription(Rules& r);
1115 
1116 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1117 
1118 	bool isRelatedToActivity(Activity* a);
1119 
1120 	bool isRelatedToTeacher(Teacher* t);
1121 
1122 	bool isRelatedToSubject(Subject* s);
1123 
1124 	bool isRelatedToActivityTag(ActivityTag* s);
1125 
1126 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1127 
1128 	bool isRelatedToRoom(Room* r);
1129 
1130 	bool hasWrongDayOrHour(Rules& r);
1131 	bool canRepairWrongDayOrHour(Rules& r);
1132 	bool repairWrongDayOrHour(Rules& r);
1133 };
1134 
1135 class ConstraintStudentsMaxBuildingChangesPerWeek: public SpaceConstraint{
1136 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxBuildingChangesPerWeek)
1137 
1138 public:
1139 
1140 	int maxBuildingChangesPerWeek;
1141 
1142 	ConstraintStudentsMaxBuildingChangesPerWeek();
1143 
1144 	ConstraintStudentsMaxBuildingChangesPerWeek(double wp, int mc);
1145 
1146 	bool computeInternalStructure(QWidget* parent, Rules& r);
1147 
1148 	QString getXmlDescription(Rules& r);
1149 
1150 	bool hasInactiveActivities(Rules& r);
1151 
1152 	QString getDescription(Rules& r);
1153 
1154 	QString getDetailedDescription(Rules& r);
1155 
1156 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1157 
1158 	bool isRelatedToActivity(Activity* a);
1159 
1160 	bool isRelatedToTeacher(Teacher* t);
1161 
1162 	bool isRelatedToSubject(Subject* s);
1163 
1164 	bool isRelatedToActivityTag(ActivityTag* s);
1165 
1166 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1167 
1168 	bool isRelatedToRoom(Room* r);
1169 
1170 	bool hasWrongDayOrHour(Rules& r);
1171 	bool canRepairWrongDayOrHour(Rules& r);
1172 	bool repairWrongDayOrHour(Rules& r);
1173 };
1174 
1175 class ConstraintStudentsSetMinGapsBetweenBuildingChanges: public SpaceConstraint{
1176 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinGapsBetweenBuildingChanges)
1177 
1178 public:
1179 	//internal variables
1180 	QList<int> iSubgroupsList;
1181 
1182 public:
1183 
1184 	int minGapsBetweenBuildingChanges;
1185 
1186 	QString studentsName;
1187 
1188 	ConstraintStudentsSetMinGapsBetweenBuildingChanges();
1189 
1190 	ConstraintStudentsSetMinGapsBetweenBuildingChanges(double wp, const QString& st, int mg);
1191 
1192 	bool computeInternalStructure(QWidget* parent, Rules& r);
1193 
1194 	QString getXmlDescription(Rules& r);
1195 
1196 	bool hasInactiveActivities(Rules& r);
1197 
1198 	QString getDescription(Rules& r);
1199 
1200 	QString getDetailedDescription(Rules& r);
1201 
1202 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1203 
1204 	bool isRelatedToActivity(Activity* a);
1205 
1206 	bool isRelatedToTeacher(Teacher* t);
1207 
1208 	bool isRelatedToSubject(Subject* s);
1209 
1210 	bool isRelatedToActivityTag(ActivityTag* s);
1211 
1212 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1213 
1214 	bool isRelatedToRoom(Room* r);
1215 
1216 	bool hasWrongDayOrHour(Rules& r);
1217 	bool canRepairWrongDayOrHour(Rules& r);
1218 	bool repairWrongDayOrHour(Rules& r);
1219 };
1220 
1221 class ConstraintStudentsMinGapsBetweenBuildingChanges: public SpaceConstraint{
1222 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinGapsBetweenBuildingChanges)
1223 
1224 public:
1225 
1226 	int minGapsBetweenBuildingChanges;
1227 
1228 	ConstraintStudentsMinGapsBetweenBuildingChanges();
1229 
1230 	ConstraintStudentsMinGapsBetweenBuildingChanges(double wp, int mg);
1231 
1232 	bool computeInternalStructure(QWidget* parent, Rules& r);
1233 
1234 	QString getXmlDescription(Rules& r);
1235 
1236 	bool hasInactiveActivities(Rules& r);
1237 
1238 	QString getDescription(Rules& r);
1239 
1240 	QString getDetailedDescription(Rules& r);
1241 
1242 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1243 
1244 	bool isRelatedToActivity(Activity* a);
1245 
1246 	bool isRelatedToTeacher(Teacher* t);
1247 
1248 	bool isRelatedToSubject(Subject* s);
1249 
1250 	bool isRelatedToActivityTag(ActivityTag* s);
1251 
1252 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1253 
1254 	bool isRelatedToRoom(Room* r);
1255 
1256 	bool hasWrongDayOrHour(Rules& r);
1257 	bool canRepairWrongDayOrHour(Rules& r);
1258 	bool repairWrongDayOrHour(Rules& r);
1259 };
1260 
1261 class ConstraintTeacherMaxBuildingChangesPerDay: public SpaceConstraint{
1262 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxBuildingChangesPerDay)
1263 
1264 public:
1265 	//internal variables
1266 	int teacher_ID;
1267 
1268 public:
1269 
1270 	int maxBuildingChangesPerDay;
1271 
1272 	QString teacherName;
1273 
1274 	ConstraintTeacherMaxBuildingChangesPerDay();
1275 
1276 	ConstraintTeacherMaxBuildingChangesPerDay(double wp, const QString& tc, int mc);
1277 
1278 	bool computeInternalStructure(QWidget* parent, Rules& r);
1279 
1280 	QString getXmlDescription(Rules& r);
1281 
1282 	bool hasInactiveActivities(Rules& r);
1283 
1284 	QString getDescription(Rules& r);
1285 
1286 	QString getDetailedDescription(Rules& r);
1287 
1288 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1289 
1290 	bool isRelatedToActivity(Activity* a);
1291 
1292 	bool isRelatedToTeacher(Teacher* t);
1293 
1294 	bool isRelatedToSubject(Subject* s);
1295 
1296 	bool isRelatedToActivityTag(ActivityTag* s);
1297 
1298 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1299 
1300 	bool isRelatedToRoom(Room* r);
1301 
1302 	bool hasWrongDayOrHour(Rules& r);
1303 	bool canRepairWrongDayOrHour(Rules& r);
1304 	bool repairWrongDayOrHour(Rules& r);
1305 };
1306 
1307 class ConstraintTeachersMaxBuildingChangesPerDay: public SpaceConstraint{
1308 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxBuildingChangesPerDay)
1309 
1310 public:
1311 
1312 	int maxBuildingChangesPerDay;
1313 
1314 	ConstraintTeachersMaxBuildingChangesPerDay();
1315 
1316 	ConstraintTeachersMaxBuildingChangesPerDay(double wp, int mc);
1317 
1318 	bool computeInternalStructure(QWidget* parent, Rules& r);
1319 
1320 	bool hasInactiveActivities(Rules& r);
1321 
1322 	QString getXmlDescription(Rules& r);
1323 
1324 	QString getDescription(Rules& r);
1325 
1326 	QString getDetailedDescription(Rules& r);
1327 
1328 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1329 
1330 	bool isRelatedToActivity(Activity* a);
1331 
1332 	bool isRelatedToTeacher(Teacher* t);
1333 
1334 	bool isRelatedToSubject(Subject* s);
1335 
1336 	bool isRelatedToActivityTag(ActivityTag* s);
1337 
1338 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1339 
1340 	bool isRelatedToRoom(Room* r);
1341 
1342 	bool hasWrongDayOrHour(Rules& r);
1343 	bool canRepairWrongDayOrHour(Rules& r);
1344 	bool repairWrongDayOrHour(Rules& r);
1345 };
1346 
1347 class ConstraintTeacherMaxBuildingChangesPerWeek: public SpaceConstraint{
1348 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxBuildingChangesPerWeek)
1349 
1350 public:
1351 	//internal variables
1352 	int teacher_ID;
1353 
1354 public:
1355 
1356 	int maxBuildingChangesPerWeek;
1357 
1358 	QString teacherName;
1359 
1360 	ConstraintTeacherMaxBuildingChangesPerWeek();
1361 
1362 	ConstraintTeacherMaxBuildingChangesPerWeek(double wp, const QString& tc, int mc);
1363 
1364 	bool computeInternalStructure(QWidget* parent, Rules& r);
1365 
1366 	bool hasInactiveActivities(Rules& r);
1367 
1368 	QString getXmlDescription(Rules& r);
1369 
1370 	QString getDescription(Rules& r);
1371 
1372 	QString getDetailedDescription(Rules& r);
1373 
1374 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1375 
1376 	bool isRelatedToActivity(Activity* a);
1377 
1378 	bool isRelatedToTeacher(Teacher* t);
1379 
1380 	bool isRelatedToSubject(Subject* s);
1381 
1382 	bool isRelatedToActivityTag(ActivityTag* s);
1383 
1384 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1385 
1386 	bool isRelatedToRoom(Room* r);
1387 
1388 	bool hasWrongDayOrHour(Rules& r);
1389 	bool canRepairWrongDayOrHour(Rules& r);
1390 	bool repairWrongDayOrHour(Rules& r);
1391 };
1392 
1393 class ConstraintTeachersMaxBuildingChangesPerWeek: public SpaceConstraint{
1394 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxBuildingChangesPerWeek)
1395 
1396 public:
1397 
1398 	int maxBuildingChangesPerWeek;
1399 
1400 	ConstraintTeachersMaxBuildingChangesPerWeek();
1401 
1402 	ConstraintTeachersMaxBuildingChangesPerWeek(double wp, int mc);
1403 
1404 	bool computeInternalStructure(QWidget* parent, Rules& r);
1405 
1406 	bool hasInactiveActivities(Rules& r);
1407 
1408 	QString getXmlDescription(Rules& r);
1409 
1410 	QString getDescription(Rules& r);
1411 
1412 	QString getDetailedDescription(Rules& r);
1413 
1414 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1415 
1416 	bool isRelatedToActivity(Activity* a);
1417 
1418 	bool isRelatedToTeacher(Teacher* t);
1419 
1420 	bool isRelatedToSubject(Subject* s);
1421 
1422 	bool isRelatedToActivityTag(ActivityTag* s);
1423 
1424 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1425 
1426 	bool isRelatedToRoom(Room* r);
1427 
1428 	bool hasWrongDayOrHour(Rules& r);
1429 	bool canRepairWrongDayOrHour(Rules& r);
1430 	bool repairWrongDayOrHour(Rules& r);
1431 };
1432 
1433 class ConstraintTeacherMinGapsBetweenBuildingChanges: public SpaceConstraint{
1434 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinGapsBetweenBuildingChanges)
1435 
1436 public:
1437 	//internal variables
1438 	int teacher_ID;
1439 
1440 public:
1441 
1442 	int minGapsBetweenBuildingChanges;
1443 
1444 	QString teacherName;
1445 
1446 	ConstraintTeacherMinGapsBetweenBuildingChanges();
1447 
1448 	ConstraintTeacherMinGapsBetweenBuildingChanges(double wp, const QString& tc, int mg);
1449 
1450 	bool computeInternalStructure(QWidget* parent, Rules& r);
1451 
1452 	bool hasInactiveActivities(Rules& r);
1453 
1454 	QString getXmlDescription(Rules& r);
1455 
1456 	QString getDescription(Rules& r);
1457 
1458 	QString getDetailedDescription(Rules& r);
1459 
1460 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1461 
1462 	bool isRelatedToActivity(Activity* a);
1463 
1464 	bool isRelatedToTeacher(Teacher* t);
1465 
1466 	bool isRelatedToSubject(Subject* s);
1467 
1468 	bool isRelatedToActivityTag(ActivityTag* s);
1469 
1470 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1471 
1472 	bool isRelatedToRoom(Room* r);
1473 
1474 	bool hasWrongDayOrHour(Rules& r);
1475 	bool canRepairWrongDayOrHour(Rules& r);
1476 	bool repairWrongDayOrHour(Rules& r);
1477 };
1478 
1479 class ConstraintTeachersMinGapsBetweenBuildingChanges: public SpaceConstraint{
1480 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinGapsBetweenBuildingChanges)
1481 
1482 public:
1483 
1484 	int minGapsBetweenBuildingChanges;
1485 
1486 	ConstraintTeachersMinGapsBetweenBuildingChanges();
1487 
1488 	ConstraintTeachersMinGapsBetweenBuildingChanges(double wp, int mg);
1489 
1490 	bool computeInternalStructure(QWidget* parent, Rules& r);
1491 
1492 	bool hasInactiveActivities(Rules& r);
1493 
1494 	QString getXmlDescription(Rules& r);
1495 
1496 	QString getDescription(Rules& r);
1497 
1498 	QString getDetailedDescription(Rules& r);
1499 
1500 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1501 
1502 	bool isRelatedToActivity(Activity* a);
1503 
1504 	bool isRelatedToTeacher(Teacher* t);
1505 
1506 	bool isRelatedToSubject(Subject* s);
1507 
1508 	bool isRelatedToActivityTag(ActivityTag* s);
1509 
1510 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1511 
1512 	bool isRelatedToRoom(Room* r);
1513 
1514 	bool hasWrongDayOrHour(Rules& r);
1515 	bool canRepairWrongDayOrHour(Rules& r);
1516 	bool repairWrongDayOrHour(Rules& r);
1517 };
1518 
1519 //2019-11-14
1520 class ConstraintStudentsSetMaxRoomChangesPerDay: public SpaceConstraint{
1521 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxRoomChangesPerDay)
1522 
1523 public:
1524 	//internal variables
1525 	QList<int> iSubgroupsList;
1526 
1527 public:
1528 
1529 	int maxRoomChangesPerDay;
1530 
1531 	QString studentsName;
1532 
1533 	ConstraintStudentsSetMaxRoomChangesPerDay();
1534 
1535 	ConstraintStudentsSetMaxRoomChangesPerDay(double wp, const QString& st, int mc);
1536 
1537 	bool computeInternalStructure(QWidget* parent, Rules& r);
1538 
1539 	QString getXmlDescription(Rules& r);
1540 
1541 	bool hasInactiveActivities(Rules& r);
1542 
1543 	QString getDescription(Rules& r);
1544 
1545 	QString getDetailedDescription(Rules& r);
1546 
1547 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1548 
1549 	bool isRelatedToActivity(Activity* a);
1550 
1551 	bool isRelatedToTeacher(Teacher* t);
1552 
1553 	bool isRelatedToSubject(Subject* s);
1554 
1555 	bool isRelatedToActivityTag(ActivityTag* s);
1556 
1557 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1558 
1559 	bool isRelatedToRoom(Room* r);
1560 
1561 	bool hasWrongDayOrHour(Rules& r);
1562 	bool canRepairWrongDayOrHour(Rules& r);
1563 	bool repairWrongDayOrHour(Rules& r);
1564 };
1565 
1566 class ConstraintStudentsMaxRoomChangesPerDay: public SpaceConstraint{
1567 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxRoomChangesPerDay)
1568 
1569 public:
1570 
1571 	int maxRoomChangesPerDay;
1572 
1573 	ConstraintStudentsMaxRoomChangesPerDay();
1574 
1575 	ConstraintStudentsMaxRoomChangesPerDay(double wp, int mc);
1576 
1577 	bool computeInternalStructure(QWidget* parent, Rules& r);
1578 
1579 	QString getXmlDescription(Rules& r);
1580 
1581 	bool hasInactiveActivities(Rules& r);
1582 
1583 	QString getDescription(Rules& r);
1584 
1585 	QString getDetailedDescription(Rules& r);
1586 
1587 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1588 
1589 	bool isRelatedToActivity(Activity* a);
1590 
1591 	bool isRelatedToTeacher(Teacher* t);
1592 
1593 	bool isRelatedToSubject(Subject* s);
1594 
1595 	bool isRelatedToActivityTag(ActivityTag* s);
1596 
1597 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1598 
1599 	bool isRelatedToRoom(Room* r);
1600 
1601 	bool hasWrongDayOrHour(Rules& r);
1602 	bool canRepairWrongDayOrHour(Rules& r);
1603 	bool repairWrongDayOrHour(Rules& r);
1604 };
1605 
1606 class ConstraintStudentsSetMaxRoomChangesPerWeek: public SpaceConstraint{
1607 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxRoomChangesPerWeek)
1608 
1609 public:
1610 	//internal variables
1611 	QList<int> iSubgroupsList;
1612 
1613 public:
1614 
1615 	int maxRoomChangesPerWeek;
1616 
1617 	QString studentsName;
1618 
1619 	ConstraintStudentsSetMaxRoomChangesPerWeek();
1620 
1621 	ConstraintStudentsSetMaxRoomChangesPerWeek(double wp, const QString& st, int mc);
1622 
1623 	bool computeInternalStructure(QWidget* parent, Rules& r);
1624 
1625 	QString getXmlDescription(Rules& r);
1626 
1627 	bool hasInactiveActivities(Rules& r);
1628 
1629 	QString getDescription(Rules& r);
1630 
1631 	QString getDetailedDescription(Rules& r);
1632 
1633 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1634 
1635 	bool isRelatedToActivity(Activity* a);
1636 
1637 	bool isRelatedToTeacher(Teacher* t);
1638 
1639 	bool isRelatedToSubject(Subject* s);
1640 
1641 	bool isRelatedToActivityTag(ActivityTag* s);
1642 
1643 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1644 
1645 	bool isRelatedToRoom(Room* r);
1646 
1647 	bool hasWrongDayOrHour(Rules& r);
1648 	bool canRepairWrongDayOrHour(Rules& r);
1649 	bool repairWrongDayOrHour(Rules& r);
1650 };
1651 
1652 class ConstraintStudentsMaxRoomChangesPerWeek: public SpaceConstraint{
1653 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxRoomChangesPerWeek)
1654 
1655 public:
1656 
1657 	int maxRoomChangesPerWeek;
1658 
1659 	ConstraintStudentsMaxRoomChangesPerWeek();
1660 
1661 	ConstraintStudentsMaxRoomChangesPerWeek(double wp, int mc);
1662 
1663 	bool computeInternalStructure(QWidget* parent, Rules& r);
1664 
1665 	QString getXmlDescription(Rules& r);
1666 
1667 	bool hasInactiveActivities(Rules& r);
1668 
1669 	QString getDescription(Rules& r);
1670 
1671 	QString getDetailedDescription(Rules& r);
1672 
1673 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1674 
1675 	bool isRelatedToActivity(Activity* a);
1676 
1677 	bool isRelatedToTeacher(Teacher* t);
1678 
1679 	bool isRelatedToSubject(Subject* s);
1680 
1681 	bool isRelatedToActivityTag(ActivityTag* s);
1682 
1683 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1684 
1685 	bool isRelatedToRoom(Room* r);
1686 
1687 	bool hasWrongDayOrHour(Rules& r);
1688 	bool canRepairWrongDayOrHour(Rules& r);
1689 	bool repairWrongDayOrHour(Rules& r);
1690 };
1691 
1692 class ConstraintStudentsSetMinGapsBetweenRoomChanges: public SpaceConstraint{
1693 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinGapsBetweenRoomChanges)
1694 
1695 public:
1696 	//internal variables
1697 	QList<int> iSubgroupsList;
1698 
1699 public:
1700 
1701 	int minGapsBetweenRoomChanges;
1702 
1703 	QString studentsName;
1704 
1705 	ConstraintStudentsSetMinGapsBetweenRoomChanges();
1706 
1707 	ConstraintStudentsSetMinGapsBetweenRoomChanges(double wp, const QString& st, int mg);
1708 
1709 	bool computeInternalStructure(QWidget* parent, Rules& r);
1710 
1711 	QString getXmlDescription(Rules& r);
1712 
1713 	bool hasInactiveActivities(Rules& r);
1714 
1715 	QString getDescription(Rules& r);
1716 
1717 	QString getDetailedDescription(Rules& r);
1718 
1719 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1720 
1721 	bool isRelatedToActivity(Activity* a);
1722 
1723 	bool isRelatedToTeacher(Teacher* t);
1724 
1725 	bool isRelatedToSubject(Subject* s);
1726 
1727 	bool isRelatedToActivityTag(ActivityTag* s);
1728 
1729 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1730 
1731 	bool isRelatedToRoom(Room* r);
1732 
1733 	bool hasWrongDayOrHour(Rules& r);
1734 	bool canRepairWrongDayOrHour(Rules& r);
1735 	bool repairWrongDayOrHour(Rules& r);
1736 };
1737 
1738 class ConstraintStudentsMinGapsBetweenRoomChanges: public SpaceConstraint{
1739 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinGapsBetweenRoomChanges)
1740 
1741 public:
1742 
1743 	int minGapsBetweenRoomChanges;
1744 
1745 	ConstraintStudentsMinGapsBetweenRoomChanges();
1746 
1747 	ConstraintStudentsMinGapsBetweenRoomChanges(double wp, int mg);
1748 
1749 	bool computeInternalStructure(QWidget* parent, Rules& r);
1750 
1751 	QString getXmlDescription(Rules& r);
1752 
1753 	bool hasInactiveActivities(Rules& r);
1754 
1755 	QString getDescription(Rules& r);
1756 
1757 	QString getDetailedDescription(Rules& r);
1758 
1759 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1760 
1761 	bool isRelatedToActivity(Activity* a);
1762 
1763 	bool isRelatedToTeacher(Teacher* t);
1764 
1765 	bool isRelatedToSubject(Subject* s);
1766 
1767 	bool isRelatedToActivityTag(ActivityTag* s);
1768 
1769 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1770 
1771 	bool isRelatedToRoom(Room* r);
1772 
1773 	bool hasWrongDayOrHour(Rules& r);
1774 	bool canRepairWrongDayOrHour(Rules& r);
1775 	bool repairWrongDayOrHour(Rules& r);
1776 };
1777 
1778 class ConstraintTeacherMaxRoomChangesPerDay: public SpaceConstraint{
1779 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxRoomChangesPerDay)
1780 
1781 public:
1782 	//internal variables
1783 	int teacher_ID;
1784 
1785 public:
1786 
1787 	int maxRoomChangesPerDay;
1788 
1789 	QString teacherName;
1790 
1791 	ConstraintTeacherMaxRoomChangesPerDay();
1792 
1793 	ConstraintTeacherMaxRoomChangesPerDay(double wp, const QString& tc, int mc);
1794 
1795 	bool computeInternalStructure(QWidget* parent, Rules& r);
1796 
1797 	QString getXmlDescription(Rules& r);
1798 
1799 	bool hasInactiveActivities(Rules& r);
1800 
1801 	QString getDescription(Rules& r);
1802 
1803 	QString getDetailedDescription(Rules& r);
1804 
1805 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1806 
1807 	bool isRelatedToActivity(Activity* a);
1808 
1809 	bool isRelatedToTeacher(Teacher* t);
1810 
1811 	bool isRelatedToSubject(Subject* s);
1812 
1813 	bool isRelatedToActivityTag(ActivityTag* s);
1814 
1815 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1816 
1817 	bool isRelatedToRoom(Room* r);
1818 
1819 	bool hasWrongDayOrHour(Rules& r);
1820 	bool canRepairWrongDayOrHour(Rules& r);
1821 	bool repairWrongDayOrHour(Rules& r);
1822 };
1823 
1824 class ConstraintTeachersMaxRoomChangesPerDay: public SpaceConstraint{
1825 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxRoomChangesPerDay)
1826 
1827 public:
1828 
1829 	int maxRoomChangesPerDay;
1830 
1831 	ConstraintTeachersMaxRoomChangesPerDay();
1832 
1833 	ConstraintTeachersMaxRoomChangesPerDay(double wp, int mc);
1834 
1835 	bool computeInternalStructure(QWidget* parent, Rules& r);
1836 
1837 	bool hasInactiveActivities(Rules& r);
1838 
1839 	QString getXmlDescription(Rules& r);
1840 
1841 	QString getDescription(Rules& r);
1842 
1843 	QString getDetailedDescription(Rules& r);
1844 
1845 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1846 
1847 	bool isRelatedToActivity(Activity* a);
1848 
1849 	bool isRelatedToTeacher(Teacher* t);
1850 
1851 	bool isRelatedToSubject(Subject* s);
1852 
1853 	bool isRelatedToActivityTag(ActivityTag* s);
1854 
1855 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1856 
1857 	bool isRelatedToRoom(Room* r);
1858 
1859 	bool hasWrongDayOrHour(Rules& r);
1860 	bool canRepairWrongDayOrHour(Rules& r);
1861 	bool repairWrongDayOrHour(Rules& r);
1862 };
1863 
1864 class ConstraintTeacherMaxRoomChangesPerWeek: public SpaceConstraint{
1865 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxRoomChangesPerWeek)
1866 
1867 public:
1868 	//internal variables
1869 	int teacher_ID;
1870 
1871 public:
1872 
1873 	int maxRoomChangesPerWeek;
1874 
1875 	QString teacherName;
1876 
1877 	ConstraintTeacherMaxRoomChangesPerWeek();
1878 
1879 	ConstraintTeacherMaxRoomChangesPerWeek(double wp, const QString& tc, int mc);
1880 
1881 	bool computeInternalStructure(QWidget* parent, Rules& r);
1882 
1883 	bool hasInactiveActivities(Rules& r);
1884 
1885 	QString getXmlDescription(Rules& r);
1886 
1887 	QString getDescription(Rules& r);
1888 
1889 	QString getDetailedDescription(Rules& r);
1890 
1891 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1892 
1893 	bool isRelatedToActivity(Activity* a);
1894 
1895 	bool isRelatedToTeacher(Teacher* t);
1896 
1897 	bool isRelatedToSubject(Subject* s);
1898 
1899 	bool isRelatedToActivityTag(ActivityTag* s);
1900 
1901 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1902 
1903 	bool isRelatedToRoom(Room* r);
1904 
1905 	bool hasWrongDayOrHour(Rules& r);
1906 	bool canRepairWrongDayOrHour(Rules& r);
1907 	bool repairWrongDayOrHour(Rules& r);
1908 };
1909 
1910 class ConstraintTeachersMaxRoomChangesPerWeek: public SpaceConstraint{
1911 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxRoomChangesPerWeek)
1912 
1913 public:
1914 
1915 	int maxRoomChangesPerWeek;
1916 
1917 	ConstraintTeachersMaxRoomChangesPerWeek();
1918 
1919 	ConstraintTeachersMaxRoomChangesPerWeek(double wp, int mc);
1920 
1921 	bool computeInternalStructure(QWidget* parent, Rules& r);
1922 
1923 	bool hasInactiveActivities(Rules& r);
1924 
1925 	QString getXmlDescription(Rules& r);
1926 
1927 	QString getDescription(Rules& r);
1928 
1929 	QString getDetailedDescription(Rules& r);
1930 
1931 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1932 
1933 	bool isRelatedToActivity(Activity* a);
1934 
1935 	bool isRelatedToTeacher(Teacher* t);
1936 
1937 	bool isRelatedToSubject(Subject* s);
1938 
1939 	bool isRelatedToActivityTag(ActivityTag* s);
1940 
1941 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1942 
1943 	bool isRelatedToRoom(Room* r);
1944 
1945 	bool hasWrongDayOrHour(Rules& r);
1946 	bool canRepairWrongDayOrHour(Rules& r);
1947 	bool repairWrongDayOrHour(Rules& r);
1948 };
1949 
1950 class ConstraintTeacherMinGapsBetweenRoomChanges: public SpaceConstraint{
1951 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinGapsBetweenRoomChanges)
1952 
1953 public:
1954 	//internal variables
1955 	int teacher_ID;
1956 
1957 public:
1958 
1959 	int minGapsBetweenRoomChanges;
1960 
1961 	QString teacherName;
1962 
1963 	ConstraintTeacherMinGapsBetweenRoomChanges();
1964 
1965 	ConstraintTeacherMinGapsBetweenRoomChanges(double wp, const QString& tc, int mg);
1966 
1967 	bool computeInternalStructure(QWidget* parent, Rules& r);
1968 
1969 	bool hasInactiveActivities(Rules& r);
1970 
1971 	QString getXmlDescription(Rules& r);
1972 
1973 	QString getDescription(Rules& r);
1974 
1975 	QString getDetailedDescription(Rules& r);
1976 
1977 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
1978 
1979 	bool isRelatedToActivity(Activity* a);
1980 
1981 	bool isRelatedToTeacher(Teacher* t);
1982 
1983 	bool isRelatedToSubject(Subject* s);
1984 
1985 	bool isRelatedToActivityTag(ActivityTag* s);
1986 
1987 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
1988 
1989 	bool isRelatedToRoom(Room* r);
1990 
1991 	bool hasWrongDayOrHour(Rules& r);
1992 	bool canRepairWrongDayOrHour(Rules& r);
1993 	bool repairWrongDayOrHour(Rules& r);
1994 };
1995 
1996 class ConstraintTeachersMinGapsBetweenRoomChanges: public SpaceConstraint{
1997 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinGapsBetweenRoomChanges)
1998 
1999 public:
2000 
2001 	int minGapsBetweenRoomChanges;
2002 
2003 	ConstraintTeachersMinGapsBetweenRoomChanges();
2004 
2005 	ConstraintTeachersMinGapsBetweenRoomChanges(double wp, int mg);
2006 
2007 	bool computeInternalStructure(QWidget* parent, Rules& r);
2008 
2009 	bool hasInactiveActivities(Rules& r);
2010 
2011 	QString getXmlDescription(Rules& r);
2012 
2013 	QString getDescription(Rules& r);
2014 
2015 	QString getDetailedDescription(Rules& r);
2016 
2017 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
2018 
2019 	bool isRelatedToActivity(Activity* a);
2020 
2021 	bool isRelatedToTeacher(Teacher* t);
2022 
2023 	bool isRelatedToSubject(Subject* s);
2024 
2025 	bool isRelatedToActivityTag(ActivityTag* s);
2026 
2027 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
2028 
2029 	bool isRelatedToRoom(Room* r);
2030 
2031 	bool hasWrongDayOrHour(Rules& r);
2032 	bool canRepairWrongDayOrHour(Rules& r);
2033 	bool repairWrongDayOrHour(Rules& r);
2034 };
2035 
2036 class ConstraintActivitiesOccupyMaxDifferentRooms: public SpaceConstraint{
2037 	Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesOccupyMaxDifferentRooms)
2038 
2039 public:
2040 	QList<int> activitiesIds;
2041 
2042 	int maxDifferentRooms;
2043 
2044 	//internal variables
2045 	QList<int> _activitiesIndices;
2046 
2047 	ConstraintActivitiesOccupyMaxDifferentRooms();
2048 
2049 	ConstraintActivitiesOccupyMaxDifferentRooms(double wp, QList<int> a_L, int max_rooms);
2050 
2051 	bool computeInternalStructure(QWidget* parent, Rules& r);
2052 
2053 	bool hasInactiveActivities(Rules& r);
2054 
2055 	QString getXmlDescription(Rules& r);
2056 
2057 	QString getDescription(Rules& r);
2058 
2059 	QString getDetailedDescription(Rules& r);
2060 
2061 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
2062 
2063 	void removeUseless(Rules& r);
2064 
2065 	bool isRelatedToActivity(Activity* a);
2066 
2067 	bool isRelatedToTeacher(Teacher* t);
2068 
2069 	bool isRelatedToSubject(Subject* s);
2070 
2071 	bool isRelatedToActivityTag(ActivityTag* s);
2072 
2073 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
2074 
2075 	bool isRelatedToRoom(Room* r);
2076 
2077 	bool hasWrongDayOrHour(Rules& r);
2078 	bool canRepairWrongDayOrHour(Rules& r);
2079 	bool repairWrongDayOrHour(Rules& r);
2080 };
2081 
2082 class ConstraintActivitiesSameRoomIfConsecutive: public SpaceConstraint{
2083 	Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameRoomIfConsecutive)
2084 
2085 public:
2086 	QList<int> activitiesIds;
2087 
2088 	//internal variables
2089 	QList<int> _activitiesIndices;
2090 
2091 	ConstraintActivitiesSameRoomIfConsecutive();
2092 
2093 	ConstraintActivitiesSameRoomIfConsecutive(double wp, QList<int> a_L);
2094 
2095 	bool computeInternalStructure(QWidget* parent, Rules& r);
2096 
2097 	bool hasInactiveActivities(Rules& r);
2098 
2099 	QString getXmlDescription(Rules& r);
2100 
2101 	QString getDescription(Rules& r);
2102 
2103 	QString getDetailedDescription(Rules& r);
2104 
2105 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
2106 
2107 	void removeUseless(Rules& r);
2108 
2109 	bool isRelatedToActivity(Activity* a);
2110 
2111 	bool isRelatedToTeacher(Teacher* t);
2112 
2113 	bool isRelatedToSubject(Subject* s);
2114 
2115 	bool isRelatedToActivityTag(ActivityTag* s);
2116 
2117 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
2118 
2119 	bool isRelatedToRoom(Room* r);
2120 
2121 	bool hasWrongDayOrHour(Rules& r);
2122 	bool canRepairWrongDayOrHour(Rules& r);
2123 	bool repairWrongDayOrHour(Rules& r);
2124 };
2125 
2126 class ConstraintStudentsMaxRoomChangesPerRealDay: public SpaceConstraint{
2127 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxRoomChangesPerRealDay)
2128 
2129 public:
2130 
2131 	int maxRoomChangesPerDay;
2132 
2133 	ConstraintStudentsMaxRoomChangesPerRealDay();
2134 
2135 	ConstraintStudentsMaxRoomChangesPerRealDay(double wp, int mc);
2136 
2137 	bool computeInternalStructure(QWidget* parent, Rules& r);
2138 
2139 	QString getXmlDescription(Rules& r);
2140 
2141 	bool hasInactiveActivities(Rules& r);
2142 
2143 	QString getDescription(Rules& r);
2144 
2145 	QString getDetailedDescription(Rules& r);
2146 
2147 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
2148 
2149 	bool isRelatedToActivity(Activity* a);
2150 
2151 	bool isRelatedToTeacher(Teacher* t);
2152 
2153 	bool isRelatedToSubject(Subject* s);
2154 
2155 	bool isRelatedToActivityTag(ActivityTag* s);
2156 
2157 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
2158 
2159 	bool isRelatedToRoom(Room* r);
2160 
2161 	bool hasWrongDayOrHour(Rules& r);
2162 	bool canRepairWrongDayOrHour(Rules& r);
2163 	bool repairWrongDayOrHour(Rules& r);
2164 };
2165 
2166 class ConstraintStudentsSetMaxRoomChangesPerRealDay: public SpaceConstraint{
2167 	Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxRoomChangesPerRealDay)
2168 
2169 public:
2170 	//internal variables
2171 	QList<int> iSubgroupsList;
2172 
2173 public:
2174 
2175 	int maxRoomChangesPerDay;
2176 
2177 	QString studentsName;
2178 
2179 	ConstraintStudentsSetMaxRoomChangesPerRealDay();
2180 
2181 	ConstraintStudentsSetMaxRoomChangesPerRealDay(double wp, QString st, int mc);
2182 
2183 	bool computeInternalStructure(QWidget* parent, Rules& r);
2184 
2185 	QString getXmlDescription(Rules& r);
2186 
2187 	bool hasInactiveActivities(Rules& r);
2188 
2189 	QString getDescription(Rules& r);
2190 
2191 	QString getDetailedDescription(Rules& r);
2192 
2193 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
2194 
2195 	bool isRelatedToActivity(Activity* a);
2196 
2197 	bool isRelatedToTeacher(Teacher* t);
2198 
2199 	bool isRelatedToSubject(Subject* s);
2200 
2201 	bool isRelatedToActivityTag(ActivityTag* s);
2202 
2203 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
2204 
2205 	bool isRelatedToRoom(Room* r);
2206 
2207 	bool hasWrongDayOrHour(Rules& r);
2208 	bool canRepairWrongDayOrHour(Rules& r);
2209 	bool repairWrongDayOrHour(Rules& r);
2210 };
2211 
2212 class ConstraintTeacherMaxRoomChangesPerRealDay: public SpaceConstraint{
2213 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxRoomChangesPerRealDay)
2214 
2215 public:
2216 	//internal variables
2217 	int teacher_ID;
2218 
2219 public:
2220 
2221 	int maxRoomChangesPerDay;
2222 
2223 	QString teacherName;
2224 
2225 	ConstraintTeacherMaxRoomChangesPerRealDay();
2226 
2227 	ConstraintTeacherMaxRoomChangesPerRealDay(double wp, QString tc, int mc);
2228 
2229 	bool computeInternalStructure(QWidget* parent, Rules& r);
2230 
2231 	QString getXmlDescription(Rules& r);
2232 
2233 	bool hasInactiveActivities(Rules& r);
2234 
2235 	QString getDescription(Rules& r);
2236 
2237 	QString getDetailedDescription(Rules& r);
2238 
2239 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
2240 
2241 	bool isRelatedToActivity(Activity* a);
2242 
2243 	bool isRelatedToTeacher(Teacher* t);
2244 
2245 	bool isRelatedToSubject(Subject* s);
2246 
2247 	bool isRelatedToActivityTag(ActivityTag* s);
2248 
2249 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
2250 
2251 	bool isRelatedToRoom(Room* r);
2252 
2253 	bool hasWrongDayOrHour(Rules& r);
2254 	bool canRepairWrongDayOrHour(Rules& r);
2255 	bool repairWrongDayOrHour(Rules& r);
2256 };
2257 
2258 class ConstraintTeachersMaxRoomChangesPerRealDay: public SpaceConstraint{
2259 	Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxRoomChangesPerRealDay)
2260 
2261 public:
2262 
2263 	int maxRoomChangesPerDay;
2264 
2265 	ConstraintTeachersMaxRoomChangesPerRealDay();
2266 
2267 	ConstraintTeachersMaxRoomChangesPerRealDay(double wp, int mc);
2268 
2269 	bool computeInternalStructure(QWidget* parent, Rules& r);
2270 
2271 	bool hasInactiveActivities(Rules& r);
2272 
2273 	QString getXmlDescription(Rules& r);
2274 
2275 	QString getDescription(Rules& r);
2276 
2277 	QString getDetailedDescription(Rules& r);
2278 
2279 	double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=nullptr);
2280 
2281 	bool isRelatedToActivity(Activity* a);
2282 
2283 	bool isRelatedToTeacher(Teacher* t);
2284 
2285 	bool isRelatedToSubject(Subject* s);
2286 
2287 	bool isRelatedToActivityTag(ActivityTag* s);
2288 
2289 	bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
2290 
2291 	bool isRelatedToRoom(Room* r);
2292 
2293 	bool hasWrongDayOrHour(Rules& r);
2294 	bool canRepairWrongDayOrHour(Rules& r);
2295 	bool repairWrongDayOrHour(Rules& r);
2296 };
2297 
2298 #endif
2299