📄 timeconstraint.h
字号:
ConstraintActivityPreferredTime(); ConstraintActivityPreferredTime(double w, bool c, int actId, int d, int h); /** Comparison operator - to be sure that we do not introduce duplicates */ bool operator==(ConstraintActivityPreferredTime& c); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(TimeChromosome& c, Rules& r, QString* conflictsString=NULL); bool isRelatedToActivity(Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToSubjectTag(SubjectTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);};/**This is a constraint.It returns conflicts if the activity is scheduled in another intervalthan the preferred set of times.*/class ConstraintActivityPreferredTimes: public TimeConstraint{public: /** Activity id */ int activityId; /** The number of preferred times */ int nPreferredTimes; /** The preferred days. If -1, then the user does not care about the day. */ int days[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIMES]; /** The preferred hour. If -1, then the user does not care about the hour. */ int hours[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIMES]; //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; ConstraintActivityPreferredTimes(); ConstraintActivityPreferredTimes(double w, bool c, int actId, int nPT, int d[], int h[]); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(TimeChromosome& c, Rules& r, QString* conflictsString=NULL); bool isRelatedToActivity(Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToSubjectTag(SubjectTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);};/**This is a constraint.It returns a conflicts factor that increases with the number of lessonsthat follow after this activity (in the same day).*/class ConstraintActivityEndsDay: public TimeConstraint{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; ConstraintActivityEndsDay(); ConstraintActivityEndsDay(double w, bool c, int actId); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(TimeChromosome& c, Rules& r, QString* conflictsString=NULL); bool isRelatedToActivity(Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToSubjectTag(SubjectTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);};/**This is a time constraint.PURPOSE: you have two activities that you want to schedule one afterthe other, in the same day. Order is important.It adds, to the fitness of the chromosome, a value thatgrows as the 2 activities are scheduled farther one from each other.For the moment, fitness factor increases with one unit for every additional hour and one unit for every day (the optimal being 0 - when the starting timeof the second activity is the ending time of the first one).*/class Constraint2ActivitiesConsecutive: public TimeConstraint{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; Constraint2ActivitiesConsecutive(); Constraint2ActivitiesConsecutive(double w, bool c, int firstActId, int secondActId); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(TimeChromosome& c, Rules& r, QString* conflictsString=NULL); bool isRelatedToActivity(Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToSubjectTag(SubjectTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);};/**This is a time constraint.PURPOSE: you have two activities that you want to schedule one afterthe other, not necessarily in the same day or adjacent. Order is important.It adds, to the fitness of the chromosome, the weight multimplied with 2 if the firstactivity is weekly (not bi-weekly) and with again with 2 if the second activityis weekly, if the condition is broken.*/class Constraint2ActivitiesOrdered: public TimeConstraint{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; Constraint2ActivitiesOrdered(); Constraint2ActivitiesOrdered(double w, bool c, int firstActId, int secondActId); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(TimeChromosome& c, Rules& r, QString* conflictsString=NULL); bool isRelatedToActivity(Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToSubjectTag(SubjectTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);};/**This is a time constraint.PURPOSE: you have two activities that you want to schedule one afterthe other, in the same day. Order is not important.It adds, to the fitness of the chromosome, a value thatgrows as the 2 activities are scheduled farther one from each other.For the moment, fitness factor increases with one unit for every additionalhour and one unit for every day.(For hours, we have a 0 as minimum if the activitiesare OK, a positive constant value if they overlap and a positiveincreasing value if they are not touching.For days - we have a simple absolute difference).*/class Constraint2ActivitiesGrouped: public TimeConstraint{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; Constraint2ActivitiesGrouped(); Constraint2ActivitiesGrouped(double w, bool c, int firstActId, int secondActId); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(TimeChromosome& c, Rules& r, QString* conflictsString=NULL); bool isRelatedToActivity(Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToSubjectTag(SubjectTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);};/**This is a constraint.It returns conflicts if a set of activities is scheduled in another intervalthan the preferred set of times.The set of activities is specified by a subject, teacher, students or a combinationof these.*/class ConstraintActivitiesPreferredTimes: public TimeConstraint{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 subject tag. If void, all subjects tags. */ QString subjectTagName; /** The number of preferred times */ int nPreferredTimes; /** The preferred days. If -1, then the user does not care about the day. */ int days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIMES]; /** The preferred hours. If -1, then the user does not care about the hour. */ int hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIMES]; //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 */ int activitiesIndices[MAX_ACTIVITIES]; ConstraintActivitiesPreferredTimes(); ConstraintActivitiesPreferredTimes(double w, bool c, QString te, QString st, QString su, QString sut, int nPT, int d[], int h[]); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(TimeChromosome& c, Rules& r, QString* conflictsString=NULL); bool isRelatedToActivity(Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToSubjectTag(SubjectTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);};/**This is a constraint.It aims at scheduling a set of activities at the same starting hour.The number of conflicts is considered the sum of differencesin the scheduling time for all pairs of activities.The difference in the scheduling time for a pair ofactivities is considered the difference in the starting hour.TODO: Weekly activities are counted as two and bi-weekly activities as one(really necessary?).IMPORTANT: The compulsory constraints of this kindimplement chromosome repairing, so no conflicts will be reported*/class ConstraintActivitiesSameStartingHour: public TimeConstraint{public: /** The number of activities involved in this constraint */ int n_activities; /** The activities involved in this constraint (id) */ 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 */ 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 w, bool c, int n_act, const int act[]); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(TimeChromosome& c, Rules& r, QString* conflictsString=NULL); /** Removes useless activities from the _activities array */ void removeUseless(Rules& r); bool isRelatedToActivity(Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToSubjectTag(SubjectTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);};/**A constraint aimed at obtaining timetableswhich do not allow for a certain teacher (from all teachers) and a certain subject tag (from all subject tags) more than max hours countinuously*/class ConstraintTeachersSubjectTagsMaxHoursContinuously: public TimeConstraint{public: /** The maximum allowed hours continuously */ int maxHoursContinuously; ConstraintTeachersSubjectTagsMaxHoursContinuously(); ConstraintTeachersSubjectTagsMaxHoursContinuously(double w, bool c, int maxhours); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(TimeChromosome& c, Rules& r, QString* conflictsString=NULL); bool isRelatedToActivity(Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToSubjectTag(SubjectTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);};/**A constraint aimed at obtaining timetableswhich do not allow for a certain teacher from all teachers and a certain subject tag more than max hours countinuously*/class ConstraintTeachersSubjectTagMaxHoursContinuously: public TimeConstraint{public: /** The maximum allowed hours continuously */ int maxHoursContinuously; /** The subject tag */ QString subjectTagName; /** The subject tag index */ int subjectTagIndex; ConstraintTeachersSubjectTagMaxHoursContinuously(); ConstraintTeachersSubjectTagMaxHoursContinuously(double w, bool c, int maxhours, const QString& subjecttag); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(TimeChromosome& c, Rules& r, QString* conflictsString=NULL); bool isRelatedToActivity(Activity* a); bool isRelatedToTeacher(Teacher* t); bool isRelatedToSubject(Subject* s); bool isRelatedToSubjectTag(SubjectTag* s); bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -