/* File timeconstraint.h */ /*************************************************************************** timeconstraint.h - description ------------------- begin : 2002 copyright : (C) 2002 by Lalescu Liviu email : Please see https://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address) ***************************************************************************/ /*************************************************************************** * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Affero General Public License as * * published by the Free Software Foundation, either version 3 of the * * License, or (at your option) any later version. * * * ***************************************************************************/ #ifndef TIMECONSTRAINT_H #define TIMECONSTRAINT_H #include #include "timetable_defs.h" #include #include #include class Rules; class Solution; class TimeConstraint; class Activity; class Teacher; class Subject; class ActivityTag; class StudentsSet; class FakeString; class QWidget; typedef QList TimeConstraintsList; const int CONSTRAINT_GENERIC_TIME =0; const int CONSTRAINT_BASIC_COMPULSORY_TIME =1; const int CONSTRAINT_BREAK_TIMES =2; const int CONSTRAINT_TEACHER_NOT_AVAILABLE_TIMES =3; const int CONSTRAINT_TEACHERS_MAX_HOURS_DAILY =4; const int CONSTRAINT_TEACHER_MAX_DAYS_PER_WEEK =5; const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_WEEK =6; const int CONSTRAINT_TEACHER_MAX_GAPS_PER_WEEK =7; const int CONSTRAINT_TEACHER_MAX_HOURS_DAILY =8; const int CONSTRAINT_TEACHERS_MAX_HOURS_CONTINUOUSLY =9; const int CONSTRAINT_TEACHER_MAX_HOURS_CONTINUOUSLY =10; const int CONSTRAINT_TEACHERS_MIN_HOURS_DAILY =11; const int CONSTRAINT_TEACHER_MIN_HOURS_DAILY =12; const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_DAY =13; const int CONSTRAINT_TEACHER_MAX_GAPS_PER_DAY =14; const int CONSTRAINT_STUDENTS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =15; const int CONSTRAINT_STUDENTS_SET_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =16; const int CONSTRAINT_STUDENTS_SET_NOT_AVAILABLE_TIMES =17; const int CONSTRAINT_STUDENTS_MAX_GAPS_PER_WEEK =18; const int CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_WEEK =19; const int CONSTRAINT_STUDENTS_MAX_HOURS_DAILY =20; const int CONSTRAINT_STUDENTS_SET_MAX_HOURS_DAILY =21; const int CONSTRAINT_STUDENTS_MAX_HOURS_CONTINUOUSLY =22; const int CONSTRAINT_STUDENTS_SET_MAX_HOURS_CONTINUOUSLY =23; const int CONSTRAINT_STUDENTS_MIN_HOURS_DAILY =24; const int CONSTRAINT_STUDENTS_SET_MIN_HOURS_DAILY =25; const int CONSTRAINT_ACTIVITY_ENDS_STUDENTS_DAY =26; const int CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME =27; const int CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME =28; const int CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING =29; const int CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES =30; const int CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS =31; const int CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS =32; const int CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES =33; const int CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES =34; const int CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR =35; const int CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY =36; const int CONSTRAINT_TWO_ACTIVITIES_CONSECUTIVE =37; const int CONSTRAINT_TWO_ACTIVITIES_ORDERED =38; const int CONSTRAINT_MIN_GAPS_BETWEEN_ACTIVITIES =39; const int CONSTRAINT_SUBACTIVITIES_PREFERRED_TIME_SLOTS =40; const int CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES =41; const int CONSTRAINT_TEACHER_INTERVAL_MAX_DAYS_PER_WEEK =42; const int CONSTRAINT_TEACHERS_INTERVAL_MAX_DAYS_PER_WEEK =43; const int CONSTRAINT_STUDENTS_SET_INTERVAL_MAX_DAYS_PER_WEEK =44; const int CONSTRAINT_STUDENTS_INTERVAL_MAX_DAYS_PER_WEEK =45; const int CONSTRAINT_ACTIVITIES_END_STUDENTS_DAY =46; const int CONSTRAINT_TWO_ACTIVITIES_GROUPED =47; const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY =48; const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY =49; const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY =50; const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY =51; const int CONSTRAINT_TEACHERS_MAX_DAYS_PER_WEEK =52; const int CONSTRAINT_THREE_ACTIVITIES_GROUPED =53; const int CONSTRAINT_MAX_DAYS_BETWEEN_ACTIVITIES =54; const int CONSTRAINT_TEACHERS_MIN_DAYS_PER_WEEK =55; const int CONSTRAINT_TEACHER_MIN_DAYS_PER_WEEK =56; const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MAX_HOURS_DAILY =57; const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MAX_HOURS_DAILY =58; const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MAX_HOURS_DAILY =59; const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MAX_HOURS_DAILY =60; const int CONSTRAINT_STUDENTS_MAX_GAPS_PER_DAY =61; const int CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_DAY =62; const int CONSTRAINT_ACTIVITIES_OCCUPY_MAX_TIME_SLOTS_FROM_SELECTION =63; const int CONSTRAINT_ACTIVITIES_MAX_SIMULTANEOUS_IN_SELECTED_TIME_SLOTS =64; const int CONSTRAINT_STUDENTS_SET_MAX_DAYS_PER_WEEK =65; const int CONSTRAINT_STUDENTS_MAX_DAYS_PER_WEEK =66; //2017-02-06 const int CONSTRAINT_TEACHER_MAX_SPAN_PER_DAY =67; const int CONSTRAINT_TEACHERS_MAX_SPAN_PER_DAY =68; const int CONSTRAINT_TEACHER_MIN_RESTING_HOURS =69; const int CONSTRAINT_TEACHERS_MIN_RESTING_HOURS =70; const int CONSTRAINT_STUDENTS_SET_MAX_SPAN_PER_DAY =71; const int CONSTRAINT_STUDENTS_MAX_SPAN_PER_DAY =72; const int CONSTRAINT_STUDENTS_SET_MIN_RESTING_HOURS =73; const int CONSTRAINT_STUDENTS_MIN_RESTING_HOURS =74; //2018-06-13 const int CONSTRAINT_TWO_ACTIVITIES_ORDERED_IF_SAME_DAY =75; //2019-06-08 const int CONSTRAINT_STUDENTS_SET_MIN_GAPS_BETWEEN_ORDERED_PAIR_OF_ACTIVITY_TAGS =76; const int CONSTRAINT_STUDENTS_MIN_GAPS_BETWEEN_ORDERED_PAIR_OF_ACTIVITY_TAGS =77; const int CONSTRAINT_TEACHER_MIN_GAPS_BETWEEN_ORDERED_PAIR_OF_ACTIVITY_TAGS =78; const int CONSTRAINT_TEACHERS_MIN_GAPS_BETWEEN_ORDERED_PAIR_OF_ACTIVITY_TAGS =79; const int CONSTRAINT_ACTIVITY_TAGS_NOT_OVERLAPPING =80; const int CONSTRAINT_ACTIVITIES_OCCUPY_MIN_TIME_SLOTS_FROM_SELECTION =81; const int CONSTRAINT_ACTIVITIES_MIN_SIMULTANEOUS_IN_SELECTED_TIME_SLOTS =82; const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MIN_HOURS_DAILY =83; const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MIN_HOURS_DAILY =84; const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MIN_HOURS_DAILY =85; const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MIN_HOURS_DAILY =86; const int CONSTRAINT_ACTIVITY_ENDS_TEACHERS_DAY =87; const int CONSTRAINT_ACTIVITIES_END_TEACHERS_DAY =88; //Begin for mornings-afternoons const int CONSTRAINT_TEACHERS_MAX_HOURS_DAILY_REAL_DAYS =89; const int CONSTRAINT_TEACHER_MAX_REAL_DAYS_PER_WEEK =90; const int CONSTRAINT_TEACHER_MAX_HOURS_DAILY_REAL_DAYS =91; const int CONSTRAINT_STUDENTS_MAX_HOURS_DAILY_REAL_DAYS =92; const int CONSTRAINT_STUDENTS_SET_MAX_HOURS_DAILY_REAL_DAYS =93; const int CONSTRAINT_TEACHERS_MAX_REAL_DAYS_PER_WEEK =94; const int CONSTRAINT_TEACHERS_MIN_REAL_DAYS_PER_WEEK =95; const int CONSTRAINT_TEACHER_MIN_REAL_DAYS_PER_WEEK =96; const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MAX_HOURS_DAILY_REAL_DAYS =97; const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MAX_HOURS_DAILY_REAL_DAYS =98; const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MAX_HOURS_DAILY_REAL_DAYS =99; const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MAX_HOURS_DAILY_REAL_DAYS=100; const int CONSTRAINT_TEACHER_MAX_AFTERNOONS_PER_WEEK =101; const int CONSTRAINT_TEACHERS_MAX_AFTERNOONS_PER_WEEK =102; const int CONSTRAINT_TEACHER_MAX_MORNINGS_PER_WEEK =103; const int CONSTRAINT_TEACHERS_MAX_MORNINGS_PER_WEEK =104; const int CONSTRAINT_TEACHER_MAX_TWO_ACTIVITY_TAGS_PER_DAY_FROM_N1N2N3 =105; const int CONSTRAINT_TEACHERS_MAX_TWO_ACTIVITY_TAGS_PER_DAY_FROM_N1N2N3 =106; const int CONSTRAINT_TEACHERS_MIN_MORNINGS_PER_WEEK =107; const int CONSTRAINT_TEACHER_MIN_MORNINGS_PER_WEEK =108; const int CONSTRAINT_TEACHERS_MIN_AFTERNOONS_PER_WEEK =109; const int CONSTRAINT_TEACHER_MIN_AFTERNOONS_PER_WEEK =110; const int CONSTRAINT_TEACHER_MAX_TWO_CONSECUTIVE_MORNINGS =111; const int CONSTRAINT_TEACHERS_MAX_TWO_CONSECUTIVE_MORNINGS =112; const int CONSTRAINT_TEACHER_MAX_TWO_CONSECUTIVE_AFTERNOONS =113; const int CONSTRAINT_TEACHERS_MAX_TWO_CONSECUTIVE_AFTERNOONS =114; //Added in FET Algeria and Morocco on 2018-11-02 const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_REAL_DAY =115; const int CONSTRAINT_TEACHER_MAX_GAPS_PER_REAL_DAY =116; const int CONSTRAINT_STUDENTS_MAX_GAPS_PER_REAL_DAY =117; const int CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_REAL_DAY =118; //2019-07-03 const int CONSTRAINT_TEACHERS_MIN_HOURS_DAILY_REAL_DAYS =119; const int CONSTRAINT_TEACHER_MIN_HOURS_DAILY_REAL_DAYS =120; //2019-08-18 - for Said213 const int CONSTRAINT_TEACHERS_AFTERNOONS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =121; const int CONSTRAINT_TEACHER_AFTERNOONS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =122; const int CONSTRAINT_TEACHERS_MIN_HOURS_PER_MORNING =123; const int CONSTRAINT_TEACHER_MIN_HOURS_PER_MORNING =124; const int CONSTRAINT_TEACHER_MAX_SPAN_PER_REAL_DAY =125; const int CONSTRAINT_TEACHERS_MAX_SPAN_PER_REAL_DAY =126; const int CONSTRAINT_STUDENTS_SET_MAX_SPAN_PER_REAL_DAY =127; const int CONSTRAINT_STUDENTS_MAX_SPAN_PER_REAL_DAY =128; const int CONSTRAINT_TEACHER_MORNING_INTERVAL_MAX_DAYS_PER_WEEK =129; const int CONSTRAINT_TEACHERS_MORNING_INTERVAL_MAX_DAYS_PER_WEEK =130; const int CONSTRAINT_TEACHER_AFTERNOON_INTERVAL_MAX_DAYS_PER_WEEK =131; const int CONSTRAINT_TEACHERS_AFTERNOON_INTERVAL_MAX_DAYS_PER_WEEK =132; const int CONSTRAINT_STUDENTS_MIN_HOURS_PER_MORNING =133; const int CONSTRAINT_STUDENTS_SET_MIN_HOURS_PER_MORNING =134; const int CONSTRAINT_TEACHER_MAX_ZERO_GAPS_PER_AFTERNOON =135; const int CONSTRAINT_TEACHERS_MAX_ZERO_GAPS_PER_AFTERNOON =136; const int CONSTRAINT_STUDENTS_SET_MAX_AFTERNOONS_PER_WEEK =137; const int CONSTRAINT_STUDENTS_MAX_AFTERNOONS_PER_WEEK =138; const int CONSTRAINT_STUDENTS_SET_MAX_MORNINGS_PER_WEEK =139; const int CONSTRAINT_STUDENTS_MAX_MORNINGS_PER_WEEK =140; const int CONSTRAINT_STUDENTS_MIN_MORNINGS_PER_WEEK =141; const int CONSTRAINT_STUDENTS_SET_MIN_MORNINGS_PER_WEEK =142; const int CONSTRAINT_STUDENTS_MIN_AFTERNOONS_PER_WEEK =143; const int CONSTRAINT_STUDENTS_SET_MIN_AFTERNOONS_PER_WEEK =144; const int CONSTRAINT_STUDENTS_SET_MORNING_INTERVAL_MAX_DAYS_PER_WEEK =145; const int CONSTRAINT_STUDENTS_MORNING_INTERVAL_MAX_DAYS_PER_WEEK =146; const int CONSTRAINT_STUDENTS_SET_AFTERNOON_INTERVAL_MAX_DAYS_PER_WEEK =147; const int CONSTRAINT_STUDENTS_AFTERNOON_INTERVAL_MAX_DAYS_PER_WEEK =148; const int CONSTRAINT_TEACHER_MAX_HOURS_PER_ALL_AFTERNOONS =149; const int CONSTRAINT_TEACHERS_MAX_HOURS_PER_ALL_AFTERNOONS =150; const int CONSTRAINT_STUDENTS_SET_MAX_HOURS_PER_ALL_AFTERNOONS =151; const int CONSTRAINT_STUDENTS_MAX_HOURS_PER_ALL_AFTERNOONS =152; const int CONSTRAINT_TEACHER_MIN_RESTING_HOURS_BETWEEN_MORNING_AND_AFTERNOON =153; const int CONSTRAINT_TEACHERS_MIN_RESTING_HOURS_BETWEEN_MORNING_AND_AFTERNOON =154; const int CONSTRAINT_STUDENTS_SET_MIN_RESTING_HOURS_BETWEEN_MORNING_AND_AFTERNOON =155; const int CONSTRAINT_STUDENTS_MIN_RESTING_HOURS_BETWEEN_MORNING_AND_AFTERNOON =156; //2020-07-24 - for lakhdarbe const int CONSTRAINT_STUDENTS_SET_AFTERNOONS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =157; const int CONSTRAINT_STUDENTS_AFTERNOONS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =158; //Added in FET Algeria and Morocco on 2020-07-29 const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_WEEK_FOR_REAL_DAYS =159; const int CONSTRAINT_TEACHER_MAX_GAPS_PER_WEEK_FOR_REAL_DAYS =160; const int CONSTRAINT_STUDENTS_MAX_GAPS_PER_WEEK_FOR_REAL_DAYS =161; const int CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_WEEK_FOR_REAL_DAYS =162; const int CONSTRAINT_STUDENTS_SET_MAX_REAL_DAYS_PER_WEEK =163; const int CONSTRAINT_STUDENTS_MAX_REAL_DAYS_PER_WEEK =164; //End for mornings-afternoons //For block-planning mode const int CONSTRAINT_MAX_TOTAL_ACTIVITIES_FROM_SET_IN_SELECTED_TIME_SLOTS =165; const int CONSTRAINT_MAX_GAPS_BETWEEN_ACTIVITIES =166; //For terms mode const int CONSTRAINT_ACTIVITIES_MAX_IN_A_TERM =167; const int CONSTRAINT_ACTIVITIES_OCCUPY_MAX_TERMS =168; //Begin for mornings-afternoons - 2021-08-12 const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_MORNING_AND_AFTERNOON =169; const int CONSTRAINT_TEACHER_MAX_GAPS_PER_MORNING_AND_AFTERNOON =170; const int CONSTRAINT_TEACHERS_MORNINGS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =171; const int CONSTRAINT_TEACHER_MORNINGS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =172; const int CONSTRAINT_STUDENTS_SET_MORNINGS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =173; const int CONSTRAINT_STUDENTS_MORNINGS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =174; //End for mornings-afternoons const int CONSTRAINT_TWO_SETS_OF_ACTIVITIES_ORDERED =175; //Begin for mornings-afternoons - 2021-09-26 const int CONSTRAINT_TEACHERS_MAX_THREE_CONSECUTIVE_DAYS =176; const int CONSTRAINT_TEACHER_MAX_THREE_CONSECUTIVE_DAYS =177; //End for mornings-afternoons - 2021-09-26 QString getActivityDetailedDescription(Rules& r, int id); /** This class represents a time constraint */ class TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(TimeConstraint) public: /** The percentage weight of this constraint, 100% compulsory, 0% non-compulsory */ double weightPercentage; bool active; QString comments; /** Specifies the type of this constraint (using the above constants). */ int type; /** True for mandatory constraints, false for non-mandatory constraints. */ //bool compulsory; /** Dummy constructor - needed for the static array of constraints. Any other use should be avoided. */ TimeConstraint(); virtual ~TimeConstraint()=0; /** DEPRECATED COMMENT BELOW: Constructor - please note that the maximum allowed weight is 100.0 The reason: unallocated activities must have very big conflict weight, and any other constraints must have much more lower weight, so that the timetable can evolve when starting with uninitialized activities. */ TimeConstraint(double wp); bool canBeUsedInOfficialMode(); bool canBeUsedInMorningsAfternoonsMode(); bool canBeUsedInBlockPlanningMode(); bool canBeUsedInTermsMode(); /** The function that calculates the fitness of a solution, according to this constraint. We need the solution to compute this fitness factor. If conflictsString!=nullptr, it will be initialized with a text explaining where this constraint is broken. */ virtual double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr)=0; /** Returns an XML description of this constraint */ virtual QString getXmlDescription(Rules& r)=0; /** Computes the internal structure for this constraint. It returns false if the constraint is an activity related one and it depends on only inactive activities. */ virtual bool computeInternalStructure(QWidget* parent, Rules& r)=0; virtual bool hasInactiveActivities(Rules& r)=0; /** Returns a small description string for this constraint */ virtual QString getDescription(Rules& r)=0; /** Returns a detailed description string for this constraint */ virtual QString getDetailedDescription(Rules& r)=0; /** Returns true if this constraint is related to this activity */ virtual bool isRelatedToActivity(Rules& r, Activity* a)=0; /** Returns true if this constraint is related to this teacher */ virtual bool isRelatedToTeacher(Teacher* t)=0; /** Returns true if this constraint is related to this subject */ virtual bool isRelatedToSubject(Subject* s)=0; /** Returns true if this constraint is related to this activity tag */ virtual bool isRelatedToActivityTag(ActivityTag* s)=0; /** Returns true if this constraint is related to this students set */ virtual bool isRelatedToStudentsSet(Rules& r, StudentsSet* s)=0; virtual bool hasWrongDayOrHour(Rules& r)=0; virtual bool canRepairWrongDayOrHour(Rules& r)=0; virtual bool repairWrongDayOrHour(Rules& r)=0; }; /** This class comprises all the basic compulsory constraints (constraints which must be fulfilled for any timetable) - the time allocation part */ class ConstraintBasicCompulsoryTime: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintBasicCompulsoryTime) public: ConstraintBasicCompulsoryTime(); ConstraintBasicCompulsoryTime(double wp); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherNotAvailableTimes: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherNotAvailableTimes) public: QList days; QList hours; /** The teacher's name */ QString teacher; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherNotAvailableTimes(); ConstraintTeacherNotAvailableTimes(double wp, const QString& tn, QList d, QList h); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetNotAvailableTimes: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetNotAvailableTimes) public: QList days; QList hours; /** The name of the students */ QString students; /** The subgroups involved in this constraint */ QList iSubgroupsList; ConstraintStudentsSetNotAvailableTimes(); ConstraintStudentsSetNotAvailableTimes(double wp, const QString& sn, QList d, QList h); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivitiesSameStartingTime: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameStartingTime) public: /** The number of activities involved in this constraint */ int n_activities; /** The activities involved in this constraint (id) */ QList activitiesId; //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME]; /** The number of activities involved in this constraint - internal structure */ int _n_activities; /** The activities involved in this constraint (indexes in the rules) - internal structure */ //int _activities[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME]; QList _activities; ConstraintActivitiesSameStartingTime(); /** Constructor, using: the weight, the number of activities and the list of activities' id-s. */ //ConstraintActivitiesSameStartingTime(double wp, int n_act, const int act[]); ConstraintActivitiesSameStartingTime(double wp, int n_act, const QList& act); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules& r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint. It aims at scheduling a set of activities so that they do not overlap. The number of conflicts is considered the number of overlapping hours. */ class ConstraintActivitiesNotOverlapping: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesNotOverlapping) public: /** The number of activities involved in this constraint */ int n_activities; /** The activities involved in this constraint (id) */ QList activitiesId; //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING]; /** The number of activities involved in this constraint - internal structure */ int _n_activities; /** The activities involved in this constraint (index in the rules) - internal structure */ //int _activities[MAX_CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING]; QList _activities; ConstraintActivitiesNotOverlapping(); /** Constructor, using: the weight, the number of activities and the list of activities. */ ConstraintActivitiesNotOverlapping(double wp, int n_act, const QList& act); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules &r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivityTagsNotOverlapping: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivityTagsNotOverlapping) public: QStringList activityTagsNames; //internal QList activityTagsIndices; QList> activitiesIndicesLists; ConstraintActivityTagsNotOverlapping(); ConstraintActivityTagsNotOverlapping(double wp, const QStringList& atl); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint. It aims at scheduling a set of activities so that they have a minimum of N days between any two of them. */ class ConstraintMinDaysBetweenActivities: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintMinDaysBetweenActivities) public: bool consecutiveIfSameDay; /** The number of activities involved in this constraint */ int n_activities; /** The activities involved in this constraint (id) */ QList activitiesId; //int activitiesId[MAX_CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES]; /** The number of minimum days between each 2 activities */ int minDays; //internal structure (redundant) /** The number of activities involved in this constraint - internal structure */ int _n_activities; /** The activities involved in this constraint (index in the rules) - internal structure */ QList _activities; //int _activities[MAX_CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES]; ConstraintMinDaysBetweenActivities(); /** Constructor, using: the weight, the number of activities and the list of activities. */ //ConstraintMinDaysBetweenActivities(double wp, bool adjacentIfBroken, int n_act, const int act[], int n); ConstraintMinDaysBetweenActivities(double wp, bool adjacentIfBroken, int n_act, const QList& act, int n); /** Comparison operator - to be sure that we do not introduce duplicates */ bool operator==(ConstraintMinDaysBetweenActivities& c); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules &r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintMaxDaysBetweenActivities: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintMaxDaysBetweenActivities) public: /** The number of activities involved in this constraint */ int n_activities; /** The activities involved in this constraint (id) */ QList activitiesId; /** The number of maximum days between each 2 activities */ int maxDays; //internal structure (redundant) /** The number of activities involved in this constraint - internal structure */ int _n_activities; /** The activities involved in this constraint (index in the rules) - internal structure */ QList _activities; ConstraintMaxDaysBetweenActivities(); /** Constructor, using: the weight, the number of activities and the list of activities. */ ConstraintMaxDaysBetweenActivities(double wp, int n_act, const QList& act, int n); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules &r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintMinGapsBetweenActivities: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintMinGapsBetweenActivities) public: /** The number of activities involved in this constraint */ int n_activities; /** The activities involved in this constraint (id) */ QList activitiesId; /** The number of minimum gaps between each 2 activities, if on the same day */ int minGaps; //internal structure (redundant) /** The number of activities involved in this constraint - internal structure */ int _n_activities; /** The activities involved in this constraint (index in the rules) - internal structure */ QList _activities; ConstraintMinGapsBetweenActivities(); /** Constructor, using: the weight, the number of activities and the list of activities. */ //ConstraintMinGapsBetweenActivities(double wp, int n_act, const int act[], int ngaps); ConstraintMinGapsBetweenActivities(double wp, int n_act, const QList& actList, int ngaps); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules &r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintMaxGapsBetweenActivities: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintMaxGapsBetweenActivities) public: /** The number of activities involved in this constraint */ int n_activities; /** The activities involved in this constraint (id) */ QList activitiesId; /** The number of maximum gaps between each 2 activities, if on the same day */ int maxGaps; //internal structure (redundant) /** The number of activities involved in this constraint - internal structure */ int _n_activities; /** The activities involved in this constraint (index in the rules) - internal structure */ QList _activities; ConstraintMaxGapsBetweenActivities(); /** Constructor, using: the weight, the number of activities and the list of activities. */ //ConstraintMaxGapsBetweenActivities(double wp, int n_act, const int act[], int ngaps); ConstraintMaxGapsBetweenActivities(double wp, int n_act, const QList& actList, int ngaps); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules &r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint, aimed at obtaining timetables which do not allow more than X hours in a day for any teacher */ class ConstraintTeachersMaxHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxHoursDaily) public: /** The maximum hours daily */ int maxHoursDaily; ConstraintTeachersMaxHoursDaily(); ConstraintTeachersMaxHoursDaily(double wp, int maxhours); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxHoursDaily) public: /** The maximum hours daily */ int maxHoursDaily; QString teacherName; int teacher_ID; ConstraintTeacherMaxHoursDaily(); ConstraintTeacherMaxHoursDaily(double wp, int maxhours, const QString& teacher); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint, aimed at obtaining timetables which do not allow more than X hours in a row for any teacher */ class ConstraintTeachersMaxHoursContinuously: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxHoursContinuously) public: /** The maximum hours continuously */ int maxHoursContinuously; ConstraintTeachersMaxHoursContinuously(); ConstraintTeachersMaxHoursContinuously(double wp, int maxhours); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxHoursContinuously: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxHoursContinuously) public: /** The maximum hours continuously */ int maxHoursContinuously; QString teacherName; int teacher_ID; ConstraintTeacherMaxHoursContinuously(); ConstraintTeacherMaxHoursContinuously(double wp, int maxhours, const QString& teacher); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersActivityTagMaxHoursContinuously: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMaxHoursContinuously) public: /** The maximum hours continuously */ int maxHoursContinuously; QString activityTagName; int activityTagIndex; QList canonicalTeachersList; ConstraintTeachersActivityTagMaxHoursContinuously(); ConstraintTeachersActivityTagMaxHoursContinuously(double wp, int maxhours, const QString& activityTag); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherActivityTagMaxHoursContinuously: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMaxHoursContinuously) public: /** The maximum hours continuously */ int maxHoursContinuously; QString teacherName; QString activityTagName; int teacher_ID; int activityTagIndex; QList canonicalTeachersList; ConstraintTeacherActivityTagMaxHoursContinuously(); ConstraintTeacherActivityTagMaxHoursContinuously(double wp, int maxhours, const QString& teacher, const QString& activityTag); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint. The resulting timetable must respect the requirement that this teacher must not have too much working days per week. */ class ConstraintTeacherMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxDaysPerWeek) public: /** The number of maximum allowed working days per week (-1 for don't care) */ int maxDaysPerWeek; /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherMaxDaysPerWeek(); ConstraintTeacherMaxDaysPerWeek(double wp, int maxnd, const QString& t); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxDaysPerWeek) public: /** The number of maximum allowed working days per week (-1 for don't care) */ int maxDaysPerWeek; ConstraintTeachersMaxDaysPerWeek(); ConstraintTeachersMaxDaysPerWeek(double wp, int maxnd); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMinDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinDaysPerWeek) public: int minDaysPerWeek; /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherMinDaysPerWeek(); ConstraintTeacherMinDaysPerWeek(double wp, int mindays, const QString& t); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMinDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinDaysPerWeek) public: int minDaysPerWeek; ConstraintTeachersMinDaysPerWeek(); ConstraintTeachersMinDaysPerWeek(double wp, int mindays); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint. It constrains the timetable to not schedule any activity in the specified day, during the start hour and end hour. */ class ConstraintBreakTimes: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintBreakTimes) public: QList days; QList hours; ConstraintBreakTimes(); ConstraintBreakTimes(double wp, QList d, QList h); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint. It adds, to the fitness of the solution, a conflicts factor computed from the gaps existing in the timetable (regarding the students). The overall result is a timetable having less gaps for the students. */ class ConstraintStudentsMaxGapsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxGapsPerWeek) public: int maxGaps; ConstraintStudentsMaxGapsPerWeek(); ConstraintStudentsMaxGapsPerWeek(double wp, int mg); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint. It adds, to the fitness of the solution, a conflicts factor computed from the gaps existing in the timetable (regarding the specified students set). */ class ConstraintStudentsSetMaxGapsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxGapsPerWeek) public: int maxGaps; /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetMaxGapsPerWeek(); ConstraintStudentsSetMaxGapsPerWeek(double wp, int mg, const QString& st); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxGapsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerWeek) public: int maxGaps; ConstraintTeachersMaxGapsPerWeek(); ConstraintTeachersMaxGapsPerWeek(double wp, int maxGaps); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxGapsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerWeek) public: int maxGaps; QString teacherName; int teacherIndex; ConstraintTeacherMaxGapsPerWeek(); ConstraintTeacherMaxGapsPerWeek(double wp, const QString& tn, int maxGaps); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxGapsPerDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerDay) public: int maxGaps; ConstraintTeachersMaxGapsPerDay(); ConstraintTeachersMaxGapsPerDay(double wp, int maxGaps); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxGapsPerDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerDay) public: int maxGaps; QString teacherName; int teacherIndex; ConstraintTeacherMaxGapsPerDay(); ConstraintTeacherMaxGapsPerDay(double wp, const QString& tn, int maxGaps); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxGapsPerMorningAndAfternoon: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerMorningAndAfternoon) public: int maxGaps; ConstraintTeachersMaxGapsPerMorningAndAfternoon(); ConstraintTeachersMaxGapsPerMorningAndAfternoon(double wp, int maxGaps); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxGapsPerMorningAndAfternoon: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerMorningAndAfternoon) public: int maxGaps; QString teacherName; int teacherIndex; ConstraintTeacherMaxGapsPerMorningAndAfternoon(); ConstraintTeacherMaxGapsPerMorningAndAfternoon(double wp, const QString& tn, int maxGaps); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint. It adds, to the fitness of the solution, a fitness factor that is related to how early the students begin their courses. The result is a timetable having more activities scheduled at the beginning of the day. IMPORTANT: fortnightly activities are treated as weekly ones, for speed and because in normal situations this does not matter. */ class ConstraintStudentsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsEarlyMaxBeginningsAtSecondHour) public: int maxBeginningsAtSecondHour; ConstraintStudentsEarlyMaxBeginningsAtSecondHour(); ConstraintStudentsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour) public: int maxBeginningsAtSecondHour; /** The name of the students */ QString students; /** The number of subgroups involved in this constraint */ //int nSubgroups; /** The subgroups involved in this constraint */ //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; QList iSubgroupsList; ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour(); ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour(double wp, int mBSH, const QString& students); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMaxHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxHoursDaily) public: int maxHoursDaily; ConstraintStudentsMaxHoursDaily(); ConstraintStudentsMaxHoursDaily(double wp, int maxnh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMaxHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxHoursDaily) public: int maxHoursDaily; /** The students set name */ QString students; //internal variables /** The number of subgroups */ //int nSubgroups; /** The subgroups */ //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; QList iSubgroupsList; ConstraintStudentsSetMaxHoursDaily(); ConstraintStudentsSetMaxHoursDaily(double wp, int maxnh, const QString& s); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMaxHoursContinuously: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxHoursContinuously) public: int maxHoursContinuously; ConstraintStudentsMaxHoursContinuously(); ConstraintStudentsMaxHoursContinuously(double wp, int maxnh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMaxHoursContinuously: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxHoursContinuously) public: int maxHoursContinuously; /** The students set name */ QString students; //internal variables /** The number of subgroups */ //int nSubgroups; /** The subgroups */ //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; QList iSubgroupsList; ConstraintStudentsSetMaxHoursContinuously(); ConstraintStudentsSetMaxHoursContinuously(double wp, int maxnh, const QString& s); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsActivityTagMaxHoursContinuously: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMaxHoursContinuously) public: int maxHoursContinuously; QString activityTagName; int activityTagIndex; QList canonicalSubgroupsList; ConstraintStudentsActivityTagMaxHoursContinuously(); ConstraintStudentsActivityTagMaxHoursContinuously(double wp, int maxnh, const QString& activityTag); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetActivityTagMaxHoursContinuously: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMaxHoursContinuously) public: int maxHoursContinuously; /** The students set name */ QString students; QString activityTagName; //internal variables int activityTagIndex; /** The number of subgroups */ //int nSubgroups; /** The subgroups */ //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; QList iSubgroupsList; QList canonicalSubgroupsList; ConstraintStudentsSetActivityTagMaxHoursContinuously(); ConstraintStudentsSetActivityTagMaxHoursContinuously(double wp, int maxnh, const QString& s, const QString& activityTag); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMinHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinHoursDaily) public: int minHoursDaily; bool allowEmptyDays; ConstraintStudentsMinHoursDaily(); ConstraintStudentsMinHoursDaily(double wp, int minnh, bool _allowEmptyDays); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMinHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinHoursDaily) public: int minHoursDaily; /** The students set name */ QString students; bool allowEmptyDays; //internal variables /** The number of subgroups */ //int nSubgroups; /** The subgroups */ //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; QList iSubgroupsList; ConstraintStudentsSetMinHoursDaily(); ConstraintStudentsSetMinHoursDaily(double wp, int minnh, const QString& s, bool _allowEmptyDays); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint. It adds, to the fitness of the solution, a fitness factor that grows as the activity is scheduled farther from the wanted time For the moment, fitness factor increases with one unit for every hour and one unit for every day. */ class ConstraintActivityPreferredStartingTime: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredStartingTime) public: /** Activity id */ int activityId; /** The preferred day. If -1, then the user does not care about the day. */ int day; /** The preferred hour. If -1, then the user does not care about the hour. */ int hour; bool permanentlyLocked; //if this is true, then this activity cannot be unlocked from the timetable view form //internal variables /** The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int activityIndex; ConstraintActivityPreferredStartingTime(); ConstraintActivityPreferredStartingTime(double wp, int actId, int d, int h, bool perm); /** Comparison operator - to be sure that we do not introduce duplicates */ bool operator==(const ConstraintActivityPreferredStartingTime& c); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint. It returns conflicts if the activity is scheduled in another interval than the preferred set of times. */ class ConstraintActivityPreferredTimeSlots: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredTimeSlots) public: /** Activity id */ int p_activityId; /** The number of preferred times */ int p_nPreferredTimeSlots_L; /** The preferred days. If -1, then the user does not care about the day. */ //int p_days[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS]; QList p_days_L; /** The preferred hour. If -1, then the user does not care about the hour. */ //int p_hours[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS]; QList p_hours_L; //internal variables /** The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int p_activityIndex; ConstraintActivityPreferredTimeSlots(); //ConstraintActivityPreferredTimeSlots(double wp, int actId, int nPT, int d[], int h[]); ConstraintActivityPreferredTimeSlots(double wp, int actId, int nPT_L, QList d_L, QList h_L); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivityPreferredStartingTimes: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredStartingTimes) public: /** Activity id */ int activityId; /** The number of preferred times */ int nPreferredStartingTimes_L; /** The preferred days. If -1, then the user does not care about the day. */ //int days[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES]; QList days_L; /** The preferred hour. If -1, then the user does not care about the hour. */ //int hours[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES]; QList hours_L; //internal variables /** The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int activityIndex; ConstraintActivityPreferredStartingTimes(); //ConstraintActivityPreferredStartingTimes(double wp, int actId, int nPT, int d[], int h[]); ConstraintActivityPreferredStartingTimes(double wp, int actId, int nPT_L, QList d_L, QList h_L); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint. It returns conflicts if a set of activities is scheduled in another interval than the preferred set of times. The set of activities is specified by a subject, teacher, students or a combination of these. */ class ConstraintActivitiesPreferredTimeSlots: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesPreferredTimeSlots) public: /** The teacher. If void, all teachers. */ QString p_teacherName; /** The students. If void, all students. */ QString p_studentsName; /** The subject. If void, all subjects. */ QString p_subjectName; /** The activity tag. If void, all activity tags. */ QString p_activityTagName; int duration; //if -1, neglected. Otherwise, >=1. /** The number of preferred times */ int p_nPreferredTimeSlots_L; /** The preferred days. If -1, then the user does not care about the day. */ //int p_days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS]; QList p_days_L; /** The preferred hours. If -1, then the user does not care about the hour. */ //int p_hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS]; QList p_hours_L; //internal variables /** The number of activities which are represented by the subject, teacher and students requirements. */ int p_nActivities; /** The indices of the activities in the rules (from 0 to rules.nActivities-1) These are indices in the internal list -> Rules::internalActivitiesList */ QList p_activitiesIndices; ConstraintActivitiesPreferredTimeSlots(); //ConstraintActivitiesPreferredTimeSlots(double wp, QString te, // QString st, QString su, QString sut, int nPT, int d[], int h[]); ConstraintActivitiesPreferredTimeSlots(double wp, const QString& te, const QString& st, const QString& su, const QString& sut, int dur, int nPT_L, QList d_L, QList h_L); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintSubactivitiesPreferredTimeSlots: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintSubactivitiesPreferredTimeSlots) public: int componentNumber; /** The teacher. If void, all teachers. */ QString p_teacherName; /** The students. If void, all students. */ QString p_studentsName; /** The subject. If void, all subjects. */ QString p_subjectName; /** The activity tag. If void, all activity tags. */ QString p_activityTagName; int duration; //if -1, neglected. Otherwise, >=1. /** The number of preferred times */ int p_nPreferredTimeSlots_L; /** The preferred days. If -1, then the user does not care about the day. */ //int p_days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS]; QList p_days_L; /** The preferred hours. If -1, then the user does not care about the hour. */ //int p_hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS]; QList p_hours_L; //internal variables /** The number of activities which are represented by the subject, teacher and students requirements. */ int p_nActivities; /** The indices of the activities in the rules (from 0 to rules.nActivities-1) These are indices in the internal list -> Rules::internalActivitiesList */ QList p_activitiesIndices; ConstraintSubactivitiesPreferredTimeSlots(); //ConstraintSubactivitiesPreferredTimeSlots(double wp, int compNo, QString te, // QString st, QString su, QString sut, int nPT, int d[], int h[]); ConstraintSubactivitiesPreferredTimeSlots(double wp, int compNo, const QString& te, const QString& st, const QString& su, const QString& sut, int dur, int nPT_L, QList d_L, QList h_L); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivitiesPreferredStartingTimes: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesPreferredStartingTimes) public: /** The teacher. If void, all teachers. */ QString teacherName; /** The students. If void, all students. */ QString studentsName; /** The subject. If void, all subjects. */ QString subjectName; /** The activity tag. If void, all activity tags. */ QString activityTagName; int duration; //if -1, neglected. Otherwise, >=1. /** The number of preferred times */ int nPreferredStartingTimes_L; /** The preferred days. If -1, then the user does not care about the day. */ //int days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES]; QList days_L; /** The preferred hours. If -1, then the user does not care about the hour. */ //int hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES]; QList hours_L; //internal variables /** The number of activities which are represented by the subject, teacher and students requirements. */ int nActivities; /** The indices of the activities in the rules (from 0 to rules.nActivities-1) These are indices in the internal list -> Rules::internalActivitiesList */ QList activitiesIndices; ConstraintActivitiesPreferredStartingTimes(); //ConstraintActivitiesPreferredStartingTimes(double wp, QString te, // QString st, QString su, QString sut, int nPT, int d[], int h[]); ConstraintActivitiesPreferredStartingTimes(double wp, const QString& te, const QString& st, const QString& su, const QString& sut, int dur, int nPT_L, QList d_L, QList h_L); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintSubactivitiesPreferredStartingTimes: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintSubactivitiesPreferredStartingTimes) public: int componentNumber; /** The teacher. If void, all teachers. */ QString teacherName; /** The students. If void, all students. */ QString studentsName; /** The subject. If void, all subjects. */ QString subjectName; /** The activity tag. If void, all activity tags. */ QString activityTagName; int duration; //if -1, neglected. Otherwise, >=1. /** The number of preferred times */ int nPreferredStartingTimes_L; /** The preferred days. If -1, then the user does not care about the day. */ //int days[MAX_N_CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES]; QList days_L; /** The preferred hours. If -1, then the user does not care about the hour. */ //int hours[MAX_N_CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES]; QList hours_L; //internal variables /** The number of activities which are represented by the subject, teacher and students requirements. */ int nActivities; /** The indices of the activities in the rules (from 0 to rules.nActivities-1) These are indices in the internal list -> Rules::internalActivitiesList */ QList activitiesIndices; ConstraintSubactivitiesPreferredStartingTimes(); ConstraintSubactivitiesPreferredStartingTimes(double wp, int compNo, const QString& te, const QString& st, const QString& su, const QString& sut, int dur, int nPT_L, QList d_L, QList h_L); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivitiesSameStartingHour: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameStartingHour) public: /** The number of activities involved in this constraint */ int n_activities; /** The activities involved in this constraint (id) */ QList activitiesId; //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR]; /** The number of activities involved in this constraint - internal structure */ int _n_activities; /** The activities involved in this constraint (index in the rules) - internal structure */ QList _activities; //int _activities[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR]; ConstraintActivitiesSameStartingHour(); /** Constructor, using: the weight, the number of activities and the list of activities' id-s. */ //ConstraintActivitiesSameStartingHour(double wp, int n_act, const int act[]); ConstraintActivitiesSameStartingHour(double wp, int n_act, const QList& act); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules& r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivitiesSameStartingDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameStartingDay) public: /** The number of activities involved in this constraint */ int n_activities; /** The activities involved in this constraint (id) */ QList activitiesId; //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY]; /** The number of activities involved in this constraint - internal structure */ int _n_activities; /** The activities involved in this constraint (index in the rules) - internal structure */ //int _activities[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY]; QList _activities; ConstraintActivitiesSameStartingDay(); /** Constructor, using: the weight, the number of activities and the list of activities' id-s. */ //ConstraintActivitiesSameStartingDay(double wp, int n_act, const int act[]); ConstraintActivitiesSameStartingDay(double wp, int n_act, const QList& act); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules& r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTwoActivitiesConsecutive: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesConsecutive) public: /** First activity id */ int firstActivityId; /** Second activity id */ int secondActivityId; //internal variables /** The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int firstActivityIndex; /** The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int secondActivityIndex; ConstraintTwoActivitiesConsecutive(); ConstraintTwoActivitiesConsecutive(double wp, int firstActId, int secondActId); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTwoActivitiesGrouped: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesGrouped) public: /** First activity id */ int firstActivityId; /** Second activity id */ int secondActivityId; //internal variables /** The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int firstActivityIndex; /** The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int secondActivityIndex; ConstraintTwoActivitiesGrouped(); ConstraintTwoActivitiesGrouped(double wp, int firstActId, int secondActId); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintThreeActivitiesGrouped: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintThreeActivitiesGrouped) public: /** First activity id */ int firstActivityId; /** Second activity id */ int secondActivityId; int thirdActivityId; //internal variables /** The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int firstActivityIndex; /** The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int secondActivityIndex; int thirdActivityIndex; ConstraintThreeActivitiesGrouped(); ConstraintThreeActivitiesGrouped(double wp, int firstActId, int secondActId, int thirdActId); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTwoActivitiesOrdered: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesOrdered) public: /** First activity id */ int firstActivityId; /** Second activity id */ int secondActivityId; //internal variables /** The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int firstActivityIndex; /** The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int secondActivityIndex; ConstraintTwoActivitiesOrdered(); ConstraintTwoActivitiesOrdered(double wp, int firstActId, int secondActId); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTwoSetsOfActivitiesOrdered: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTwoSetsOfActivitiesOrdered) public: QList firstActivitiesIdsList; QList secondActivitiesIdsList; //internal variables QList firstActivitiesIndicesList; QList secondActivitiesIndicesList; ConstraintTwoSetsOfActivitiesOrdered(); ConstraintTwoSetsOfActivitiesOrdered(double wp, const QList& firstActsIds, const QList& secondActsIds); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules &r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTwoActivitiesOrderedIfSameDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesOrderedIfSameDay) public: /** First activity id */ int firstActivityId; /** Second activity id */ int secondActivityId; //internal variables /** The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int firstActivityIndex; /** The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int secondActivityIndex; ConstraintTwoActivitiesOrderedIfSameDay(); ConstraintTwoActivitiesOrderedIfSameDay(double wp, int firstActId, int secondActId); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivityEndsStudentsDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivityEndsStudentsDay) public: /** Activity id */ int activityId; //internal variables /** The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int activityIndex; ConstraintActivityEndsStudentsDay(); ConstraintActivityEndsStudentsDay(double wp, int actId); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMinHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinHoursDaily) public: /** The minimum hours daily */ int minHoursDaily; bool allowEmptyDays; ConstraintTeachersMinHoursDaily(); ConstraintTeachersMinHoursDaily(double wp, int minhours, bool _allowEmptyDays); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMinHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinHoursDaily) public: /** The minimum hours daily */ int minHoursDaily; QString teacherName; int teacher_ID; bool allowEmptyDays; ConstraintTeacherMinHoursDaily(); ConstraintTeacherMinHoursDaily(double wp, int minhours, const QString& teacher, bool _allowEmptyDays); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherIntervalMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherIntervalMaxDaysPerWeek) public: /** The number of maximum allowed working days per week */ int maxDaysPerWeek; int startHour; int endHour; //might be = to gt.rules.nHoursPerDay /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherIntervalMaxDaysPerWeek(); ConstraintTeacherIntervalMaxDaysPerWeek(double wp, int maxnd, const QString& tn, int sh, int eh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersIntervalMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersIntervalMaxDaysPerWeek) public: /** The number of maximum allowed working days per week */ int maxDaysPerWeek; int startHour; int endHour; //might be = to gt.rules.nHoursPerDay ConstraintTeachersIntervalMaxDaysPerWeek(); ConstraintTeachersIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetIntervalMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetIntervalMaxDaysPerWeek) public: /** The number of maximum allowed working days per week */ int maxDaysPerWeek; int startHour; int endHour; //might be = to gt.rules.nHoursPerDay /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetIntervalMaxDaysPerWeek(); ConstraintStudentsSetIntervalMaxDaysPerWeek(double wp, int maxnd, const QString& sn, int sh, int eh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsIntervalMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsIntervalMaxDaysPerWeek) public: /** The number of maximum allowed working days per week */ int maxDaysPerWeek; int startHour; int endHour; //might be = to gt.rules.nHoursPerDay ConstraintStudentsIntervalMaxDaysPerWeek(); ConstraintStudentsIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivitiesEndStudentsDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesEndStudentsDay) public: /** The teacher. If void, all teachers. */ QString teacherName; /** The students. If void, all students. */ QString studentsName; /** The subject. If void, all subjects. */ QString subjectName; /** The activity tag. If void, all activity tags. */ QString activityTagName; //internal data /** The number of activities which are represented by the subject, teacher and students requirements. */ int nActivities; /** The indices of the activities in the rules (from 0 to rules.nActivities-1) These are indices in the internal list -> Rules::internalActivitiesList */ QList activitiesIndices; ConstraintActivitiesEndStudentsDay(); ConstraintActivitiesEndStudentsDay(double wp, const QString& te, const QString& st, const QString& su, const QString& sut); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivityEndsTeachersDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivityEndsTeachersDay) public: /** Activity id */ int activityId; //internal variables /** The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity */ int activityIndex; ConstraintActivityEndsTeachersDay(); ConstraintActivityEndsTeachersDay(double wp, int actId); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivitiesEndTeachersDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesEndTeachersDay) public: /** The teacher. If void, all teachers. */ QString teacherName; /** The students. If void, all students. */ QString studentsName; /** The subject. If void, all subjects. */ QString subjectName; /** The activity tag. If void, all activity tags. */ QString activityTagName; //internal data /** The number of activities which are represented by the subject, teacher and students requirements. */ int nActivities; /** The indices of the activities in the rules (from 0 to rules.nActivities-1) These are indices in the internal list -> Rules::internalActivitiesList */ //int activitiesIndices[MAX_ACTIVITIES]; QList activitiesIndices; ConstraintActivitiesEndTeachersDay(); ConstraintActivitiesEndTeachersDay(double wp, const QString& te, const QString& st, const QString& su, const QString& sut); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersActivityTagMaxHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMaxHoursDaily) public: /** The maximum hours daily */ int maxHoursDaily; QString activityTagName; int activityTagIndex; QList canonicalTeachersList; ConstraintTeachersActivityTagMaxHoursDaily(); ConstraintTeachersActivityTagMaxHoursDaily(double wp, int maxhours, const QString& activityTag); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherActivityTagMaxHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMaxHoursDaily) public: /** The maximum hours daily */ int maxHoursDaily; QString teacherName; QString activityTagName; int teacher_ID; int activityTagIndex; QList canonicalTeachersList; ConstraintTeacherActivityTagMaxHoursDaily(); ConstraintTeacherActivityTagMaxHoursDaily(double wp, int maxhours, const QString& teacher, const QString& activityTag); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsActivityTagMaxHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMaxHoursDaily) public: int maxHoursDaily; QString activityTagName; int activityTagIndex; QList canonicalSubgroupsList; ConstraintStudentsActivityTagMaxHoursDaily(); ConstraintStudentsActivityTagMaxHoursDaily(double wp, int maxnh, const QString& activityTag); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetActivityTagMaxHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMaxHoursDaily) public: int maxHoursDaily; /** The students set name */ QString students; QString activityTagName; //internal variables int activityTagIndex; /** The number of subgroups */ //int nSubgroups; /** The subgroups */ //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; QList iSubgroupsList; QList canonicalSubgroupsList; ConstraintStudentsSetActivityTagMaxHoursDaily(); ConstraintStudentsSetActivityTagMaxHoursDaily(double wp, int maxnh, const QString& s, const QString& activityTag); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersActivityTagMinHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMinHoursDaily) public: /** The minimum hours daily */ int minHoursDaily; bool allowEmptyDays; QString activityTagName; int activityTagIndex; QList canonicalTeachersList; ConstraintTeachersActivityTagMinHoursDaily(); ConstraintTeachersActivityTagMinHoursDaily(double wp, int minhours, bool allowemptydays, const QString& activityTag); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherActivityTagMinHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMinHoursDaily) public: /** The minimum hours daily */ int minHoursDaily; bool allowEmptyDays; QString teacherName; QString activityTagName; int teacher_ID; int activityTagIndex; QList canonicalTeachersList; ConstraintTeacherActivityTagMinHoursDaily(); ConstraintTeacherActivityTagMinHoursDaily(double wp, int minhours, bool allowemptydays, const QString& teacher, const QString& activityTag); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsActivityTagMinHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMinHoursDaily) public: int minHoursDaily; bool allowEmptyDays; QString activityTagName; int activityTagIndex; QList canonicalSubgroupsList; ConstraintStudentsActivityTagMinHoursDaily(); ConstraintStudentsActivityTagMinHoursDaily(double wp, int maxnh, bool allowEmptyDays, const QString& activityTag); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetActivityTagMinHoursDaily: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMinHoursDaily) public: int minHoursDaily; bool allowEmptyDays; /** The students set name */ QString students; QString activityTagName; //internal variables int activityTagIndex; /** The number of subgroups */ //int nSubgroups; /** The subgroups */ //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; QList iSubgroupsList; QList canonicalSubgroupsList; ConstraintStudentsSetActivityTagMinHoursDaily(); ConstraintStudentsSetActivityTagMinHoursDaily(double wp, int minnh, bool allowEmptyDays, const QString& s, const QString& activityTag); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMaxGapsPerDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxGapsPerDay) public: int maxGaps; ConstraintStudentsMaxGapsPerDay(); ConstraintStudentsMaxGapsPerDay(double wp, int mg); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMaxGapsPerDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxGapsPerDay) public: int maxGaps; /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetMaxGapsPerDay(); ConstraintStudentsSetMaxGapsPerDay(double wp, int mg, const QString& st); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivitiesOccupyMaxTimeSlotsFromSelection: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesOccupyMaxTimeSlotsFromSelection) public: QList activitiesIds; QList selectedDays; QList selectedHours; int maxOccupiedTimeSlots; //internal variables QList _activitiesIndices; ConstraintActivitiesOccupyMaxTimeSlotsFromSelection(); ConstraintActivitiesOccupyMaxTimeSlotsFromSelection(double wp, QList a_L, QList d_L, QList h_L, int max_slots); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules& r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivitiesOccupyMinTimeSlotsFromSelection: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesOccupyMinTimeSlotsFromSelection) public: QList activitiesIds; QList selectedDays; QList selectedHours; int minOccupiedTimeSlots; //internal variables QList _activitiesIndices; ConstraintActivitiesOccupyMinTimeSlotsFromSelection(); ConstraintActivitiesOccupyMinTimeSlotsFromSelection(double wp, QList a_L, QList d_L, QList h_L, int min_slots); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules& r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots) public: QList activitiesIds; QList selectedDays; QList selectedHours; int maxSimultaneous; //internal variables QList _activitiesIndices; ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots(); ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots(double wp, QList a_L, QList d_L, QList h_L, int max_simultaneous); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules& r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivitiesMinSimultaneousInSelectedTimeSlots: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesMinSimultaneousInSelectedTimeSlots) public: QList activitiesIds; QList selectedDays; QList selectedHours; int minSimultaneous; bool allowEmptySlots; //internal variables QList _activitiesIndices; ConstraintActivitiesMinSimultaneousInSelectedTimeSlots(); ConstraintActivitiesMinSimultaneousInSelectedTimeSlots(double wp, QList a_L, QList d_L, QList h_L, int min_simultaneous, bool allow_empty_slots); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules& r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintMaxTotalActivitiesFromSetInSelectedTimeSlots: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintMaxTotalActivitiesFromSetInSelectedTimeSlots) public: QList activitiesIds; QList selectedDays; QList selectedHours; int maxActivities; //internal variables QList _activitiesIndices; ConstraintMaxTotalActivitiesFromSetInSelectedTimeSlots(); ConstraintMaxTotalActivitiesFromSetInSelectedTimeSlots(double wp, QList a_L, QList d_L, QList h_L, int max_activities); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules& r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivitiesMaxInATerm: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesMaxInATerm) public: QList activitiesIds; int maxActivitiesInATerm; //internal variables QList _activitiesIndices; ConstraintActivitiesMaxInATerm(); ConstraintActivitiesMaxInATerm(double wp, QList a_L, int max_acts); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules& r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintActivitiesOccupyMaxTerms: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesOccupyMaxTerms) public: QList activitiesIds; int maxOccupiedTerms; //internal variables QList _activitiesIndices; ConstraintActivitiesOccupyMaxTerms(); ConstraintActivitiesOccupyMaxTerms(double wp, QList a_L, int max_occupied); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); void removeUseless(Rules& r); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxDaysPerWeek) public: /** The number of maximum allowed working days per week */ int maxDaysPerWeek; /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetMaxDaysPerWeek(); ConstraintStudentsSetMaxDaysPerWeek(double wp, int maxnd, const QString& sn); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxDaysPerWeek) public: /** The number of maximum allowed working days per week */ int maxDaysPerWeek; ConstraintStudentsMaxDaysPerWeek(); ConstraintStudentsMaxDaysPerWeek(double wp, int maxnd); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxSpanPerDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxSpanPerDay) public: /** The maximum span daily */ int maxSpanPerDay; bool allowOneDayExceptionPlusOne; QString teacherName; int teacher_ID; ConstraintTeacherMaxSpanPerDay(); ConstraintTeacherMaxSpanPerDay(double wp, int maxspan, bool except, const QString& teacher); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxSpanPerDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxSpanPerDay) public: /** The maximum span daily */ int maxSpanPerDay; bool allowOneDayExceptionPlusOne; ConstraintTeachersMaxSpanPerDay(); ConstraintTeachersMaxSpanPerDay(double wp, int maxspan, bool except); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMinRestingHours: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinRestingHours) public: int minRestingHours; bool circular; QString teacherName; int teacher_ID; ConstraintTeacherMinRestingHours(); ConstraintTeacherMinRestingHours(double wp, int minrestinghours, bool circ, const QString& teacher); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMinRestingHours: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinRestingHours) public: int minRestingHours; bool circular; ConstraintTeachersMinRestingHours(); ConstraintTeachersMinRestingHours(double wp, int minrestinghours, bool circ); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMaxSpanPerDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxSpanPerDay) public: int maxSpanPerDay; /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetMaxSpanPerDay(); ConstraintStudentsSetMaxSpanPerDay(double wp, int maxspan, const QString& sn); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMaxSpanPerDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxSpanPerDay) public: int maxSpanPerDay; ConstraintStudentsMaxSpanPerDay(); ConstraintStudentsMaxSpanPerDay(double wp, int maxspan); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMinRestingHours: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinRestingHours) public: int minRestingHours; bool circular; /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetMinRestingHours(); ConstraintStudentsSetMinRestingHours(double wp, int minrestinghours, bool circ, const QString& sn); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMinRestingHours: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinRestingHours) public: int minRestingHours; bool circular; ConstraintStudentsMinRestingHours(); ConstraintStudentsMinRestingHours(double wp, int minrestinghours, bool circ); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags) public: int minGaps; QString students; QString firstActivityTag; QString secondActivityTag; //internal variables QList canonicalSubgroupsList; int _firstActivityTagIndex; int _secondActivityTagIndex; ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags(); ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags(double wp, const QString& _students, int _minGaps, const QString& _firstActivityTag, const QString& _secondActivityTag); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMinGapsBetweenOrderedPairOfActivityTags: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinGapsBetweenOrderedPairOfActivityTags) public: int minGaps; QString firstActivityTag; QString secondActivityTag; //internal variables QList canonicalSubgroupsList; int _firstActivityTagIndex; int _secondActivityTagIndex; ConstraintStudentsMinGapsBetweenOrderedPairOfActivityTags(); ConstraintStudentsMinGapsBetweenOrderedPairOfActivityTags(double wp, int _minGaps, const QString& _firstActivityTag, const QString& _secondActivityTag); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMinGapsBetweenOrderedPairOfActivityTags: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinGapsBetweenOrderedPairOfActivityTags) public: int minGaps; QString teacher; QString firstActivityTag; QString secondActivityTag; //internal variables QList canonicalTeachersList; int _firstActivityTagIndex; int _secondActivityTagIndex; ConstraintTeacherMinGapsBetweenOrderedPairOfActivityTags(); ConstraintTeacherMinGapsBetweenOrderedPairOfActivityTags(double wp, const QString& _teacher, int _minGaps, const QString& _firstActivityTag, const QString& _secondActivityTag); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMinGapsBetweenOrderedPairOfActivityTags: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinGapsBetweenOrderedPairOfActivityTags) public: int minGaps; QString firstActivityTag; QString secondActivityTag; //internal variables QList canonicalTeachersList; int _firstActivityTagIndex; int _secondActivityTagIndex; ConstraintTeachersMinGapsBetweenOrderedPairOfActivityTags(); ConstraintTeachersMinGapsBetweenOrderedPairOfActivityTags(double wp, int _minGaps, const QString& _firstActivityTag, const QString& _secondActivityTag); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; //Begin for mornings-afternoons /** This is a constraint, aimed at obtaining timetables which do not allow more than X hours in a day for any teacher */ class ConstraintTeachersMaxHoursDailyRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxHoursDailyRealDays) public: /** The maximum hours daily */ int maxHoursDaily; ConstraintTeachersMaxHoursDailyRealDays(); ConstraintTeachersMaxHoursDailyRealDays(double wp, int maxhours); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxHoursDailyRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxHoursDailyRealDays) public: /** The maximum hours daily */ int maxHoursDaily; QString teacherName; int teacher_ID; ConstraintTeacherMaxHoursDailyRealDays(); ConstraintTeacherMaxHoursDailyRealDays(double wp, int maxhours, const QString& teacher); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; /** This is a constraint. The resulting timetable must respect the requirement that this teacher must not have too much working days per week. */ class ConstraintTeacherMaxRealDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxRealDaysPerWeek) public: /** The number of maximum allowed working days per week (-1 for don't care) */ int maxDaysPerWeek; /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherMaxRealDaysPerWeek(); ConstraintTeacherMaxRealDaysPerWeek(double wp, int maxnd, QString t); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxRealDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxRealDaysPerWeek) public: /** The number of maximum allowed working days per week (-1 for don't care) */ int maxDaysPerWeek; ConstraintTeachersMaxRealDaysPerWeek(); ConstraintTeachersMaxRealDaysPerWeek(double wp, int maxnd); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMinRealDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinRealDaysPerWeek) public: int minDaysPerWeek; /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherMinRealDaysPerWeek(); ConstraintTeacherMinRealDaysPerWeek(double wp, int mindays, const QString& t); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMinRealDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinRealDaysPerWeek) public: int minDaysPerWeek; ConstraintTeachersMinRealDaysPerWeek(); ConstraintTeachersMinRealDaysPerWeek(double wp, int mindays); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxGapsPerRealDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerRealDay) public: int maxGaps; bool allowOneDayExceptionPlusOne; ConstraintTeachersMaxGapsPerRealDay(); ConstraintTeachersMaxGapsPerRealDay(double wp, int maxGaps, bool except); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxGapsPerRealDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerRealDay) public: int maxGaps; bool allowOneDayExceptionPlusOne; QString teacherName; int teacherIndex; ConstraintTeacherMaxGapsPerRealDay(); ConstraintTeacherMaxGapsPerRealDay(double wp, QString tn, int maxGaps, bool except); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMaxHoursDailyRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxHoursDailyRealDays) public: int maxHoursDaily; ConstraintStudentsMaxHoursDailyRealDays(); ConstraintStudentsMaxHoursDailyRealDays(double wp, int maxnh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMaxHoursDailyRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxHoursDailyRealDays) public: int maxHoursDaily; /** The students set name */ QString students; //internal variables /** The number of subgroups */ //int nSubgroups; /** The subgroups */ //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; QList iSubgroupsList; ConstraintStudentsSetMaxHoursDailyRealDays(); ConstraintStudentsSetMaxHoursDailyRealDays(double wp, int maxnh, QString s); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMinHoursPerMorning: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinHoursPerMorning) public: /** The minimum hours per morning */ int minHoursPerMorning; bool allowEmptyMornings; ConstraintTeachersMinHoursPerMorning(); ConstraintTeachersMinHoursPerMorning(double wp, int minhours, bool _allowEmptyMornings); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMinHoursPerMorning: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinHoursPerMorning) public: /** The minimum hours per morning */ int minHoursPerMorning; QString teacherName; int teacher_ID; bool allowEmptyMornings; ConstraintTeacherMinHoursPerMorning(); ConstraintTeacherMinHoursPerMorning(double wp, int minhours, const QString& teacher, bool _allowEmptyMornings); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMinHoursDailyRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinHoursDailyRealDays) public: /** The minimum hours daily */ int minHoursDaily; bool allowEmptyDays; ConstraintTeachersMinHoursDailyRealDays(); ConstraintTeachersMinHoursDailyRealDays(double wp, int minhours, bool _allowEmptyDays); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMinHoursDailyRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinHoursDailyRealDays) public: /** The minimum hours daily */ int minHoursDaily; QString teacherName; int teacher_ID; bool allowEmptyDays; ConstraintTeacherMinHoursDailyRealDays(); ConstraintTeacherMinHoursDailyRealDays(double wp, int minhours, const QString& teacher, bool _allowEmptyDays); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; //morning class ConstraintTeacherMorningIntervalMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMorningIntervalMaxDaysPerWeek) public: /** The number of maximum allowed working days per week (mornings) */ int maxDaysPerWeek; int startHour; int endHour; //might be = to gt.rules.nHoursPerDay /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherMorningIntervalMaxDaysPerWeek(); ConstraintTeacherMorningIntervalMaxDaysPerWeek(double wp, int maxnd, QString tn, int sh, int eh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMorningIntervalMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMorningIntervalMaxDaysPerWeek) public: /** The number of maximum allowed working days per week (mornings) */ int maxDaysPerWeek; int startHour; int endHour; //might be = to gt.rules.nHoursPerDay ConstraintTeachersMorningIntervalMaxDaysPerWeek(); ConstraintTeachersMorningIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; //afternoon class ConstraintTeacherAfternoonIntervalMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherIntervalMaxDaysPerWeek) public: /** The number of maximum allowed working days per week (afternoons) */ int maxDaysPerWeek; int startHour; int endHour; //might be = to gt.rules.nHoursPerDay /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherAfternoonIntervalMaxDaysPerWeek(); ConstraintTeacherAfternoonIntervalMaxDaysPerWeek(double wp, int maxnd, QString tn, int sh, int eh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersAfternoonIntervalMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersIntervalMaxDaysPerWeek) public: /** The number of maximum allowed working days per week (afternoons) */ int maxDaysPerWeek; int startHour; int endHour; //might be = to gt.rules.nHoursPerDay ConstraintTeachersAfternoonIntervalMaxDaysPerWeek(); ConstraintTeachersAfternoonIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersActivityTagMaxHoursDailyRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMaxHoursDailyRealDays) public: /** The maximum hours daily */ int maxHoursDaily; QString activityTagName; int activityTagIndex; QList canonicalTeachersList; ConstraintTeachersActivityTagMaxHoursDailyRealDays(); ConstraintTeachersActivityTagMaxHoursDailyRealDays(double wp, int maxhours, const QString& activityTag); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherActivityTagMaxHoursDailyRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMaxHoursDailyRealDays) public: /** The maximum hours daily */ int maxHoursDaily; QString teacherName; QString activityTagName; int teacher_ID; int activityTagIndex; QList canonicalTeachersList; ConstraintTeacherActivityTagMaxHoursDailyRealDays(); ConstraintTeacherActivityTagMaxHoursDailyRealDays(double wp, int maxhours, const QString& teacher, const QString& activityTag); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsActivityTagMaxHoursDailyRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMaxHoursDailyRealDays) public: int maxHoursDaily; QString activityTagName; int activityTagIndex; QList canonicalSubgroupsList; ConstraintStudentsActivityTagMaxHoursDailyRealDays(); ConstraintStudentsActivityTagMaxHoursDailyRealDays(double wp, int maxnh, const QString& activityTag); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetActivityTagMaxHoursDailyRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMaxHoursDailyRealDays) public: int maxHoursDaily; /** The students set name */ QString students; QString activityTagName; //internal variables int activityTagIndex; /** The number of subgroups */ //int nSubgroups; /** The subgroups */ //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; QList iSubgroupsList; QList canonicalSubgroupsList; ConstraintStudentsSetActivityTagMaxHoursDailyRealDays(); ConstraintStudentsSetActivityTagMaxHoursDailyRealDays(double wp, int maxnh, const QString& s, const QString& activityTag); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMaxGapsPerRealDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxGapsPerRealDay) public: int maxGaps; ConstraintStudentsMaxGapsPerRealDay(); ConstraintStudentsMaxGapsPerRealDay(double wp, int mg); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMaxGapsPerRealDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxGapsPerRealDay) public: int maxGaps; /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetMaxGapsPerRealDay(); ConstraintStudentsSetMaxGapsPerRealDay(double wp, int mg, const QString& st ); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMaxRealDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxRealDaysPerWeek) public: /** The number of maximum allowed working days per week */ int maxDaysPerWeek; /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetMaxRealDaysPerWeek(); ConstraintStudentsSetMaxRealDaysPerWeek(double wp, int maxnd, QString sn); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMaxRealDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxRealDaysPerWeek) public: /** The number of maximum allowed working days per week */ int maxDaysPerWeek; ConstraintStudentsMaxRealDaysPerWeek(); ConstraintStudentsMaxRealDaysPerWeek(double wp, int maxnd); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxSpanPerRealDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxSpanPerRealDay) public: /** The maximum span daily */ int maxSpanPerDay; bool allowOneDayExceptionPlusOne; QString teacherName; int teacher_ID; ConstraintTeacherMaxSpanPerRealDay(); ConstraintTeacherMaxSpanPerRealDay(double wp, int maxspan, bool except, const QString& teacher); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxSpanPerRealDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxSpanPerRealDay) public: /** The maximum span daily */ int maxSpanPerDay; bool allowOneDayExceptionPlusOne; ConstraintTeachersMaxSpanPerRealDay(); ConstraintTeachersMaxSpanPerRealDay(double wp, int maxspan, bool except); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMaxSpanPerRealDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxSpanPerRealDay) public: int maxSpanPerDay; /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetMaxSpanPerRealDay(); ConstraintStudentsSetMaxSpanPerRealDay(double wp, int maxspan, const QString& sn); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMaxSpanPerRealDay: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxSpanPerRealDay) public: int maxSpanPerDay; ConstraintStudentsMaxSpanPerRealDay(); ConstraintStudentsMaxSpanPerRealDay(double wp, int maxspan); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxAfternoonsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxAfternoonsPerWeek) public: /** The number of maximum allowed working days per week (-1 for don't care) */ int maxAfternoonsPerWeek; /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherMaxAfternoonsPerWeek(); ConstraintTeacherMaxAfternoonsPerWeek(double wp, int maxnd, QString t); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxAfternoonsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxAfternoonsPerWeek) public: /** The number of maximum allowed working days per week (-1 for don't care) */ int maxAfternoonsPerWeek; ConstraintTeachersMaxAfternoonsPerWeek(); ConstraintTeachersMaxAfternoonsPerWeek(double wp, int maxnd); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxMorningsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxMorningsPerWeek) public: /** The number of maximum allowed working days per week (-1 for don't care) */ int maxMorningsPerWeek; /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherMaxMorningsPerWeek(); ConstraintTeacherMaxMorningsPerWeek(double wp, int maxnd, QString t); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxMorningsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxMorningsPerWeek) public: /** The number of maximum allowed working days per week (-1 for don't care) */ int maxMorningsPerWeek; ConstraintTeachersMaxMorningsPerWeek(); ConstraintTeachersMaxMorningsPerWeek(double wp, int maxnd); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxTwoActivityTagsPerDayFromN1N2N3: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxTwoActivityTagsPerDayFromN1N2N3) public: /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherMaxTwoActivityTagsPerDayFromN1N2N3(); ConstraintTeacherMaxTwoActivityTagsPerDayFromN1N2N3(double wp, QString t); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxTwoActivityTagsPerDayFromN1N2N3: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxTwoActivityTagsPerDayFromN1N2N3) public: ConstraintTeachersMaxTwoActivityTagsPerDayFromN1N2N3(); ConstraintTeachersMaxTwoActivityTagsPerDayFromN1N2N3(double wp); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMinMorningsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinMorningsPerWeek) public: int minMorningsPerWeek; /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherMinMorningsPerWeek(); ConstraintTeacherMinMorningsPerWeek(double wp, int minmornings, const QString& t); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMinMorningsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinMorningsPerWeek) public: int minMorningsPerWeek; ConstraintTeachersMinMorningsPerWeek(); ConstraintTeachersMinMorningsPerWeek(double wp, int minmornings); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMinAfternoonsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinAfternoonsPerWeek) public: int minAfternoonsPerWeek; /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherMinAfternoonsPerWeek(); ConstraintTeacherMinAfternoonsPerWeek(double wp, int minafternoons, const QString& t); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMinAfternoonsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinAfternoonsPerWeek) public: int minAfternoonsPerWeek; ConstraintTeachersMinAfternoonsPerWeek(); ConstraintTeachersMinAfternoonsPerWeek(double wp, int minafternoons); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxTwoConsecutiveMornings: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxTwoConsecutiveMornings) public: /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherMaxTwoConsecutiveMornings(); ConstraintTeacherMaxTwoConsecutiveMornings(double wp, QString t); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxTwoConsecutiveMornings: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxTwoConsecutiveMornings) public: ConstraintTeachersMaxTwoConsecutiveMornings(); ConstraintTeachersMaxTwoConsecutiveMornings(double wp); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxTwoConsecutiveAfternoons: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxTwoConsecutiveAfternoons) public: /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; ConstraintTeacherMaxTwoConsecutiveAfternoons(); ConstraintTeacherMaxTwoConsecutiveAfternoons(double wp, QString t); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxTwoConsecutiveAfternoons: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxTwoConsecutiveAfternoons) public: ConstraintTeachersMaxTwoConsecutiveAfternoons(); ConstraintTeachersMaxTwoConsecutiveAfternoons(double wp); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersAfternoonsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersAfternoonsEarlyMaxBeginningsAtSecondHour) public: int maxBeginningsAtSecondHour; ConstraintTeachersAfternoonsEarlyMaxBeginningsAtSecondHour(); ConstraintTeachersAfternoonsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherAfternoonsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherAfternoonsEarlyMaxBeginningsAtSecondHour) public: int maxBeginningsAtSecondHour; QString teacherName; //internal int teacherIndex; ConstraintTeacherAfternoonsEarlyMaxBeginningsAtSecondHour(); ConstraintTeacherAfternoonsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH, const QString& teacher); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMorningsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMorningsEarlyMaxBeginningsAtSecondHour) public: int maxBeginningsAtSecondHour; ConstraintTeachersMorningsEarlyMaxBeginningsAtSecondHour(); ConstraintTeachersMorningsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMorningsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMorningsEarlyMaxBeginningsAtSecondHour) public: int maxBeginningsAtSecondHour; QString teacherName; //internal int teacherIndex; ConstraintTeacherMorningsEarlyMaxBeginningsAtSecondHour(); ConstraintTeacherMorningsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH, const QString& teacher); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; //2020-06-14 class ConstraintStudentsMinHoursPerMorning: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinHoursPerMorning) public: int minHoursPerMorning; bool allowEmptyMornings; ConstraintStudentsMinHoursPerMorning(); ConstraintStudentsMinHoursPerMorning(double wp, int minnh, bool _allowEmptyMornings); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMinHoursPerMorning: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinHoursPerMorning) public: int minHoursPerMorning; /** The students set name */ QString students; bool allowEmptyMornings; //internal variables /** The number of subgroups */ //int nSubgroups; /** The subgroups */ //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; QList iSubgroupsList; ConstraintStudentsSetMinHoursPerMorning(); ConstraintStudentsSetMinHoursPerMorning(double wp, int minnh, QString s, bool _allowEmptyMornings); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxZeroGapsPerAfternoon: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxZeroGapsPerAfternoon) public: QString teacherName; int teacherIndex; ConstraintTeacherMaxZeroGapsPerAfternoon(); ConstraintTeacherMaxZeroGapsPerAfternoon(double wp, QString tn); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxZeroGapsPerAfternoon: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxZeroGapsPerAfternoon) public: ConstraintTeachersMaxZeroGapsPerAfternoon(); ConstraintTeachersMaxZeroGapsPerAfternoon(double wp); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; //2020-06-25 class ConstraintStudentsMaxAfternoonsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxAfternoonsPerWeek) public: int maxAfternoonsPerWeek; ConstraintStudentsMaxAfternoonsPerWeek(); ConstraintStudentsMaxAfternoonsPerWeek(double wp, int maxnd); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMaxAfternoonsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxAfternoonsPerWeek) public: int maxAfternoonsPerWeek; QString students; QList iSubgroupsList; ConstraintStudentsSetMaxAfternoonsPerWeek(); ConstraintStudentsSetMaxAfternoonsPerWeek(double wp, int maxnd, const QString& sn); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMaxMorningsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxMorningsPerWeek) public: int maxMorningsPerWeek; ConstraintStudentsMaxMorningsPerWeek(); ConstraintStudentsMaxMorningsPerWeek(double wp, int maxnd); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMaxMorningsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxMorningsPerWeek) public: int maxMorningsPerWeek; QString students; QList iSubgroupsList; ConstraintStudentsSetMaxMorningsPerWeek(); ConstraintStudentsSetMaxMorningsPerWeek(double wp, int maxnd, const QString& sn); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; //2020-06-26 class ConstraintStudentsMinAfternoonsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinAfternoonsPerWeek) public: int minAfternoonsPerWeek; ConstraintStudentsMinAfternoonsPerWeek(); ConstraintStudentsMinAfternoonsPerWeek(double wp, int minnd); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMinAfternoonsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinAfternoonsPerWeek) public: int minAfternoonsPerWeek; QString students; QList iSubgroupsList; ConstraintStudentsSetMinAfternoonsPerWeek(); ConstraintStudentsSetMinAfternoonsPerWeek(double wp, int minnd, const QString& sn); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMinMorningsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinMorningsPerWeek) public: int minMorningsPerWeek; ConstraintStudentsMinMorningsPerWeek(); ConstraintStudentsMinMorningsPerWeek(double wp, int minnd); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMinMorningsPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinMorningsPerWeek) public: int minMorningsPerWeek; QString students; QList iSubgroupsList; ConstraintStudentsSetMinMorningsPerWeek(); ConstraintStudentsSetMinMorningsPerWeek(double wp, int minnd, const QString& sn); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; //2020-06-26 class ConstraintStudentsSetMorningIntervalMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetIntervalMaxDaysPerWeek) public: /** The number of maximum allowed working days per week */ int maxDaysPerWeek; int startHour; int endHour; //might be = to gt.rules.nHoursPerDay /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetMorningIntervalMaxDaysPerWeek(); ConstraintStudentsSetMorningIntervalMaxDaysPerWeek(double wp, int maxnd, QString sn, int sh, int eh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMorningIntervalMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsIntervalMaxDaysPerWeek) public: /** The number of maximum allowed working days per week */ int maxDaysPerWeek; int startHour; int endHour; //might be = to gt.rules.nHoursPerDay ConstraintStudentsMorningIntervalMaxDaysPerWeek(); ConstraintStudentsMorningIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetAfternoonIntervalMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetIntervalMaxDaysPerWeek) public: /** The number of maximum allowed working days per week */ int maxDaysPerWeek; int startHour; int endHour; //might be = to gt.rules.nHoursPerDay /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetAfternoonIntervalMaxDaysPerWeek(); ConstraintStudentsSetAfternoonIntervalMaxDaysPerWeek(double wp, int maxnd, QString sn, int sh, int eh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsAfternoonIntervalMaxDaysPerWeek: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsIntervalMaxDaysPerWeek) public: /** The number of maximum allowed working days per week */ int maxDaysPerWeek; int startHour; int endHour; //might be = to gt.rules.nHoursPerDay ConstraintStudentsAfternoonIntervalMaxDaysPerWeek(); ConstraintStudentsAfternoonIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; //2020-06-28 class ConstraintTeacherMaxHoursPerAllAfternoons: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxHoursPerAllAfternoons) public: int maxHoursPerAllAfternoons; QString teacherName; int teacher_ID; ConstraintTeacherMaxHoursPerAllAfternoons(); ConstraintTeacherMaxHoursPerAllAfternoons(double wp, int maxhours, const QString& teacher); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxHoursPerAllAfternoons: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxHoursPerAllAfternoons) public: int maxHoursPerAllAfternoons; ConstraintTeachersMaxHoursPerAllAfternoons(); ConstraintTeachersMaxHoursPerAllAfternoons(double wp, int maxhours); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; //2020-06-28 class ConstraintStudentsSetMaxHoursPerAllAfternoons: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxHoursPerAllAfternoons) public: int maxHoursPerAllAfternoons; QString students; QList iSubgroupsList; ConstraintStudentsSetMaxHoursPerAllAfternoons(); ConstraintStudentsSetMaxHoursPerAllAfternoons(double wp, int maxhours, const QString& st); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMaxHoursPerAllAfternoons: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxHoursPerAllAfternoons) public: int maxHoursPerAllAfternoons; ConstraintStudentsMaxHoursPerAllAfternoons(); ConstraintStudentsMaxHoursPerAllAfternoons(double wp, int maxhours); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMinRestingHoursBetweenMorningAndAfternoon: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinRestingHoursBetweenMorningAndAfternoon) public: int minRestingHours; QString teacherName; int teacher_ID; ConstraintTeacherMinRestingHoursBetweenMorningAndAfternoon(); ConstraintTeacherMinRestingHoursBetweenMorningAndAfternoon(double wp, int minrestinghours, const QString& teacher); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMinRestingHoursBetweenMorningAndAfternoon: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinRestingHoursBetweenMorningAndAfternoon) public: int minRestingHours; ConstraintTeachersMinRestingHoursBetweenMorningAndAfternoon(); ConstraintTeachersMinRestingHoursBetweenMorningAndAfternoon(double wp, int minrestinghours); QString getXmlDescription(Rules& r); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMinRestingHoursBetweenMorningAndAfternoon: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinRestingHoursBetweenMorningAndAfternoon) public: int minRestingHours; /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetMinRestingHoursBetweenMorningAndAfternoon(); ConstraintStudentsSetMinRestingHoursBetweenMorningAndAfternoon(double wp, int minrestinghours, const QString& sn); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMinRestingHoursBetweenMorningAndAfternoon: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinRestingHoursBetweenMorningAndAfternoon) public: int minRestingHours; ConstraintStudentsMinRestingHoursBetweenMorningAndAfternoon(); ConstraintStudentsMinRestingHoursBetweenMorningAndAfternoon(double wp, int minrestinghours); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsAfternoonsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsAfternoonsEarlyMaxBeginningsAtSecondHour) public: int maxBeginningsAtSecondHour; ConstraintStudentsAfternoonsEarlyMaxBeginningsAtSecondHour(); ConstraintStudentsAfternoonsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetAfternoonsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetAfternoonsEarlyMaxBeginningsAtSecondHour) public: int maxBeginningsAtSecondHour; /** The name of the students */ QString students; /** The number of subgroups involved in this constraint */ //int nSubgroups; /** The subgroups involved in this constraint */ //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; QList iSubgroupsList; ConstraintStudentsSetAfternoonsEarlyMaxBeginningsAtSecondHour(); ConstraintStudentsSetAfternoonsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH, const QString& students); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMorningsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMorningsEarlyMaxBeginningsAtSecondHour) public: int maxBeginningsAtSecondHour; ConstraintStudentsMorningsEarlyMaxBeginningsAtSecondHour(); ConstraintStudentsMorningsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMorningsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMorningsEarlyMaxBeginningsAtSecondHour) public: int maxBeginningsAtSecondHour; /** The name of the students */ QString students; /** The number of subgroups involved in this constraint */ //int nSubgroups; /** The subgroups involved in this constraint */ //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT]; QList iSubgroupsList; ConstraintStudentsSetMorningsEarlyMaxBeginningsAtSecondHour(); ConstraintStudentsSetMorningsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH, const QString& students); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; //2020-07-29 class ConstraintTeachersMaxGapsPerWeekForRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerWeekForRealDays) public: int maxGaps; ConstraintTeachersMaxGapsPerWeekForRealDays(); ConstraintTeachersMaxGapsPerWeekForRealDays(double wp, int maxGaps); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeacherMaxGapsPerWeekForRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerWeekForRealDays) public: int maxGaps; QString teacherName; int teacherIndex; ConstraintTeacherMaxGapsPerWeekForRealDays(); ConstraintTeacherMaxGapsPerWeekForRealDays(double wp, QString tn, int maxGaps); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsMaxGapsPerWeekForRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxGapsPerWeekForRealDays) public: int maxGaps; ConstraintStudentsMaxGapsPerWeekForRealDays(); ConstraintStudentsMaxGapsPerWeekForRealDays(double wp, int mg); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintStudentsSetMaxGapsPerWeekForRealDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxGapsPerWeekForRealDays) public: int maxGaps; /** The name of the students set for this constraint */ QString students; //internal redundant data /** The number of subgroups */ //int nSubgroups; /** The subgroups */ QList iSubgroupsList; ConstraintStudentsSetMaxGapsPerWeekForRealDays(); ConstraintStudentsSetMaxGapsPerWeekForRealDays(double wp, int mg, const QString& st ); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList&dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; //End for mornings-afternoons //Begin mornings-afternoons 2021-09-26 class ConstraintTeacherMaxThreeConsecutiveDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxThreeConsecutiveDays) public: /** The teacher's name */ QString teacherName; /** The teacher's id, or index in the rules */ int teacher_ID; bool allowAMAMException; //AMAM=afternoon morning afternoon morning. ConstraintTeacherMaxThreeConsecutiveDays(); ConstraintTeacherMaxThreeConsecutiveDays(double wp, bool ae, const QString& tn); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; class ConstraintTeachersMaxThreeConsecutiveDays: public TimeConstraint{ Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxThreeConsecutiveDays) public: bool allowAMAMException; //AMAM=afternoon morning afternoon morning. ConstraintTeachersMaxThreeConsecutiveDays(); ConstraintTeachersMaxThreeConsecutiveDays(double wp, bool ae); bool computeInternalStructure(QWidget* parent, Rules& r); bool hasInactiveActivities(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); double fitness(Solution& c, Rules& r, QList& cl, QList& dl, FakeString* conflictsString=nullptr); bool isRelatedToActivity(Rules& r, Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToActivityTag(ActivityTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s); bool hasWrongDayOrHour(Rules& r); bool canRepairWrongDayOrHour(Rules& r); bool repairWrongDayOrHour(Rules& r); }; //End mornings-afternoons 2021-09-26 #endif