?? how-to-implement-new-constraints.txt
字號:
FET - How to add new types of constraints-----------------------------------------TIME CONSTRAINTS:-----------------To implement new constraints (into the sources of FET), you will have to thinkat these aspects:- First of all, all the constraints are derived from the class TimeConstraint,which has some pure virtual functions which you must inherit and implement.This means that I could have added a kind of plug-ins, but for the momentI preferred the easier solution.- There are constraints refering to teachers. You can use the table "teachersMatrix"for this purpose. This is an array a[MAX_TEACHERS][MAX_DAYS_PER_WEEK][MAX_HOURS_PER_DAY].It is already calculated when you enter the constraint, so do not bother tothink how to compute it. Each location in this array has a value. If it is 0,then you have no activity at that time. If it is 1, then you have a biweekly activityscheduled. If it is 2, you have a weekly activity scheduled then. If it is greaterthan 2, then you have more than 2 activities (so, a basic compulsory constraints conflict)(for instance, 3 means one weekly activity and a biweekly one or 3 biweekly activities).Now, you can manipulate information in this matrix to return an integer value, which isthe number of conflicts. The best way is to provide an evolutionary path for yourobjective (for instance, if you want a teacher to have 4 weekly activities on Monday,the best way would be to return the modulus of 8 (4*2) minus the sum of the columnfor Monday.- There are constraints referring to students. Please treat them identically withthose referring to teachers.- There are constraints referring to subjects - TODO - You have here the ConstraintSubjectRequiresRoom - please see that as an example.- There are constraints referring to the activities. You can work on the matricesteachersMatrix and studentsMatrix or you can use directly the array times of thecandidate solution (chromosome). This array is named times[MAX_ACTIVITIES] and eachlocation contains the starting time of the corresponding activity (times[i] containsthe starting time of activity i, which is the i-th activity in the list ofactivities). Starting time means nDaysPerWeek*hour+day, so you can obtainthe hour and day by a divide and modulo operation. Having the starting timeof each activity, it is easy to write a procedure to handle any kind of constraint.You are advised to respect the same principle of evolution, that is, as the candidatesolution is getting closer to a global solution, the conflicts factor must decrease(gradually).- The places you will have to look over and modify are: engine: - timeconstraint.h and timeconstraint.cpp - rules.cpp, function "read" - rules.cpp - when erasing activities, teachers, students or rooms referring to your constraint, you must take care to erase also your constraint or a part of it. - rules.cpp - when renaming teachers etc. - there are some special kinds of constraints, which hopefully you can avoid. For instance, compulsory ConstraintActivitiesSameTime and ConstraintActivityPreferredTime work by repairing. interface: - you will have to modify fetmainform_template.ui, fetmainform.h and fetmainform.cpp and add some new files, named correspondigly (e-mail me if uncertain). - you will have to modify alltimeconstraintsform.cpp.SPACE CONSTRAINTS:------------------TODO
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -