📄 spaceconstraint.h
字号:
bool isRelatedToBuilding(Building* b); bool isRelatedToRoom(Room* r);};/**This is a constraint. Its purpose: a subject+subject tag must be taught ina room which has the necessary equipments.*/class ConstraintSubjectSubjectTagRequireEquipments: public SpaceConstraint{private: //The number of activities referred to by this constraint int _nActivities; //The list of activities referred to by this constraint. //This is a list of indices in the rules internal activities list. int _activities[MAX_ACTIVITIES_FOR_A_SUBJECT]; //The number of equipments referred to by this constraint int _nEquipments; //The indices of the equipments referred to by this constraint int _equipments[MAX_EQUIPMENTS_FOR_A_CONSTRAINT];public: QString subjectName; QString subjectTagName; QStringList equipmentsNames; ConstraintSubjectSubjectTagRequireEquipments(); ConstraintSubjectSubjectTagRequireEquipments(double w, bool c, const QString& subj, const QString& subt); void addRequiredEquipment(const QString& equip); /** Returns the number of removed equipments (must be 0 or 1, of course) */ int removeRequiredEquipment(const QString& equip); /** Returns true if the equipment is in the list of required equipments, false otherwise. */ bool searchRequiredEquipment(const QString& equip); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(SpaceChromosome& c, Rules& r, const int days[/*MAX_ACTIVITIES*/], const int hours[/*MAX_ACTIVITIES*/], 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); bool isRelatedToEquipment(Equipment* e); bool isRelatedToBuilding(Building* b); bool isRelatedToRoom(Room* r);};/**This is a constraint. Its purpose: a teacher must teach inhis preferred room.*/class ConstraintTeacherRequiresRoom: public SpaceConstraint{public: //The number of activities referred to by this constraint int _nActivities; //The list of activities referred to by this constraint. //This is a list of indices in the rules internal activities list. int _activities[MAX_ACTIVITIES_FOR_A_TEACHER]; //The index of the room int _room; //---------------------------------------------------------- QString teacherName; QString roomName; ConstraintTeacherRequiresRoom(); ConstraintTeacherRequiresRoom(double w, bool c, const QString& teach, const QString& room); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(SpaceChromosome& c, Rules& r, const int days[/*MAX_ACTIVITIES*/], const int hours[/*MAX_ACTIVITIES*/], 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); bool isRelatedToEquipment(Equipment* e); bool isRelatedToBuilding(Building* b); bool isRelatedToRoom(Room* r);};/**This is a constraint. Its purpose: a teacher must teach a certain subject inhis preferred room.*/class ConstraintTeacherSubjectRequireRoom: public SpaceConstraint{public: //The number of activities referred to by this constraint int _nActivities; //The list of activities referred to by this constraint. //This is a list of indices in the rules internal activities list. int _activities[MAX_ACTIVITIES_FOR_A_TEACHER_AND_SUBJECT]; //The index of the room int _room; //---------------------------------------------------------- QString teacherName; QString subjectName; QString roomName; ConstraintTeacherSubjectRequireRoom(); ConstraintTeacherSubjectRequireRoom(double w, bool c, const QString& teach, const QString& subj, const QString& room); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(SpaceChromosome& c, Rules& r, const int days[/*MAX_ACTIVITIES*/], const int hours[/*MAX_ACTIVITIES*/], 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); bool isRelatedToEquipment(Equipment* e); bool isRelatedToBuilding(Building* b); bool isRelatedToRoom(Room* r);};/**This is a constraint aimed to minimize the number of rooms usedfor all the students.*/class ConstraintMinimizeNumberOfRoomsForStudents: public SpaceConstraint{public: ConstraintMinimizeNumberOfRoomsForStudents(); ConstraintMinimizeNumberOfRoomsForStudents(double w, bool c); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(SpaceChromosome& c, Rules& r, const int days[/*MAX_ACTIVITIES*/], const int hours[/*MAX_ACTIVITIES*/], 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); bool isRelatedToEquipment(Equipment* e); bool isRelatedToBuilding(Building* b); bool isRelatedToRoom(Room* r);};/**This is a constraint aimed to minimize the number of rooms usedfor all the teachers.*/class ConstraintMinimizeNumberOfRoomsForTeachers: public SpaceConstraint{public: ConstraintMinimizeNumberOfRoomsForTeachers(); ConstraintMinimizeNumberOfRoomsForTeachers(double w, bool c); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(SpaceChromosome& c, Rules& r, const int days[/*MAX_ACTIVITIES*/], const int hours[/*MAX_ACTIVITIES*/], 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); bool isRelatedToEquipment(Equipment* e); bool isRelatedToBuilding(Building* b); bool isRelatedToRoom(Room* r);};/**This is a constraint. Its purpose: an activity must take part inthe preferred room.*/class ConstraintActivityPreferredRoom: public SpaceConstraint{public: //The activity referred to by this constraint. //This is an index in the rules internal activities list. int _activity; //The index of the room int _room; //---------------------------------------------------------- int activityId; QString roomName; ConstraintActivityPreferredRoom(); ConstraintActivityPreferredRoom(double w, bool c, int aid, const QString& room); /** Comparison operator - to be sure we do not introduce duplicates */ bool operator==(ConstraintActivityPreferredRoom& c); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(SpaceChromosome& c, Rules& r, const int days[/*MAX_ACTIVITIES*/], const int hours[/*MAX_ACTIVITIES*/], 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); bool isRelatedToEquipment(Equipment* e); bool isRelatedToBuilding(Building* b); bool isRelatedToRoom(Room* r);};/**This is a constraint. Its purpose: an activity must take part inthe preferred rooms.*/class ConstraintActivityPreferredRooms: public SpaceConstraint{public: //The activity referred to by this constraint. //This is an index in the rules internal activities list. int _activity; //The number of preferred rooms int _n_preferred_rooms; //The indexes of the rooms int _rooms[MAX_CONSTRAINT_ACTIVITY_PREFERRED_ROOMS]; //---------------------------------------------------------- int activityId; QStringList roomsNames; ConstraintActivityPreferredRooms(); ConstraintActivityPreferredRooms(double w, bool c, int aid, const QStringList& roomsList); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r); QString getDetailedDescription(Rules& r); int fitness(SpaceChromosome& c, Rules& r, const int days[/*MAX_ACTIVITIES*/], const int hours[/*MAX_ACTIVITIES*/], 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); bool isRelatedToEquipment(Equipment* e); bool isRelatedToBuilding(Building* b); bool isRelatedToRoom(Room* r);};/**This is a constraint.It aims at scheduling a set of activities in the same room.The number of conflicts is considered the sum of x for all pairs,where x is 1 if 2 activities have different rooms and 0 if theyhave the same room.The compulsory constraints of this kindimplement chromosome repairing, so no conflicts will be reported*/class ConstraintActivitiesSameRoom: public SpaceConstraint{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_ROOM]; /** 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_ROOM]; ConstraintActivitiesSameRoom(); /** Constructor, using: the weight, the number of activities and the list of activities' id-s. */ ConstraintActivitiesSameRoom(double w, bool c, int n_act, const int act[]); bool computeInternalStructure(Rules& r); QString getXmlDescription(Rules& r); QString getDescription(Rules& r);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -