Back to index

fet  5.18.0
timeconstraint.h
Go to the documentation of this file.
00001 /*
00002 File timeconstraint.h
00003 */
00004 
00005 /*
00006 Copyright 2002, 2003 Lalescu Liviu.
00007 
00008 This file is part of FET.
00009 
00010 FET is free software; you can redistribute it and/or modify
00011 it under the terms of the GNU General Public License as published by
00012 the Free Software Foundation; either version 2 of the License, or
00013 (at your option) any later version.
00014 
00015 FET is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with FET; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 */
00024 
00025 #ifndef TIMECONSTRAINT_H
00026 #define TIMECONSTRAINT_H
00027 
00028 #include <QCoreApplication>
00029 
00030 #include "timetable_defs.h"
00031 
00032 #include <QString>
00033 #include <QList>
00034 #include <QStringList>
00035 
00036 class Rules;
00037 class Solution;
00038 class TimeConstraint;
00039 class Activity;
00040 class Teacher;
00041 class Subject;
00042 class ActivityTag;
00043 class StudentsSet;
00044 
00045 class QWidget;
00046 
00047 typedef QList<TimeConstraint*> TimeConstraintsList;
00048 
00049 const int CONSTRAINT_GENERIC_TIME                                                                 =0;
00050 
00051 const int CONSTRAINT_BASIC_COMPULSORY_TIME                                                        =1;
00052 const int CONSTRAINT_BREAK_TIMES                                                                  =2;
00053 
00054 const int CONSTRAINT_TEACHER_NOT_AVAILABLE_TIMES                                    =3;
00055 const int CONSTRAINT_TEACHERS_MAX_HOURS_DAILY                                              =4;
00056 const int CONSTRAINT_TEACHER_MAX_DAYS_PER_WEEK                                             =5;
00057 const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_WEEK                                            =6;
00058 const int CONSTRAINT_TEACHER_MAX_GAPS_PER_WEEK                                             =7;
00059 const int CONSTRAINT_TEACHER_MAX_HOURS_DAILY                                               =8;
00060 const int CONSTRAINT_TEACHERS_MAX_HOURS_CONTINUOUSLY                                =9;
00061 const int CONSTRAINT_TEACHER_MAX_HOURS_CONTINUOUSLY                                        =10;
00062 
00063 const int CONSTRAINT_TEACHERS_MIN_HOURS_DAILY                                              =11;
00064 const int CONSTRAINT_TEACHER_MIN_HOURS_DAILY                                               =12;
00065 const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_DAY                                             =13;
00066 const int CONSTRAINT_TEACHER_MAX_GAPS_PER_DAY                                              =14;
00067 
00068 const int CONSTRAINT_STUDENTS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR            =15;
00069 const int CONSTRAINT_STUDENTS_SET_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR =16;
00070 const int CONSTRAINT_STUDENTS_SET_NOT_AVAILABLE_TIMES                               =17;
00071 const int CONSTRAINT_STUDENTS_MAX_GAPS_PER_WEEK                                            =18;
00072 const int CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_WEEK                                        =19;
00073 
00074 const int CONSTRAINT_STUDENTS_MAX_HOURS_DAILY                                              =20;
00075 const int CONSTRAINT_STUDENTS_SET_MAX_HOURS_DAILY                                          =21;
00076 const int CONSTRAINT_STUDENTS_MAX_HOURS_CONTINUOUSLY                                =22;
00077 const int CONSTRAINT_STUDENTS_SET_MAX_HOURS_CONTINUOUSLY                            =23;
00078 
00079 const int CONSTRAINT_STUDENTS_MIN_HOURS_DAILY                                              =24;
00080 const int CONSTRAINT_STUDENTS_SET_MIN_HOURS_DAILY                                          =25;
00081 
00082 const int CONSTRAINT_ACTIVITY_ENDS_STUDENTS_DAY                                            =26;
00083 const int CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME                               =27;
00084 const int CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME                                         =28;
00085 const int CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING                                            =29;
00086 const int CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES                                    =30;
00087 const int CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS                                         =31;
00088 const int CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS                                =32;
00089 const int CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES                              =33;
00090 const int CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES                            =34;
00091 const int CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR                                         =35;
00092 const int CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY                                          =36;
00093 const int CONSTRAINT_TWO_ACTIVITIES_CONSECUTIVE                                            =37;
00094 const int CONSTRAINT_TWO_ACTIVITIES_ORDERED                                                       =38;
00095 const int CONSTRAINT_MIN_GAPS_BETWEEN_ACTIVITIES                                    =39;
00096 const int CONSTRAINT_SUBACTIVITIES_PREFERRED_TIME_SLOTS                             =40;
00097 const int CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES                         =41;
00098 
00099 const int CONSTRAINT_TEACHER_INTERVAL_MAX_DAYS_PER_WEEK                             =42;
00100 const int CONSTRAINT_TEACHERS_INTERVAL_MAX_DAYS_PER_WEEK                            =43;
00101 const int CONSTRAINT_STUDENTS_SET_INTERVAL_MAX_DAYS_PER_WEEK                 =44;
00102 const int CONSTRAINT_STUDENTS_INTERVAL_MAX_DAYS_PER_WEEK                            =45;
00103 
00104 const int CONSTRAINT_ACTIVITIES_END_STUDENTS_DAY                                    =46;
00105 
00106 const int CONSTRAINT_TWO_ACTIVITIES_GROUPED                                                       =47;
00107 
00108 const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY            =48;
00109 const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY             =49;
00110 const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY            =50;
00111 const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY =51;
00112 
00113 const int CONSTRAINT_TEACHERS_MAX_DAYS_PER_WEEK                                            =52;
00114 
00115 const int CONSTRAINT_THREE_ACTIVITIES_GROUPED                                              =53;
00116 const int CONSTRAINT_MAX_DAYS_BETWEEN_ACTIVITIES                                    =54;
00117 
00118 const int CONSTRAINT_TEACHERS_MIN_DAYS_PER_WEEK                                            =55;
00119 const int CONSTRAINT_TEACHER_MIN_DAYS_PER_WEEK                                             =56;
00120 
00121 const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MAX_HOURS_DAILY                          =57;
00122 const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MAX_HOURS_DAILY                           =58;
00123 const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MAX_HOURS_DAILY                          =59;
00124 const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MAX_HOURS_DAILY               =60;
00125 
00126 const int CONSTRAINT_STUDENTS_MAX_GAPS_PER_DAY                                             =61;
00127 const int CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_DAY                                         =62;
00128 
00129 const int CONSTRAINT_ACTIVITIES_OCCUPY_MAX_TIME_SLOTS_FROM_SELECTION  =63;
00130 const int CONSTRAINT_ACTIVITIES_MAX_SIMULTANEOUS_IN_SELECTED_TIME_SLOTS      =64;
00131 
00132 QString getActivityDetailedDescription(Rules& r, int id);
00133 
00137 class TimeConstraint{
00138        Q_DECLARE_TR_FUNCTIONS(TimeConstraint)
00139 
00140 public:
00144        double weightPercentage;
00145        
00146        bool active;
00147        
00148        QString comments;
00149 
00153        int type;
00154 
00158        //bool compulsory;
00159 
00164        TimeConstraint();
00165        
00166        virtual ~TimeConstraint()=0;
00167 
00175        TimeConstraint(double wp);
00176 
00183        virtual double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, QString* conflictsString=NULL)=0;
00184 
00188        virtual QString getXmlDescription(Rules& r)=0;
00189 
00196        virtual bool computeInternalStructure(QWidget* parent, Rules& r)=0;
00197        
00198        virtual bool hasInactiveActivities(Rules& r)=0;
00199 
00203        virtual QString getDescription(Rules& r)=0;
00204 
00208        virtual QString getDetailedDescription(Rules& r)=0;
00209        
00213        virtual bool isRelatedToActivity(Rules& r, Activity* a)=0;
00214 
00218        virtual bool isRelatedToTeacher(Teacher* t)=0;
00219 
00223        virtual bool isRelatedToSubject(Subject* s)=0;
00224 
00228        virtual bool isRelatedToActivityTag(ActivityTag* s)=0;
00229 
00233        virtual bool isRelatedToStudentsSet(Rules& r, StudentsSet* s)=0;
00234        
00235        virtual bool hasWrongDayOrHour(Rules& r)=0;
00236        virtual bool canRepairWrongDayOrHour(Rules& r)=0;
00237        virtual bool repairWrongDayOrHour(Rules& r)=0;
00238 };
00239 
00244 class ConstraintBasicCompulsoryTime: public TimeConstraint{
00245        Q_DECLARE_TR_FUNCTIONS(ConstraintBasicCompulsoryTime)
00246 
00247 public:
00248        ConstraintBasicCompulsoryTime();
00249 
00250        ConstraintBasicCompulsoryTime(double wp);
00251 
00252        bool computeInternalStructure(QWidget* parent, Rules& r);
00253        
00254        bool hasInactiveActivities(Rules& r);
00255 
00256        QString getXmlDescription(Rules& r);
00257 
00258        QString getDescription(Rules& r);
00259 
00260        QString getDetailedDescription(Rules& r);
00261 
00262        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00263 
00264        bool isRelatedToActivity(Rules& r, Activity* a);
00265        
00266        bool isRelatedToTeacher(Teacher* t);
00267 
00268        bool isRelatedToSubject(Subject* s);
00269 
00270        bool isRelatedToActivityTag(ActivityTag* s);
00271        
00272        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00273 
00274        bool hasWrongDayOrHour(Rules& r);
00275        bool canRepairWrongDayOrHour(Rules& r);
00276        bool repairWrongDayOrHour(Rules& r);
00277 };
00278 
00279 class ConstraintTeacherNotAvailableTimes: public TimeConstraint{
00280        Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherNotAvailableTimes)
00281 
00282 public:
00283        QList<int> days;
00284        QList<int> hours;
00285 
00289        QString teacher;
00290 
00294        int teacher_ID;
00295 
00296        ConstraintTeacherNotAvailableTimes();
00297 
00298        ConstraintTeacherNotAvailableTimes(double wp, const QString& tn, QList<int> d, QList<int> h);
00299 
00300        bool computeInternalStructure(QWidget* parent, Rules& r);
00301 
00302        bool hasInactiveActivities(Rules& r);
00303 
00304        QString getXmlDescription(Rules& r);
00305 
00306        QString getDescription(Rules& r);
00307 
00308        QString getDetailedDescription(Rules& r);
00309 
00310        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00311 
00312        bool isRelatedToActivity(Rules& r, Activity* a);
00313        
00314        bool isRelatedToTeacher(Teacher* t);
00315 
00316        bool isRelatedToSubject(Subject* s);
00317 
00318        bool isRelatedToActivityTag(ActivityTag* s);
00319        
00320        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00321 
00322        bool hasWrongDayOrHour(Rules& r);
00323        bool canRepairWrongDayOrHour(Rules& r);
00324        bool repairWrongDayOrHour(Rules& r);
00325 };
00326 
00327 class ConstraintStudentsSetNotAvailableTimes: public TimeConstraint{
00328        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetNotAvailableTimes)
00329 
00330 public:
00331        QList<int> days;
00332        QList<int> hours;
00333 
00337        QString students;
00338 
00342        QList<int> iSubgroupsList;
00343 
00344        ConstraintStudentsSetNotAvailableTimes();
00345 
00346        ConstraintStudentsSetNotAvailableTimes(double wp, const QString& sn, QList<int> d, QList<int> h);
00347 
00348        bool computeInternalStructure(QWidget* parent, Rules& r);
00349 
00350        bool hasInactiveActivities(Rules& r);
00351 
00352        QString getXmlDescription(Rules& r);
00353 
00354        QString getDescription(Rules& r);
00355 
00356        QString getDetailedDescription(Rules& r);
00357 
00358        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00359 
00360        bool isRelatedToActivity(Rules& r, Activity* a);
00361        
00362        bool isRelatedToTeacher(Teacher* t);
00363 
00364        bool isRelatedToSubject(Subject* s);
00365 
00366        bool isRelatedToActivityTag(ActivityTag* s);
00367        
00368        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00369 
00370        bool hasWrongDayOrHour(Rules& r);
00371        bool canRepairWrongDayOrHour(Rules& r);
00372        bool repairWrongDayOrHour(Rules& r);
00373 };
00374 
00375 class ConstraintActivitiesSameStartingTime: public TimeConstraint{
00376        Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameStartingTime)
00377 
00378 public:
00382        int n_activities;
00383 
00387        QList<int> activitiesId;
00388        //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME];
00389 
00393        int _n_activities;
00394 
00398        //int _activities[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME];
00399        QList<int> _activities;
00400 
00401        ConstraintActivitiesSameStartingTime();
00402 
00407        //ConstraintActivitiesSameStartingTime(double wp, int n_act, const int act[]);
00408        ConstraintActivitiesSameStartingTime(double wp, int n_act, const QList<int>& act);
00409 
00410        bool computeInternalStructure(QWidget* parent, Rules& r);
00411 
00412        bool hasInactiveActivities(Rules& r);
00413 
00414        QString getXmlDescription(Rules& r);
00415 
00416        QString getDescription(Rules& r);
00417 
00418        QString getDetailedDescription(Rules& r);
00419 
00420        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00421 
00422        void removeUseless(Rules& r);
00423 
00424        bool isRelatedToActivity(Rules& r, Activity* a);
00425        
00426        bool isRelatedToTeacher(Teacher* t);
00427 
00428        bool isRelatedToSubject(Subject* s);
00429 
00430        bool isRelatedToActivityTag(ActivityTag* s);
00431        
00432        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00433 
00434        bool hasWrongDayOrHour(Rules& r);
00435        bool canRepairWrongDayOrHour(Rules& r);
00436        bool repairWrongDayOrHour(Rules& r);
00437 };
00438 
00445 class ConstraintActivitiesNotOverlapping: public TimeConstraint{
00446        Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesNotOverlapping)
00447 
00448 public:
00452        int n_activities;
00453 
00457        QList<int> activitiesId;
00458        //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING];
00459 
00463        int _n_activities;
00464 
00468        //int _activities[MAX_CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING];
00469        QList<int> _activities;
00470 
00471        ConstraintActivitiesNotOverlapping();
00472 
00477        ConstraintActivitiesNotOverlapping(double wp, int n_act, const QList<int>& act);
00478 
00479        bool computeInternalStructure(QWidget* parent, Rules& r);
00480 
00481        bool hasInactiveActivities(Rules& r);
00482 
00483        QString getXmlDescription(Rules& r);
00484 
00485        QString getDescription(Rules& r);
00486 
00487        QString getDetailedDescription(Rules& r);
00488 
00489        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00490 
00491        void removeUseless(Rules &r);
00492 
00493        bool isRelatedToActivity(Rules& r, Activity* a);
00494        
00495        bool isRelatedToTeacher(Teacher* t);
00496 
00497        bool isRelatedToSubject(Subject* s);
00498 
00499        bool isRelatedToActivityTag(ActivityTag* s);
00500        
00501        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00502 
00503        bool hasWrongDayOrHour(Rules& r);
00504        bool canRepairWrongDayOrHour(Rules& r);
00505        bool repairWrongDayOrHour(Rules& r);
00506 };
00507 
00513 class ConstraintMinDaysBetweenActivities: public TimeConstraint{
00514        Q_DECLARE_TR_FUNCTIONS(ConstraintMinDaysBetweenActivities)
00515 
00516 public:
00517        bool consecutiveIfSameDay;
00518 
00522        int n_activities;
00523 
00527        QList<int> activitiesId;
00528        //int activitiesId[MAX_CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES];
00529 
00533        int minDays;
00534 
00535        //internal structure (redundant)
00536 
00540        int _n_activities;
00541 
00545        QList<int> _activities;
00546        //int _activities[MAX_CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES];
00547 
00548        ConstraintMinDaysBetweenActivities();
00549 
00554        //ConstraintMinDaysBetweenActivities(double wp, bool adjacentIfBroken, int n_act, const int act[], int n);
00555        ConstraintMinDaysBetweenActivities(double wp, bool adjacentIfBroken, int n_act, const QList<int>& act, int n);
00556 
00560        bool operator==(ConstraintMinDaysBetweenActivities& c);
00561 
00562        bool computeInternalStructure(QWidget* parent, Rules& r);
00563 
00564        bool hasInactiveActivities(Rules& r);
00565 
00566        QString getXmlDescription(Rules& r);
00567 
00568        QString getDescription(Rules& r);
00569 
00570        QString getDetailedDescription(Rules& r);
00571 
00572        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00573 
00574        void removeUseless(Rules &r);
00575 
00576        bool isRelatedToActivity(Rules& r, Activity* a);
00577        
00578        bool isRelatedToTeacher(Teacher* t);
00579 
00580        bool isRelatedToSubject(Subject* s);
00581 
00582        bool isRelatedToActivityTag(ActivityTag* s);
00583        
00584        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00585 
00586        bool hasWrongDayOrHour(Rules& r);
00587        bool canRepairWrongDayOrHour(Rules& r);
00588        bool repairWrongDayOrHour(Rules& r);
00589 };
00590 
00591 class ConstraintMaxDaysBetweenActivities: public TimeConstraint{
00592        Q_DECLARE_TR_FUNCTIONS(ConstraintMaxDaysBetweenActivities)
00593 
00594 public:
00598        int n_activities;
00599 
00603        QList<int> activitiesId;
00604 
00608        int maxDays;
00609 
00610        //internal structure (redundant)
00611 
00615        int _n_activities;
00616 
00620        QList<int> _activities;
00621 
00622        ConstraintMaxDaysBetweenActivities();
00623 
00628        ConstraintMaxDaysBetweenActivities(double wp, int n_act, const QList<int>& act, int n);
00629 
00630        bool computeInternalStructure(QWidget* parent, Rules& r);
00631 
00632        bool hasInactiveActivities(Rules& r);
00633 
00634        QString getXmlDescription(Rules& r);
00635 
00636        QString getDescription(Rules& r);
00637 
00638        QString getDetailedDescription(Rules& r);
00639 
00640        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00641 
00642        void removeUseless(Rules &r);
00643 
00644        bool isRelatedToActivity(Rules& r, Activity* a);
00645        
00646        bool isRelatedToTeacher(Teacher* t);
00647 
00648        bool isRelatedToSubject(Subject* s);
00649 
00650        bool isRelatedToActivityTag(ActivityTag* s);
00651        
00652        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00653 
00654        bool hasWrongDayOrHour(Rules& r);
00655        bool canRepairWrongDayOrHour(Rules& r);
00656        bool repairWrongDayOrHour(Rules& r);
00657 };
00658 
00659 class ConstraintMinGapsBetweenActivities: public TimeConstraint{
00660        Q_DECLARE_TR_FUNCTIONS(ConstraintMinGapsBetweenActivities)
00661 
00662 public:
00666        int n_activities;
00667 
00671        QList<int> activitiesId;
00672 
00676        int minGaps;
00677 
00678        //internal structure (redundant)
00679 
00683        int _n_activities;
00684 
00688        QList<int> _activities;
00689 
00690        ConstraintMinGapsBetweenActivities();
00691 
00696        //ConstraintMinGapsBetweenActivities(double wp, int n_act, const int act[], int ngaps);
00697        ConstraintMinGapsBetweenActivities(double wp, int n_act, const QList<int>& actList, int ngaps);
00698 
00699        bool computeInternalStructure(QWidget* parent, Rules& r);
00700 
00701        bool hasInactiveActivities(Rules& r);
00702 
00703        QString getXmlDescription(Rules& r);
00704 
00705        QString getDescription(Rules& r);
00706 
00707        QString getDetailedDescription(Rules& r);
00708 
00709        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00710 
00711        void removeUseless(Rules &r);
00712 
00713        bool isRelatedToActivity(Rules& r, Activity* a);
00714        
00715        bool isRelatedToTeacher(Teacher* t);
00716 
00717        bool isRelatedToSubject(Subject* s);
00718 
00719        bool isRelatedToActivityTag(ActivityTag* s);
00720        
00721        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00722 
00723        bool hasWrongDayOrHour(Rules& r);
00724        bool canRepairWrongDayOrHour(Rules& r);
00725        bool repairWrongDayOrHour(Rules& r);
00726 };
00727 
00732 class ConstraintTeachersMaxHoursDaily: public TimeConstraint{
00733        Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxHoursDaily)
00734 
00735 public:
00739        int maxHoursDaily;
00740 
00741        ConstraintTeachersMaxHoursDaily();
00742 
00743        ConstraintTeachersMaxHoursDaily(double wp, int maxhours);
00744 
00745        QString getXmlDescription(Rules& r);
00746 
00747        bool computeInternalStructure(QWidget* parent, Rules& r);
00748 
00749        bool hasInactiveActivities(Rules& r);
00750 
00751        QString getDescription(Rules& r);
00752 
00753        QString getDetailedDescription(Rules& r);
00754 
00755        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00756 
00757        bool isRelatedToActivity(Rules& r, Activity* a);
00758        
00759        bool isRelatedToTeacher(Teacher* t);
00760 
00761        bool isRelatedToSubject(Subject* s);
00762 
00763        bool isRelatedToActivityTag(ActivityTag* s);
00764        
00765        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00766 
00767        bool hasWrongDayOrHour(Rules& r);
00768        bool canRepairWrongDayOrHour(Rules& r);
00769        bool repairWrongDayOrHour(Rules& r);
00770 };
00771 
00772 class ConstraintTeacherMaxHoursDaily: public TimeConstraint{
00773        Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxHoursDaily)
00774 
00775 public:
00779        int maxHoursDaily;
00780        
00781        QString teacherName;
00782        
00783        int teacher_ID;
00784 
00785        ConstraintTeacherMaxHoursDaily();
00786 
00787        ConstraintTeacherMaxHoursDaily(double wp, int maxhours, const QString& teacher);
00788 
00789        QString getXmlDescription(Rules& r);
00790 
00791        bool computeInternalStructure(QWidget* parent, Rules& r);
00792 
00793        bool hasInactiveActivities(Rules& r);
00794 
00795        QString getDescription(Rules& r);
00796 
00797        QString getDetailedDescription(Rules& r);
00798 
00799        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00800 
00801        bool isRelatedToActivity(Rules& r, Activity* a);
00802        
00803        bool isRelatedToTeacher(Teacher* t);
00804 
00805        bool isRelatedToSubject(Subject* s);
00806 
00807        bool isRelatedToActivityTag(ActivityTag* s);
00808        
00809        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00810 
00811        bool hasWrongDayOrHour(Rules& r);
00812        bool canRepairWrongDayOrHour(Rules& r);
00813        bool repairWrongDayOrHour(Rules& r);
00814 };
00815 
00820 class ConstraintTeachersMaxHoursContinuously: public TimeConstraint{
00821        Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxHoursContinuously)
00822 
00823 public:
00827        int maxHoursContinuously;
00828 
00829        ConstraintTeachersMaxHoursContinuously();
00830 
00831        ConstraintTeachersMaxHoursContinuously(double wp, int maxhours);
00832 
00833        QString getXmlDescription(Rules& r);
00834 
00835        bool computeInternalStructure(QWidget* parent, Rules& r);
00836 
00837        bool hasInactiveActivities(Rules& r);
00838 
00839        QString getDescription(Rules& r);
00840 
00841        QString getDetailedDescription(Rules& r);
00842 
00843        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00844 
00845        bool isRelatedToActivity(Rules& r, Activity* a);
00846        
00847        bool isRelatedToTeacher(Teacher* t);
00848 
00849        bool isRelatedToSubject(Subject* s);
00850 
00851        bool isRelatedToActivityTag(ActivityTag* s);
00852        
00853        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00854 
00855        bool hasWrongDayOrHour(Rules& r);
00856        bool canRepairWrongDayOrHour(Rules& r);
00857        bool repairWrongDayOrHour(Rules& r);
00858 };
00859 
00860 class ConstraintTeacherMaxHoursContinuously: public TimeConstraint{
00861        Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxHoursContinuously)
00862 
00863 public:
00867        int maxHoursContinuously;
00868        
00869        QString teacherName;
00870        
00871        int teacher_ID;
00872 
00873        ConstraintTeacherMaxHoursContinuously();
00874 
00875        ConstraintTeacherMaxHoursContinuously(double wp, int maxhours, const QString& teacher);
00876 
00877        QString getXmlDescription(Rules& r);
00878 
00879        bool computeInternalStructure(QWidget* parent, Rules& r);
00880 
00881        bool hasInactiveActivities(Rules& r);
00882 
00883        QString getDescription(Rules& r);
00884 
00885        QString getDetailedDescription(Rules& r);
00886 
00887        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00888 
00889        bool isRelatedToActivity(Rules& r, Activity* a);
00890        
00891        bool isRelatedToTeacher(Teacher* t);
00892 
00893        bool isRelatedToSubject(Subject* s);
00894 
00895        bool isRelatedToActivityTag(ActivityTag* s);
00896        
00897        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00898 
00899        bool hasWrongDayOrHour(Rules& r);
00900        bool canRepairWrongDayOrHour(Rules& r);
00901        bool repairWrongDayOrHour(Rules& r);
00902 };
00903 
00904 class ConstraintTeachersActivityTagMaxHoursContinuously: public TimeConstraint{
00905        Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMaxHoursContinuously)
00906 
00907 public:
00911        int maxHoursContinuously;
00912        
00913        QString activityTagName;
00914        
00915        int activityTagIndex;
00916        
00917        QList<int> canonicalTeachersList;
00918 
00919        ConstraintTeachersActivityTagMaxHoursContinuously();
00920 
00921        ConstraintTeachersActivityTagMaxHoursContinuously(double wp, int maxhours, const QString& activityTag);
00922 
00923        QString getXmlDescription(Rules& r);
00924 
00925        bool computeInternalStructure(QWidget* parent, Rules& r);
00926 
00927        bool hasInactiveActivities(Rules& r);
00928 
00929        QString getDescription(Rules& r);
00930 
00931        QString getDetailedDescription(Rules& r);
00932 
00933        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00934 
00935        bool isRelatedToActivity(Rules& r, Activity* a);
00936        
00937        bool isRelatedToTeacher(Teacher* t);
00938 
00939        bool isRelatedToSubject(Subject* s);
00940 
00941        bool isRelatedToActivityTag(ActivityTag* s);
00942        
00943        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00944 
00945        bool hasWrongDayOrHour(Rules& r);
00946        bool canRepairWrongDayOrHour(Rules& r);
00947        bool repairWrongDayOrHour(Rules& r);
00948 };
00949 
00950 class ConstraintTeacherActivityTagMaxHoursContinuously: public TimeConstraint{
00951        Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMaxHoursContinuously)
00952 
00953 public:
00957        int maxHoursContinuously;
00958        
00959        QString teacherName;
00960        
00961        QString activityTagName;
00962        
00963        int teacher_ID;
00964 
00965        int activityTagIndex;
00966        
00967        QList<int> canonicalTeachersList;
00968 
00969        ConstraintTeacherActivityTagMaxHoursContinuously();
00970 
00971        ConstraintTeacherActivityTagMaxHoursContinuously(double wp, int maxhours, const QString& teacher, const QString& activityTag);
00972 
00973        QString getXmlDescription(Rules& r);
00974 
00975        bool computeInternalStructure(QWidget* parent, Rules& r);
00976 
00977        bool hasInactiveActivities(Rules& r);
00978 
00979        QString getDescription(Rules& r);
00980 
00981        QString getDetailedDescription(Rules& r);
00982 
00983        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
00984 
00985        bool isRelatedToActivity(Rules& r, Activity* a);
00986        
00987        bool isRelatedToTeacher(Teacher* t);
00988 
00989        bool isRelatedToSubject(Subject* s);
00990 
00991        bool isRelatedToActivityTag(ActivityTag* s);
00992        
00993        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
00994 
00995        bool hasWrongDayOrHour(Rules& r);
00996        bool canRepairWrongDayOrHour(Rules& r);
00997        bool repairWrongDayOrHour(Rules& r);
00998 };
00999 
01006 class ConstraintTeacherMaxDaysPerWeek: public TimeConstraint{
01007        Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxDaysPerWeek)
01008 
01009 public:
01013        int maxDaysPerWeek;
01014 
01018        QString teacherName;
01019 
01023        int teacher_ID;
01024 
01025        ConstraintTeacherMaxDaysPerWeek();
01026 
01027        ConstraintTeacherMaxDaysPerWeek(double wp, int maxnd, QString t);
01028 
01029        bool computeInternalStructure(QWidget* parent, Rules& r);
01030 
01031        bool hasInactiveActivities(Rules& r);
01032 
01033        QString getXmlDescription(Rules& r);
01034 
01035        QString getDescription(Rules& r);
01036 
01037        QString getDetailedDescription(Rules& r);
01038 
01039        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01040 
01041        bool isRelatedToActivity(Rules& r, Activity* a);
01042        
01043        bool isRelatedToTeacher(Teacher* t);
01044 
01045        bool isRelatedToSubject(Subject* s);
01046 
01047        bool isRelatedToActivityTag(ActivityTag* s);
01048        
01049        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01050 
01051        bool hasWrongDayOrHour(Rules& r);
01052        bool canRepairWrongDayOrHour(Rules& r);
01053        bool repairWrongDayOrHour(Rules& r);
01054 };
01055 
01056 class ConstraintTeachersMaxDaysPerWeek: public TimeConstraint{
01057        Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxDaysPerWeek)
01058 
01059 public:
01063        int maxDaysPerWeek;
01064 
01065        ConstraintTeachersMaxDaysPerWeek();
01066 
01067        ConstraintTeachersMaxDaysPerWeek(double wp, int maxnd);
01068 
01069        bool computeInternalStructure(QWidget* parent, Rules& r);
01070 
01071        bool hasInactiveActivities(Rules& r);
01072 
01073        QString getXmlDescription(Rules& r);
01074 
01075        QString getDescription(Rules& r);
01076 
01077        QString getDetailedDescription(Rules& r);
01078 
01079        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01080 
01081        bool isRelatedToActivity(Rules& r, Activity* a);
01082        
01083        bool isRelatedToTeacher(Teacher* t);
01084 
01085        bool isRelatedToSubject(Subject* s);
01086 
01087        bool isRelatedToActivityTag(ActivityTag* s);
01088        
01089        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01090 
01091        bool hasWrongDayOrHour(Rules& r);
01092        bool canRepairWrongDayOrHour(Rules& r);
01093        bool repairWrongDayOrHour(Rules& r);
01094 };
01095 
01096 class ConstraintTeacherMinDaysPerWeek: public TimeConstraint{
01097        Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinDaysPerWeek)
01098 
01099 public:
01100        int minDaysPerWeek;
01101 
01105        QString teacherName;
01106 
01110        int teacher_ID;
01111 
01112        ConstraintTeacherMinDaysPerWeek();
01113 
01114        ConstraintTeacherMinDaysPerWeek(double wp, int mindays, const QString& t);
01115 
01116        bool computeInternalStructure(QWidget* parent, Rules& r);
01117 
01118        bool hasInactiveActivities(Rules& r);
01119 
01120        QString getXmlDescription(Rules& r);
01121 
01122        QString getDescription(Rules& r);
01123 
01124        QString getDetailedDescription(Rules& r);
01125 
01126        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01127 
01128        bool isRelatedToActivity(Rules& r, Activity* a);
01129        
01130        bool isRelatedToTeacher(Teacher* t);
01131 
01132        bool isRelatedToSubject(Subject* s);
01133 
01134        bool isRelatedToActivityTag(ActivityTag* s);
01135        
01136        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01137 
01138        bool hasWrongDayOrHour(Rules& r);
01139        bool canRepairWrongDayOrHour(Rules& r);
01140        bool repairWrongDayOrHour(Rules& r);
01141 };
01142 
01143 class ConstraintTeachersMinDaysPerWeek: public TimeConstraint{
01144        Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinDaysPerWeek)
01145 
01146 public:
01147        int minDaysPerWeek;
01148 
01149        ConstraintTeachersMinDaysPerWeek();
01150 
01151        ConstraintTeachersMinDaysPerWeek(double wp, int mindays);
01152 
01153        bool computeInternalStructure(QWidget* parent, Rules& r);
01154 
01155        bool hasInactiveActivities(Rules& r);
01156 
01157        QString getXmlDescription(Rules& r);
01158 
01159        QString getDescription(Rules& r);
01160 
01161        QString getDetailedDescription(Rules& r);
01162 
01163        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01164 
01165        bool isRelatedToActivity(Rules& r, Activity* a);
01166        
01167        bool isRelatedToTeacher(Teacher* t);
01168 
01169        bool isRelatedToSubject(Subject* s);
01170 
01171        bool isRelatedToActivityTag(ActivityTag* s);
01172        
01173        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01174 
01175        bool hasWrongDayOrHour(Rules& r);
01176        bool canRepairWrongDayOrHour(Rules& r);
01177        bool repairWrongDayOrHour(Rules& r);
01178 };
01179 
01185 class ConstraintBreakTimes: public TimeConstraint{
01186        Q_DECLARE_TR_FUNCTIONS(ConstraintBreakTimes)
01187 
01188 public:
01189        QList<int> days;
01190        QList<int> hours;
01191 
01192        ConstraintBreakTimes();
01193 
01194        ConstraintBreakTimes(double wp, QList<int> d, QList<int> h);
01195 
01196        bool computeInternalStructure(QWidget* parent, Rules& r);
01197 
01198        bool hasInactiveActivities(Rules& r);
01199 
01200        QString getXmlDescription(Rules& r);
01201 
01202        QString getDescription(Rules& r);
01203 
01204        QString getDetailedDescription(Rules& r);
01205 
01206        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01207 
01208        bool isRelatedToActivity(Rules& r, Activity* a);
01209        
01210        bool isRelatedToTeacher(Teacher* t);
01211 
01212        bool isRelatedToSubject(Subject* s);
01213 
01214        bool isRelatedToActivityTag(ActivityTag* s);
01215        
01216        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01217 
01218        bool hasWrongDayOrHour(Rules& r);
01219        bool canRepairWrongDayOrHour(Rules& r);
01220        bool repairWrongDayOrHour(Rules& r);
01221 };
01222 
01229 class ConstraintStudentsMaxGapsPerWeek: public TimeConstraint{
01230        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxGapsPerWeek)
01231 
01232 public:
01233        int maxGaps;
01234 
01235        ConstraintStudentsMaxGapsPerWeek();
01236 
01237        ConstraintStudentsMaxGapsPerWeek(double wp, int mg);
01238 
01239        bool computeInternalStructure(QWidget* parent, Rules& r);
01240 
01241        bool hasInactiveActivities(Rules& r);
01242 
01243        QString getXmlDescription(Rules& r);
01244 
01245        QString getDescription(Rules& r);
01246 
01247        QString getDetailedDescription(Rules& r);
01248 
01249        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01250 
01251        bool isRelatedToActivity(Rules& r, Activity* a);
01252        
01253        bool isRelatedToTeacher(Teacher* t);
01254 
01255        bool isRelatedToSubject(Subject* s);
01256 
01257        bool isRelatedToActivityTag(ActivityTag* s);
01258        
01259        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01260 
01261        bool hasWrongDayOrHour(Rules& r);
01262        bool canRepairWrongDayOrHour(Rules& r);
01263        bool repairWrongDayOrHour(Rules& r);
01264 };
01265 
01271 class ConstraintStudentsSetMaxGapsPerWeek: public TimeConstraint{
01272        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxGapsPerWeek)
01273 
01274 public:
01275        int maxGaps;
01276 
01280        QString students;
01281 
01282        //internal redundant data
01283 
01287        //int nSubgroups;
01288 
01292        QList<int> iSubgroupsList;
01293 
01294        ConstraintStudentsSetMaxGapsPerWeek();
01295 
01296        ConstraintStudentsSetMaxGapsPerWeek(double wp, int mg, const QString& st );
01297 
01298        bool computeInternalStructure(QWidget* parent, Rules& r);
01299 
01300        bool hasInactiveActivities(Rules& r);
01301 
01302        QString getXmlDescription(Rules& r);
01303 
01304        QString getDescription(Rules& r);
01305 
01306        QString getDetailedDescription(Rules& r);
01307 
01308        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01309 
01310        bool isRelatedToActivity(Rules& r, Activity* a);
01311        
01312        bool isRelatedToTeacher(Teacher* t);
01313 
01314        bool isRelatedToSubject(Subject* s);
01315 
01316        bool isRelatedToActivityTag(ActivityTag* s);
01317        
01318        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01319 
01320        bool hasWrongDayOrHour(Rules& r);
01321        bool canRepairWrongDayOrHour(Rules& r);
01322        bool repairWrongDayOrHour(Rules& r);
01323 };
01324 
01325 class ConstraintTeachersMaxGapsPerWeek: public TimeConstraint{
01326        Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerWeek)
01327 
01328 public:
01329        int maxGaps;  
01330 
01331        ConstraintTeachersMaxGapsPerWeek();
01332 
01333        ConstraintTeachersMaxGapsPerWeek(double wp, int maxGaps);
01334 
01335        bool computeInternalStructure(QWidget* parent, Rules& r);
01336 
01337        bool hasInactiveActivities(Rules& r);
01338 
01339        QString getXmlDescription(Rules& r);
01340 
01341        QString getDescription(Rules& r);
01342 
01343        QString getDetailedDescription(Rules& r);
01344 
01345        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01346 
01347        bool isRelatedToActivity(Rules& r, Activity* a);
01348        
01349        bool isRelatedToTeacher(Teacher* t);
01350 
01351        bool isRelatedToSubject(Subject* s);
01352 
01353        bool isRelatedToActivityTag(ActivityTag* s);
01354        
01355        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01356 
01357        bool hasWrongDayOrHour(Rules& r);
01358        bool canRepairWrongDayOrHour(Rules& r);
01359        bool repairWrongDayOrHour(Rules& r);
01360 };
01361 
01362 class ConstraintTeacherMaxGapsPerWeek: public TimeConstraint{
01363        Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerWeek)
01364 
01365 public:
01366        int maxGaps;
01367        
01368        QString teacherName;
01369        
01370        int teacherIndex;
01371 
01372        ConstraintTeacherMaxGapsPerWeek();
01373 
01374        ConstraintTeacherMaxGapsPerWeek(double wp, QString tn, int maxGaps);
01375 
01376        bool computeInternalStructure(QWidget* parent, Rules& r);
01377 
01378        bool hasInactiveActivities(Rules& r);
01379 
01380        QString getXmlDescription(Rules& r);
01381 
01382        QString getDescription(Rules& r);
01383 
01384        QString getDetailedDescription(Rules& r);
01385 
01386        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01387 
01388        bool isRelatedToActivity(Rules& r, Activity* a);
01389        
01390        bool isRelatedToTeacher(Teacher* t);
01391 
01392        bool isRelatedToSubject(Subject* s);
01393 
01394        bool isRelatedToActivityTag(ActivityTag* s);
01395        
01396        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01397 
01398        bool hasWrongDayOrHour(Rules& r);
01399        bool canRepairWrongDayOrHour(Rules& r);
01400        bool repairWrongDayOrHour(Rules& r);
01401 };
01402 
01403 class ConstraintTeachersMaxGapsPerDay: public TimeConstraint{
01404        Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerDay)
01405 
01406 public:
01407        int maxGaps;  
01408 
01409        ConstraintTeachersMaxGapsPerDay();
01410 
01411        ConstraintTeachersMaxGapsPerDay(double wp, int maxGaps);
01412 
01413        bool computeInternalStructure(QWidget* parent, Rules& r);
01414 
01415        bool hasInactiveActivities(Rules& r);
01416 
01417        QString getXmlDescription(Rules& r);
01418 
01419        QString getDescription(Rules& r);
01420 
01421        QString getDetailedDescription(Rules& r);
01422 
01423        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01424 
01425        bool isRelatedToActivity(Rules& r, Activity* a);
01426        
01427        bool isRelatedToTeacher(Teacher* t);
01428 
01429        bool isRelatedToSubject(Subject* s);
01430 
01431        bool isRelatedToActivityTag(ActivityTag* s);
01432        
01433        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01434 
01435        bool hasWrongDayOrHour(Rules& r);
01436        bool canRepairWrongDayOrHour(Rules& r);
01437        bool repairWrongDayOrHour(Rules& r);
01438 };
01439 
01440 class ConstraintTeacherMaxGapsPerDay: public TimeConstraint{
01441        Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerDay)
01442 
01443 public:
01444        int maxGaps;
01445        
01446        QString teacherName;
01447        
01448        int teacherIndex;
01449 
01450        ConstraintTeacherMaxGapsPerDay();
01451 
01452        ConstraintTeacherMaxGapsPerDay(double wp, QString tn, int maxGaps);
01453 
01454        bool computeInternalStructure(QWidget* parent, Rules& r);
01455 
01456        bool hasInactiveActivities(Rules& r);
01457 
01458        QString getXmlDescription(Rules& r);
01459 
01460        QString getDescription(Rules& r);
01461 
01462        QString getDetailedDescription(Rules& r);
01463 
01464        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01465 
01466        bool isRelatedToActivity(Rules& r, Activity* a);
01467        
01468        bool isRelatedToTeacher(Teacher* t);
01469 
01470        bool isRelatedToSubject(Subject* s);
01471 
01472        bool isRelatedToActivityTag(ActivityTag* s);
01473        
01474        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01475 
01476        bool hasWrongDayOrHour(Rules& r);
01477        bool canRepairWrongDayOrHour(Rules& r);
01478        bool repairWrongDayOrHour(Rules& r);
01479 };
01480 
01489 class ConstraintStudentsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{
01490        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsEarlyMaxBeginningsAtSecondHour)
01491 
01492 public:
01493 
01494        int maxBeginningsAtSecondHour;
01495 
01496        ConstraintStudentsEarlyMaxBeginningsAtSecondHour();
01497 
01498        ConstraintStudentsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH);
01499 
01500        bool computeInternalStructure(QWidget* parent, Rules& r);
01501 
01502        bool hasInactiveActivities(Rules& r);
01503 
01504        QString getXmlDescription(Rules& r);
01505 
01506        QString getDescription(Rules& r);
01507 
01508        QString getDetailedDescription(Rules& r);
01509 
01510        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01511 
01512        bool isRelatedToActivity(Rules& r, Activity* a);
01513        
01514        bool isRelatedToTeacher(Teacher* t);
01515 
01516        bool isRelatedToSubject(Subject* s);
01517 
01518        bool isRelatedToActivityTag(ActivityTag* s);
01519        
01520        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01521 
01522        bool hasWrongDayOrHour(Rules& r);
01523        bool canRepairWrongDayOrHour(Rules& r);
01524        bool repairWrongDayOrHour(Rules& r);
01525 };
01526 
01527 class ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour: public TimeConstraint{
01528        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour)
01529 
01530 public:
01531        int maxBeginningsAtSecondHour;
01532 
01536        QString students;
01537 
01541        //int nSubgroups;
01542 
01546        //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
01547        QList<int> iSubgroupsList;
01548 
01549        ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour();
01550 
01551        ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour(double wp, int mBSH, const QString& students);
01552 
01553        bool computeInternalStructure(QWidget* parent, Rules& r);
01554 
01555        bool hasInactiveActivities(Rules& r);
01556 
01557        QString getXmlDescription(Rules& r);
01558 
01559        QString getDescription(Rules& r);
01560 
01561        QString getDetailedDescription(Rules& r);
01562 
01563        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01564 
01565        bool isRelatedToActivity(Rules& r, Activity* a);
01566        
01567        bool isRelatedToTeacher(Teacher* t);
01568 
01569        bool isRelatedToSubject(Subject* s);
01570 
01571        bool isRelatedToActivityTag(ActivityTag* s);
01572        
01573        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01574 
01575        bool hasWrongDayOrHour(Rules& r);
01576        bool canRepairWrongDayOrHour(Rules& r);
01577        bool repairWrongDayOrHour(Rules& r);
01578 };
01579 
01580 class ConstraintStudentsMaxHoursDaily: public TimeConstraint{
01581        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxHoursDaily)
01582 
01583 public:
01584        int maxHoursDaily;
01585 
01586        ConstraintStudentsMaxHoursDaily();
01587 
01588        ConstraintStudentsMaxHoursDaily(double wp, int maxnh);
01589 
01590        bool computeInternalStructure(QWidget* parent, Rules& r);
01591 
01592        bool hasInactiveActivities(Rules& r);
01593 
01594        QString getXmlDescription(Rules& r);
01595 
01596        QString getDescription(Rules& r);
01597 
01598        QString getDetailedDescription(Rules& r);
01599 
01600        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01601 
01602        bool isRelatedToActivity(Rules& r, Activity* a);
01603        
01604        bool isRelatedToTeacher(Teacher* t);
01605 
01606        bool isRelatedToSubject(Subject* s);
01607 
01608        bool isRelatedToActivityTag(ActivityTag* s);
01609        
01610        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01611 
01612        bool hasWrongDayOrHour(Rules& r);
01613        bool canRepairWrongDayOrHour(Rules& r);
01614        bool repairWrongDayOrHour(Rules& r);
01615 };
01616 
01617 class ConstraintStudentsSetMaxHoursDaily: public TimeConstraint{
01618        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxHoursDaily)
01619 
01620 public:
01621        int maxHoursDaily;
01622 
01626        QString students;
01627 
01628        //internal variables
01629 
01633        //int nSubgroups;
01634 
01638        //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
01639        QList<int> iSubgroupsList;
01640 
01641        ConstraintStudentsSetMaxHoursDaily();
01642 
01643        ConstraintStudentsSetMaxHoursDaily(double wp, int maxnh, QString s);
01644 
01645        bool computeInternalStructure(QWidget* parent, Rules& r);
01646 
01647        bool hasInactiveActivities(Rules& r);
01648 
01649        QString getXmlDescription(Rules& r);
01650 
01651        QString getDescription(Rules& r);
01652 
01653        QString getDetailedDescription(Rules& r);
01654 
01655        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01656 
01657        bool isRelatedToActivity(Rules& r, Activity* a);
01658        
01659        bool isRelatedToTeacher(Teacher* t);
01660 
01661        bool isRelatedToSubject(Subject* s);
01662 
01663        bool isRelatedToActivityTag(ActivityTag* s);
01664        
01665        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01666 
01667        bool hasWrongDayOrHour(Rules& r);
01668        bool canRepairWrongDayOrHour(Rules& r);
01669        bool repairWrongDayOrHour(Rules& r);
01670 };
01671 
01672 class ConstraintStudentsMaxHoursContinuously: public TimeConstraint{
01673        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxHoursContinuously)
01674 
01675 public:
01676        int maxHoursContinuously;
01677 
01678        ConstraintStudentsMaxHoursContinuously();
01679 
01680        ConstraintStudentsMaxHoursContinuously(double wp, int maxnh);
01681 
01682        bool computeInternalStructure(QWidget* parent, Rules& r);
01683 
01684        bool hasInactiveActivities(Rules& r);
01685 
01686        QString getXmlDescription(Rules& r);
01687 
01688        QString getDescription(Rules& r);
01689 
01690        QString getDetailedDescription(Rules& r);
01691 
01692        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01693 
01694        bool isRelatedToActivity(Rules& r, Activity* a);
01695        
01696        bool isRelatedToTeacher(Teacher* t);
01697 
01698        bool isRelatedToSubject(Subject* s);
01699 
01700        bool isRelatedToActivityTag(ActivityTag* s);
01701        
01702        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01703 
01704        bool hasWrongDayOrHour(Rules& r);
01705        bool canRepairWrongDayOrHour(Rules& r);
01706        bool repairWrongDayOrHour(Rules& r);
01707 };
01708 
01709 class ConstraintStudentsSetMaxHoursContinuously: public TimeConstraint{
01710        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxHoursContinuously)
01711 
01712 public:
01713        int maxHoursContinuously;
01714 
01718        QString students;
01719 
01720        //internal variables
01721 
01725        //int nSubgroups;
01726 
01730        //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
01731        QList<int> iSubgroupsList;
01732 
01733        ConstraintStudentsSetMaxHoursContinuously();
01734 
01735        ConstraintStudentsSetMaxHoursContinuously(double wp, int maxnh, QString s);
01736 
01737        bool computeInternalStructure(QWidget* parent, Rules& r);
01738 
01739        bool hasInactiveActivities(Rules& r);
01740 
01741        QString getXmlDescription(Rules& r);
01742 
01743        QString getDescription(Rules& r);
01744 
01745        QString getDetailedDescription(Rules& r);
01746 
01747        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01748 
01749        bool isRelatedToActivity(Rules& r, Activity* a);
01750        
01751        bool isRelatedToTeacher(Teacher* t);
01752 
01753        bool isRelatedToSubject(Subject* s);
01754 
01755        bool isRelatedToActivityTag(ActivityTag* s);
01756        
01757        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01758 
01759        bool hasWrongDayOrHour(Rules& r);
01760        bool canRepairWrongDayOrHour(Rules& r);
01761        bool repairWrongDayOrHour(Rules& r);
01762 };
01763 
01764 class ConstraintStudentsActivityTagMaxHoursContinuously: public TimeConstraint{
01765        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMaxHoursContinuously)
01766 
01767 public:
01768        int maxHoursContinuously;
01769        
01770        QString activityTagName;
01771        
01772        int activityTagIndex;
01773        
01774        QList<int> canonicalSubgroupsList;
01775 
01776        ConstraintStudentsActivityTagMaxHoursContinuously();
01777 
01778        ConstraintStudentsActivityTagMaxHoursContinuously(double wp, int maxnh, const QString& activityTag);
01779 
01780        bool computeInternalStructure(QWidget* parent, Rules& r);
01781 
01782        bool hasInactiveActivities(Rules& r);
01783 
01784        QString getXmlDescription(Rules& r);
01785 
01786        QString getDescription(Rules& r);
01787 
01788        QString getDetailedDescription(Rules& r);
01789 
01790        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01791 
01792        bool isRelatedToActivity(Rules& r, Activity* a);
01793        
01794        bool isRelatedToTeacher(Teacher* t);
01795 
01796        bool isRelatedToSubject(Subject* s);
01797 
01798        bool isRelatedToActivityTag(ActivityTag* s);
01799        
01800        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01801 
01802        bool hasWrongDayOrHour(Rules& r);
01803        bool canRepairWrongDayOrHour(Rules& r);
01804        bool repairWrongDayOrHour(Rules& r);
01805 };
01806 
01807 class ConstraintStudentsSetActivityTagMaxHoursContinuously: public TimeConstraint{
01808        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMaxHoursContinuously)
01809 
01810 public:
01811        int maxHoursContinuously;
01812 
01816        QString students;
01817        
01818        QString activityTagName;
01819 
01820        //internal variables
01821        
01822        int activityTagIndex;
01823 
01827        //int nSubgroups;
01828 
01832        //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
01833        QList<int> iSubgroupsList;
01834        
01835        QList<int> canonicalSubgroupsList;
01836 
01837        ConstraintStudentsSetActivityTagMaxHoursContinuously();
01838 
01839        ConstraintStudentsSetActivityTagMaxHoursContinuously(double wp, int maxnh, const QString& s, const QString& activityTag);
01840 
01841        bool computeInternalStructure(QWidget* parent, Rules& r);
01842 
01843        bool hasInactiveActivities(Rules& r);
01844 
01845        QString getXmlDescription(Rules& r);
01846 
01847        QString getDescription(Rules& r);
01848 
01849        QString getDetailedDescription(Rules& r);
01850 
01851        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01852 
01853        bool isRelatedToActivity(Rules& r, Activity* a);
01854        
01855        bool isRelatedToTeacher(Teacher* t);
01856 
01857        bool isRelatedToSubject(Subject* s);
01858 
01859        bool isRelatedToActivityTag(ActivityTag* s);
01860        
01861        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01862 
01863        bool hasWrongDayOrHour(Rules& r);
01864        bool canRepairWrongDayOrHour(Rules& r);
01865        bool repairWrongDayOrHour(Rules& r);
01866 };
01867 
01868 class ConstraintStudentsMinHoursDaily: public TimeConstraint{
01869        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinHoursDaily)
01870 
01871 public:
01872        int minHoursDaily;
01873        
01874        bool allowEmptyDays;
01875 
01876        ConstraintStudentsMinHoursDaily();
01877 
01878        ConstraintStudentsMinHoursDaily(double wp, int minnh, bool _allowEmptyDays);
01879 
01880        bool computeInternalStructure(QWidget* parent, Rules& r);
01881 
01882        bool hasInactiveActivities(Rules& r);
01883 
01884        QString getXmlDescription(Rules& r);
01885 
01886        QString getDescription(Rules& r);
01887 
01888        QString getDetailedDescription(Rules& r);
01889 
01890        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01891 
01892        bool isRelatedToActivity(Rules& r, Activity* a);
01893        
01894        bool isRelatedToTeacher(Teacher* t);
01895 
01896        bool isRelatedToSubject(Subject* s);
01897 
01898        bool isRelatedToActivityTag(ActivityTag* s);
01899        
01900        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01901 
01902        bool hasWrongDayOrHour(Rules& r);
01903        bool canRepairWrongDayOrHour(Rules& r);
01904        bool repairWrongDayOrHour(Rules& r);
01905 };
01906 
01907 class ConstraintStudentsSetMinHoursDaily: public TimeConstraint{
01908        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinHoursDaily)
01909 
01910 public:
01911        int minHoursDaily;
01912 
01916        QString students;
01917        
01918        bool allowEmptyDays;
01919 
01920        //internal variables
01921 
01925        //int nSubgroups;
01926 
01930        //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
01931        QList<int> iSubgroupsList;
01932 
01933        ConstraintStudentsSetMinHoursDaily();
01934 
01935        ConstraintStudentsSetMinHoursDaily(double wp, int minnh, QString s, bool _allowEmptyDays);
01936 
01937        bool computeInternalStructure(QWidget* parent, Rules& r);
01938 
01939        bool hasInactiveActivities(Rules& r);
01940 
01941        QString getXmlDescription(Rules& r);
01942 
01943        QString getDescription(Rules& r);
01944 
01945        QString getDetailedDescription(Rules& r);
01946 
01947        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
01948 
01949        bool isRelatedToActivity(Rules& r, Activity* a);
01950        
01951        bool isRelatedToTeacher(Teacher* t);
01952 
01953        bool isRelatedToSubject(Subject* s);
01954 
01955        bool isRelatedToActivityTag(ActivityTag* s);
01956        
01957        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
01958 
01959        bool hasWrongDayOrHour(Rules& r);
01960        bool canRepairWrongDayOrHour(Rules& r);
01961        bool repairWrongDayOrHour(Rules& r);
01962 };
01963 
01971 class ConstraintActivityPreferredStartingTime: public TimeConstraint{
01972        Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredStartingTime)
01973 
01974 public:
01978        int activityId;
01979 
01983        int day;
01984 
01988        int hour;
01989 
01990        bool permanentlyLocked; //if this is true, then this activity cannot be unlocked from the timetable view form
01991 
01992        //internal variables
01996        int activityIndex;
01997        
01998        ConstraintActivityPreferredStartingTime();
01999 
02000        ConstraintActivityPreferredStartingTime(double wp, int actId, int d, int h, bool perm);
02001 
02005        bool operator==(ConstraintActivityPreferredStartingTime& c);
02006 
02007        bool computeInternalStructure(QWidget* parent, Rules& r);
02008 
02009        bool hasInactiveActivities(Rules& r);
02010 
02011        QString getXmlDescription(Rules& r);
02012 
02013        QString getDescription(Rules& r);
02014 
02015        QString getDetailedDescription(Rules& r);
02016 
02017        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02018 
02019        bool isRelatedToActivity(Rules& r, Activity* a);
02020        
02021        bool isRelatedToTeacher(Teacher* t);
02022 
02023        bool isRelatedToSubject(Subject* s);
02024 
02025        bool isRelatedToActivityTag(ActivityTag* s);
02026        
02027        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02028 
02029        bool hasWrongDayOrHour(Rules& r);
02030        bool canRepairWrongDayOrHour(Rules& r);
02031        bool repairWrongDayOrHour(Rules& r);
02032 };
02033 
02039 class ConstraintActivityPreferredTimeSlots: public TimeConstraint{
02040        Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredTimeSlots)
02041 
02042 public:
02046        int p_activityId;
02047 
02051        int p_nPreferredTimeSlots_L;
02052 
02056        //int p_days[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS];
02057        QList<int> p_days_L;
02058 
02062        //int p_hours[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS];
02063        QList<int> p_hours_L;
02064 
02065        //internal variables
02069        int p_activityIndex;
02070 
02071        ConstraintActivityPreferredTimeSlots();
02072 
02073        //ConstraintActivityPreferredTimeSlots(double wp, int actId, int nPT, int d[], int h[]);
02074        ConstraintActivityPreferredTimeSlots(double wp, int actId, int nPT_L, QList<int> d_L, QList<int> h_L);
02075 
02076        bool computeInternalStructure(QWidget* parent, Rules& r);
02077 
02078        bool hasInactiveActivities(Rules& r);
02079 
02080        QString getXmlDescription(Rules& r);
02081 
02082        QString getDescription(Rules& r);
02083 
02084        QString getDetailedDescription(Rules& r);
02085 
02086        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02087 
02088        bool isRelatedToActivity(Rules& r, Activity* a);
02089        
02090        bool isRelatedToTeacher(Teacher* t);
02091 
02092        bool isRelatedToSubject(Subject* s);
02093 
02094        bool isRelatedToActivityTag(ActivityTag* s);
02095        
02096        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02097 
02098        bool hasWrongDayOrHour(Rules& r);
02099        bool canRepairWrongDayOrHour(Rules& r);
02100        bool repairWrongDayOrHour(Rules& r);
02101 };
02102 
02103 class ConstraintActivityPreferredStartingTimes: public TimeConstraint{
02104        Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredStartingTimes)
02105 
02106 public:
02110        int activityId;
02111 
02115        int nPreferredStartingTimes_L;
02116 
02120        //int days[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES];
02121        QList<int> days_L;
02122 
02126        //int hours[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES];
02127        QList<int> hours_L;
02128 
02129        //internal variables
02133        int activityIndex;
02134 
02135        ConstraintActivityPreferredStartingTimes();
02136 
02137        //ConstraintActivityPreferredStartingTimes(double wp, int actId, int nPT, int d[], int h[]);
02138        ConstraintActivityPreferredStartingTimes(double wp, int actId, int nPT_L, QList<int> d_L, QList<int> h_L);
02139 
02140        bool computeInternalStructure(QWidget* parent, Rules& r);
02141 
02142        bool hasInactiveActivities(Rules& r);
02143 
02144        QString getXmlDescription(Rules& r);
02145 
02146        QString getDescription(Rules& r);
02147 
02148        QString getDetailedDescription(Rules& r);
02149 
02150        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02151 
02152        bool isRelatedToActivity(Rules& r, Activity* a);
02153        
02154        bool isRelatedToTeacher(Teacher* t);
02155 
02156        bool isRelatedToSubject(Subject* s);
02157 
02158        bool isRelatedToActivityTag(ActivityTag* s);
02159        
02160        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02161 
02162        bool hasWrongDayOrHour(Rules& r);
02163        bool canRepairWrongDayOrHour(Rules& r);
02164        bool repairWrongDayOrHour(Rules& r);
02165 };
02166 
02174 class ConstraintActivitiesPreferredTimeSlots: public TimeConstraint{
02175        Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesPreferredTimeSlots)
02176 
02177 public:
02181        QString p_teacherName;
02182 
02186        QString p_studentsName;
02187 
02191        QString p_subjectName;
02192 
02196        QString p_activityTagName;
02197 
02201        int p_nPreferredTimeSlots_L;
02202 
02206        //int p_days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS];
02207        QList<int> p_days_L;
02208 
02212        //int p_hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS];
02213        QList<int> p_hours_L;
02214 
02215        //internal variables
02216        
02220        int p_nActivities;
02221        
02226        //int p_activitiesIndices[MAX_ACTIVITIES];
02227        QList<int> p_activitiesIndices;
02228 
02229        ConstraintActivitiesPreferredTimeSlots();
02230 
02231        //ConstraintActivitiesPreferredTimeSlots(double wp, QString te,
02232        //     QString st, QString su, QString sut, int nPT, int d[], int h[]);
02233        ConstraintActivitiesPreferredTimeSlots(double wp, QString te,
02234               QString st, QString su, QString sut, int nPT_L, QList<int> d_L, QList<int> h_L);
02235 
02236        bool computeInternalStructure(QWidget* parent, Rules& r);
02237 
02238        bool hasInactiveActivities(Rules& r);
02239 
02240        QString getXmlDescription(Rules& r);
02241 
02242        QString getDescription(Rules& r);
02243 
02244        QString getDetailedDescription(Rules& r);
02245 
02246        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02247 
02248        bool isRelatedToActivity(Rules& r, Activity* a);
02249        
02250        bool isRelatedToTeacher(Teacher* t);
02251 
02252        bool isRelatedToSubject(Subject* s);
02253 
02254        bool isRelatedToActivityTag(ActivityTag* s);
02255        
02256        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02257 
02258        bool hasWrongDayOrHour(Rules& r);
02259        bool canRepairWrongDayOrHour(Rules& r);
02260        bool repairWrongDayOrHour(Rules& r);
02261 };
02262 
02263 class ConstraintSubactivitiesPreferredTimeSlots: public TimeConstraint{
02264        Q_DECLARE_TR_FUNCTIONS(ConstraintSubactivitiesPreferredTimeSlots)
02265 
02266 public:
02267        int componentNumber;
02268 
02272        QString p_teacherName;
02273 
02277        QString p_studentsName;
02278 
02282        QString p_subjectName;
02283 
02287        QString p_activityTagName;
02288 
02292        int p_nPreferredTimeSlots_L;
02293 
02297        //int p_days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS];
02298        QList<int> p_days_L;
02299 
02303        //int p_hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS];
02304        QList<int> p_hours_L;
02305 
02306        //internal variables
02307        
02311        int p_nActivities;
02312        
02317        //int p_activitiesIndices[MAX_ACTIVITIES];
02318        QList<int> p_activitiesIndices;
02319 
02320        ConstraintSubactivitiesPreferredTimeSlots();
02321 
02322        //ConstraintSubactivitiesPreferredTimeSlots(double wp, int compNo, QString te,
02323        //     QString st, QString su, QString sut, int nPT, int d[], int h[]);
02324        ConstraintSubactivitiesPreferredTimeSlots(double wp, int compNo, QString te,
02325               QString st, QString su, QString sut, int nPT_L, QList<int> d_L, QList<int> h_L);
02326 
02327        bool computeInternalStructure(QWidget* parent, Rules& r);
02328 
02329        bool hasInactiveActivities(Rules& r);
02330 
02331        QString getXmlDescription(Rules& r);
02332 
02333        QString getDescription(Rules& r);
02334 
02335        QString getDetailedDescription(Rules& r);
02336 
02337        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02338 
02339        bool isRelatedToActivity(Rules& r, Activity* a);
02340        
02341        bool isRelatedToTeacher(Teacher* t);
02342 
02343        bool isRelatedToSubject(Subject* s);
02344 
02345        bool isRelatedToActivityTag(ActivityTag* s);
02346        
02347        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02348 
02349        bool hasWrongDayOrHour(Rules& r);
02350        bool canRepairWrongDayOrHour(Rules& r);
02351        bool repairWrongDayOrHour(Rules& r);
02352 };
02353 
02354 class ConstraintActivitiesPreferredStartingTimes: public TimeConstraint{
02355        Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesPreferredStartingTimes)
02356 
02357 public:
02361        QString teacherName;
02362 
02366        QString studentsName;
02367 
02371        QString subjectName;
02372 
02376        QString activityTagName;
02377 
02381        int nPreferredStartingTimes_L;
02382 
02386        //int days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES];
02387        QList<int> days_L;
02388 
02392        //int hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES];
02393        QList<int> hours_L;
02394 
02395        //internal variables
02396        
02400        int nActivities;
02401        
02406        //int activitiesIndices[MAX_ACTIVITIES];
02407        QList<int> activitiesIndices;
02408 
02409        ConstraintActivitiesPreferredStartingTimes();
02410 
02411        //ConstraintActivitiesPreferredStartingTimes(double wp, QString te,
02412        //     QString st, QString su, QString sut, int nPT, int d[], int h[]);
02413        ConstraintActivitiesPreferredStartingTimes(double wp, QString te,
02414               QString st, QString su, QString sut, int nPT_L, QList<int> d_L, QList<int> h_L);
02415 
02416        bool computeInternalStructure(QWidget* parent, Rules& r);
02417 
02418        bool hasInactiveActivities(Rules& r);
02419 
02420        QString getXmlDescription(Rules& r);
02421 
02422        QString getDescription(Rules& r);
02423 
02424        QString getDetailedDescription(Rules& r);
02425 
02426        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02427 
02428        bool isRelatedToActivity(Rules& r, Activity* a);
02429        
02430        bool isRelatedToTeacher(Teacher* t);
02431 
02432        bool isRelatedToSubject(Subject* s);
02433 
02434        bool isRelatedToActivityTag(ActivityTag* s);
02435        
02436        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02437 
02438        bool hasWrongDayOrHour(Rules& r);
02439        bool canRepairWrongDayOrHour(Rules& r);
02440        bool repairWrongDayOrHour(Rules& r);
02441 };
02442 
02443 class ConstraintSubactivitiesPreferredStartingTimes: public TimeConstraint{
02444        Q_DECLARE_TR_FUNCTIONS(ConstraintSubactivitiesPreferredStartingTimes)
02445 
02446 public:
02447        int componentNumber;
02448 
02452        QString teacherName;
02453 
02457        QString studentsName;
02458 
02462        QString subjectName;
02463 
02467        QString activityTagName;
02468 
02472        int nPreferredStartingTimes_L;
02473 
02477        //int days[MAX_N_CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES];
02478        QList<int> days_L;
02479 
02483        //int hours[MAX_N_CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES];
02484        QList<int> hours_L;
02485 
02486        //internal variables
02487        
02491        int nActivities;
02492        
02497        //int activitiesIndices[MAX_ACTIVITIES];
02498        QList<int> activitiesIndices;
02499 
02500        ConstraintSubactivitiesPreferredStartingTimes();
02501 
02502        ConstraintSubactivitiesPreferredStartingTimes(double wp, int compNo, QString te,
02503               QString st, QString su, QString sut, int nPT_L, QList<int> d_L, QList<int> h_L);
02504 
02505        bool computeInternalStructure(QWidget* parent, Rules& r);
02506 
02507        bool hasInactiveActivities(Rules& r);
02508 
02509        QString getXmlDescription(Rules& r);
02510 
02511        QString getDescription(Rules& r);
02512 
02513        QString getDetailedDescription(Rules& r);
02514 
02515        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02516 
02517        bool isRelatedToActivity(Rules& r, Activity* a);
02518        
02519        bool isRelatedToTeacher(Teacher* t);
02520 
02521        bool isRelatedToSubject(Subject* s);
02522 
02523        bool isRelatedToActivityTag(ActivityTag* s);
02524        
02525        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02526 
02527        bool hasWrongDayOrHour(Rules& r);
02528        bool canRepairWrongDayOrHour(Rules& r);
02529        bool repairWrongDayOrHour(Rules& r);
02530 };
02531 
02532 class ConstraintActivitiesSameStartingHour: public TimeConstraint{
02533        Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameStartingHour)
02534 
02535 public:
02539        int n_activities;
02540 
02544        QList<int> activitiesId;
02545        //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR];
02546 
02550        int _n_activities;
02551 
02555        QList<int> _activities;
02556        //int _activities[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR];
02557 
02558        ConstraintActivitiesSameStartingHour();
02559 
02564        //ConstraintActivitiesSameStartingHour(double wp, int n_act, const int act[]);
02565        ConstraintActivitiesSameStartingHour(double wp, int n_act, const QList<int>& act);
02566 
02567        bool computeInternalStructure(QWidget* parent, Rules& r);
02568 
02569        bool hasInactiveActivities(Rules& r);
02570 
02571        QString getXmlDescription(Rules& r);
02572 
02573        QString getDescription(Rules& r);
02574 
02575        QString getDetailedDescription(Rules& r);
02576 
02577        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02578 
02579        void removeUseless(Rules& r);
02580 
02581        bool isRelatedToActivity(Rules& r, Activity* a);
02582 
02583        
02584        bool isRelatedToTeacher(Teacher* t);
02585 
02586        bool isRelatedToSubject(Subject* s);
02587 
02588        bool isRelatedToActivityTag(ActivityTag* s);
02589        
02590        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02591 
02592        bool hasWrongDayOrHour(Rules& r);
02593        bool canRepairWrongDayOrHour(Rules& r);
02594        bool repairWrongDayOrHour(Rules& r);
02595 };
02596 
02597 class ConstraintActivitiesSameStartingDay: public TimeConstraint{
02598        Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameStartingDay)
02599 
02600 public:
02604        int n_activities;
02605 
02609        QList<int> activitiesId;
02610        //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY];
02611 
02615        int _n_activities;
02616 
02620        //int _activities[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY];
02621        QList<int> _activities;
02622 
02623        ConstraintActivitiesSameStartingDay();
02624 
02629        //ConstraintActivitiesSameStartingDay(double wp, int n_act, const int act[]);
02630        ConstraintActivitiesSameStartingDay(double wp, int n_act, const QList<int>& act);
02631 
02632        bool computeInternalStructure(QWidget* parent, Rules& r);
02633 
02634        bool hasInactiveActivities(Rules& r);
02635 
02636        QString getXmlDescription(Rules& r);
02637 
02638        QString getDescription(Rules& r);
02639 
02640        QString getDetailedDescription(Rules& r);
02641 
02642        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02643 
02644        void removeUseless(Rules& r);
02645 
02646        bool isRelatedToActivity(Rules& r, Activity* a);
02647        
02648        bool isRelatedToTeacher(Teacher* t);
02649 
02650        bool isRelatedToSubject(Subject* s);
02651 
02652        bool isRelatedToActivityTag(ActivityTag* s);
02653        
02654        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02655 
02656        bool hasWrongDayOrHour(Rules& r);
02657        bool canRepairWrongDayOrHour(Rules& r);
02658        bool repairWrongDayOrHour(Rules& r);
02659 };
02660 
02661 class ConstraintTwoActivitiesConsecutive: public TimeConstraint{
02662        Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesConsecutive)
02663 
02664 public:
02668        int firstActivityId;
02669 
02673        int secondActivityId;
02674 
02675        //internal variables
02679        int firstActivityIndex;
02680 
02684        int secondActivityIndex;
02685 
02686        ConstraintTwoActivitiesConsecutive();
02687 
02688        ConstraintTwoActivitiesConsecutive(double wp, int firstActId, int secondActId);
02689 
02690        bool computeInternalStructure(QWidget* parent, Rules& r);
02691 
02692        bool hasInactiveActivities(Rules& r);
02693 
02694        QString getXmlDescription(Rules& r);
02695 
02696        QString getDescription(Rules& r);
02697 
02698        QString getDetailedDescription(Rules& r);
02699 
02700        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02701 
02702        bool isRelatedToActivity(Rules& r, Activity* a);
02703        
02704        bool isRelatedToTeacher(Teacher* t);
02705 
02706        bool isRelatedToSubject(Subject* s);
02707 
02708        bool isRelatedToActivityTag(ActivityTag* s);
02709        
02710        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02711 
02712        bool hasWrongDayOrHour(Rules& r);
02713        bool canRepairWrongDayOrHour(Rules& r);
02714        bool repairWrongDayOrHour(Rules& r);
02715 };
02716 
02717 class ConstraintTwoActivitiesGrouped: public TimeConstraint{
02718        Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesGrouped)
02719 
02720 public:
02724        int firstActivityId;
02725 
02729        int secondActivityId;
02730 
02731        //internal variables
02735        int firstActivityIndex;
02736 
02740        int secondActivityIndex;
02741 
02742        ConstraintTwoActivitiesGrouped();
02743 
02744        ConstraintTwoActivitiesGrouped(double wp, int firstActId, int secondActId);
02745 
02746        bool computeInternalStructure(QWidget* parent, Rules& r);
02747 
02748        bool hasInactiveActivities(Rules& r);
02749 
02750        QString getXmlDescription(Rules& r);
02751 
02752        QString getDescription(Rules& r);
02753 
02754        QString getDetailedDescription(Rules& r);
02755 
02756        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02757 
02758        bool isRelatedToActivity(Rules& r, Activity* a);
02759        
02760        bool isRelatedToTeacher(Teacher* t);
02761 
02762        bool isRelatedToSubject(Subject* s);
02763 
02764        bool isRelatedToActivityTag(ActivityTag* s);
02765        
02766        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02767 
02768        bool hasWrongDayOrHour(Rules& r);
02769        bool canRepairWrongDayOrHour(Rules& r);
02770        bool repairWrongDayOrHour(Rules& r);
02771 };
02772 
02773 class ConstraintThreeActivitiesGrouped: public TimeConstraint{
02774        Q_DECLARE_TR_FUNCTIONS(ConstraintThreeActivitiesGrouped)
02775 
02776 public:
02780        int firstActivityId;
02781 
02785        int secondActivityId;
02786 
02787        int thirdActivityId;
02788 
02789        //internal variables
02793        int firstActivityIndex;
02794 
02798        int secondActivityIndex;
02799 
02800        int thirdActivityIndex;
02801 
02802        ConstraintThreeActivitiesGrouped();
02803 
02804        ConstraintThreeActivitiesGrouped(double wp, int firstActId, int secondActId, int thirdActId);
02805 
02806        bool computeInternalStructure(QWidget* parent, Rules& r);
02807 
02808        bool hasInactiveActivities(Rules& r);
02809 
02810        QString getXmlDescription(Rules& r);
02811 
02812        QString getDescription(Rules& r);
02813 
02814        QString getDetailedDescription(Rules& r);
02815 
02816        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02817 
02818        bool isRelatedToActivity(Rules& r, Activity* a);
02819        
02820        bool isRelatedToTeacher(Teacher* t);
02821 
02822        bool isRelatedToSubject(Subject* s);
02823 
02824        bool isRelatedToActivityTag(ActivityTag* s);
02825        
02826        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02827 
02828        bool hasWrongDayOrHour(Rules& r);
02829        bool canRepairWrongDayOrHour(Rules& r);
02830        bool repairWrongDayOrHour(Rules& r);
02831 };
02832 
02833 class ConstraintTwoActivitiesOrdered: public TimeConstraint{
02834        Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesOrdered)
02835 
02836 public:
02840        int firstActivityId;
02841 
02845        int secondActivityId;
02846 
02847        //internal variables
02851        int firstActivityIndex;
02852 
02856        int secondActivityIndex;
02857 
02858        ConstraintTwoActivitiesOrdered();
02859 
02860        ConstraintTwoActivitiesOrdered(double wp, int firstActId, int secondActId);
02861 
02862        bool computeInternalStructure(QWidget* parent, Rules& r);
02863 
02864        bool hasInactiveActivities(Rules& r);
02865 
02866        QString getXmlDescription(Rules& r);
02867 
02868        QString getDescription(Rules& r);
02869 
02870        QString getDetailedDescription(Rules& r);
02871 
02872        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02873 
02874        bool isRelatedToActivity(Rules& r, Activity* a);
02875        
02876        bool isRelatedToTeacher(Teacher* t);
02877 
02878        bool isRelatedToSubject(Subject* s);
02879 
02880        bool isRelatedToActivityTag(ActivityTag* s);
02881        
02882        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02883 
02884        bool hasWrongDayOrHour(Rules& r);
02885        bool canRepairWrongDayOrHour(Rules& r);
02886        bool repairWrongDayOrHour(Rules& r);
02887 };
02888 
02889 class ConstraintActivityEndsStudentsDay: public TimeConstraint{
02890        Q_DECLARE_TR_FUNCTIONS(ConstraintActivityEndsStudentsDay)
02891 
02892 public:
02896        int activityId;
02897 
02898        //internal variables
02902        int activityIndex;
02903 
02904        ConstraintActivityEndsStudentsDay();
02905 
02906        ConstraintActivityEndsStudentsDay(double wp, int actId);
02907 
02908        bool computeInternalStructure(QWidget* parent, Rules& r);
02909 
02910        bool hasInactiveActivities(Rules& r);
02911 
02912        QString getXmlDescription(Rules& r);
02913 
02914        QString getDescription(Rules& r);
02915 
02916        QString getDetailedDescription(Rules& r);
02917 
02918        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02919 
02920        bool isRelatedToActivity(Rules& r, Activity* a);
02921        
02922        bool isRelatedToTeacher(Teacher* t);
02923 
02924        bool isRelatedToSubject(Subject* s);
02925 
02926        bool isRelatedToActivityTag(ActivityTag* s);
02927        
02928        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02929 
02930        bool hasWrongDayOrHour(Rules& r);
02931        bool canRepairWrongDayOrHour(Rules& r);
02932        bool repairWrongDayOrHour(Rules& r);
02933 };
02934 
02935 class ConstraintTeachersMinHoursDaily: public TimeConstraint{
02936        Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinHoursDaily)
02937 
02938 public:
02942        int minHoursDaily;
02943        
02944        bool allowEmptyDays;
02945 
02946        ConstraintTeachersMinHoursDaily();
02947 
02948        ConstraintTeachersMinHoursDaily(double wp, int minhours, bool _allowEmptyDays);
02949 
02950        QString getXmlDescription(Rules& r);
02951 
02952        bool computeInternalStructure(QWidget* parent, Rules& r);
02953 
02954        bool hasInactiveActivities(Rules& r);
02955 
02956        QString getDescription(Rules& r);
02957 
02958        QString getDetailedDescription(Rules& r);
02959 
02960        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
02961 
02962        bool isRelatedToActivity(Rules& r, Activity* a);
02963        
02964        bool isRelatedToTeacher(Teacher* t);
02965 
02966        bool isRelatedToSubject(Subject* s);
02967 
02968        bool isRelatedToActivityTag(ActivityTag* s);
02969        
02970        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
02971 
02972        bool hasWrongDayOrHour(Rules& r);
02973        bool canRepairWrongDayOrHour(Rules& r);
02974        bool repairWrongDayOrHour(Rules& r);
02975 };
02976 
02977 class ConstraintTeacherMinHoursDaily: public TimeConstraint{
02978        Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinHoursDaily)
02979 
02980 public:
02984        int minHoursDaily;
02985        
02986        QString teacherName;
02987        
02988        int teacher_ID;
02989        
02990        bool allowEmptyDays;
02991 
02992        ConstraintTeacherMinHoursDaily();
02993 
02994        ConstraintTeacherMinHoursDaily(double wp, int minhours, const QString& teacher, bool _allowEmptyDays);
02995 
02996        QString getXmlDescription(Rules& r);
02997 
02998        bool computeInternalStructure(QWidget* parent, Rules& r);
02999 
03000        bool hasInactiveActivities(Rules& r);
03001 
03002        QString getDescription(Rules& r);
03003 
03004        QString getDetailedDescription(Rules& r);
03005 
03006        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03007 
03008        bool isRelatedToActivity(Rules& r, Activity* a);
03009        
03010        bool isRelatedToTeacher(Teacher* t);
03011 
03012        bool isRelatedToSubject(Subject* s);
03013 
03014        bool isRelatedToActivityTag(ActivityTag* s);
03015        
03016        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03017 
03018        bool hasWrongDayOrHour(Rules& r);
03019        bool canRepairWrongDayOrHour(Rules& r);
03020        bool repairWrongDayOrHour(Rules& r);
03021 };
03022 
03023 class ConstraintTeacherIntervalMaxDaysPerWeek: public TimeConstraint{
03024        Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherIntervalMaxDaysPerWeek)
03025 
03026 public:
03030        int maxDaysPerWeek;
03031        
03032        int startHour;
03033 
03034        int endHour; //might be = to gt.rules.nHoursPerDay
03035 
03039        QString teacherName;
03040 
03044        int teacher_ID;
03045 
03046        ConstraintTeacherIntervalMaxDaysPerWeek();
03047 
03048        ConstraintTeacherIntervalMaxDaysPerWeek(double wp, int maxnd, QString tn, int sh, int eh);
03049 
03050        bool computeInternalStructure(QWidget* parent, Rules& r);
03051 
03052        bool hasInactiveActivities(Rules& r);
03053 
03054        QString getXmlDescription(Rules& r);
03055 
03056        QString getDescription(Rules& r);
03057 
03058        QString getDetailedDescription(Rules& r);
03059 
03060        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03061 
03062        bool isRelatedToActivity(Rules& r, Activity* a);
03063        
03064        bool isRelatedToTeacher(Teacher* t);
03065 
03066        bool isRelatedToSubject(Subject* s);
03067 
03068        bool isRelatedToActivityTag(ActivityTag* s);
03069        
03070        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03071 
03072        bool hasWrongDayOrHour(Rules& r);
03073        bool canRepairWrongDayOrHour(Rules& r);
03074        bool repairWrongDayOrHour(Rules& r);
03075 };
03076 
03077 class ConstraintTeachersIntervalMaxDaysPerWeek: public TimeConstraint{
03078        Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersIntervalMaxDaysPerWeek)
03079 
03080 public:
03084        int maxDaysPerWeek;
03085        
03086        int startHour;
03087 
03088        int endHour; //might be = to gt.rules.nHoursPerDay
03089 
03090 
03091        ConstraintTeachersIntervalMaxDaysPerWeek();
03092 
03093        ConstraintTeachersIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh);
03094 
03095        bool computeInternalStructure(QWidget* parent, Rules& r);
03096 
03097        bool hasInactiveActivities(Rules& r);
03098 
03099        QString getXmlDescription(Rules& r);
03100 
03101        QString getDescription(Rules& r);
03102 
03103        QString getDetailedDescription(Rules& r);
03104 
03105        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03106 
03107        bool isRelatedToActivity(Rules& r, Activity* a);
03108        
03109        bool isRelatedToTeacher(Teacher* t);
03110 
03111        bool isRelatedToSubject(Subject* s);
03112 
03113        bool isRelatedToActivityTag(ActivityTag* s);
03114        
03115        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03116 
03117        bool hasWrongDayOrHour(Rules& r);
03118        bool canRepairWrongDayOrHour(Rules& r);
03119        bool repairWrongDayOrHour(Rules& r);
03120 };
03121 
03122 class ConstraintStudentsSetIntervalMaxDaysPerWeek: public TimeConstraint{
03123        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetIntervalMaxDaysPerWeek)
03124 
03125 public:
03129        int maxDaysPerWeek;
03130        
03131        int startHour;
03132 
03133        int endHour; //might be = to gt.rules.nHoursPerDay
03134 
03138        QString students;
03139 
03140        //internal redundant data
03141 
03145        //int nSubgroups;
03146 
03150        QList<int> iSubgroupsList;
03151 
03152        ConstraintStudentsSetIntervalMaxDaysPerWeek();
03153 
03154        ConstraintStudentsSetIntervalMaxDaysPerWeek(double wp, int maxnd, QString sn, int sh, int eh);
03155 
03156        bool computeInternalStructure(QWidget* parent, Rules& r);
03157 
03158        bool hasInactiveActivities(Rules& r);
03159 
03160        QString getXmlDescription(Rules& r);
03161 
03162        QString getDescription(Rules& r);
03163 
03164        QString getDetailedDescription(Rules& r);
03165 
03166        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03167 
03168        bool isRelatedToActivity(Rules& r, Activity* a);
03169        
03170        bool isRelatedToTeacher(Teacher* t);
03171 
03172        bool isRelatedToSubject(Subject* s);
03173 
03174        bool isRelatedToActivityTag(ActivityTag* s);
03175        
03176        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03177 
03178        bool hasWrongDayOrHour(Rules& r);
03179        bool canRepairWrongDayOrHour(Rules& r);
03180        bool repairWrongDayOrHour(Rules& r);
03181 };
03182 
03183 class ConstraintStudentsIntervalMaxDaysPerWeek: public TimeConstraint{
03184        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsIntervalMaxDaysPerWeek)
03185 
03186 public:
03190        int maxDaysPerWeek;
03191        
03192        int startHour;
03193 
03194        int endHour; //might be = to gt.rules.nHoursPerDay
03195 
03196 
03197        ConstraintStudentsIntervalMaxDaysPerWeek();
03198 
03199        ConstraintStudentsIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh);
03200 
03201        bool computeInternalStructure(QWidget* parent, Rules& r);
03202 
03203        bool hasInactiveActivities(Rules& r);
03204 
03205        QString getXmlDescription(Rules& r);
03206 
03207        QString getDescription(Rules& r);
03208 
03209        QString getDetailedDescription(Rules& r);
03210 
03211        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03212 
03213        bool isRelatedToActivity(Rules& r, Activity* a);
03214        
03215        bool isRelatedToTeacher(Teacher* t);
03216 
03217        bool isRelatedToSubject(Subject* s);
03218 
03219        bool isRelatedToActivityTag(ActivityTag* s);
03220        
03221        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03222 
03223        bool hasWrongDayOrHour(Rules& r);
03224        bool canRepairWrongDayOrHour(Rules& r);
03225        bool repairWrongDayOrHour(Rules& r);
03226 };
03227 
03228 class ConstraintActivitiesEndStudentsDay: public TimeConstraint{
03229        Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesEndStudentsDay)
03230 
03231 public:
03235        QString teacherName;
03236 
03240        QString studentsName;
03241 
03245        QString subjectName;
03246 
03250        QString activityTagName;
03251        
03252        
03253        //internal data
03254 
03258        int nActivities;
03259        
03264        //int activitiesIndices[MAX_ACTIVITIES];
03265        QList<int> activitiesIndices;
03266 
03267        ConstraintActivitiesEndStudentsDay();
03268 
03269        ConstraintActivitiesEndStudentsDay(double wp, QString te, QString st, QString su, QString sut);
03270 
03271        bool computeInternalStructure(QWidget* parent, Rules& r);
03272 
03273        bool hasInactiveActivities(Rules& r);
03274 
03275        QString getXmlDescription(Rules& r);
03276 
03277        QString getDescription(Rules& r);
03278 
03279        QString getDetailedDescription(Rules& r);
03280 
03281        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03282 
03283        bool isRelatedToActivity(Rules& r, Activity* a);
03284        
03285        bool isRelatedToTeacher(Teacher* t);
03286 
03287        bool isRelatedToSubject(Subject* s);
03288 
03289        bool isRelatedToActivityTag(ActivityTag* s);
03290        
03291        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03292 
03293        bool hasWrongDayOrHour(Rules& r);
03294        bool canRepairWrongDayOrHour(Rules& r);
03295        bool repairWrongDayOrHour(Rules& r);
03296 };
03297 
03298 class ConstraintTeachersActivityTagMaxHoursDaily: public TimeConstraint{
03299        Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMaxHoursDaily)
03300 
03301 public:
03305        int maxHoursDaily;
03306        
03307        QString activityTagName;
03308        
03309        int activityTagIndex;
03310        
03311        QList<int> canonicalTeachersList;
03312 
03313        ConstraintTeachersActivityTagMaxHoursDaily();
03314 
03315        ConstraintTeachersActivityTagMaxHoursDaily(double wp, int maxhours, const QString& activityTag);
03316 
03317        QString getXmlDescription(Rules& r);
03318 
03319        bool computeInternalStructure(QWidget* parent, Rules& r);
03320 
03321        bool hasInactiveActivities(Rules& r);
03322 
03323        QString getDescription(Rules& r);
03324 
03325        QString getDetailedDescription(Rules& r);
03326 
03327        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03328 
03329        bool isRelatedToActivity(Rules& r, Activity* a);
03330        
03331        bool isRelatedToTeacher(Teacher* t);
03332 
03333        bool isRelatedToSubject(Subject* s);
03334 
03335        bool isRelatedToActivityTag(ActivityTag* s);
03336        
03337        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03338 
03339        bool hasWrongDayOrHour(Rules& r);
03340        bool canRepairWrongDayOrHour(Rules& r);
03341        bool repairWrongDayOrHour(Rules& r);
03342 };
03343 
03344 class ConstraintTeacherActivityTagMaxHoursDaily: public TimeConstraint{
03345        Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMaxHoursDaily)
03346 
03347 public:
03351        int maxHoursDaily;
03352        
03353        QString teacherName;
03354        
03355        QString activityTagName;
03356        
03357        int teacher_ID;
03358 
03359        int activityTagIndex;
03360        
03361        QList<int> canonicalTeachersList;
03362 
03363        ConstraintTeacherActivityTagMaxHoursDaily();
03364 
03365        ConstraintTeacherActivityTagMaxHoursDaily(double wp, int maxhours, const QString& teacher, const QString& activityTag);
03366 
03367        QString getXmlDescription(Rules& r);
03368 
03369        bool computeInternalStructure(QWidget* parent, Rules& r);
03370 
03371        bool hasInactiveActivities(Rules& r);
03372 
03373        QString getDescription(Rules& r);
03374 
03375        QString getDetailedDescription(Rules& r);
03376 
03377        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03378 
03379        bool isRelatedToActivity(Rules& r, Activity* a);
03380        
03381        bool isRelatedToTeacher(Teacher* t);
03382 
03383        bool isRelatedToSubject(Subject* s);
03384 
03385        bool isRelatedToActivityTag(ActivityTag* s);
03386        
03387        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03388 
03389        bool hasWrongDayOrHour(Rules& r);
03390        bool canRepairWrongDayOrHour(Rules& r);
03391        bool repairWrongDayOrHour(Rules& r);
03392 };
03393 
03394 class ConstraintStudentsActivityTagMaxHoursDaily: public TimeConstraint{
03395        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMaxHoursDaily)
03396 
03397 public:
03398        int maxHoursDaily;
03399        
03400        QString activityTagName;
03401        
03402        int activityTagIndex;
03403        
03404        QList<int> canonicalSubgroupsList;
03405 
03406        ConstraintStudentsActivityTagMaxHoursDaily();
03407 
03408        ConstraintStudentsActivityTagMaxHoursDaily(double wp, int maxnh, const QString& activityTag);
03409 
03410        bool computeInternalStructure(QWidget* parent, Rules& r);
03411 
03412        bool hasInactiveActivities(Rules& r);
03413 
03414        QString getXmlDescription(Rules& r);
03415 
03416        QString getDescription(Rules& r);
03417 
03418        QString getDetailedDescription(Rules& r);
03419 
03420        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03421 
03422        bool isRelatedToActivity(Rules& r, Activity* a);
03423        
03424        bool isRelatedToTeacher(Teacher* t);
03425 
03426        bool isRelatedToSubject(Subject* s);
03427 
03428        bool isRelatedToActivityTag(ActivityTag* s);
03429        
03430        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03431 
03432        bool hasWrongDayOrHour(Rules& r);
03433        bool canRepairWrongDayOrHour(Rules& r);
03434        bool repairWrongDayOrHour(Rules& r);
03435 };
03436 
03437 class ConstraintStudentsSetActivityTagMaxHoursDaily: public TimeConstraint{
03438        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMaxHoursDaily)
03439 
03440 public:
03441        int maxHoursDaily;
03442 
03446        QString students;
03447        
03448        QString activityTagName;
03449 
03450        //internal variables
03451        
03452        int activityTagIndex;
03453 
03457        //int nSubgroups;
03458 
03462        //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
03463        QList<int> iSubgroupsList;
03464        
03465        QList<int> canonicalSubgroupsList;
03466 
03467        ConstraintStudentsSetActivityTagMaxHoursDaily();
03468 
03469        ConstraintStudentsSetActivityTagMaxHoursDaily(double wp, int maxnh, const QString& s, const QString& activityTag);
03470 
03471        bool computeInternalStructure(QWidget* parent, Rules& r);
03472 
03473        bool hasInactiveActivities(Rules& r);
03474 
03475        QString getXmlDescription(Rules& r);
03476 
03477        QString getDescription(Rules& r);
03478 
03479        QString getDetailedDescription(Rules& r);
03480 
03481        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03482 
03483        bool isRelatedToActivity(Rules& r, Activity* a);
03484        
03485        bool isRelatedToTeacher(Teacher* t);
03486 
03487        bool isRelatedToSubject(Subject* s);
03488 
03489        bool isRelatedToActivityTag(ActivityTag* s);
03490        
03491        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03492 
03493        bool hasWrongDayOrHour(Rules& r);
03494        bool canRepairWrongDayOrHour(Rules& r);
03495        bool repairWrongDayOrHour(Rules& r);
03496 };
03497 
03498 class ConstraintStudentsMaxGapsPerDay: public TimeConstraint{
03499        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxGapsPerDay)
03500 
03501 public:
03502        int maxGaps;
03503 
03504        ConstraintStudentsMaxGapsPerDay();
03505 
03506        ConstraintStudentsMaxGapsPerDay(double wp, int mg);
03507 
03508        bool computeInternalStructure(QWidget* parent, Rules& r);
03509 
03510        bool hasInactiveActivities(Rules& r);
03511 
03512        QString getXmlDescription(Rules& r);
03513 
03514        QString getDescription(Rules& r);
03515 
03516        QString getDetailedDescription(Rules& r);
03517 
03518        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03519 
03520        bool isRelatedToActivity(Rules& r, Activity* a);
03521        
03522        bool isRelatedToTeacher(Teacher* t);
03523 
03524        bool isRelatedToSubject(Subject* s);
03525 
03526        bool isRelatedToActivityTag(ActivityTag* s);
03527        
03528        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03529 
03530        bool hasWrongDayOrHour(Rules& r);
03531        bool canRepairWrongDayOrHour(Rules& r);
03532        bool repairWrongDayOrHour(Rules& r);
03533 };
03534 
03535 class ConstraintStudentsSetMaxGapsPerDay: public TimeConstraint{
03536        Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxGapsPerDay)
03537 
03538 public:
03539        int maxGaps;
03540 
03544        QString students;
03545 
03546        //internal redundant data
03547 
03551        //int nSubgroups;
03552 
03556        QList<int> iSubgroupsList;
03557 
03558        ConstraintStudentsSetMaxGapsPerDay();
03559 
03560        ConstraintStudentsSetMaxGapsPerDay(double wp, int mg, const QString& st );
03561 
03562        bool computeInternalStructure(QWidget* parent, Rules& r);
03563 
03564        bool hasInactiveActivities(Rules& r);
03565 
03566        QString getXmlDescription(Rules& r);
03567 
03568        QString getDescription(Rules& r);
03569 
03570        QString getDetailedDescription(Rules& r);
03571 
03572        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03573 
03574        bool isRelatedToActivity(Rules& r, Activity* a);
03575        
03576        bool isRelatedToTeacher(Teacher* t);
03577 
03578        bool isRelatedToSubject(Subject* s);
03579 
03580        bool isRelatedToActivityTag(ActivityTag* s);
03581        
03582        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03583 
03584        bool hasWrongDayOrHour(Rules& r);
03585        bool canRepairWrongDayOrHour(Rules& r);
03586        bool repairWrongDayOrHour(Rules& r);
03587 };
03588 
03589 class ConstraintActivitiesOccupyMaxTimeSlotsFromSelection: public TimeConstraint{
03590        Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesOccupyMaxTimeSlotsFromSelection)
03591 
03592 public:
03593        QList<int> activitiesIds;
03594        
03595        QList<int> selectedDays;
03596        QList<int> selectedHours;
03597        
03598        int maxOccupiedTimeSlots;
03599 
03600        //internal variables
03601        QList<int> _activitiesIndices;
03602 
03603        ConstraintActivitiesOccupyMaxTimeSlotsFromSelection();
03604 
03605        ConstraintActivitiesOccupyMaxTimeSlotsFromSelection(double wp, QList<int> a_L, QList<int> d_L, QList<int> h_L, int max_slots);
03606 
03607        bool computeInternalStructure(QWidget* parent, Rules& r);
03608 
03609        bool hasInactiveActivities(Rules& r);
03610 
03611        QString getXmlDescription(Rules& r);
03612 
03613        QString getDescription(Rules& r);
03614 
03615        QString getDetailedDescription(Rules& r);
03616 
03617        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03618 
03619        void removeUseless(Rules& r);
03620 
03621        bool isRelatedToActivity(Rules& r, Activity* a);
03622        
03623        bool isRelatedToTeacher(Teacher* t);
03624 
03625        bool isRelatedToSubject(Subject* s);
03626 
03627        bool isRelatedToActivityTag(ActivityTag* s);
03628        
03629        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03630 
03631        bool hasWrongDayOrHour(Rules& r);
03632        bool canRepairWrongDayOrHour(Rules& r);
03633        bool repairWrongDayOrHour(Rules& r);
03634 };
03635 
03636 class ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots: public TimeConstraint{
03637        Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots)
03638 
03639 public:
03640        QList<int> activitiesIds;
03641        
03642        QList<int> selectedDays;
03643        QList<int> selectedHours;
03644        
03645        int maxSimultaneous;
03646 
03647        //internal variables
03648        QList<int> _activitiesIndices;
03649 
03650        ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots();
03651 
03652        ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots(double wp, QList<int> a_L, QList<int> d_L, QList<int> h_L, int max_simultaneous);
03653 
03654        bool computeInternalStructure(QWidget* parent, Rules& r);
03655 
03656        bool hasInactiveActivities(Rules& r);
03657 
03658        QString getXmlDescription(Rules& r);
03659 
03660        QString getDescription(Rules& r);
03661 
03662        QString getDetailedDescription(Rules& r);
03663 
03664        double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>&dl, QString* conflictsString=NULL);
03665 
03666        void removeUseless(Rules& r);
03667 
03668        bool isRelatedToActivity(Rules& r, Activity* a);
03669        
03670        bool isRelatedToTeacher(Teacher* t);
03671 
03672        bool isRelatedToSubject(Subject* s);
03673 
03674        bool isRelatedToActivityTag(ActivityTag* s);
03675        
03676        bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
03677 
03678        bool hasWrongDayOrHour(Rules& r);
03679        bool canRepairWrongDayOrHour(Rules& r);
03680        bool repairWrongDayOrHour(Rules& r);
03681 };
03682 
03683 #endif