"Fossies" - the Fresh Open Source Software Archive

Member "fet-5.45.1/src/engine/timeconstraint.h" (23 Jun 2020, 120907 Bytes) of package /linux/privat/fet-5.45.1.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "timeconstraint.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.45.0_vs_5.45.1.

    1 /*
    2 File timeconstraint.h
    3 */
    4 
    5 /***************************************************************************
    6                           timeconstraint.h  -  description
    7                              -------------------
    8     begin                : 2002
    9     copyright            : (C) 2002 by Lalescu Liviu
   10     email                : Please see https://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)
   11  ***************************************************************************/
   12 
   13 /***************************************************************************
   14  *                                                                         *
   15  *   This program is free software: you can redistribute it and/or modify  *
   16  *   it under the terms of the GNU Affero General Public License as        *
   17  *   published by the Free Software Foundation, either version 3 of the    *
   18  *   License, or (at your option) any later version.                       *
   19  *                                                                         *
   20  ***************************************************************************/
   21 
   22 #ifndef TIMECONSTRAINT_H
   23 #define TIMECONSTRAINT_H
   24 
   25 #include <QCoreApplication>
   26 
   27 #include "timetable_defs.h"
   28 
   29 #include <QString>
   30 #include <QList>
   31 #include <QStringList>
   32 
   33 class Rules;
   34 class Solution;
   35 class TimeConstraint;
   36 class Activity;
   37 class Teacher;
   38 class Subject;
   39 class ActivityTag;
   40 class StudentsSet;
   41 
   42 class FakeString;
   43 
   44 class QWidget;
   45 
   46 typedef QList<TimeConstraint*> TimeConstraintsList;
   47 
   48 const int CONSTRAINT_GENERIC_TIME                                       =0;
   49 
   50 const int CONSTRAINT_BASIC_COMPULSORY_TIME                              =1;
   51 const int CONSTRAINT_BREAK_TIMES                                        =2;
   52 
   53 const int CONSTRAINT_TEACHER_NOT_AVAILABLE_TIMES                        =3;
   54 const int CONSTRAINT_TEACHERS_MAX_HOURS_DAILY                           =4;
   55 const int CONSTRAINT_TEACHER_MAX_DAYS_PER_WEEK                          =5;
   56 const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_WEEK                         =6;
   57 const int CONSTRAINT_TEACHER_MAX_GAPS_PER_WEEK                          =7;
   58 const int CONSTRAINT_TEACHER_MAX_HOURS_DAILY                            =8;
   59 const int CONSTRAINT_TEACHERS_MAX_HOURS_CONTINUOUSLY                    =9;
   60 const int CONSTRAINT_TEACHER_MAX_HOURS_CONTINUOUSLY                     =10;
   61 
   62 const int CONSTRAINT_TEACHERS_MIN_HOURS_DAILY                           =11;
   63 const int CONSTRAINT_TEACHER_MIN_HOURS_DAILY                            =12;
   64 const int CONSTRAINT_TEACHERS_MAX_GAPS_PER_DAY                          =13;
   65 const int CONSTRAINT_TEACHER_MAX_GAPS_PER_DAY                           =14;
   66 
   67 const int CONSTRAINT_STUDENTS_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR       =15;
   68 const int CONSTRAINT_STUDENTS_SET_EARLY_MAX_BEGINNINGS_AT_SECOND_HOUR   =16;
   69 const int CONSTRAINT_STUDENTS_SET_NOT_AVAILABLE_TIMES                   =17;
   70 const int CONSTRAINT_STUDENTS_MAX_GAPS_PER_WEEK                         =18;
   71 const int CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_WEEK                     =19;
   72 
   73 const int CONSTRAINT_STUDENTS_MAX_HOURS_DAILY                           =20;
   74 const int CONSTRAINT_STUDENTS_SET_MAX_HOURS_DAILY                       =21;
   75 const int CONSTRAINT_STUDENTS_MAX_HOURS_CONTINUOUSLY                    =22;
   76 const int CONSTRAINT_STUDENTS_SET_MAX_HOURS_CONTINUOUSLY                =23;
   77 
   78 const int CONSTRAINT_STUDENTS_MIN_HOURS_DAILY                           =24;
   79 const int CONSTRAINT_STUDENTS_SET_MIN_HOURS_DAILY                       =25;
   80 
   81 const int CONSTRAINT_ACTIVITY_ENDS_STUDENTS_DAY                         =26;
   82 const int CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIME                   =27;
   83 const int CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME                      =28;
   84 const int CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING                         =29;
   85 const int CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES                        =30;
   86 const int CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS                      =31;
   87 const int CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS                    =32;
   88 const int CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES                  =33;
   89 const int CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES                =34;
   90 const int CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR                      =35;
   91 const int CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY                       =36;
   92 const int CONSTRAINT_TWO_ACTIVITIES_CONSECUTIVE                         =37;
   93 const int CONSTRAINT_TWO_ACTIVITIES_ORDERED                             =38;
   94 const int CONSTRAINT_MIN_GAPS_BETWEEN_ACTIVITIES                        =39;
   95 const int CONSTRAINT_SUBACTIVITIES_PREFERRED_TIME_SLOTS                 =40;
   96 const int CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES             =41;
   97 
   98 const int CONSTRAINT_TEACHER_INTERVAL_MAX_DAYS_PER_WEEK                 =42;
   99 const int CONSTRAINT_TEACHERS_INTERVAL_MAX_DAYS_PER_WEEK                =43;
  100 const int CONSTRAINT_STUDENTS_SET_INTERVAL_MAX_DAYS_PER_WEEK            =44;
  101 const int CONSTRAINT_STUDENTS_INTERVAL_MAX_DAYS_PER_WEEK                =45;
  102 
  103 const int CONSTRAINT_ACTIVITIES_END_STUDENTS_DAY                        =46;
  104 
  105 const int CONSTRAINT_TWO_ACTIVITIES_GROUPED                             =47;
  106 
  107 const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY       =48;
  108 const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY        =49;
  109 const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY       =50;
  110 const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MAX_HOURS_CONTINUOUSLY   =51;
  111 
  112 const int CONSTRAINT_TEACHERS_MAX_DAYS_PER_WEEK                         =52;
  113 
  114 const int CONSTRAINT_THREE_ACTIVITIES_GROUPED                           =53;
  115 const int CONSTRAINT_MAX_DAYS_BETWEEN_ACTIVITIES                        =54;
  116 
  117 const int CONSTRAINT_TEACHERS_MIN_DAYS_PER_WEEK                         =55;
  118 const int CONSTRAINT_TEACHER_MIN_DAYS_PER_WEEK                          =56;
  119 
  120 const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MAX_HOURS_DAILY              =57;
  121 const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MAX_HOURS_DAILY               =58;
  122 const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MAX_HOURS_DAILY              =59;
  123 const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MAX_HOURS_DAILY          =60;
  124 
  125 const int CONSTRAINT_STUDENTS_MAX_GAPS_PER_DAY                          =61;
  126 const int CONSTRAINT_STUDENTS_SET_MAX_GAPS_PER_DAY                      =62;
  127 
  128 const int CONSTRAINT_ACTIVITIES_OCCUPY_MAX_TIME_SLOTS_FROM_SELECTION    =63;
  129 const int CONSTRAINT_ACTIVITIES_MAX_SIMULTANEOUS_IN_SELECTED_TIME_SLOTS =64;
  130 
  131 const int CONSTRAINT_STUDENTS_SET_MAX_DAYS_PER_WEEK                     =65;
  132 const int CONSTRAINT_STUDENTS_MAX_DAYS_PER_WEEK                         =66;
  133 
  134 //2017-02-06
  135 const int CONSTRAINT_TEACHER_MAX_SPAN_PER_DAY                           =67;
  136 const int CONSTRAINT_TEACHERS_MAX_SPAN_PER_DAY                          =68;
  137 const int CONSTRAINT_TEACHER_MIN_RESTING_HOURS                          =69;
  138 const int CONSTRAINT_TEACHERS_MIN_RESTING_HOURS                         =70;
  139 const int CONSTRAINT_STUDENTS_SET_MAX_SPAN_PER_DAY                      =71;
  140 const int CONSTRAINT_STUDENTS_MAX_SPAN_PER_DAY                          =72;
  141 const int CONSTRAINT_STUDENTS_SET_MIN_RESTING_HOURS                     =73;
  142 const int CONSTRAINT_STUDENTS_MIN_RESTING_HOURS                         =74;
  143 
  144 //2018-06-13
  145 const int CONSTRAINT_TWO_ACTIVITIES_ORDERED_IF_SAME_DAY                 =75;
  146 
  147 //2019-06-08
  148 const int CONSTRAINT_STUDENTS_SET_MIN_GAPS_BETWEEN_ORDERED_PAIR_OF_ACTIVITY_TAGS    =76;
  149 const int CONSTRAINT_STUDENTS_MIN_GAPS_BETWEEN_ORDERED_PAIR_OF_ACTIVITY_TAGS        =77;
  150 const int CONSTRAINT_TEACHER_MIN_GAPS_BETWEEN_ORDERED_PAIR_OF_ACTIVITY_TAGS         =78;
  151 const int CONSTRAINT_TEACHERS_MIN_GAPS_BETWEEN_ORDERED_PAIR_OF_ACTIVITY_TAGS        =79;
  152 
  153 const int CONSTRAINT_ACTIVITY_TAGS_NOT_OVERLAPPING                      =80;
  154 
  155 const int CONSTRAINT_ACTIVITIES_OCCUPY_MIN_TIME_SLOTS_FROM_SELECTION    =81;
  156 const int CONSTRAINT_ACTIVITIES_MIN_SIMULTANEOUS_IN_SELECTED_TIME_SLOTS =82;
  157 
  158 const int CONSTRAINT_TEACHERS_ACTIVITY_TAG_MIN_HOURS_DAILY              =83;
  159 const int CONSTRAINT_TEACHER_ACTIVITY_TAG_MIN_HOURS_DAILY               =84;
  160 const int CONSTRAINT_STUDENTS_ACTIVITY_TAG_MIN_HOURS_DAILY              =85;
  161 const int CONSTRAINT_STUDENTS_SET_ACTIVITY_TAG_MIN_HOURS_DAILY          =86;
  162 
  163 QString getActivityDetailedDescription(Rules& r, int id);
  164 
  165 /**
  166 This class represents a time constraint
  167 */
  168 class TimeConstraint{
  169     Q_DECLARE_TR_FUNCTIONS(TimeConstraint)
  170 
  171 public:
  172     /**
  173     The percentage weight of this constraint, 100% compulsory, 0% non-compulsory
  174     */
  175     double weightPercentage;
  176     
  177     bool active;
  178     
  179     QString comments;
  180 
  181     /**
  182     Specifies the type of this constraint (using the above constants).
  183     */
  184     int type;
  185 
  186     /**
  187     True for mandatory constraints, false for non-mandatory constraints.
  188     */
  189     //bool compulsory;
  190 
  191     /**
  192     Dummy constructor - needed for the static array of constraints.
  193     Any other use should be avoided.
  194     */
  195     TimeConstraint();
  196     
  197     virtual ~TimeConstraint()=0;
  198 
  199     /**
  200     DEPRECATED COMMENT
  201     Constructor - please note that the maximum allowed weight is 100.0
  202     The reason: unallocated activities must have very big conflict weight,
  203     and any other restrictions must have much more lower weight,
  204     so that the timetable can evolve when starting with uninitialized activities.
  205     */
  206     TimeConstraint(double wp);
  207 
  208     /**
  209     The function that calculates the fitness of a solution, according to this
  210     constraint. We need the rules to compute this fitness factor.
  211     If conflictsString!=NULL,
  212     it will be initialized with a text explaining where this restriction is broken.
  213     */
  214     virtual double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL)=0;
  215 
  216     /**
  217     Returns an XML description of this constraint
  218     */
  219     virtual QString getXmlDescription(Rules& r)=0;
  220 
  221     /**
  222     Computes the internal structure for this constraint.
  223     
  224     It returns false if the constraint is an activity related
  225     one and it depends on only inactive activities.
  226     */
  227     virtual bool computeInternalStructure(QWidget* parent, Rules& r)=0;
  228     
  229     virtual bool hasInactiveActivities(Rules& r)=0;
  230 
  231     /**
  232     Returns a small description string for this constraint
  233     */
  234     virtual QString getDescription(Rules& r)=0;
  235 
  236     /**
  237     Returns a detailed description string for this constraint
  238     */
  239     virtual QString getDetailedDescription(Rules& r)=0;
  240     
  241     /**
  242     Returns true if this constraint is related to this activity
  243     */
  244     virtual bool isRelatedToActivity(Rules& r, Activity* a)=0;
  245 
  246     /**
  247     Returns true if this constraint is related to this teacher
  248     */
  249     virtual bool isRelatedToTeacher(Teacher* t)=0;
  250 
  251     /**
  252     Returns true if this constraint is related to this subject
  253     */
  254     virtual bool isRelatedToSubject(Subject* s)=0;
  255 
  256     /**
  257     Returns true if this constraint is related to this activity tag
  258     */
  259     virtual bool isRelatedToActivityTag(ActivityTag* s)=0;
  260 
  261     /**
  262     Returns true if this constraint is related to this students set
  263     */
  264     virtual bool isRelatedToStudentsSet(Rules& r, StudentsSet* s)=0;
  265     
  266     virtual bool hasWrongDayOrHour(Rules& r)=0;
  267     virtual bool canRepairWrongDayOrHour(Rules& r)=0;
  268     virtual bool repairWrongDayOrHour(Rules& r)=0;
  269 };
  270 
  271 /**
  272 This class comprises all the basic compulsory constraints (constraints
  273 which must be fulfilled for any timetable) - the time allocation part
  274 */
  275 class ConstraintBasicCompulsoryTime: public TimeConstraint{
  276     Q_DECLARE_TR_FUNCTIONS(ConstraintBasicCompulsoryTime)
  277 
  278 public:
  279     ConstraintBasicCompulsoryTime();
  280 
  281     ConstraintBasicCompulsoryTime(double wp);
  282 
  283     bool computeInternalStructure(QWidget* parent, Rules& r);
  284     
  285     bool hasInactiveActivities(Rules& r);
  286 
  287     QString getXmlDescription(Rules& r);
  288 
  289     QString getDescription(Rules& r);
  290 
  291     QString getDetailedDescription(Rules& r);
  292 
  293     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  294 
  295     bool isRelatedToActivity(Rules& r, Activity* a);
  296     
  297     bool isRelatedToTeacher(Teacher* t);
  298 
  299     bool isRelatedToSubject(Subject* s);
  300 
  301     bool isRelatedToActivityTag(ActivityTag* s);
  302     
  303     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  304 
  305     bool hasWrongDayOrHour(Rules& r);
  306     bool canRepairWrongDayOrHour(Rules& r);
  307     bool repairWrongDayOrHour(Rules& r);
  308 };
  309 
  310 class ConstraintTeacherNotAvailableTimes: public TimeConstraint{
  311     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherNotAvailableTimes)
  312 
  313 public:
  314     QList<int> days;
  315     QList<int> hours;
  316 
  317     /**
  318     The teacher's name
  319     */
  320     QString teacher;
  321 
  322     /**
  323     The teacher's id, or index in the rules
  324     */
  325     int teacher_ID;
  326 
  327     ConstraintTeacherNotAvailableTimes();
  328 
  329     ConstraintTeacherNotAvailableTimes(double wp, const QString& tn, QList<int> d, QList<int> h);
  330 
  331     bool computeInternalStructure(QWidget* parent, Rules& r);
  332 
  333     bool hasInactiveActivities(Rules& r);
  334 
  335     QString getXmlDescription(Rules& r);
  336 
  337     QString getDescription(Rules& r);
  338 
  339     QString getDetailedDescription(Rules& r);
  340 
  341     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  342 
  343     bool isRelatedToActivity(Rules& r, Activity* a);
  344     
  345     bool isRelatedToTeacher(Teacher* t);
  346 
  347     bool isRelatedToSubject(Subject* s);
  348 
  349     bool isRelatedToActivityTag(ActivityTag* s);
  350     
  351     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  352 
  353     bool hasWrongDayOrHour(Rules& r);
  354     bool canRepairWrongDayOrHour(Rules& r);
  355     bool repairWrongDayOrHour(Rules& r);
  356 };
  357 
  358 class ConstraintStudentsSetNotAvailableTimes: public TimeConstraint{
  359     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetNotAvailableTimes)
  360 
  361 public:
  362     QList<int> days;
  363     QList<int> hours;
  364 
  365     /**
  366     The name of the students
  367     */
  368     QString students;
  369 
  370     /**
  371     The subgroups involved in this restriction
  372     */
  373     QList<int> iSubgroupsList;
  374 
  375     ConstraintStudentsSetNotAvailableTimes();
  376 
  377     ConstraintStudentsSetNotAvailableTimes(double wp, const QString& sn, QList<int> d, QList<int> h);
  378 
  379     bool computeInternalStructure(QWidget* parent, Rules& r);
  380 
  381     bool hasInactiveActivities(Rules& r);
  382 
  383     QString getXmlDescription(Rules& r);
  384 
  385     QString getDescription(Rules& r);
  386 
  387     QString getDetailedDescription(Rules& r);
  388 
  389     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  390 
  391     bool isRelatedToActivity(Rules& r, Activity* a);
  392     
  393     bool isRelatedToTeacher(Teacher* t);
  394 
  395     bool isRelatedToSubject(Subject* s);
  396 
  397     bool isRelatedToActivityTag(ActivityTag* s);
  398     
  399     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  400 
  401     bool hasWrongDayOrHour(Rules& r);
  402     bool canRepairWrongDayOrHour(Rules& r);
  403     bool repairWrongDayOrHour(Rules& r);
  404 };
  405 
  406 class ConstraintActivitiesSameStartingTime: public TimeConstraint{
  407     Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameStartingTime)
  408 
  409 public:
  410     /**
  411     The number of activities involved in this constraint
  412     */
  413     int n_activities;
  414 
  415     /**
  416     The activities involved in this constraint (id)
  417     */
  418     QList<int> activitiesId;
  419     //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME];
  420 
  421     /**
  422     The number of activities involved in this constraint - internal structure
  423     */
  424     int _n_activities;
  425 
  426     /**
  427     The activities involved in this constraint (indexes in the rules) - internal structure
  428     */
  429     //int _activities[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_TIME];
  430     QList<int> _activities;
  431 
  432     ConstraintActivitiesSameStartingTime();
  433 
  434     /**
  435     Constructor, using:
  436     the weight, the number of activities and the list of activities' id-s.
  437     */
  438     //ConstraintActivitiesSameStartingTime(double wp, int n_act, const int act[]);
  439     ConstraintActivitiesSameStartingTime(double wp, int n_act, const QList<int>& act);
  440 
  441     bool computeInternalStructure(QWidget* parent, Rules& r);
  442 
  443     bool hasInactiveActivities(Rules& r);
  444 
  445     QString getXmlDescription(Rules& r);
  446 
  447     QString getDescription(Rules& r);
  448 
  449     QString getDetailedDescription(Rules& r);
  450 
  451     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  452 
  453     void removeUseless(Rules& r);
  454 
  455     bool isRelatedToActivity(Rules& r, Activity* a);
  456     
  457     bool isRelatedToTeacher(Teacher* t);
  458 
  459     bool isRelatedToSubject(Subject* s);
  460 
  461     bool isRelatedToActivityTag(ActivityTag* s);
  462     
  463     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  464 
  465     bool hasWrongDayOrHour(Rules& r);
  466     bool canRepairWrongDayOrHour(Rules& r);
  467     bool repairWrongDayOrHour(Rules& r);
  468 };
  469 
  470 /**
  471 This is a constraint.
  472 It aims at scheduling a set of activities so that they do not overlap.
  473 The number of conflicts is considered the number of overlapping
  474 hours.
  475 */
  476 class ConstraintActivitiesNotOverlapping: public TimeConstraint{
  477     Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesNotOverlapping)
  478 
  479 public:
  480     /**
  481     The number of activities involved in this constraint
  482     */
  483     int n_activities;
  484 
  485     /**
  486     The activities involved in this constraint (id)
  487     */
  488     QList<int> activitiesId;
  489     //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING];
  490 
  491     /**
  492     The number of activities involved in this constraint - internal structure
  493     */
  494     int _n_activities;
  495 
  496     /**
  497     The activities involved in this constraint (index in the rules) - internal structure
  498     */
  499     //int _activities[MAX_CONSTRAINT_ACTIVITIES_NOT_OVERLAPPING];
  500     QList<int> _activities;
  501 
  502     ConstraintActivitiesNotOverlapping();
  503 
  504     /**
  505     Constructor, using:
  506     the weight, the number of activities and the list of activities.
  507     */
  508     ConstraintActivitiesNotOverlapping(double wp, int n_act, const QList<int>& act);
  509 
  510     bool computeInternalStructure(QWidget* parent, Rules& r);
  511 
  512     bool hasInactiveActivities(Rules& r);
  513 
  514     QString getXmlDescription(Rules& r);
  515 
  516     QString getDescription(Rules& r);
  517 
  518     QString getDetailedDescription(Rules& r);
  519 
  520     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  521 
  522     void removeUseless(Rules &r);
  523 
  524     bool isRelatedToActivity(Rules& r, Activity* a);
  525     
  526     bool isRelatedToTeacher(Teacher* t);
  527 
  528     bool isRelatedToSubject(Subject* s);
  529 
  530     bool isRelatedToActivityTag(ActivityTag* s);
  531     
  532     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  533 
  534     bool hasWrongDayOrHour(Rules& r);
  535     bool canRepairWrongDayOrHour(Rules& r);
  536     bool repairWrongDayOrHour(Rules& r);
  537 };
  538 
  539 class ConstraintActivityTagsNotOverlapping: public TimeConstraint{
  540     Q_DECLARE_TR_FUNCTIONS(ConstraintActivityTagsNotOverlapping)
  541 
  542 public:
  543     QStringList activityTagsNames;
  544     
  545     //internal
  546     QList<int> activityTagsIndices;
  547     
  548     QList<QList<int> > activitiesIndicesLists;
  549 
  550     ConstraintActivityTagsNotOverlapping();
  551 
  552     ConstraintActivityTagsNotOverlapping(double wp, const QStringList& atl);
  553 
  554     bool computeInternalStructure(QWidget* parent, Rules& r);
  555 
  556     bool hasInactiveActivities(Rules& r);
  557 
  558     QString getXmlDescription(Rules& r);
  559 
  560     QString getDescription(Rules& r);
  561 
  562     QString getDetailedDescription(Rules& r);
  563 
  564     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  565 
  566     bool isRelatedToActivity(Rules& r, Activity* a);
  567     
  568     bool isRelatedToTeacher(Teacher* t);
  569 
  570     bool isRelatedToSubject(Subject* s);
  571 
  572     bool isRelatedToActivityTag(ActivityTag* s);
  573     
  574     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  575 
  576     bool hasWrongDayOrHour(Rules& r);
  577     bool canRepairWrongDayOrHour(Rules& r);
  578     bool repairWrongDayOrHour(Rules& r);
  579 };
  580 
  581 /**
  582 This is a constraint.
  583 It aims at scheduling a set of activities so that they
  584 have a minimum of N days between any two of them.
  585 */
  586 class ConstraintMinDaysBetweenActivities: public TimeConstraint{
  587     Q_DECLARE_TR_FUNCTIONS(ConstraintMinDaysBetweenActivities)
  588 
  589 public:
  590     bool consecutiveIfSameDay;
  591 
  592     /**
  593     The number of activities involved in this constraint
  594     */
  595     int n_activities;
  596 
  597     /**
  598     The activities involved in this constraint (id)
  599     */
  600     QList<int> activitiesId;
  601     //int activitiesId[MAX_CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES];
  602 
  603     /**
  604     The number of minimum days between each 2 activities
  605     */
  606     int minDays;
  607 
  608     //internal structure (redundant)
  609 
  610     /**
  611     The number of activities involved in this constraint - internal structure
  612     */
  613     int _n_activities;
  614 
  615     /**
  616     The activities involved in this constraint (index in the rules) - internal structure
  617     */
  618     QList<int> _activities;
  619     //int _activities[MAX_CONSTRAINT_MIN_DAYS_BETWEEN_ACTIVITIES];
  620 
  621     ConstraintMinDaysBetweenActivities();
  622 
  623     /**
  624     Constructor, using:
  625     the weight, the number of activities and the list of activities.
  626     */
  627     //ConstraintMinDaysBetweenActivities(double wp, bool adjacentIfBroken, int n_act, const int act[], int n);
  628     ConstraintMinDaysBetweenActivities(double wp, bool adjacentIfBroken, int n_act, const QList<int>& act, int n);
  629 
  630     /**
  631     Comparison operator - to be sure that we do not introduce duplicates
  632     */
  633     bool operator==(ConstraintMinDaysBetweenActivities& c);
  634 
  635     bool computeInternalStructure(QWidget* parent, Rules& r);
  636 
  637     bool hasInactiveActivities(Rules& r);
  638 
  639     QString getXmlDescription(Rules& r);
  640 
  641     QString getDescription(Rules& r);
  642 
  643     QString getDetailedDescription(Rules& r);
  644 
  645     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  646 
  647     void removeUseless(Rules &r);
  648 
  649     bool isRelatedToActivity(Rules& r, Activity* a);
  650     
  651     bool isRelatedToTeacher(Teacher* t);
  652 
  653     bool isRelatedToSubject(Subject* s);
  654 
  655     bool isRelatedToActivityTag(ActivityTag* s);
  656     
  657     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  658 
  659     bool hasWrongDayOrHour(Rules& r);
  660     bool canRepairWrongDayOrHour(Rules& r);
  661     bool repairWrongDayOrHour(Rules& r);
  662 };
  663 
  664 class ConstraintMaxDaysBetweenActivities: public TimeConstraint{
  665     Q_DECLARE_TR_FUNCTIONS(ConstraintMaxDaysBetweenActivities)
  666 
  667 public:
  668     /**
  669     The number of activities involved in this constraint
  670     */
  671     int n_activities;
  672 
  673     /**
  674     The activities involved in this constraint (id)
  675     */
  676     QList<int> activitiesId;
  677 
  678     /**
  679     The number of maximum days between each 2 activities
  680     */
  681     int maxDays;
  682 
  683     //internal structure (redundant)
  684 
  685     /**
  686     The number of activities involved in this constraint - internal structure
  687     */
  688     int _n_activities;
  689 
  690     /**
  691     The activities involved in this constraint (index in the rules) - internal structure
  692     */
  693     QList<int> _activities;
  694 
  695     ConstraintMaxDaysBetweenActivities();
  696 
  697     /**
  698     Constructor, using:
  699     the weight, the number of activities and the list of activities.
  700     */
  701     ConstraintMaxDaysBetweenActivities(double wp, int n_act, const QList<int>& act, int n);
  702 
  703     bool computeInternalStructure(QWidget* parent, Rules& r);
  704 
  705     bool hasInactiveActivities(Rules& r);
  706 
  707     QString getXmlDescription(Rules& r);
  708 
  709     QString getDescription(Rules& r);
  710 
  711     QString getDetailedDescription(Rules& r);
  712 
  713     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  714 
  715     void removeUseless(Rules &r);
  716 
  717     bool isRelatedToActivity(Rules& r, Activity* a);
  718     
  719     bool isRelatedToTeacher(Teacher* t);
  720 
  721     bool isRelatedToSubject(Subject* s);
  722 
  723     bool isRelatedToActivityTag(ActivityTag* s);
  724     
  725     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  726 
  727     bool hasWrongDayOrHour(Rules& r);
  728     bool canRepairWrongDayOrHour(Rules& r);
  729     bool repairWrongDayOrHour(Rules& r);
  730 };
  731 
  732 class ConstraintMinGapsBetweenActivities: public TimeConstraint{
  733     Q_DECLARE_TR_FUNCTIONS(ConstraintMinGapsBetweenActivities)
  734 
  735 public:
  736     /**
  737     The number of activities involved in this constraint
  738     */
  739     int n_activities;
  740 
  741     /**
  742     The activities involved in this constraint (id)
  743     */
  744     QList<int> activitiesId;
  745 
  746     /**
  747     The number of minimum gaps between each 2 activities, if on the same day
  748     */
  749     int minGaps;
  750 
  751     //internal structure (redundant)
  752 
  753     /**
  754     The number of activities involved in this constraint - internal structure
  755     */
  756     int _n_activities;
  757 
  758     /**
  759     The activities involved in this constraint (index in the rules) - internal structure
  760     */
  761     QList<int> _activities;
  762 
  763     ConstraintMinGapsBetweenActivities();
  764 
  765     /**
  766     Constructor, using:
  767     the weight, the number of activities and the list of activities.
  768     */
  769     //ConstraintMinGapsBetweenActivities(double wp, int n_act, const int act[], int ngaps);
  770     ConstraintMinGapsBetweenActivities(double wp, int n_act, const QList<int>& actList, int ngaps);
  771 
  772     bool computeInternalStructure(QWidget* parent, Rules& r);
  773 
  774     bool hasInactiveActivities(Rules& r);
  775 
  776     QString getXmlDescription(Rules& r);
  777 
  778     QString getDescription(Rules& r);
  779 
  780     QString getDetailedDescription(Rules& r);
  781 
  782     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  783 
  784     void removeUseless(Rules &r);
  785 
  786     bool isRelatedToActivity(Rules& r, Activity* a);
  787     
  788     bool isRelatedToTeacher(Teacher* t);
  789 
  790     bool isRelatedToSubject(Subject* s);
  791 
  792     bool isRelatedToActivityTag(ActivityTag* s);
  793     
  794     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  795 
  796     bool hasWrongDayOrHour(Rules& r);
  797     bool canRepairWrongDayOrHour(Rules& r);
  798     bool repairWrongDayOrHour(Rules& r);
  799 };
  800 
  801 /**
  802 This is a constraint, aimed at obtaining timetables
  803 which do not allow more than X hours in a day for any teacher
  804 */
  805 class ConstraintTeachersMaxHoursDaily: public TimeConstraint{
  806     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxHoursDaily)
  807 
  808 public:
  809     /**
  810     The maximum hours daily
  811     */
  812     int maxHoursDaily;
  813 
  814     ConstraintTeachersMaxHoursDaily();
  815 
  816     ConstraintTeachersMaxHoursDaily(double wp, int maxhours);
  817 
  818     QString getXmlDescription(Rules& r);
  819 
  820     bool computeInternalStructure(QWidget* parent, Rules& r);
  821 
  822     bool hasInactiveActivities(Rules& r);
  823 
  824     QString getDescription(Rules& r);
  825 
  826     QString getDetailedDescription(Rules& r);
  827 
  828     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  829 
  830     bool isRelatedToActivity(Rules& r, Activity* a);
  831     
  832     bool isRelatedToTeacher(Teacher* t);
  833 
  834     bool isRelatedToSubject(Subject* s);
  835 
  836     bool isRelatedToActivityTag(ActivityTag* s);
  837     
  838     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  839 
  840     bool hasWrongDayOrHour(Rules& r);
  841     bool canRepairWrongDayOrHour(Rules& r);
  842     bool repairWrongDayOrHour(Rules& r);
  843 };
  844 
  845 class ConstraintTeacherMaxHoursDaily: public TimeConstraint{
  846     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxHoursDaily)
  847 
  848 public:
  849     /**
  850     The maximum hours daily
  851     */
  852     int maxHoursDaily;
  853     
  854     QString teacherName;
  855     
  856     int teacher_ID;
  857 
  858     ConstraintTeacherMaxHoursDaily();
  859 
  860     ConstraintTeacherMaxHoursDaily(double wp, int maxhours, const QString& teacher);
  861 
  862     QString getXmlDescription(Rules& r);
  863 
  864     bool computeInternalStructure(QWidget* parent, Rules& r);
  865 
  866     bool hasInactiveActivities(Rules& r);
  867 
  868     QString getDescription(Rules& r);
  869 
  870     QString getDetailedDescription(Rules& r);
  871 
  872     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  873 
  874     bool isRelatedToActivity(Rules& r, Activity* a);
  875     
  876     bool isRelatedToTeacher(Teacher* t);
  877 
  878     bool isRelatedToSubject(Subject* s);
  879 
  880     bool isRelatedToActivityTag(ActivityTag* s);
  881     
  882     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  883 
  884     bool hasWrongDayOrHour(Rules& r);
  885     bool canRepairWrongDayOrHour(Rules& r);
  886     bool repairWrongDayOrHour(Rules& r);
  887 };
  888 
  889 /**
  890 This is a constraint, aimed at obtaining timetables
  891 which do not allow more than X hours in a row for any teacher
  892 */
  893 class ConstraintTeachersMaxHoursContinuously: public TimeConstraint{
  894     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxHoursContinuously)
  895 
  896 public:
  897     /**
  898     The maximum hours continuously
  899     */
  900     int maxHoursContinuously;
  901 
  902     ConstraintTeachersMaxHoursContinuously();
  903 
  904     ConstraintTeachersMaxHoursContinuously(double wp, int maxhours);
  905 
  906     QString getXmlDescription(Rules& r);
  907 
  908     bool computeInternalStructure(QWidget* parent, Rules& r);
  909 
  910     bool hasInactiveActivities(Rules& r);
  911 
  912     QString getDescription(Rules& r);
  913 
  914     QString getDetailedDescription(Rules& r);
  915 
  916     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  917 
  918     bool isRelatedToActivity(Rules& r, Activity* a);
  919     
  920     bool isRelatedToTeacher(Teacher* t);
  921 
  922     bool isRelatedToSubject(Subject* s);
  923 
  924     bool isRelatedToActivityTag(ActivityTag* s);
  925     
  926     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  927 
  928     bool hasWrongDayOrHour(Rules& r);
  929     bool canRepairWrongDayOrHour(Rules& r);
  930     bool repairWrongDayOrHour(Rules& r);
  931 };
  932 
  933 class ConstraintTeacherMaxHoursContinuously: public TimeConstraint{
  934     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxHoursContinuously)
  935 
  936 public:
  937     /**
  938     The maximum hours continuously
  939     */
  940     int maxHoursContinuously;
  941     
  942     QString teacherName;
  943     
  944     int teacher_ID;
  945 
  946     ConstraintTeacherMaxHoursContinuously();
  947 
  948     ConstraintTeacherMaxHoursContinuously(double wp, int maxhours, const QString& teacher);
  949 
  950     QString getXmlDescription(Rules& r);
  951 
  952     bool computeInternalStructure(QWidget* parent, Rules& r);
  953 
  954     bool hasInactiveActivities(Rules& r);
  955 
  956     QString getDescription(Rules& r);
  957 
  958     QString getDetailedDescription(Rules& r);
  959 
  960     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
  961 
  962     bool isRelatedToActivity(Rules& r, Activity* a);
  963     
  964     bool isRelatedToTeacher(Teacher* t);
  965 
  966     bool isRelatedToSubject(Subject* s);
  967 
  968     bool isRelatedToActivityTag(ActivityTag* s);
  969     
  970     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
  971 
  972     bool hasWrongDayOrHour(Rules& r);
  973     bool canRepairWrongDayOrHour(Rules& r);
  974     bool repairWrongDayOrHour(Rules& r);
  975 };
  976 
  977 class ConstraintTeachersActivityTagMaxHoursContinuously: public TimeConstraint{
  978     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMaxHoursContinuously)
  979 
  980 public:
  981     /**
  982     The maximum hours continuously
  983     */
  984     int maxHoursContinuously;
  985     
  986     QString activityTagName;
  987     
  988     int activityTagIndex;
  989     
  990     QList<int> canonicalTeachersList;
  991 
  992     ConstraintTeachersActivityTagMaxHoursContinuously();
  993 
  994     ConstraintTeachersActivityTagMaxHoursContinuously(double wp, int maxhours, const QString& activityTag);
  995 
  996     QString getXmlDescription(Rules& r);
  997 
  998     bool computeInternalStructure(QWidget* parent, Rules& r);
  999 
 1000     bool hasInactiveActivities(Rules& r);
 1001 
 1002     QString getDescription(Rules& r);
 1003 
 1004     QString getDetailedDescription(Rules& r);
 1005 
 1006     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1007 
 1008     bool isRelatedToActivity(Rules& r, Activity* a);
 1009     
 1010     bool isRelatedToTeacher(Teacher* t);
 1011 
 1012     bool isRelatedToSubject(Subject* s);
 1013 
 1014     bool isRelatedToActivityTag(ActivityTag* s);
 1015     
 1016     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1017 
 1018     bool hasWrongDayOrHour(Rules& r);
 1019     bool canRepairWrongDayOrHour(Rules& r);
 1020     bool repairWrongDayOrHour(Rules& r);
 1021 };
 1022 
 1023 class ConstraintTeacherActivityTagMaxHoursContinuously: public TimeConstraint{
 1024     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMaxHoursContinuously)
 1025 
 1026 public:
 1027     /**
 1028     The maximum hours continuously
 1029     */
 1030     int maxHoursContinuously;
 1031     
 1032     QString teacherName;
 1033     
 1034     QString activityTagName;
 1035     
 1036     int teacher_ID;
 1037 
 1038     int activityTagIndex;
 1039     
 1040     QList<int> canonicalTeachersList;
 1041 
 1042     ConstraintTeacherActivityTagMaxHoursContinuously();
 1043 
 1044     ConstraintTeacherActivityTagMaxHoursContinuously(double wp, int maxhours, const QString& teacher, const QString& activityTag);
 1045 
 1046     QString getXmlDescription(Rules& r);
 1047 
 1048     bool computeInternalStructure(QWidget* parent, Rules& r);
 1049 
 1050     bool hasInactiveActivities(Rules& r);
 1051 
 1052     QString getDescription(Rules& r);
 1053 
 1054     QString getDetailedDescription(Rules& r);
 1055 
 1056     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1057 
 1058     bool isRelatedToActivity(Rules& r, Activity* a);
 1059     
 1060     bool isRelatedToTeacher(Teacher* t);
 1061 
 1062     bool isRelatedToSubject(Subject* s);
 1063 
 1064     bool isRelatedToActivityTag(ActivityTag* s);
 1065     
 1066     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1067 
 1068     bool hasWrongDayOrHour(Rules& r);
 1069     bool canRepairWrongDayOrHour(Rules& r);
 1070     bool repairWrongDayOrHour(Rules& r);
 1071 };
 1072 
 1073 /**
 1074 This is a constraint.
 1075 The resulting timetable must respect the requirement
 1076 that this teacher must not have too much working
 1077 days per week.
 1078 */
 1079 class ConstraintTeacherMaxDaysPerWeek: public TimeConstraint{
 1080     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxDaysPerWeek)
 1081 
 1082 public:
 1083     /**
 1084     The number of maximum allowed working days per week (-1 for don't care)
 1085     */
 1086     int maxDaysPerWeek;
 1087 
 1088     /**
 1089     The teacher's name
 1090     */
 1091     QString teacherName;
 1092 
 1093     /**
 1094     The teacher's id, or index in the rules
 1095     */
 1096     int teacher_ID;
 1097 
 1098     ConstraintTeacherMaxDaysPerWeek();
 1099 
 1100     ConstraintTeacherMaxDaysPerWeek(double wp, int maxnd, const QString& t);
 1101 
 1102     bool computeInternalStructure(QWidget* parent, Rules& r);
 1103 
 1104     bool hasInactiveActivities(Rules& r);
 1105 
 1106     QString getXmlDescription(Rules& r);
 1107 
 1108     QString getDescription(Rules& r);
 1109 
 1110     QString getDetailedDescription(Rules& r);
 1111 
 1112     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1113 
 1114     bool isRelatedToActivity(Rules& r, Activity* a);
 1115     
 1116     bool isRelatedToTeacher(Teacher* t);
 1117 
 1118     bool isRelatedToSubject(Subject* s);
 1119 
 1120     bool isRelatedToActivityTag(ActivityTag* s);
 1121     
 1122     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1123 
 1124     bool hasWrongDayOrHour(Rules& r);
 1125     bool canRepairWrongDayOrHour(Rules& r);
 1126     bool repairWrongDayOrHour(Rules& r);
 1127 };
 1128 
 1129 class ConstraintTeachersMaxDaysPerWeek: public TimeConstraint{
 1130     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxDaysPerWeek)
 1131 
 1132 public:
 1133     /**
 1134     The number of maximum allowed working days per week (-1 for don't care)
 1135     */
 1136     int maxDaysPerWeek;
 1137 
 1138     ConstraintTeachersMaxDaysPerWeek();
 1139 
 1140     ConstraintTeachersMaxDaysPerWeek(double wp, int maxnd);
 1141 
 1142     bool computeInternalStructure(QWidget* parent, Rules& r);
 1143 
 1144     bool hasInactiveActivities(Rules& r);
 1145 
 1146     QString getXmlDescription(Rules& r);
 1147 
 1148     QString getDescription(Rules& r);
 1149 
 1150     QString getDetailedDescription(Rules& r);
 1151 
 1152     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1153 
 1154     bool isRelatedToActivity(Rules& r, Activity* a);
 1155     
 1156     bool isRelatedToTeacher(Teacher* t);
 1157 
 1158     bool isRelatedToSubject(Subject* s);
 1159 
 1160     bool isRelatedToActivityTag(ActivityTag* s);
 1161     
 1162     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1163 
 1164     bool hasWrongDayOrHour(Rules& r);
 1165     bool canRepairWrongDayOrHour(Rules& r);
 1166     bool repairWrongDayOrHour(Rules& r);
 1167 };
 1168 
 1169 class ConstraintTeacherMinDaysPerWeek: public TimeConstraint{
 1170     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinDaysPerWeek)
 1171 
 1172 public:
 1173     int minDaysPerWeek;
 1174 
 1175     /**
 1176     The teacher's name
 1177     */
 1178     QString teacherName;
 1179 
 1180     /**
 1181     The teacher's id, or index in the rules
 1182     */
 1183     int teacher_ID;
 1184 
 1185     ConstraintTeacherMinDaysPerWeek();
 1186 
 1187     ConstraintTeacherMinDaysPerWeek(double wp, int mindays, const QString& t);
 1188 
 1189     bool computeInternalStructure(QWidget* parent, Rules& r);
 1190 
 1191     bool hasInactiveActivities(Rules& r);
 1192 
 1193     QString getXmlDescription(Rules& r);
 1194 
 1195     QString getDescription(Rules& r);
 1196 
 1197     QString getDetailedDescription(Rules& r);
 1198 
 1199     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1200 
 1201     bool isRelatedToActivity(Rules& r, Activity* a);
 1202     
 1203     bool isRelatedToTeacher(Teacher* t);
 1204 
 1205     bool isRelatedToSubject(Subject* s);
 1206 
 1207     bool isRelatedToActivityTag(ActivityTag* s);
 1208     
 1209     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1210 
 1211     bool hasWrongDayOrHour(Rules& r);
 1212     bool canRepairWrongDayOrHour(Rules& r);
 1213     bool repairWrongDayOrHour(Rules& r);
 1214 };
 1215 
 1216 class ConstraintTeachersMinDaysPerWeek: public TimeConstraint{
 1217     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinDaysPerWeek)
 1218 
 1219 public:
 1220     int minDaysPerWeek;
 1221 
 1222     ConstraintTeachersMinDaysPerWeek();
 1223 
 1224     ConstraintTeachersMinDaysPerWeek(double wp, int mindays);
 1225 
 1226     bool computeInternalStructure(QWidget* parent, Rules& r);
 1227 
 1228     bool hasInactiveActivities(Rules& r);
 1229 
 1230     QString getXmlDescription(Rules& r);
 1231 
 1232     QString getDescription(Rules& r);
 1233 
 1234     QString getDetailedDescription(Rules& r);
 1235 
 1236     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1237 
 1238     bool isRelatedToActivity(Rules& r, Activity* a);
 1239     
 1240     bool isRelatedToTeacher(Teacher* t);
 1241 
 1242     bool isRelatedToSubject(Subject* s);
 1243 
 1244     bool isRelatedToActivityTag(ActivityTag* s);
 1245     
 1246     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1247 
 1248     bool hasWrongDayOrHour(Rules& r);
 1249     bool canRepairWrongDayOrHour(Rules& r);
 1250     bool repairWrongDayOrHour(Rules& r);
 1251 };
 1252 
 1253 /**
 1254 This is a constraint.
 1255 It constrains the timetable to not schedule any activity
 1256 in the specified day, during the start hour and end hour.
 1257 */
 1258 class ConstraintBreakTimes: public TimeConstraint{
 1259     Q_DECLARE_TR_FUNCTIONS(ConstraintBreakTimes)
 1260 
 1261 public:
 1262     QList<int> days;
 1263     QList<int> hours;
 1264 
 1265     ConstraintBreakTimes();
 1266 
 1267     ConstraintBreakTimes(double wp, QList<int> d, QList<int> h);
 1268 
 1269     bool computeInternalStructure(QWidget* parent, Rules& r);
 1270 
 1271     bool hasInactiveActivities(Rules& r);
 1272 
 1273     QString getXmlDescription(Rules& r);
 1274 
 1275     QString getDescription(Rules& r);
 1276 
 1277     QString getDetailedDescription(Rules& r);
 1278 
 1279     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1280 
 1281     bool isRelatedToActivity(Rules& r, Activity* a);
 1282     
 1283     bool isRelatedToTeacher(Teacher* t);
 1284 
 1285     bool isRelatedToSubject(Subject* s);
 1286 
 1287     bool isRelatedToActivityTag(ActivityTag* s);
 1288     
 1289     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1290 
 1291     bool hasWrongDayOrHour(Rules& r);
 1292     bool canRepairWrongDayOrHour(Rules& r);
 1293     bool repairWrongDayOrHour(Rules& r);
 1294 };
 1295 
 1296 /**
 1297 This is a constraint. It adds, to the fitness of
 1298 the solution, a conflicts factor computed from the gaps
 1299 existing in the timetable (regarding the students).
 1300 The overall result is a timetable having less gaps for the students.
 1301 */
 1302 class ConstraintStudentsMaxGapsPerWeek: public TimeConstraint{
 1303     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxGapsPerWeek)
 1304 
 1305 public:
 1306     int maxGaps;
 1307 
 1308     ConstraintStudentsMaxGapsPerWeek();
 1309 
 1310     ConstraintStudentsMaxGapsPerWeek(double wp, int mg);
 1311 
 1312     bool computeInternalStructure(QWidget* parent, Rules& r);
 1313 
 1314     bool hasInactiveActivities(Rules& r);
 1315 
 1316     QString getXmlDescription(Rules& r);
 1317 
 1318     QString getDescription(Rules& r);
 1319 
 1320     QString getDetailedDescription(Rules& r);
 1321 
 1322     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1323 
 1324     bool isRelatedToActivity(Rules& r, Activity* a);
 1325     
 1326     bool isRelatedToTeacher(Teacher* t);
 1327 
 1328     bool isRelatedToSubject(Subject* s);
 1329 
 1330     bool isRelatedToActivityTag(ActivityTag* s);
 1331     
 1332     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1333 
 1334     bool hasWrongDayOrHour(Rules& r);
 1335     bool canRepairWrongDayOrHour(Rules& r);
 1336     bool repairWrongDayOrHour(Rules& r);
 1337 };
 1338 
 1339 /**
 1340 This is a constraint. It adds, to the fitness of
 1341 the solution, a conflicts factor computed from the gaps
 1342 existing in the timetable (regarding the specified students set).
 1343 */
 1344 class ConstraintStudentsSetMaxGapsPerWeek: public TimeConstraint{
 1345     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxGapsPerWeek)
 1346 
 1347 public:
 1348     int maxGaps;
 1349 
 1350     /**
 1351     The name of the students set for this constraint
 1352     */
 1353     QString students;
 1354 
 1355     //internal redundant data
 1356 
 1357     /**
 1358     The number of subgroups
 1359     */
 1360     //int nSubgroups;
 1361 
 1362     /**
 1363     The subgroups
 1364     */
 1365     QList<int> iSubgroupsList;
 1366 
 1367     ConstraintStudentsSetMaxGapsPerWeek();
 1368 
 1369     ConstraintStudentsSetMaxGapsPerWeek(double wp, int mg, const QString& st);
 1370 
 1371     bool computeInternalStructure(QWidget* parent, Rules& r);
 1372 
 1373     bool hasInactiveActivities(Rules& r);
 1374 
 1375     QString getXmlDescription(Rules& r);
 1376 
 1377     QString getDescription(Rules& r);
 1378 
 1379     QString getDetailedDescription(Rules& r);
 1380 
 1381     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1382 
 1383     bool isRelatedToActivity(Rules& r, Activity* a);
 1384     
 1385     bool isRelatedToTeacher(Teacher* t);
 1386 
 1387     bool isRelatedToSubject(Subject* s);
 1388 
 1389     bool isRelatedToActivityTag(ActivityTag* s);
 1390     
 1391     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1392 
 1393     bool hasWrongDayOrHour(Rules& r);
 1394     bool canRepairWrongDayOrHour(Rules& r);
 1395     bool repairWrongDayOrHour(Rules& r);
 1396 };
 1397 
 1398 class ConstraintTeachersMaxGapsPerWeek: public TimeConstraint{
 1399     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerWeek)
 1400 
 1401 public:
 1402     int maxGaps;    
 1403 
 1404     ConstraintTeachersMaxGapsPerWeek();
 1405 
 1406     ConstraintTeachersMaxGapsPerWeek(double wp, int maxGaps);
 1407 
 1408     bool computeInternalStructure(QWidget* parent, Rules& r);
 1409 
 1410     bool hasInactiveActivities(Rules& r);
 1411 
 1412     QString getXmlDescription(Rules& r);
 1413 
 1414     QString getDescription(Rules& r);
 1415 
 1416     QString getDetailedDescription(Rules& r);
 1417 
 1418     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1419 
 1420     bool isRelatedToActivity(Rules& r, Activity* a);
 1421     
 1422     bool isRelatedToTeacher(Teacher* t);
 1423 
 1424     bool isRelatedToSubject(Subject* s);
 1425 
 1426     bool isRelatedToActivityTag(ActivityTag* s);
 1427     
 1428     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1429 
 1430     bool hasWrongDayOrHour(Rules& r);
 1431     bool canRepairWrongDayOrHour(Rules& r);
 1432     bool repairWrongDayOrHour(Rules& r);
 1433 };
 1434 
 1435 class ConstraintTeacherMaxGapsPerWeek: public TimeConstraint{
 1436     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerWeek)
 1437 
 1438 public:
 1439     int maxGaps;
 1440     
 1441     QString teacherName;
 1442     
 1443     int teacherIndex;
 1444 
 1445     ConstraintTeacherMaxGapsPerWeek();
 1446 
 1447     ConstraintTeacherMaxGapsPerWeek(double wp, const QString& tn, int maxGaps);
 1448 
 1449     bool computeInternalStructure(QWidget* parent, Rules& r);
 1450 
 1451     bool hasInactiveActivities(Rules& r);
 1452 
 1453     QString getXmlDescription(Rules& r);
 1454 
 1455     QString getDescription(Rules& r);
 1456 
 1457     QString getDetailedDescription(Rules& r);
 1458 
 1459     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1460 
 1461     bool isRelatedToActivity(Rules& r, Activity* a);
 1462     
 1463     bool isRelatedToTeacher(Teacher* t);
 1464 
 1465     bool isRelatedToSubject(Subject* s);
 1466 
 1467     bool isRelatedToActivityTag(ActivityTag* s);
 1468     
 1469     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1470 
 1471     bool hasWrongDayOrHour(Rules& r);
 1472     bool canRepairWrongDayOrHour(Rules& r);
 1473     bool repairWrongDayOrHour(Rules& r);
 1474 };
 1475 
 1476 class ConstraintTeachersMaxGapsPerDay: public TimeConstraint{
 1477     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxGapsPerDay)
 1478 
 1479 public:
 1480     int maxGaps;    
 1481 
 1482     ConstraintTeachersMaxGapsPerDay();
 1483 
 1484     ConstraintTeachersMaxGapsPerDay(double wp, int maxGaps);
 1485 
 1486     bool computeInternalStructure(QWidget* parent, Rules& r);
 1487 
 1488     bool hasInactiveActivities(Rules& r);
 1489 
 1490     QString getXmlDescription(Rules& r);
 1491 
 1492     QString getDescription(Rules& r);
 1493 
 1494     QString getDetailedDescription(Rules& r);
 1495 
 1496     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1497 
 1498     bool isRelatedToActivity(Rules& r, Activity* a);
 1499     
 1500     bool isRelatedToTeacher(Teacher* t);
 1501 
 1502     bool isRelatedToSubject(Subject* s);
 1503 
 1504     bool isRelatedToActivityTag(ActivityTag* s);
 1505     
 1506     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1507 
 1508     bool hasWrongDayOrHour(Rules& r);
 1509     bool canRepairWrongDayOrHour(Rules& r);
 1510     bool repairWrongDayOrHour(Rules& r);
 1511 };
 1512 
 1513 class ConstraintTeacherMaxGapsPerDay: public TimeConstraint{
 1514     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxGapsPerDay)
 1515 
 1516 public:
 1517     int maxGaps;
 1518     
 1519     QString teacherName;
 1520     
 1521     int teacherIndex;
 1522 
 1523     ConstraintTeacherMaxGapsPerDay();
 1524 
 1525     ConstraintTeacherMaxGapsPerDay(double wp, const QString& tn, int maxGaps);
 1526 
 1527     bool computeInternalStructure(QWidget* parent, Rules& r);
 1528 
 1529     bool hasInactiveActivities(Rules& r);
 1530 
 1531     QString getXmlDescription(Rules& r);
 1532 
 1533     QString getDescription(Rules& r);
 1534 
 1535     QString getDetailedDescription(Rules& r);
 1536 
 1537     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1538 
 1539     bool isRelatedToActivity(Rules& r, Activity* a);
 1540     
 1541     bool isRelatedToTeacher(Teacher* t);
 1542 
 1543     bool isRelatedToSubject(Subject* s);
 1544 
 1545     bool isRelatedToActivityTag(ActivityTag* s);
 1546     
 1547     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1548 
 1549     bool hasWrongDayOrHour(Rules& r);
 1550     bool canRepairWrongDayOrHour(Rules& r);
 1551     bool repairWrongDayOrHour(Rules& r);
 1552 };
 1553 
 1554 /**
 1555 This is a constraint. It adds, to the fitness of
 1556 the solution, a fitness factor that is related to how early
 1557 the students begin their courses. The result is a timetable
 1558 having more activities scheduled at the beginning of the day.
 1559 IMPORTANT: fortnightly activities are treated as weekly ones,
 1560 for speed and because in normal situations this does not matter.
 1561 */
 1562 class ConstraintStudentsEarlyMaxBeginningsAtSecondHour: public TimeConstraint{
 1563     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsEarlyMaxBeginningsAtSecondHour)
 1564 
 1565 public:
 1566 
 1567     int maxBeginningsAtSecondHour;
 1568 
 1569     ConstraintStudentsEarlyMaxBeginningsAtSecondHour();
 1570 
 1571     ConstraintStudentsEarlyMaxBeginningsAtSecondHour(double wp, int mBSH);
 1572 
 1573     bool computeInternalStructure(QWidget* parent, Rules& r);
 1574 
 1575     bool hasInactiveActivities(Rules& r);
 1576 
 1577     QString getXmlDescription(Rules& r);
 1578 
 1579     QString getDescription(Rules& r);
 1580 
 1581     QString getDetailedDescription(Rules& r);
 1582 
 1583     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1584 
 1585     bool isRelatedToActivity(Rules& r, Activity* a);
 1586     
 1587     bool isRelatedToTeacher(Teacher* t);
 1588 
 1589     bool isRelatedToSubject(Subject* s);
 1590 
 1591     bool isRelatedToActivityTag(ActivityTag* s);
 1592     
 1593     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1594 
 1595     bool hasWrongDayOrHour(Rules& r);
 1596     bool canRepairWrongDayOrHour(Rules& r);
 1597     bool repairWrongDayOrHour(Rules& r);
 1598 };
 1599 
 1600 class ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour: public TimeConstraint{
 1601     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour)
 1602 
 1603 public:
 1604     int maxBeginningsAtSecondHour;
 1605 
 1606     /**
 1607     The name of the students
 1608     */
 1609     QString students;
 1610 
 1611     /**
 1612     The number of subgroups involved in this restriction
 1613     */
 1614     //int nSubgroups;
 1615 
 1616     /**
 1617     The subgroups involved in this restriction
 1618     */
 1619     //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
 1620     QList<int> iSubgroupsList;
 1621 
 1622     ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour();
 1623 
 1624     ConstraintStudentsSetEarlyMaxBeginningsAtSecondHour(double wp, int mBSH, const QString& students);
 1625 
 1626     bool computeInternalStructure(QWidget* parent, Rules& r);
 1627 
 1628     bool hasInactiveActivities(Rules& r);
 1629 
 1630     QString getXmlDescription(Rules& r);
 1631 
 1632     QString getDescription(Rules& r);
 1633 
 1634     QString getDetailedDescription(Rules& r);
 1635 
 1636     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1637 
 1638     bool isRelatedToActivity(Rules& r, Activity* a);
 1639     
 1640     bool isRelatedToTeacher(Teacher* t);
 1641 
 1642     bool isRelatedToSubject(Subject* s);
 1643 
 1644     bool isRelatedToActivityTag(ActivityTag* s);
 1645     
 1646     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1647 
 1648     bool hasWrongDayOrHour(Rules& r);
 1649     bool canRepairWrongDayOrHour(Rules& r);
 1650     bool repairWrongDayOrHour(Rules& r);
 1651 };
 1652 
 1653 class ConstraintStudentsMaxHoursDaily: public TimeConstraint{
 1654     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxHoursDaily)
 1655 
 1656 public:
 1657     int maxHoursDaily;
 1658 
 1659     ConstraintStudentsMaxHoursDaily();
 1660 
 1661     ConstraintStudentsMaxHoursDaily(double wp, int maxnh);
 1662 
 1663     bool computeInternalStructure(QWidget* parent, Rules& r);
 1664 
 1665     bool hasInactiveActivities(Rules& r);
 1666 
 1667     QString getXmlDescription(Rules& r);
 1668 
 1669     QString getDescription(Rules& r);
 1670 
 1671     QString getDetailedDescription(Rules& r);
 1672 
 1673     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1674 
 1675     bool isRelatedToActivity(Rules& r, Activity* a);
 1676     
 1677     bool isRelatedToTeacher(Teacher* t);
 1678 
 1679     bool isRelatedToSubject(Subject* s);
 1680 
 1681     bool isRelatedToActivityTag(ActivityTag* s);
 1682     
 1683     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1684 
 1685     bool hasWrongDayOrHour(Rules& r);
 1686     bool canRepairWrongDayOrHour(Rules& r);
 1687     bool repairWrongDayOrHour(Rules& r);
 1688 };
 1689 
 1690 class ConstraintStudentsSetMaxHoursDaily: public TimeConstraint{
 1691     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxHoursDaily)
 1692 
 1693 public:
 1694     int maxHoursDaily;
 1695 
 1696     /**
 1697     The students set name
 1698     */
 1699     QString students;
 1700 
 1701     //internal variables
 1702 
 1703     /**
 1704     The number of subgroups
 1705     */
 1706     //int nSubgroups;
 1707 
 1708     /**
 1709     The subgroups
 1710     */
 1711     //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
 1712     QList<int> iSubgroupsList;
 1713 
 1714     ConstraintStudentsSetMaxHoursDaily();
 1715 
 1716     ConstraintStudentsSetMaxHoursDaily(double wp, int maxnh, const QString& s);
 1717 
 1718     bool computeInternalStructure(QWidget* parent, Rules& r);
 1719 
 1720     bool hasInactiveActivities(Rules& r);
 1721 
 1722     QString getXmlDescription(Rules& r);
 1723 
 1724     QString getDescription(Rules& r);
 1725 
 1726     QString getDetailedDescription(Rules& r);
 1727 
 1728     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1729 
 1730     bool isRelatedToActivity(Rules& r, Activity* a);
 1731     
 1732     bool isRelatedToTeacher(Teacher* t);
 1733 
 1734     bool isRelatedToSubject(Subject* s);
 1735 
 1736     bool isRelatedToActivityTag(ActivityTag* s);
 1737     
 1738     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1739 
 1740     bool hasWrongDayOrHour(Rules& r);
 1741     bool canRepairWrongDayOrHour(Rules& r);
 1742     bool repairWrongDayOrHour(Rules& r);
 1743 };
 1744 
 1745 class ConstraintStudentsMaxHoursContinuously: public TimeConstraint{
 1746     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxHoursContinuously)
 1747 
 1748 public:
 1749     int maxHoursContinuously;
 1750 
 1751     ConstraintStudentsMaxHoursContinuously();
 1752 
 1753     ConstraintStudentsMaxHoursContinuously(double wp, int maxnh);
 1754 
 1755     bool computeInternalStructure(QWidget* parent, Rules& r);
 1756 
 1757     bool hasInactiveActivities(Rules& r);
 1758 
 1759     QString getXmlDescription(Rules& r);
 1760 
 1761     QString getDescription(Rules& r);
 1762 
 1763     QString getDetailedDescription(Rules& r);
 1764 
 1765     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1766 
 1767     bool isRelatedToActivity(Rules& r, Activity* a);
 1768     
 1769     bool isRelatedToTeacher(Teacher* t);
 1770 
 1771     bool isRelatedToSubject(Subject* s);
 1772 
 1773     bool isRelatedToActivityTag(ActivityTag* s);
 1774     
 1775     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1776 
 1777     bool hasWrongDayOrHour(Rules& r);
 1778     bool canRepairWrongDayOrHour(Rules& r);
 1779     bool repairWrongDayOrHour(Rules& r);
 1780 };
 1781 
 1782 class ConstraintStudentsSetMaxHoursContinuously: public TimeConstraint{
 1783     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxHoursContinuously)
 1784 
 1785 public:
 1786     int maxHoursContinuously;
 1787 
 1788     /**
 1789     The students set name
 1790     */
 1791     QString students;
 1792 
 1793     //internal variables
 1794 
 1795     /**
 1796     The number of subgroups
 1797     */
 1798     //int nSubgroups;
 1799 
 1800     /**
 1801     The subgroups
 1802     */
 1803     //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
 1804     QList<int> iSubgroupsList;
 1805 
 1806     ConstraintStudentsSetMaxHoursContinuously();
 1807 
 1808     ConstraintStudentsSetMaxHoursContinuously(double wp, int maxnh, const QString& s);
 1809 
 1810     bool computeInternalStructure(QWidget* parent, Rules& r);
 1811 
 1812     bool hasInactiveActivities(Rules& r);
 1813 
 1814     QString getXmlDescription(Rules& r);
 1815 
 1816     QString getDescription(Rules& r);
 1817 
 1818     QString getDetailedDescription(Rules& r);
 1819 
 1820     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1821 
 1822     bool isRelatedToActivity(Rules& r, Activity* a);
 1823     
 1824     bool isRelatedToTeacher(Teacher* t);
 1825 
 1826     bool isRelatedToSubject(Subject* s);
 1827 
 1828     bool isRelatedToActivityTag(ActivityTag* s);
 1829     
 1830     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1831 
 1832     bool hasWrongDayOrHour(Rules& r);
 1833     bool canRepairWrongDayOrHour(Rules& r);
 1834     bool repairWrongDayOrHour(Rules& r);
 1835 };
 1836 
 1837 class ConstraintStudentsActivityTagMaxHoursContinuously: public TimeConstraint{
 1838     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMaxHoursContinuously)
 1839 
 1840 public:
 1841     int maxHoursContinuously;
 1842     
 1843     QString activityTagName;
 1844     
 1845     int activityTagIndex;
 1846     
 1847     QList<int> canonicalSubgroupsList;
 1848 
 1849     ConstraintStudentsActivityTagMaxHoursContinuously();
 1850 
 1851     ConstraintStudentsActivityTagMaxHoursContinuously(double wp, int maxnh, const QString& activityTag);
 1852 
 1853     bool computeInternalStructure(QWidget* parent, Rules& r);
 1854 
 1855     bool hasInactiveActivities(Rules& r);
 1856 
 1857     QString getXmlDescription(Rules& r);
 1858 
 1859     QString getDescription(Rules& r);
 1860 
 1861     QString getDetailedDescription(Rules& r);
 1862 
 1863     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1864 
 1865     bool isRelatedToActivity(Rules& r, Activity* a);
 1866     
 1867     bool isRelatedToTeacher(Teacher* t);
 1868 
 1869     bool isRelatedToSubject(Subject* s);
 1870 
 1871     bool isRelatedToActivityTag(ActivityTag* s);
 1872     
 1873     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1874 
 1875     bool hasWrongDayOrHour(Rules& r);
 1876     bool canRepairWrongDayOrHour(Rules& r);
 1877     bool repairWrongDayOrHour(Rules& r);
 1878 };
 1879 
 1880 class ConstraintStudentsSetActivityTagMaxHoursContinuously: public TimeConstraint{
 1881     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMaxHoursContinuously)
 1882 
 1883 public:
 1884     int maxHoursContinuously;
 1885 
 1886     /**
 1887     The students set name
 1888     */
 1889     QString students;
 1890     
 1891     QString activityTagName;
 1892 
 1893     //internal variables
 1894     
 1895     int activityTagIndex;
 1896 
 1897     /**
 1898     The number of subgroups
 1899     */
 1900     //int nSubgroups;
 1901 
 1902     /**
 1903     The subgroups
 1904     */
 1905     //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
 1906     QList<int> iSubgroupsList;
 1907     
 1908     QList<int> canonicalSubgroupsList;
 1909 
 1910     ConstraintStudentsSetActivityTagMaxHoursContinuously();
 1911 
 1912     ConstraintStudentsSetActivityTagMaxHoursContinuously(double wp, int maxnh, const QString& s, const QString& activityTag);
 1913 
 1914     bool computeInternalStructure(QWidget* parent, Rules& r);
 1915 
 1916     bool hasInactiveActivities(Rules& r);
 1917 
 1918     QString getXmlDescription(Rules& r);
 1919 
 1920     QString getDescription(Rules& r);
 1921 
 1922     QString getDetailedDescription(Rules& r);
 1923 
 1924     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1925 
 1926     bool isRelatedToActivity(Rules& r, Activity* a);
 1927     
 1928     bool isRelatedToTeacher(Teacher* t);
 1929 
 1930     bool isRelatedToSubject(Subject* s);
 1931 
 1932     bool isRelatedToActivityTag(ActivityTag* s);
 1933     
 1934     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1935 
 1936     bool hasWrongDayOrHour(Rules& r);
 1937     bool canRepairWrongDayOrHour(Rules& r);
 1938     bool repairWrongDayOrHour(Rules& r);
 1939 };
 1940 
 1941 class ConstraintStudentsMinHoursDaily: public TimeConstraint{
 1942     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinHoursDaily)
 1943 
 1944 public:
 1945     int minHoursDaily;
 1946     
 1947     bool allowEmptyDays;
 1948 
 1949     ConstraintStudentsMinHoursDaily();
 1950 
 1951     ConstraintStudentsMinHoursDaily(double wp, int minnh, bool _allowEmptyDays);
 1952 
 1953     bool computeInternalStructure(QWidget* parent, Rules& r);
 1954 
 1955     bool hasInactiveActivities(Rules& r);
 1956 
 1957     QString getXmlDescription(Rules& r);
 1958 
 1959     QString getDescription(Rules& r);
 1960 
 1961     QString getDetailedDescription(Rules& r);
 1962 
 1963     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 1964 
 1965     bool isRelatedToActivity(Rules& r, Activity* a);
 1966     
 1967     bool isRelatedToTeacher(Teacher* t);
 1968 
 1969     bool isRelatedToSubject(Subject* s);
 1970 
 1971     bool isRelatedToActivityTag(ActivityTag* s);
 1972     
 1973     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 1974 
 1975     bool hasWrongDayOrHour(Rules& r);
 1976     bool canRepairWrongDayOrHour(Rules& r);
 1977     bool repairWrongDayOrHour(Rules& r);
 1978 };
 1979 
 1980 class ConstraintStudentsSetMinHoursDaily: public TimeConstraint{
 1981     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinHoursDaily)
 1982 
 1983 public:
 1984     int minHoursDaily;
 1985 
 1986     /**
 1987     The students set name
 1988     */
 1989     QString students;
 1990     
 1991     bool allowEmptyDays;
 1992 
 1993     //internal variables
 1994 
 1995     /**
 1996     The number of subgroups
 1997     */
 1998     //int nSubgroups;
 1999 
 2000     /**
 2001     The subgroups
 2002     */
 2003     //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
 2004     QList<int> iSubgroupsList;
 2005 
 2006     ConstraintStudentsSetMinHoursDaily();
 2007 
 2008     ConstraintStudentsSetMinHoursDaily(double wp, int minnh, const QString& s, bool _allowEmptyDays);
 2009 
 2010     bool computeInternalStructure(QWidget* parent, Rules& r);
 2011 
 2012     bool hasInactiveActivities(Rules& r);
 2013 
 2014     QString getXmlDescription(Rules& r);
 2015 
 2016     QString getDescription(Rules& r);
 2017 
 2018     QString getDetailedDescription(Rules& r);
 2019 
 2020     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2021 
 2022     bool isRelatedToActivity(Rules& r, Activity* a);
 2023     
 2024     bool isRelatedToTeacher(Teacher* t);
 2025 
 2026     bool isRelatedToSubject(Subject* s);
 2027 
 2028     bool isRelatedToActivityTag(ActivityTag* s);
 2029     
 2030     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2031 
 2032     bool hasWrongDayOrHour(Rules& r);
 2033     bool canRepairWrongDayOrHour(Rules& r);
 2034     bool repairWrongDayOrHour(Rules& r);
 2035 };
 2036 
 2037 /**
 2038 This is a constraint.
 2039 It adds, to the fitness of the solution, a fitness factor that
 2040 grows as the activity is scheduled farther from the wanted time
 2041 For the moment, fitness factor increases with one unit for every hour
 2042 and one unit for every day.
 2043 */
 2044 class ConstraintActivityPreferredStartingTime: public TimeConstraint{
 2045     Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredStartingTime)
 2046 
 2047 public:
 2048     /**
 2049     Activity id
 2050     */
 2051     int activityId;
 2052 
 2053     /**
 2054     The preferred day. If -1, then the user does not care about the day.
 2055     */
 2056     int day;
 2057 
 2058     /**
 2059     The preferred hour. If -1, then the user does not care about the hour.
 2060     */
 2061     int hour;
 2062 
 2063     bool permanentlyLocked; //if this is true, then this activity cannot be unlocked from the timetable view form
 2064 
 2065     //internal variables
 2066     /**
 2067     The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2068     */
 2069     int activityIndex;
 2070     
 2071     ConstraintActivityPreferredStartingTime();
 2072 
 2073     ConstraintActivityPreferredStartingTime(double wp, int actId, int d, int h, bool perm);
 2074 
 2075     /**
 2076     Comparison operator - to be sure that we do not introduce duplicates
 2077     */
 2078     bool operator==(ConstraintActivityPreferredStartingTime& c);
 2079 
 2080     bool computeInternalStructure(QWidget* parent, Rules& r);
 2081 
 2082     bool hasInactiveActivities(Rules& r);
 2083 
 2084     QString getXmlDescription(Rules& r);
 2085 
 2086     QString getDescription(Rules& r);
 2087 
 2088     QString getDetailedDescription(Rules& r);
 2089 
 2090     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2091 
 2092     bool isRelatedToActivity(Rules& r, Activity* a);
 2093     
 2094     bool isRelatedToTeacher(Teacher* t);
 2095 
 2096     bool isRelatedToSubject(Subject* s);
 2097 
 2098     bool isRelatedToActivityTag(ActivityTag* s);
 2099     
 2100     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2101 
 2102     bool hasWrongDayOrHour(Rules& r);
 2103     bool canRepairWrongDayOrHour(Rules& r);
 2104     bool repairWrongDayOrHour(Rules& r);
 2105 };
 2106 
 2107 /**
 2108 This is a constraint.
 2109 It returns conflicts if the activity is scheduled in another interval
 2110 than the preferred set of times.
 2111 */
 2112 class ConstraintActivityPreferredTimeSlots: public TimeConstraint{
 2113     Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredTimeSlots)
 2114 
 2115 public:
 2116     /**
 2117     Activity id
 2118     */
 2119     int p_activityId;
 2120 
 2121     /**
 2122     The number of preferred times
 2123     */
 2124     int p_nPreferredTimeSlots_L;
 2125 
 2126     /**
 2127     The preferred days. If -1, then the user does not care about the day.
 2128     */
 2129     //int p_days[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS];
 2130     QList<int> p_days_L;
 2131 
 2132     /**
 2133     The preferred hour. If -1, then the user does not care about the hour.
 2134     */
 2135     //int p_hours[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIME_SLOTS];
 2136     QList<int> p_hours_L;
 2137 
 2138     //internal variables
 2139     /**
 2140     The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2141     */
 2142     int p_activityIndex;
 2143 
 2144     ConstraintActivityPreferredTimeSlots();
 2145 
 2146     //ConstraintActivityPreferredTimeSlots(double wp, int actId, int nPT, int d[], int h[]);
 2147     ConstraintActivityPreferredTimeSlots(double wp, int actId, int nPT_L, QList<int> d_L, QList<int> h_L);
 2148 
 2149     bool computeInternalStructure(QWidget* parent, Rules& r);
 2150 
 2151     bool hasInactiveActivities(Rules& r);
 2152 
 2153     QString getXmlDescription(Rules& r);
 2154 
 2155     QString getDescription(Rules& r);
 2156 
 2157     QString getDetailedDescription(Rules& r);
 2158 
 2159     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2160 
 2161     bool isRelatedToActivity(Rules& r, Activity* a);
 2162     
 2163     bool isRelatedToTeacher(Teacher* t);
 2164 
 2165     bool isRelatedToSubject(Subject* s);
 2166 
 2167     bool isRelatedToActivityTag(ActivityTag* s);
 2168     
 2169     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2170 
 2171     bool hasWrongDayOrHour(Rules& r);
 2172     bool canRepairWrongDayOrHour(Rules& r);
 2173     bool repairWrongDayOrHour(Rules& r);
 2174 };
 2175 
 2176 class ConstraintActivityPreferredStartingTimes: public TimeConstraint{
 2177     Q_DECLARE_TR_FUNCTIONS(ConstraintActivityPreferredStartingTimes)
 2178 
 2179 public:
 2180     /**
 2181     Activity id
 2182     */
 2183     int activityId;
 2184 
 2185     /**
 2186     The number of preferred times
 2187     */
 2188     int nPreferredStartingTimes_L;
 2189 
 2190     /**
 2191     The preferred days. If -1, then the user does not care about the day.
 2192     */
 2193     //int days[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES];
 2194     QList<int> days_L;
 2195 
 2196     /**
 2197     The preferred hour. If -1, then the user does not care about the hour.
 2198     */
 2199     //int hours[MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_STARTING_TIMES];
 2200     QList<int> hours_L;
 2201 
 2202     //internal variables
 2203     /**
 2204     The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2205     */
 2206     int activityIndex;
 2207 
 2208     ConstraintActivityPreferredStartingTimes();
 2209 
 2210     //ConstraintActivityPreferredStartingTimes(double wp, int actId, int nPT, int d[], int h[]);
 2211     ConstraintActivityPreferredStartingTimes(double wp, int actId, int nPT_L, QList<int> d_L, QList<int> h_L);
 2212 
 2213     bool computeInternalStructure(QWidget* parent, Rules& r);
 2214 
 2215     bool hasInactiveActivities(Rules& r);
 2216 
 2217     QString getXmlDescription(Rules& r);
 2218 
 2219     QString getDescription(Rules& r);
 2220 
 2221     QString getDetailedDescription(Rules& r);
 2222 
 2223     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2224 
 2225     bool isRelatedToActivity(Rules& r, Activity* a);
 2226     
 2227     bool isRelatedToTeacher(Teacher* t);
 2228 
 2229     bool isRelatedToSubject(Subject* s);
 2230 
 2231     bool isRelatedToActivityTag(ActivityTag* s);
 2232     
 2233     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2234 
 2235     bool hasWrongDayOrHour(Rules& r);
 2236     bool canRepairWrongDayOrHour(Rules& r);
 2237     bool repairWrongDayOrHour(Rules& r);
 2238 };
 2239 
 2240 /**
 2241 This is a constraint.
 2242 It returns conflicts if a set of activities is scheduled in another interval
 2243 than the preferred set of times.
 2244 The set of activities is specified by a subject, teacher, students or a combination
 2245 of these.
 2246 */
 2247 class ConstraintActivitiesPreferredTimeSlots: public TimeConstraint{
 2248     Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesPreferredTimeSlots)
 2249 
 2250 public:
 2251     /**
 2252     The teacher. If void, all teachers.
 2253     */
 2254     QString p_teacherName;
 2255 
 2256     /**
 2257     The students. If void, all students.
 2258     */
 2259     QString p_studentsName;
 2260 
 2261     /**
 2262     The subject. If void, all subjects.
 2263     */
 2264     QString p_subjectName;
 2265 
 2266     /**
 2267     The activity tag. If void, all activity tags.
 2268     */
 2269     QString p_activityTagName;
 2270 
 2271     int duration; //if -1, neglected. Otherwise, >=1.
 2272 
 2273     /**
 2274     The number of preferred times
 2275     */
 2276     int p_nPreferredTimeSlots_L;
 2277 
 2278     /**
 2279     The preferred days. If -1, then the user does not care about the day.
 2280     */
 2281     //int p_days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS];
 2282     QList<int> p_days_L;
 2283 
 2284     /**
 2285     The preferred hours. If -1, then the user does not care about the hour.
 2286     */
 2287     //int p_hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS];
 2288     QList<int> p_hours_L;
 2289 
 2290     //internal variables
 2291     
 2292     /**
 2293     The number of activities which are represented by the subject, teacher and students requirements.
 2294     */
 2295     int p_nActivities;
 2296     
 2297     /**
 2298     The indices of the activities in the rules (from 0 to rules.nActivities-1)
 2299     These are indices in the internal list -> Rules::internalActivitiesList
 2300     */
 2301     //int p_activitiesIndices[MAX_ACTIVITIES];
 2302     QList<int> p_activitiesIndices;
 2303 
 2304     ConstraintActivitiesPreferredTimeSlots();
 2305 
 2306     //ConstraintActivitiesPreferredTimeSlots(double wp, QString te,
 2307     //  QString st, QString su, QString sut, int nPT, int d[], int h[]);
 2308     ConstraintActivitiesPreferredTimeSlots(double wp, const QString& te,
 2309         const QString& st, const QString& su, const QString& sut, int dur, int nPT_L, QList<int> d_L, QList<int> h_L);
 2310 
 2311     bool computeInternalStructure(QWidget* parent, Rules& r);
 2312 
 2313     bool hasInactiveActivities(Rules& r);
 2314 
 2315     QString getXmlDescription(Rules& r);
 2316 
 2317     QString getDescription(Rules& r);
 2318 
 2319     QString getDetailedDescription(Rules& r);
 2320 
 2321     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2322 
 2323     bool isRelatedToActivity(Rules& r, Activity* a);
 2324     
 2325     bool isRelatedToTeacher(Teacher* t);
 2326 
 2327     bool isRelatedToSubject(Subject* s);
 2328 
 2329     bool isRelatedToActivityTag(ActivityTag* s);
 2330     
 2331     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2332 
 2333     bool hasWrongDayOrHour(Rules& r);
 2334     bool canRepairWrongDayOrHour(Rules& r);
 2335     bool repairWrongDayOrHour(Rules& r);
 2336 };
 2337 
 2338 class ConstraintSubactivitiesPreferredTimeSlots: public TimeConstraint{
 2339     Q_DECLARE_TR_FUNCTIONS(ConstraintSubactivitiesPreferredTimeSlots)
 2340 
 2341 public:
 2342     int componentNumber;
 2343 
 2344     /**
 2345     The teacher. If void, all teachers.
 2346     */
 2347     QString p_teacherName;
 2348 
 2349     /**
 2350     The students. If void, all students.
 2351     */
 2352     QString p_studentsName;
 2353 
 2354     /**
 2355     The subject. If void, all subjects.
 2356     */
 2357     QString p_subjectName;
 2358 
 2359     /**
 2360     The activity tag. If void, all activity tags.
 2361     */
 2362     QString p_activityTagName;
 2363 
 2364     int duration; //if -1, neglected. Otherwise, >=1.
 2365 
 2366     /**
 2367     The number of preferred times
 2368     */
 2369     int p_nPreferredTimeSlots_L;
 2370 
 2371     /**
 2372     The preferred days. If -1, then the user does not care about the day.
 2373     */
 2374     //int p_days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS];
 2375     QList<int> p_days_L;
 2376 
 2377     /**
 2378     The preferred hours. If -1, then the user does not care about the hour.
 2379     */
 2380     //int p_hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIME_SLOTS];
 2381     QList<int> p_hours_L;
 2382 
 2383     //internal variables
 2384     
 2385     /**
 2386     The number of activities which are represented by the subject, teacher and students requirements.
 2387     */
 2388     int p_nActivities;
 2389     
 2390     /**
 2391     The indices of the activities in the rules (from 0 to rules.nActivities-1)
 2392     These are indices in the internal list -> Rules::internalActivitiesList
 2393     */
 2394     //int p_activitiesIndices[MAX_ACTIVITIES];
 2395     QList<int> p_activitiesIndices;
 2396 
 2397     ConstraintSubactivitiesPreferredTimeSlots();
 2398 
 2399     //ConstraintSubactivitiesPreferredTimeSlots(double wp, int compNo, QString te,
 2400     //  QString st, QString su, QString sut, int nPT, int d[], int h[]);
 2401     ConstraintSubactivitiesPreferredTimeSlots(double wp, int compNo, const QString& te,
 2402         const QString& st, const QString& su, const QString& sut, int dur, int nPT_L, QList<int> d_L, QList<int> h_L);
 2403 
 2404     bool computeInternalStructure(QWidget* parent, Rules& r);
 2405 
 2406     bool hasInactiveActivities(Rules& r);
 2407 
 2408     QString getXmlDescription(Rules& r);
 2409 
 2410     QString getDescription(Rules& r);
 2411 
 2412     QString getDetailedDescription(Rules& r);
 2413 
 2414     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2415 
 2416     bool isRelatedToActivity(Rules& r, Activity* a);
 2417     
 2418     bool isRelatedToTeacher(Teacher* t);
 2419 
 2420     bool isRelatedToSubject(Subject* s);
 2421 
 2422     bool isRelatedToActivityTag(ActivityTag* s);
 2423     
 2424     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2425 
 2426     bool hasWrongDayOrHour(Rules& r);
 2427     bool canRepairWrongDayOrHour(Rules& r);
 2428     bool repairWrongDayOrHour(Rules& r);
 2429 };
 2430 
 2431 class ConstraintActivitiesPreferredStartingTimes: public TimeConstraint{
 2432     Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesPreferredStartingTimes)
 2433 
 2434 public:
 2435     /**
 2436     The teacher. If void, all teachers.
 2437     */
 2438     QString teacherName;
 2439 
 2440     /**
 2441     The students. If void, all students.
 2442     */
 2443     QString studentsName;
 2444 
 2445     /**
 2446     The subject. If void, all subjects.
 2447     */
 2448     QString subjectName;
 2449 
 2450     /**
 2451     The activity tag. If void, all activity tags.
 2452     */
 2453     QString activityTagName;
 2454 
 2455     int duration; //if -1, neglected. Otherwise, >=1.
 2456 
 2457     /**
 2458     The number of preferred times
 2459     */
 2460     int nPreferredStartingTimes_L;
 2461 
 2462     /**
 2463     The preferred days. If -1, then the user does not care about the day.
 2464     */
 2465     //int days[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES];
 2466     QList<int> days_L;
 2467 
 2468     /**
 2469     The preferred hours. If -1, then the user does not care about the hour.
 2470     */
 2471     //int hours[MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_STARTING_TIMES];
 2472     QList<int> hours_L;
 2473 
 2474     //internal variables
 2475     
 2476     /**
 2477     The number of activities which are represented by the subject, teacher and students requirements.
 2478     */
 2479     int nActivities;
 2480     
 2481     /**
 2482     The indices of the activities in the rules (from 0 to rules.nActivities-1)
 2483     These are indices in the internal list -> Rules::internalActivitiesList
 2484     */
 2485     //int activitiesIndices[MAX_ACTIVITIES];
 2486     QList<int> activitiesIndices;
 2487 
 2488     ConstraintActivitiesPreferredStartingTimes();
 2489 
 2490     //ConstraintActivitiesPreferredStartingTimes(double wp, QString te,
 2491     //  QString st, QString su, QString sut, int nPT, int d[], int h[]);
 2492     ConstraintActivitiesPreferredStartingTimes(double wp, const QString& te,
 2493         const QString& st, const QString& su, const QString& sut, int dur, int nPT_L, QList<int> d_L, QList<int> h_L);
 2494 
 2495     bool computeInternalStructure(QWidget* parent, Rules& r);
 2496 
 2497     bool hasInactiveActivities(Rules& r);
 2498 
 2499     QString getXmlDescription(Rules& r);
 2500 
 2501     QString getDescription(Rules& r);
 2502 
 2503     QString getDetailedDescription(Rules& r);
 2504 
 2505     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2506 
 2507     bool isRelatedToActivity(Rules& r, Activity* a);
 2508     
 2509     bool isRelatedToTeacher(Teacher* t);
 2510 
 2511     bool isRelatedToSubject(Subject* s);
 2512 
 2513     bool isRelatedToActivityTag(ActivityTag* s);
 2514     
 2515     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2516 
 2517     bool hasWrongDayOrHour(Rules& r);
 2518     bool canRepairWrongDayOrHour(Rules& r);
 2519     bool repairWrongDayOrHour(Rules& r);
 2520 };
 2521 
 2522 class ConstraintSubactivitiesPreferredStartingTimes: public TimeConstraint{
 2523     Q_DECLARE_TR_FUNCTIONS(ConstraintSubactivitiesPreferredStartingTimes)
 2524 
 2525 public:
 2526     int componentNumber;
 2527 
 2528     /**
 2529     The teacher. If void, all teachers.
 2530     */
 2531     QString teacherName;
 2532 
 2533     /**
 2534     The students. If void, all students.
 2535     */
 2536     QString studentsName;
 2537 
 2538     /**
 2539     The subject. If void, all subjects.
 2540     */
 2541     QString subjectName;
 2542 
 2543     /**
 2544     The activity tag. If void, all activity tags.
 2545     */
 2546     QString activityTagName;
 2547 
 2548     int duration; //if -1, neglected. Otherwise, >=1.
 2549 
 2550     /**
 2551     The number of preferred times
 2552     */
 2553     int nPreferredStartingTimes_L;
 2554 
 2555     /**
 2556     The preferred days. If -1, then the user does not care about the day.
 2557     */
 2558     //int days[MAX_N_CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES];
 2559     QList<int> days_L;
 2560 
 2561     /**
 2562     The preferred hours. If -1, then the user does not care about the hour.
 2563     */
 2564     //int hours[MAX_N_CONSTRAINT_SUBACTIVITIES_PREFERRED_STARTING_TIMES];
 2565     QList<int> hours_L;
 2566 
 2567     //internal variables
 2568     
 2569     /**
 2570     The number of activities which are represented by the subject, teacher and students requirements.
 2571     */
 2572     int nActivities;
 2573     
 2574     /**
 2575     The indices of the activities in the rules (from 0 to rules.nActivities-1)
 2576     These are indices in the internal list -> Rules::internalActivitiesList
 2577     */
 2578     //int activitiesIndices[MAX_ACTIVITIES];
 2579     QList<int> activitiesIndices;
 2580 
 2581     ConstraintSubactivitiesPreferredStartingTimes();
 2582 
 2583     ConstraintSubactivitiesPreferredStartingTimes(double wp, int compNo, const QString& te,
 2584         const QString& st, const QString& su, const QString& sut, int dur, int nPT_L, QList<int> d_L, QList<int> h_L);
 2585 
 2586     bool computeInternalStructure(QWidget* parent, Rules& r);
 2587 
 2588     bool hasInactiveActivities(Rules& r);
 2589 
 2590     QString getXmlDescription(Rules& r);
 2591 
 2592     QString getDescription(Rules& r);
 2593 
 2594     QString getDetailedDescription(Rules& r);
 2595 
 2596     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2597 
 2598     bool isRelatedToActivity(Rules& r, Activity* a);
 2599     
 2600     bool isRelatedToTeacher(Teacher* t);
 2601 
 2602     bool isRelatedToSubject(Subject* s);
 2603 
 2604     bool isRelatedToActivityTag(ActivityTag* s);
 2605     
 2606     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2607 
 2608     bool hasWrongDayOrHour(Rules& r);
 2609     bool canRepairWrongDayOrHour(Rules& r);
 2610     bool repairWrongDayOrHour(Rules& r);
 2611 };
 2612 
 2613 class ConstraintActivitiesSameStartingHour: public TimeConstraint{
 2614     Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameStartingHour)
 2615 
 2616 public:
 2617     /**
 2618     The number of activities involved in this constraint
 2619     */
 2620     int n_activities;
 2621 
 2622     /**
 2623     The activities involved in this constraint (id)
 2624     */
 2625     QList<int> activitiesId;
 2626     //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR];
 2627 
 2628     /**
 2629     The number of activities involved in this constraint - internal structure
 2630     */
 2631     int _n_activities;
 2632 
 2633     /**
 2634     The activities involved in this constraint (index in the rules) - internal structure
 2635     */
 2636     QList<int> _activities;
 2637     //int _activities[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_HOUR];
 2638 
 2639     ConstraintActivitiesSameStartingHour();
 2640 
 2641     /**
 2642     Constructor, using:
 2643     the weight, the number of activities and the list of activities' id-s.
 2644     */
 2645     //ConstraintActivitiesSameStartingHour(double wp, int n_act, const int act[]);
 2646     ConstraintActivitiesSameStartingHour(double wp, int n_act, const QList<int>& act);
 2647 
 2648     bool computeInternalStructure(QWidget* parent, Rules& r);
 2649 
 2650     bool hasInactiveActivities(Rules& r);
 2651 
 2652     QString getXmlDescription(Rules& r);
 2653 
 2654     QString getDescription(Rules& r);
 2655 
 2656     QString getDetailedDescription(Rules& r);
 2657 
 2658     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2659 
 2660     void removeUseless(Rules& r);
 2661 
 2662     bool isRelatedToActivity(Rules& r, Activity* a);
 2663 
 2664     
 2665     bool isRelatedToTeacher(Teacher* t);
 2666 
 2667     bool isRelatedToSubject(Subject* s);
 2668 
 2669     bool isRelatedToActivityTag(ActivityTag* s);
 2670     
 2671     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2672 
 2673     bool hasWrongDayOrHour(Rules& r);
 2674     bool canRepairWrongDayOrHour(Rules& r);
 2675     bool repairWrongDayOrHour(Rules& r);
 2676 };
 2677 
 2678 class ConstraintActivitiesSameStartingDay: public TimeConstraint{
 2679     Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesSameStartingDay)
 2680 
 2681 public:
 2682     /**
 2683     The number of activities involved in this constraint
 2684     */
 2685     int n_activities;
 2686 
 2687     /**
 2688     The activities involved in this constraint (id)
 2689     */
 2690     QList<int> activitiesId;
 2691     //int activitiesId[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY];
 2692 
 2693     /**
 2694     The number of activities involved in this constraint - internal structure
 2695     */
 2696     int _n_activities;
 2697 
 2698     /**
 2699     The activities involved in this constraint (index in the rules) - internal structure
 2700     */
 2701     //int _activities[MAX_CONSTRAINT_ACTIVITIES_SAME_STARTING_DAY];
 2702     QList<int> _activities;
 2703 
 2704     ConstraintActivitiesSameStartingDay();
 2705 
 2706     /**
 2707     Constructor, using:
 2708     the weight, the number of activities and the list of activities' id-s.
 2709     */
 2710     //ConstraintActivitiesSameStartingDay(double wp, int n_act, const int act[]);
 2711     ConstraintActivitiesSameStartingDay(double wp, int n_act, const QList<int>& act);
 2712 
 2713     bool computeInternalStructure(QWidget* parent, Rules& r);
 2714 
 2715     bool hasInactiveActivities(Rules& r);
 2716 
 2717     QString getXmlDescription(Rules& r);
 2718 
 2719     QString getDescription(Rules& r);
 2720 
 2721     QString getDetailedDescription(Rules& r);
 2722 
 2723     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2724 
 2725     void removeUseless(Rules& r);
 2726 
 2727     bool isRelatedToActivity(Rules& r, Activity* a);
 2728     
 2729     bool isRelatedToTeacher(Teacher* t);
 2730 
 2731     bool isRelatedToSubject(Subject* s);
 2732 
 2733     bool isRelatedToActivityTag(ActivityTag* s);
 2734     
 2735     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2736 
 2737     bool hasWrongDayOrHour(Rules& r);
 2738     bool canRepairWrongDayOrHour(Rules& r);
 2739     bool repairWrongDayOrHour(Rules& r);
 2740 };
 2741 
 2742 class ConstraintTwoActivitiesConsecutive: public TimeConstraint{
 2743     Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesConsecutive)
 2744 
 2745 public:
 2746     /**
 2747     First activity id
 2748     */
 2749     int firstActivityId;
 2750 
 2751     /**
 2752     Second activity id
 2753     */
 2754     int secondActivityId;
 2755 
 2756     //internal variables
 2757     /**
 2758     The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2759     */
 2760     int firstActivityIndex;
 2761 
 2762     /**
 2763     The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2764     */
 2765     int secondActivityIndex;
 2766 
 2767     ConstraintTwoActivitiesConsecutive();
 2768 
 2769     ConstraintTwoActivitiesConsecutive(double wp, int firstActId, int secondActId);
 2770 
 2771     bool computeInternalStructure(QWidget* parent, Rules& r);
 2772 
 2773     bool hasInactiveActivities(Rules& r);
 2774 
 2775     QString getXmlDescription(Rules& r);
 2776 
 2777     QString getDescription(Rules& r);
 2778 
 2779     QString getDetailedDescription(Rules& r);
 2780 
 2781     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2782 
 2783     bool isRelatedToActivity(Rules& r, Activity* a);
 2784     
 2785     bool isRelatedToTeacher(Teacher* t);
 2786 
 2787     bool isRelatedToSubject(Subject* s);
 2788 
 2789     bool isRelatedToActivityTag(ActivityTag* s);
 2790     
 2791     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2792 
 2793     bool hasWrongDayOrHour(Rules& r);
 2794     bool canRepairWrongDayOrHour(Rules& r);
 2795     bool repairWrongDayOrHour(Rules& r);
 2796 };
 2797 
 2798 class ConstraintTwoActivitiesGrouped: public TimeConstraint{
 2799     Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesGrouped)
 2800 
 2801 public:
 2802     /**
 2803     First activity id
 2804     */
 2805     int firstActivityId;
 2806 
 2807     /**
 2808     Second activity id
 2809     */
 2810     int secondActivityId;
 2811 
 2812     //internal variables
 2813     /**
 2814     The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2815     */
 2816     int firstActivityIndex;
 2817 
 2818     /**
 2819     The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2820     */
 2821     int secondActivityIndex;
 2822 
 2823     ConstraintTwoActivitiesGrouped();
 2824 
 2825     ConstraintTwoActivitiesGrouped(double wp, int firstActId, int secondActId);
 2826 
 2827     bool computeInternalStructure(QWidget* parent, Rules& r);
 2828 
 2829     bool hasInactiveActivities(Rules& r);
 2830 
 2831     QString getXmlDescription(Rules& r);
 2832 
 2833     QString getDescription(Rules& r);
 2834 
 2835     QString getDetailedDescription(Rules& r);
 2836 
 2837     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2838 
 2839     bool isRelatedToActivity(Rules& r, Activity* a);
 2840     
 2841     bool isRelatedToTeacher(Teacher* t);
 2842 
 2843     bool isRelatedToSubject(Subject* s);
 2844 
 2845     bool isRelatedToActivityTag(ActivityTag* s);
 2846     
 2847     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2848 
 2849     bool hasWrongDayOrHour(Rules& r);
 2850     bool canRepairWrongDayOrHour(Rules& r);
 2851     bool repairWrongDayOrHour(Rules& r);
 2852 };
 2853 
 2854 class ConstraintThreeActivitiesGrouped: public TimeConstraint{
 2855     Q_DECLARE_TR_FUNCTIONS(ConstraintThreeActivitiesGrouped)
 2856 
 2857 public:
 2858     /**
 2859     First activity id
 2860     */
 2861     int firstActivityId;
 2862 
 2863     /**
 2864     Second activity id
 2865     */
 2866     int secondActivityId;
 2867 
 2868     int thirdActivityId;
 2869 
 2870     //internal variables
 2871     /**
 2872     The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2873     */
 2874     int firstActivityIndex;
 2875 
 2876     /**
 2877     The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2878     */
 2879     int secondActivityIndex;
 2880 
 2881     int thirdActivityIndex;
 2882 
 2883     ConstraintThreeActivitiesGrouped();
 2884 
 2885     ConstraintThreeActivitiesGrouped(double wp, int firstActId, int secondActId, int thirdActId);
 2886 
 2887     bool computeInternalStructure(QWidget* parent, Rules& r);
 2888 
 2889     bool hasInactiveActivities(Rules& r);
 2890 
 2891     QString getXmlDescription(Rules& r);
 2892 
 2893     QString getDescription(Rules& r);
 2894 
 2895     QString getDetailedDescription(Rules& r);
 2896 
 2897     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2898 
 2899     bool isRelatedToActivity(Rules& r, Activity* a);
 2900     
 2901     bool isRelatedToTeacher(Teacher* t);
 2902 
 2903     bool isRelatedToSubject(Subject* s);
 2904 
 2905     bool isRelatedToActivityTag(ActivityTag* s);
 2906     
 2907     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2908 
 2909     bool hasWrongDayOrHour(Rules& r);
 2910     bool canRepairWrongDayOrHour(Rules& r);
 2911     bool repairWrongDayOrHour(Rules& r);
 2912 };
 2913 
 2914 class ConstraintTwoActivitiesOrdered: public TimeConstraint{
 2915     Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesOrdered)
 2916 
 2917 public:
 2918     /**
 2919     First activity id
 2920     */
 2921     int firstActivityId;
 2922 
 2923     /**
 2924     Second activity id
 2925     */
 2926     int secondActivityId;
 2927 
 2928     //internal variables
 2929     /**
 2930     The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2931     */
 2932     int firstActivityIndex;
 2933 
 2934     /**
 2935     The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2936     */
 2937     int secondActivityIndex;
 2938 
 2939     ConstraintTwoActivitiesOrdered();
 2940 
 2941     ConstraintTwoActivitiesOrdered(double wp, int firstActId, int secondActId);
 2942 
 2943     bool computeInternalStructure(QWidget* parent, Rules& r);
 2944 
 2945     bool hasInactiveActivities(Rules& r);
 2946 
 2947     QString getXmlDescription(Rules& r);
 2948 
 2949     QString getDescription(Rules& r);
 2950 
 2951     QString getDetailedDescription(Rules& r);
 2952 
 2953     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 2954 
 2955     bool isRelatedToActivity(Rules& r, Activity* a);
 2956     
 2957     bool isRelatedToTeacher(Teacher* t);
 2958 
 2959     bool isRelatedToSubject(Subject* s);
 2960 
 2961     bool isRelatedToActivityTag(ActivityTag* s);
 2962     
 2963     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 2964 
 2965     bool hasWrongDayOrHour(Rules& r);
 2966     bool canRepairWrongDayOrHour(Rules& r);
 2967     bool repairWrongDayOrHour(Rules& r);
 2968 };
 2969 
 2970 class ConstraintTwoActivitiesOrderedIfSameDay: public TimeConstraint{
 2971     Q_DECLARE_TR_FUNCTIONS(ConstraintTwoActivitiesOrderedIfSameDay)
 2972 
 2973 public:
 2974     /**
 2975     First activity id
 2976     */
 2977     int firstActivityId;
 2978 
 2979     /**
 2980     Second activity id
 2981     */
 2982     int secondActivityId;
 2983 
 2984     //internal variables
 2985     /**
 2986     The index of the first activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2987     */
 2988     int firstActivityIndex;
 2989 
 2990     /**
 2991     The index of the second activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 2992     */
 2993     int secondActivityIndex;
 2994 
 2995     ConstraintTwoActivitiesOrderedIfSameDay();
 2996 
 2997     ConstraintTwoActivitiesOrderedIfSameDay(double wp, int firstActId, int secondActId);
 2998 
 2999     bool computeInternalStructure(QWidget* parent, Rules& r);
 3000 
 3001     bool hasInactiveActivities(Rules& r);
 3002 
 3003     QString getXmlDescription(Rules& r);
 3004 
 3005     QString getDescription(Rules& r);
 3006 
 3007     QString getDetailedDescription(Rules& r);
 3008 
 3009     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3010 
 3011     bool isRelatedToActivity(Rules& r, Activity* a);
 3012     
 3013     bool isRelatedToTeacher(Teacher* t);
 3014 
 3015     bool isRelatedToSubject(Subject* s);
 3016 
 3017     bool isRelatedToActivityTag(ActivityTag* s);
 3018     
 3019     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3020 
 3021     bool hasWrongDayOrHour(Rules& r);
 3022     bool canRepairWrongDayOrHour(Rules& r);
 3023     bool repairWrongDayOrHour(Rules& r);
 3024 };
 3025 
 3026 class ConstraintActivityEndsStudentsDay: public TimeConstraint{
 3027     Q_DECLARE_TR_FUNCTIONS(ConstraintActivityEndsStudentsDay)
 3028 
 3029 public:
 3030     /**
 3031     Activity id
 3032     */
 3033     int activityId;
 3034 
 3035     //internal variables
 3036     /**
 3037     The index of the activity in the rules (from 0 to rules.nActivities-1) - it is not the id of the activity
 3038     */
 3039     int activityIndex;
 3040 
 3041     ConstraintActivityEndsStudentsDay();
 3042 
 3043     ConstraintActivityEndsStudentsDay(double wp, int actId);
 3044 
 3045     bool computeInternalStructure(QWidget* parent, Rules& r);
 3046 
 3047     bool hasInactiveActivities(Rules& r);
 3048 
 3049     QString getXmlDescription(Rules& r);
 3050 
 3051     QString getDescription(Rules& r);
 3052 
 3053     QString getDetailedDescription(Rules& r);
 3054 
 3055     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3056 
 3057     bool isRelatedToActivity(Rules& r, Activity* a);
 3058     
 3059     bool isRelatedToTeacher(Teacher* t);
 3060 
 3061     bool isRelatedToSubject(Subject* s);
 3062 
 3063     bool isRelatedToActivityTag(ActivityTag* s);
 3064     
 3065     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3066 
 3067     bool hasWrongDayOrHour(Rules& r);
 3068     bool canRepairWrongDayOrHour(Rules& r);
 3069     bool repairWrongDayOrHour(Rules& r);
 3070 };
 3071 
 3072 class ConstraintTeachersMinHoursDaily: public TimeConstraint{
 3073     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinHoursDaily)
 3074 
 3075 public:
 3076     /**
 3077     The minimum hours daily
 3078     */
 3079     int minHoursDaily;
 3080     
 3081     bool allowEmptyDays;
 3082 
 3083     ConstraintTeachersMinHoursDaily();
 3084 
 3085     ConstraintTeachersMinHoursDaily(double wp, int minhours, bool _allowEmptyDays);
 3086 
 3087     QString getXmlDescription(Rules& r);
 3088 
 3089     bool computeInternalStructure(QWidget* parent, Rules& r);
 3090 
 3091     bool hasInactiveActivities(Rules& r);
 3092 
 3093     QString getDescription(Rules& r);
 3094 
 3095     QString getDetailedDescription(Rules& r);
 3096 
 3097     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3098 
 3099     bool isRelatedToActivity(Rules& r, Activity* a);
 3100     
 3101     bool isRelatedToTeacher(Teacher* t);
 3102 
 3103     bool isRelatedToSubject(Subject* s);
 3104 
 3105     bool isRelatedToActivityTag(ActivityTag* s);
 3106     
 3107     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3108 
 3109     bool hasWrongDayOrHour(Rules& r);
 3110     bool canRepairWrongDayOrHour(Rules& r);
 3111     bool repairWrongDayOrHour(Rules& r);
 3112 };
 3113 
 3114 class ConstraintTeacherMinHoursDaily: public TimeConstraint{
 3115     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinHoursDaily)
 3116 
 3117 public:
 3118     /**
 3119     The minimum hours daily
 3120     */
 3121     int minHoursDaily;
 3122     
 3123     QString teacherName;
 3124     
 3125     int teacher_ID;
 3126     
 3127     bool allowEmptyDays;
 3128 
 3129     ConstraintTeacherMinHoursDaily();
 3130 
 3131     ConstraintTeacherMinHoursDaily(double wp, int minhours, const QString& teacher, bool _allowEmptyDays);
 3132 
 3133     QString getXmlDescription(Rules& r);
 3134 
 3135     bool computeInternalStructure(QWidget* parent, Rules& r);
 3136 
 3137     bool hasInactiveActivities(Rules& r);
 3138 
 3139     QString getDescription(Rules& r);
 3140 
 3141     QString getDetailedDescription(Rules& r);
 3142 
 3143     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3144 
 3145     bool isRelatedToActivity(Rules& r, Activity* a);
 3146     
 3147     bool isRelatedToTeacher(Teacher* t);
 3148 
 3149     bool isRelatedToSubject(Subject* s);
 3150 
 3151     bool isRelatedToActivityTag(ActivityTag* s);
 3152     
 3153     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3154 
 3155     bool hasWrongDayOrHour(Rules& r);
 3156     bool canRepairWrongDayOrHour(Rules& r);
 3157     bool repairWrongDayOrHour(Rules& r);
 3158 };
 3159 
 3160 class ConstraintTeacherIntervalMaxDaysPerWeek: public TimeConstraint{
 3161     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherIntervalMaxDaysPerWeek)
 3162 
 3163 public:
 3164     /**
 3165     The number of maximum allowed working days per week
 3166     */
 3167     int maxDaysPerWeek;
 3168     
 3169     int startHour;
 3170 
 3171     int endHour; //might be = to gt.rules.nHoursPerDay
 3172 
 3173     /**
 3174     The teacher's name
 3175     */
 3176     QString teacherName;
 3177 
 3178     /**
 3179     The teacher's id, or index in the rules
 3180     */
 3181     int teacher_ID;
 3182 
 3183     ConstraintTeacherIntervalMaxDaysPerWeek();
 3184 
 3185     ConstraintTeacherIntervalMaxDaysPerWeek(double wp, int maxnd, const QString& tn, int sh, int eh);
 3186 
 3187     bool computeInternalStructure(QWidget* parent, Rules& r);
 3188 
 3189     bool hasInactiveActivities(Rules& r);
 3190 
 3191     QString getXmlDescription(Rules& r);
 3192 
 3193     QString getDescription(Rules& r);
 3194 
 3195     QString getDetailedDescription(Rules& r);
 3196 
 3197     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3198 
 3199     bool isRelatedToActivity(Rules& r, Activity* a);
 3200     
 3201     bool isRelatedToTeacher(Teacher* t);
 3202 
 3203     bool isRelatedToSubject(Subject* s);
 3204 
 3205     bool isRelatedToActivityTag(ActivityTag* s);
 3206     
 3207     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3208 
 3209     bool hasWrongDayOrHour(Rules& r);
 3210     bool canRepairWrongDayOrHour(Rules& r);
 3211     bool repairWrongDayOrHour(Rules& r);
 3212 };
 3213 
 3214 class ConstraintTeachersIntervalMaxDaysPerWeek: public TimeConstraint{
 3215     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersIntervalMaxDaysPerWeek)
 3216 
 3217 public:
 3218     /**
 3219     The number of maximum allowed working days per week
 3220     */
 3221     int maxDaysPerWeek;
 3222     
 3223     int startHour;
 3224 
 3225     int endHour; //might be = to gt.rules.nHoursPerDay
 3226 
 3227     ConstraintTeachersIntervalMaxDaysPerWeek();
 3228 
 3229     ConstraintTeachersIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh);
 3230 
 3231     bool computeInternalStructure(QWidget* parent, Rules& r);
 3232 
 3233     bool hasInactiveActivities(Rules& r);
 3234 
 3235     QString getXmlDescription(Rules& r);
 3236 
 3237     QString getDescription(Rules& r);
 3238 
 3239     QString getDetailedDescription(Rules& r);
 3240 
 3241     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3242 
 3243     bool isRelatedToActivity(Rules& r, Activity* a);
 3244     
 3245     bool isRelatedToTeacher(Teacher* t);
 3246 
 3247     bool isRelatedToSubject(Subject* s);
 3248 
 3249     bool isRelatedToActivityTag(ActivityTag* s);
 3250     
 3251     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3252 
 3253     bool hasWrongDayOrHour(Rules& r);
 3254     bool canRepairWrongDayOrHour(Rules& r);
 3255     bool repairWrongDayOrHour(Rules& r);
 3256 };
 3257 
 3258 class ConstraintStudentsSetIntervalMaxDaysPerWeek: public TimeConstraint{
 3259     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetIntervalMaxDaysPerWeek)
 3260 
 3261 public:
 3262     /**
 3263     The number of maximum allowed working days per week
 3264     */
 3265     int maxDaysPerWeek;
 3266     
 3267     int startHour;
 3268 
 3269     int endHour; //might be = to gt.rules.nHoursPerDay
 3270 
 3271     /**
 3272     The name of the students set for this constraint
 3273     */
 3274     QString students;
 3275 
 3276     //internal redundant data
 3277 
 3278     /**
 3279     The number of subgroups
 3280     */
 3281     //int nSubgroups;
 3282 
 3283     /**
 3284     The subgroups
 3285     */
 3286     QList<int> iSubgroupsList;
 3287 
 3288     ConstraintStudentsSetIntervalMaxDaysPerWeek();
 3289 
 3290     ConstraintStudentsSetIntervalMaxDaysPerWeek(double wp, int maxnd, const QString& sn, int sh, int eh);
 3291 
 3292     bool computeInternalStructure(QWidget* parent, Rules& r);
 3293 
 3294     bool hasInactiveActivities(Rules& r);
 3295 
 3296     QString getXmlDescription(Rules& r);
 3297 
 3298     QString getDescription(Rules& r);
 3299 
 3300     QString getDetailedDescription(Rules& r);
 3301 
 3302     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3303 
 3304     bool isRelatedToActivity(Rules& r, Activity* a);
 3305     
 3306     bool isRelatedToTeacher(Teacher* t);
 3307 
 3308     bool isRelatedToSubject(Subject* s);
 3309 
 3310     bool isRelatedToActivityTag(ActivityTag* s);
 3311     
 3312     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3313 
 3314     bool hasWrongDayOrHour(Rules& r);
 3315     bool canRepairWrongDayOrHour(Rules& r);
 3316     bool repairWrongDayOrHour(Rules& r);
 3317 };
 3318 
 3319 class ConstraintStudentsIntervalMaxDaysPerWeek: public TimeConstraint{
 3320     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsIntervalMaxDaysPerWeek)
 3321 
 3322 public:
 3323     /**
 3324     The number of maximum allowed working days per week
 3325     */
 3326     int maxDaysPerWeek;
 3327     
 3328     int startHour;
 3329 
 3330     int endHour; //might be = to gt.rules.nHoursPerDay
 3331 
 3332     ConstraintStudentsIntervalMaxDaysPerWeek();
 3333 
 3334     ConstraintStudentsIntervalMaxDaysPerWeek(double wp, int maxnd, int sh, int eh);
 3335 
 3336     bool computeInternalStructure(QWidget* parent, Rules& r);
 3337 
 3338     bool hasInactiveActivities(Rules& r);
 3339 
 3340     QString getXmlDescription(Rules& r);
 3341 
 3342     QString getDescription(Rules& r);
 3343 
 3344     QString getDetailedDescription(Rules& r);
 3345 
 3346     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3347 
 3348     bool isRelatedToActivity(Rules& r, Activity* a);
 3349     
 3350     bool isRelatedToTeacher(Teacher* t);
 3351 
 3352     bool isRelatedToSubject(Subject* s);
 3353 
 3354     bool isRelatedToActivityTag(ActivityTag* s);
 3355     
 3356     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3357 
 3358     bool hasWrongDayOrHour(Rules& r);
 3359     bool canRepairWrongDayOrHour(Rules& r);
 3360     bool repairWrongDayOrHour(Rules& r);
 3361 };
 3362 
 3363 class ConstraintActivitiesEndStudentsDay: public TimeConstraint{
 3364     Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesEndStudentsDay)
 3365 
 3366 public:
 3367     /**
 3368     The teacher. If void, all teachers.
 3369     */
 3370     QString teacherName;
 3371 
 3372     /**
 3373     The students. If void, all students.
 3374     */
 3375     QString studentsName;
 3376 
 3377     /**
 3378     The subject. If void, all subjects.
 3379     */
 3380     QString subjectName;
 3381 
 3382     /**
 3383     The activity tag. If void, all activity tags.
 3384     */
 3385     QString activityTagName;
 3386     
 3387     
 3388     //internal data
 3389 
 3390     /**
 3391     The number of activities which are represented by the subject, teacher and students requirements.
 3392     */
 3393     int nActivities;
 3394     
 3395     /**
 3396     The indices of the activities in the rules (from 0 to rules.nActivities-1)
 3397     These are indices in the internal list -> Rules::internalActivitiesList
 3398     */
 3399     //int activitiesIndices[MAX_ACTIVITIES];
 3400     QList<int> activitiesIndices;
 3401 
 3402     ConstraintActivitiesEndStudentsDay();
 3403 
 3404     ConstraintActivitiesEndStudentsDay(double wp, const QString& te, const QString& st, const QString& su, const QString& sut);
 3405 
 3406     bool computeInternalStructure(QWidget* parent, Rules& r);
 3407 
 3408     bool hasInactiveActivities(Rules& r);
 3409 
 3410     QString getXmlDescription(Rules& r);
 3411 
 3412     QString getDescription(Rules& r);
 3413 
 3414     QString getDetailedDescription(Rules& r);
 3415 
 3416     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3417 
 3418     bool isRelatedToActivity(Rules& r, Activity* a);
 3419     
 3420     bool isRelatedToTeacher(Teacher* t);
 3421 
 3422     bool isRelatedToSubject(Subject* s);
 3423 
 3424     bool isRelatedToActivityTag(ActivityTag* s);
 3425     
 3426     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3427 
 3428     bool hasWrongDayOrHour(Rules& r);
 3429     bool canRepairWrongDayOrHour(Rules& r);
 3430     bool repairWrongDayOrHour(Rules& r);
 3431 };
 3432 
 3433 class ConstraintTeachersActivityTagMaxHoursDaily: public TimeConstraint{
 3434     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMaxHoursDaily)
 3435 
 3436 public:
 3437     /**
 3438     The maximum hours daily
 3439     */
 3440     int maxHoursDaily;
 3441     
 3442     QString activityTagName;
 3443     
 3444     int activityTagIndex;
 3445     
 3446     QList<int> canonicalTeachersList;
 3447 
 3448     ConstraintTeachersActivityTagMaxHoursDaily();
 3449 
 3450     ConstraintTeachersActivityTagMaxHoursDaily(double wp, int maxhours, const QString& activityTag);
 3451 
 3452     QString getXmlDescription(Rules& r);
 3453 
 3454     bool computeInternalStructure(QWidget* parent, Rules& r);
 3455 
 3456     bool hasInactiveActivities(Rules& r);
 3457 
 3458     QString getDescription(Rules& r);
 3459 
 3460     QString getDetailedDescription(Rules& r);
 3461 
 3462     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3463 
 3464     bool isRelatedToActivity(Rules& r, Activity* a);
 3465     
 3466     bool isRelatedToTeacher(Teacher* t);
 3467 
 3468     bool isRelatedToSubject(Subject* s);
 3469 
 3470     bool isRelatedToActivityTag(ActivityTag* s);
 3471     
 3472     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3473 
 3474     bool hasWrongDayOrHour(Rules& r);
 3475     bool canRepairWrongDayOrHour(Rules& r);
 3476     bool repairWrongDayOrHour(Rules& r);
 3477 };
 3478 
 3479 class ConstraintTeacherActivityTagMaxHoursDaily: public TimeConstraint{
 3480     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMaxHoursDaily)
 3481 
 3482 public:
 3483     /**
 3484     The maximum hours daily
 3485     */
 3486     int maxHoursDaily;
 3487     
 3488     QString teacherName;
 3489     
 3490     QString activityTagName;
 3491     
 3492     int teacher_ID;
 3493 
 3494     int activityTagIndex;
 3495     
 3496     QList<int> canonicalTeachersList;
 3497 
 3498     ConstraintTeacherActivityTagMaxHoursDaily();
 3499 
 3500     ConstraintTeacherActivityTagMaxHoursDaily(double wp, int maxhours, const QString& teacher, const QString& activityTag);
 3501 
 3502     QString getXmlDescription(Rules& r);
 3503 
 3504     bool computeInternalStructure(QWidget* parent, Rules& r);
 3505 
 3506     bool hasInactiveActivities(Rules& r);
 3507 
 3508     QString getDescription(Rules& r);
 3509 
 3510     QString getDetailedDescription(Rules& r);
 3511 
 3512     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3513 
 3514     bool isRelatedToActivity(Rules& r, Activity* a);
 3515     
 3516     bool isRelatedToTeacher(Teacher* t);
 3517 
 3518     bool isRelatedToSubject(Subject* s);
 3519 
 3520     bool isRelatedToActivityTag(ActivityTag* s);
 3521     
 3522     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3523 
 3524     bool hasWrongDayOrHour(Rules& r);
 3525     bool canRepairWrongDayOrHour(Rules& r);
 3526     bool repairWrongDayOrHour(Rules& r);
 3527 };
 3528 
 3529 class ConstraintStudentsActivityTagMaxHoursDaily: public TimeConstraint{
 3530     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMaxHoursDaily)
 3531 
 3532 public:
 3533     int maxHoursDaily;
 3534     
 3535     QString activityTagName;
 3536     
 3537     int activityTagIndex;
 3538     
 3539     QList<int> canonicalSubgroupsList;
 3540 
 3541     ConstraintStudentsActivityTagMaxHoursDaily();
 3542 
 3543     ConstraintStudentsActivityTagMaxHoursDaily(double wp, int maxnh, const QString& activityTag);
 3544 
 3545     bool computeInternalStructure(QWidget* parent, Rules& r);
 3546 
 3547     bool hasInactiveActivities(Rules& r);
 3548 
 3549     QString getXmlDescription(Rules& r);
 3550 
 3551     QString getDescription(Rules& r);
 3552 
 3553     QString getDetailedDescription(Rules& r);
 3554 
 3555     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3556 
 3557     bool isRelatedToActivity(Rules& r, Activity* a);
 3558     
 3559     bool isRelatedToTeacher(Teacher* t);
 3560 
 3561     bool isRelatedToSubject(Subject* s);
 3562 
 3563     bool isRelatedToActivityTag(ActivityTag* s);
 3564     
 3565     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3566 
 3567     bool hasWrongDayOrHour(Rules& r);
 3568     bool canRepairWrongDayOrHour(Rules& r);
 3569     bool repairWrongDayOrHour(Rules& r);
 3570 };
 3571 
 3572 class ConstraintStudentsSetActivityTagMaxHoursDaily: public TimeConstraint{
 3573     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMaxHoursDaily)
 3574 
 3575 public:
 3576     int maxHoursDaily;
 3577 
 3578     /**
 3579     The students set name
 3580     */
 3581     QString students;
 3582     
 3583     QString activityTagName;
 3584 
 3585     //internal variables
 3586     
 3587     int activityTagIndex;
 3588 
 3589     /**
 3590     The number of subgroups
 3591     */
 3592     //int nSubgroups;
 3593 
 3594     /**
 3595     The subgroups
 3596     */
 3597     //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
 3598     QList<int> iSubgroupsList;
 3599     
 3600     QList<int> canonicalSubgroupsList;
 3601 
 3602     ConstraintStudentsSetActivityTagMaxHoursDaily();
 3603 
 3604     ConstraintStudentsSetActivityTagMaxHoursDaily(double wp, int maxnh, const QString& s, const QString& activityTag);
 3605 
 3606     bool computeInternalStructure(QWidget* parent, Rules& r);
 3607 
 3608     bool hasInactiveActivities(Rules& r);
 3609 
 3610     QString getXmlDescription(Rules& r);
 3611 
 3612     QString getDescription(Rules& r);
 3613 
 3614     QString getDetailedDescription(Rules& r);
 3615 
 3616     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3617 
 3618     bool isRelatedToActivity(Rules& r, Activity* a);
 3619     
 3620     bool isRelatedToTeacher(Teacher* t);
 3621 
 3622     bool isRelatedToSubject(Subject* s);
 3623 
 3624     bool isRelatedToActivityTag(ActivityTag* s);
 3625     
 3626     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3627 
 3628     bool hasWrongDayOrHour(Rules& r);
 3629     bool canRepairWrongDayOrHour(Rules& r);
 3630     bool repairWrongDayOrHour(Rules& r);
 3631 };
 3632 
 3633 class ConstraintTeachersActivityTagMinHoursDaily: public TimeConstraint{
 3634     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersActivityTagMinHoursDaily)
 3635 
 3636 public:
 3637     /**
 3638     The minimum hours daily
 3639     */
 3640     int minHoursDaily;
 3641     
 3642     bool allowEmptyDays;
 3643     
 3644     QString activityTagName;
 3645     
 3646     int activityTagIndex;
 3647     
 3648     QList<int> canonicalTeachersList;
 3649 
 3650     ConstraintTeachersActivityTagMinHoursDaily();
 3651 
 3652     ConstraintTeachersActivityTagMinHoursDaily(double wp, int minhours, bool allowemptydays, const QString& activityTag);
 3653 
 3654     QString getXmlDescription(Rules& r);
 3655 
 3656     bool computeInternalStructure(QWidget* parent, Rules& r);
 3657 
 3658     bool hasInactiveActivities(Rules& r);
 3659 
 3660     QString getDescription(Rules& r);
 3661 
 3662     QString getDetailedDescription(Rules& r);
 3663 
 3664     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3665 
 3666     bool isRelatedToActivity(Rules& r, Activity* a);
 3667     
 3668     bool isRelatedToTeacher(Teacher* t);
 3669 
 3670     bool isRelatedToSubject(Subject* s);
 3671 
 3672     bool isRelatedToActivityTag(ActivityTag* s);
 3673     
 3674     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3675 
 3676     bool hasWrongDayOrHour(Rules& r);
 3677     bool canRepairWrongDayOrHour(Rules& r);
 3678     bool repairWrongDayOrHour(Rules& r);
 3679 };
 3680 
 3681 class ConstraintTeacherActivityTagMinHoursDaily: public TimeConstraint{
 3682     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherActivityTagMinHoursDaily)
 3683 
 3684 public:
 3685     /**
 3686     The minimum hours daily
 3687     */
 3688     int minHoursDaily;
 3689     
 3690     bool allowEmptyDays;
 3691     
 3692     QString teacherName;
 3693     
 3694     QString activityTagName;
 3695     
 3696     int teacher_ID;
 3697 
 3698     int activityTagIndex;
 3699     
 3700     QList<int> canonicalTeachersList;
 3701 
 3702     ConstraintTeacherActivityTagMinHoursDaily();
 3703 
 3704     ConstraintTeacherActivityTagMinHoursDaily(double wp, int minhours, bool allowemptydays, const QString& teacher, const QString& activityTag);
 3705 
 3706     QString getXmlDescription(Rules& r);
 3707 
 3708     bool computeInternalStructure(QWidget* parent, Rules& r);
 3709 
 3710     bool hasInactiveActivities(Rules& r);
 3711 
 3712     QString getDescription(Rules& r);
 3713 
 3714     QString getDetailedDescription(Rules& r);
 3715 
 3716     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3717 
 3718     bool isRelatedToActivity(Rules& r, Activity* a);
 3719     
 3720     bool isRelatedToTeacher(Teacher* t);
 3721 
 3722     bool isRelatedToSubject(Subject* s);
 3723 
 3724     bool isRelatedToActivityTag(ActivityTag* s);
 3725     
 3726     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3727 
 3728     bool hasWrongDayOrHour(Rules& r);
 3729     bool canRepairWrongDayOrHour(Rules& r);
 3730     bool repairWrongDayOrHour(Rules& r);
 3731 };
 3732 
 3733 class ConstraintStudentsActivityTagMinHoursDaily: public TimeConstraint{
 3734     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsActivityTagMinHoursDaily)
 3735 
 3736 public:
 3737     int minHoursDaily;
 3738     
 3739     bool allowEmptyDays;
 3740     
 3741     QString activityTagName;
 3742     
 3743     int activityTagIndex;
 3744     
 3745     QList<int> canonicalSubgroupsList;
 3746 
 3747     ConstraintStudentsActivityTagMinHoursDaily();
 3748 
 3749     ConstraintStudentsActivityTagMinHoursDaily(double wp, int maxnh, bool allowEmptyDays, const QString& activityTag);
 3750 
 3751     bool computeInternalStructure(QWidget* parent, Rules& r);
 3752 
 3753     bool hasInactiveActivities(Rules& r);
 3754 
 3755     QString getXmlDescription(Rules& r);
 3756 
 3757     QString getDescription(Rules& r);
 3758 
 3759     QString getDetailedDescription(Rules& r);
 3760 
 3761     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3762 
 3763     bool isRelatedToActivity(Rules& r, Activity* a);
 3764     
 3765     bool isRelatedToTeacher(Teacher* t);
 3766 
 3767     bool isRelatedToSubject(Subject* s);
 3768 
 3769     bool isRelatedToActivityTag(ActivityTag* s);
 3770     
 3771     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3772 
 3773     bool hasWrongDayOrHour(Rules& r);
 3774     bool canRepairWrongDayOrHour(Rules& r);
 3775     bool repairWrongDayOrHour(Rules& r);
 3776 };
 3777 
 3778 class ConstraintStudentsSetActivityTagMinHoursDaily: public TimeConstraint{
 3779     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetActivityTagMinHoursDaily)
 3780 
 3781 public:
 3782     int minHoursDaily;
 3783     
 3784     bool allowEmptyDays;
 3785 
 3786     /**
 3787     The students set name
 3788     */
 3789     QString students;
 3790     
 3791     QString activityTagName;
 3792 
 3793     //internal variables
 3794     
 3795     int activityTagIndex;
 3796 
 3797     /**
 3798     The number of subgroups
 3799     */
 3800     //int nSubgroups;
 3801 
 3802     /**
 3803     The subgroups
 3804     */
 3805     //int subgroups[MAX_SUBGROUPS_PER_CONSTRAINT];
 3806     QList<int> iSubgroupsList;
 3807     
 3808     QList<int> canonicalSubgroupsList;
 3809 
 3810     ConstraintStudentsSetActivityTagMinHoursDaily();
 3811 
 3812     ConstraintStudentsSetActivityTagMinHoursDaily(double wp, int minnh, bool allowEmptyDays, const QString& s, const QString& activityTag);
 3813 
 3814     bool computeInternalStructure(QWidget* parent, Rules& r);
 3815 
 3816     bool hasInactiveActivities(Rules& r);
 3817 
 3818     QString getXmlDescription(Rules& r);
 3819 
 3820     QString getDescription(Rules& r);
 3821 
 3822     QString getDetailedDescription(Rules& r);
 3823 
 3824     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3825 
 3826     bool isRelatedToActivity(Rules& r, Activity* a);
 3827     
 3828     bool isRelatedToTeacher(Teacher* t);
 3829 
 3830     bool isRelatedToSubject(Subject* s);
 3831 
 3832     bool isRelatedToActivityTag(ActivityTag* s);
 3833     
 3834     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3835 
 3836     bool hasWrongDayOrHour(Rules& r);
 3837     bool canRepairWrongDayOrHour(Rules& r);
 3838     bool repairWrongDayOrHour(Rules& r);
 3839 };
 3840 
 3841 class ConstraintStudentsMaxGapsPerDay: public TimeConstraint{
 3842     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxGapsPerDay)
 3843 
 3844 public:
 3845     int maxGaps;
 3846 
 3847     ConstraintStudentsMaxGapsPerDay();
 3848 
 3849     ConstraintStudentsMaxGapsPerDay(double wp, int mg);
 3850 
 3851     bool computeInternalStructure(QWidget* parent, Rules& r);
 3852 
 3853     bool hasInactiveActivities(Rules& r);
 3854 
 3855     QString getXmlDescription(Rules& r);
 3856 
 3857     QString getDescription(Rules& r);
 3858 
 3859     QString getDetailedDescription(Rules& r);
 3860 
 3861     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3862 
 3863     bool isRelatedToActivity(Rules& r, Activity* a);
 3864     
 3865     bool isRelatedToTeacher(Teacher* t);
 3866 
 3867     bool isRelatedToSubject(Subject* s);
 3868 
 3869     bool isRelatedToActivityTag(ActivityTag* s);
 3870     
 3871     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3872 
 3873     bool hasWrongDayOrHour(Rules& r);
 3874     bool canRepairWrongDayOrHour(Rules& r);
 3875     bool repairWrongDayOrHour(Rules& r);
 3876 };
 3877 
 3878 class ConstraintStudentsSetMaxGapsPerDay: public TimeConstraint{
 3879     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxGapsPerDay)
 3880 
 3881 public:
 3882     int maxGaps;
 3883 
 3884     /**
 3885     The name of the students set for this constraint
 3886     */
 3887     QString students;
 3888 
 3889     //internal redundant data
 3890 
 3891     /**
 3892     The number of subgroups
 3893     */
 3894     //int nSubgroups;
 3895 
 3896     /**
 3897     The subgroups
 3898     */
 3899     QList<int> iSubgroupsList;
 3900 
 3901     ConstraintStudentsSetMaxGapsPerDay();
 3902 
 3903     ConstraintStudentsSetMaxGapsPerDay(double wp, int mg, const QString& st);
 3904 
 3905     bool computeInternalStructure(QWidget* parent, Rules& r);
 3906 
 3907     bool hasInactiveActivities(Rules& r);
 3908 
 3909     QString getXmlDescription(Rules& r);
 3910 
 3911     QString getDescription(Rules& r);
 3912 
 3913     QString getDetailedDescription(Rules& r);
 3914 
 3915     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3916 
 3917     bool isRelatedToActivity(Rules& r, Activity* a);
 3918     
 3919     bool isRelatedToTeacher(Teacher* t);
 3920 
 3921     bool isRelatedToSubject(Subject* s);
 3922 
 3923     bool isRelatedToActivityTag(ActivityTag* s);
 3924     
 3925     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3926 
 3927     bool hasWrongDayOrHour(Rules& r);
 3928     bool canRepairWrongDayOrHour(Rules& r);
 3929     bool repairWrongDayOrHour(Rules& r);
 3930 };
 3931 
 3932 class ConstraintActivitiesOccupyMaxTimeSlotsFromSelection: public TimeConstraint{
 3933     Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesOccupyMaxTimeSlotsFromSelection)
 3934 
 3935 public:
 3936     QList<int> activitiesIds;
 3937     
 3938     QList<int> selectedDays;
 3939     QList<int> selectedHours;
 3940     
 3941     int maxOccupiedTimeSlots;
 3942 
 3943     //internal variables
 3944     QList<int> _activitiesIndices;
 3945 
 3946     ConstraintActivitiesOccupyMaxTimeSlotsFromSelection();
 3947 
 3948     ConstraintActivitiesOccupyMaxTimeSlotsFromSelection(double wp, QList<int> a_L, QList<int> d_L, QList<int> h_L, int max_slots);
 3949 
 3950     bool computeInternalStructure(QWidget* parent, Rules& r);
 3951 
 3952     bool hasInactiveActivities(Rules& r);
 3953 
 3954     QString getXmlDescription(Rules& r);
 3955 
 3956     QString getDescription(Rules& r);
 3957 
 3958     QString getDetailedDescription(Rules& r);
 3959 
 3960     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 3961 
 3962     void removeUseless(Rules& r);
 3963 
 3964     bool isRelatedToActivity(Rules& r, Activity* a);
 3965     
 3966     bool isRelatedToTeacher(Teacher* t);
 3967 
 3968     bool isRelatedToSubject(Subject* s);
 3969 
 3970     bool isRelatedToActivityTag(ActivityTag* s);
 3971     
 3972     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 3973 
 3974     bool hasWrongDayOrHour(Rules& r);
 3975     bool canRepairWrongDayOrHour(Rules& r);
 3976     bool repairWrongDayOrHour(Rules& r);
 3977 };
 3978 
 3979 class ConstraintActivitiesOccupyMinTimeSlotsFromSelection: public TimeConstraint{
 3980     Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesOccupyMinTimeSlotsFromSelection)
 3981 
 3982 public:
 3983     QList<int> activitiesIds;
 3984     
 3985     QList<int> selectedDays;
 3986     QList<int> selectedHours;
 3987     
 3988     int minOccupiedTimeSlots;
 3989 
 3990     //internal variables
 3991     QList<int> _activitiesIndices;
 3992 
 3993     ConstraintActivitiesOccupyMinTimeSlotsFromSelection();
 3994 
 3995     ConstraintActivitiesOccupyMinTimeSlotsFromSelection(double wp, QList<int> a_L, QList<int> d_L, QList<int> h_L, int min_slots);
 3996 
 3997     bool computeInternalStructure(QWidget* parent, Rules& r);
 3998 
 3999     bool hasInactiveActivities(Rules& r);
 4000 
 4001     QString getXmlDescription(Rules& r);
 4002 
 4003     QString getDescription(Rules& r);
 4004 
 4005     QString getDetailedDescription(Rules& r);
 4006 
 4007     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4008 
 4009     void removeUseless(Rules& r);
 4010 
 4011     bool isRelatedToActivity(Rules& r, Activity* a);
 4012     
 4013     bool isRelatedToTeacher(Teacher* t);
 4014 
 4015     bool isRelatedToSubject(Subject* s);
 4016 
 4017     bool isRelatedToActivityTag(ActivityTag* s);
 4018     
 4019     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4020 
 4021     bool hasWrongDayOrHour(Rules& r);
 4022     bool canRepairWrongDayOrHour(Rules& r);
 4023     bool repairWrongDayOrHour(Rules& r);
 4024 };
 4025 
 4026 class ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots: public TimeConstraint{
 4027     Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots)
 4028 
 4029 public:
 4030     QList<int> activitiesIds;
 4031     
 4032     QList<int> selectedDays;
 4033     QList<int> selectedHours;
 4034     
 4035     int maxSimultaneous;
 4036 
 4037     //internal variables
 4038     QList<int> _activitiesIndices;
 4039 
 4040     ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots();
 4041 
 4042     ConstraintActivitiesMaxSimultaneousInSelectedTimeSlots(double wp, QList<int> a_L, QList<int> d_L, QList<int> h_L, int max_simultaneous);
 4043 
 4044     bool computeInternalStructure(QWidget* parent, Rules& r);
 4045 
 4046     bool hasInactiveActivities(Rules& r);
 4047 
 4048     QString getXmlDescription(Rules& r);
 4049 
 4050     QString getDescription(Rules& r);
 4051 
 4052     QString getDetailedDescription(Rules& r);
 4053 
 4054     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4055 
 4056     void removeUseless(Rules& r);
 4057 
 4058     bool isRelatedToActivity(Rules& r, Activity* a);
 4059     
 4060     bool isRelatedToTeacher(Teacher* t);
 4061 
 4062     bool isRelatedToSubject(Subject* s);
 4063 
 4064     bool isRelatedToActivityTag(ActivityTag* s);
 4065     
 4066     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4067 
 4068     bool hasWrongDayOrHour(Rules& r);
 4069     bool canRepairWrongDayOrHour(Rules& r);
 4070     bool repairWrongDayOrHour(Rules& r);
 4071 };
 4072 
 4073 class ConstraintActivitiesMinSimultaneousInSelectedTimeSlots: public TimeConstraint{
 4074     Q_DECLARE_TR_FUNCTIONS(ConstraintActivitiesMinSimultaneousInSelectedTimeSlots)
 4075 
 4076 public:
 4077     QList<int> activitiesIds;
 4078     
 4079     QList<int> selectedDays;
 4080     QList<int> selectedHours;
 4081     
 4082     int minSimultaneous;
 4083     
 4084     bool allowEmptySlots;
 4085 
 4086     //internal variables
 4087     QList<int> _activitiesIndices;
 4088 
 4089     ConstraintActivitiesMinSimultaneousInSelectedTimeSlots();
 4090 
 4091     ConstraintActivitiesMinSimultaneousInSelectedTimeSlots(double wp, QList<int> a_L, QList<int> d_L, QList<int> h_L, int min_simultaneous, bool allow_empty_slots);
 4092 
 4093     bool computeInternalStructure(QWidget* parent, Rules& r);
 4094 
 4095     bool hasInactiveActivities(Rules& r);
 4096 
 4097     QString getXmlDescription(Rules& r);
 4098 
 4099     QString getDescription(Rules& r);
 4100 
 4101     QString getDetailedDescription(Rules& r);
 4102 
 4103     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4104 
 4105     void removeUseless(Rules& r);
 4106 
 4107     bool isRelatedToActivity(Rules& r, Activity* a);
 4108     
 4109     bool isRelatedToTeacher(Teacher* t);
 4110 
 4111     bool isRelatedToSubject(Subject* s);
 4112 
 4113     bool isRelatedToActivityTag(ActivityTag* s);
 4114     
 4115     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4116 
 4117     bool hasWrongDayOrHour(Rules& r);
 4118     bool canRepairWrongDayOrHour(Rules& r);
 4119     bool repairWrongDayOrHour(Rules& r);
 4120 };
 4121 
 4122 class ConstraintStudentsSetMaxDaysPerWeek: public TimeConstraint{
 4123     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxDaysPerWeek)
 4124 
 4125 public:
 4126     /**
 4127     The number of maximum allowed working days per week
 4128     */
 4129     int maxDaysPerWeek;
 4130     
 4131     /**
 4132     The name of the students set for this constraint
 4133     */
 4134     QString students;
 4135 
 4136     //internal redundant data
 4137 
 4138     /**
 4139     The number of subgroups
 4140     */
 4141     //int nSubgroups;
 4142 
 4143     /**
 4144     The subgroups
 4145     */
 4146     QList<int> iSubgroupsList;
 4147 
 4148     ConstraintStudentsSetMaxDaysPerWeek();
 4149 
 4150     ConstraintStudentsSetMaxDaysPerWeek(double wp, int maxnd, const QString& sn);
 4151 
 4152     bool computeInternalStructure(QWidget* parent, Rules& r);
 4153 
 4154     bool hasInactiveActivities(Rules& r);
 4155 
 4156     QString getXmlDescription(Rules& r);
 4157 
 4158     QString getDescription(Rules& r);
 4159 
 4160     QString getDetailedDescription(Rules& r);
 4161 
 4162     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4163 
 4164     bool isRelatedToActivity(Rules& r, Activity* a);
 4165     
 4166     bool isRelatedToTeacher(Teacher* t);
 4167 
 4168     bool isRelatedToSubject(Subject* s);
 4169 
 4170     bool isRelatedToActivityTag(ActivityTag* s);
 4171     
 4172     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4173 
 4174     bool hasWrongDayOrHour(Rules& r);
 4175     bool canRepairWrongDayOrHour(Rules& r);
 4176     bool repairWrongDayOrHour(Rules& r);
 4177 };
 4178 
 4179 class ConstraintStudentsMaxDaysPerWeek: public TimeConstraint{
 4180     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxDaysPerWeek)
 4181 
 4182 public:
 4183     /**
 4184     The number of maximum allowed working days per week
 4185     */
 4186     int maxDaysPerWeek;
 4187     
 4188     ConstraintStudentsMaxDaysPerWeek();
 4189 
 4190     ConstraintStudentsMaxDaysPerWeek(double wp, int maxnd);
 4191 
 4192     bool computeInternalStructure(QWidget* parent, Rules& r);
 4193 
 4194     bool hasInactiveActivities(Rules& r);
 4195 
 4196     QString getXmlDescription(Rules& r);
 4197 
 4198     QString getDescription(Rules& r);
 4199 
 4200     QString getDetailedDescription(Rules& r);
 4201 
 4202     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4203 
 4204     bool isRelatedToActivity(Rules& r, Activity* a);
 4205     
 4206     bool isRelatedToTeacher(Teacher* t);
 4207 
 4208     bool isRelatedToSubject(Subject* s);
 4209 
 4210     bool isRelatedToActivityTag(ActivityTag* s);
 4211     
 4212     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4213 
 4214     bool hasWrongDayOrHour(Rules& r);
 4215     bool canRepairWrongDayOrHour(Rules& r);
 4216     bool repairWrongDayOrHour(Rules& r);
 4217 };
 4218 
 4219 class ConstraintTeacherMaxSpanPerDay: public TimeConstraint{
 4220     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMaxSpanPerDay)
 4221 
 4222 public:
 4223     /**
 4224     The maximum span daily
 4225     */
 4226     int maxSpanPerDay;
 4227     
 4228     bool allowOneDayExceptionPlusOne;
 4229     
 4230     QString teacherName;
 4231     
 4232     int teacher_ID;
 4233 
 4234     ConstraintTeacherMaxSpanPerDay();
 4235 
 4236     ConstraintTeacherMaxSpanPerDay(double wp, int maxspan, bool except, const QString& teacher);
 4237 
 4238     QString getXmlDescription(Rules& r);
 4239 
 4240     bool computeInternalStructure(QWidget* parent, Rules& r);
 4241 
 4242     bool hasInactiveActivities(Rules& r);
 4243 
 4244     QString getDescription(Rules& r);
 4245 
 4246     QString getDetailedDescription(Rules& r);
 4247 
 4248     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4249 
 4250     bool isRelatedToActivity(Rules& r, Activity* a);
 4251     
 4252     bool isRelatedToTeacher(Teacher* t);
 4253 
 4254     bool isRelatedToSubject(Subject* s);
 4255 
 4256     bool isRelatedToActivityTag(ActivityTag* s);
 4257     
 4258     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4259 
 4260     bool hasWrongDayOrHour(Rules& r);
 4261     bool canRepairWrongDayOrHour(Rules& r);
 4262     bool repairWrongDayOrHour(Rules& r);
 4263 };
 4264 
 4265 class ConstraintTeachersMaxSpanPerDay: public TimeConstraint{
 4266     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMaxSpanPerDay)
 4267 
 4268 public:
 4269     /**
 4270     The maximum span daily
 4271     */
 4272     int maxSpanPerDay;
 4273     
 4274     bool allowOneDayExceptionPlusOne;
 4275 
 4276     ConstraintTeachersMaxSpanPerDay();
 4277 
 4278     ConstraintTeachersMaxSpanPerDay(double wp, int maxspan, bool except);
 4279 
 4280     QString getXmlDescription(Rules& r);
 4281 
 4282     bool computeInternalStructure(QWidget* parent, Rules& r);
 4283 
 4284     bool hasInactiveActivities(Rules& r);
 4285 
 4286     QString getDescription(Rules& r);
 4287 
 4288     QString getDetailedDescription(Rules& r);
 4289 
 4290     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4291 
 4292     bool isRelatedToActivity(Rules& r, Activity* a);
 4293     
 4294     bool isRelatedToTeacher(Teacher* t);
 4295 
 4296     bool isRelatedToSubject(Subject* s);
 4297 
 4298     bool isRelatedToActivityTag(ActivityTag* s);
 4299     
 4300     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4301 
 4302     bool hasWrongDayOrHour(Rules& r);
 4303     bool canRepairWrongDayOrHour(Rules& r);
 4304     bool repairWrongDayOrHour(Rules& r);
 4305 };
 4306 
 4307 class ConstraintTeacherMinRestingHours: public TimeConstraint{
 4308     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinRestingHours)
 4309 
 4310 public:
 4311     int minRestingHours;
 4312     
 4313     bool circular;
 4314     
 4315     QString teacherName;
 4316     
 4317     int teacher_ID;
 4318 
 4319     ConstraintTeacherMinRestingHours();
 4320 
 4321     ConstraintTeacherMinRestingHours(double wp, int minrestinghours, bool circ, const QString& teacher);
 4322 
 4323     QString getXmlDescription(Rules& r);
 4324 
 4325     bool computeInternalStructure(QWidget* parent, Rules& r);
 4326 
 4327     bool hasInactiveActivities(Rules& r);
 4328 
 4329     QString getDescription(Rules& r);
 4330 
 4331     QString getDetailedDescription(Rules& r);
 4332 
 4333     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4334 
 4335     bool isRelatedToActivity(Rules& r, Activity* a);
 4336     
 4337     bool isRelatedToTeacher(Teacher* t);
 4338 
 4339     bool isRelatedToSubject(Subject* s);
 4340 
 4341     bool isRelatedToActivityTag(ActivityTag* s);
 4342     
 4343     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4344 
 4345     bool hasWrongDayOrHour(Rules& r);
 4346     bool canRepairWrongDayOrHour(Rules& r);
 4347     bool repairWrongDayOrHour(Rules& r);
 4348 };
 4349 
 4350 class ConstraintTeachersMinRestingHours: public TimeConstraint{
 4351     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinRestingHours)
 4352 
 4353 public:
 4354     int minRestingHours;
 4355     
 4356     bool circular;
 4357     
 4358     ConstraintTeachersMinRestingHours();
 4359 
 4360     ConstraintTeachersMinRestingHours(double wp, int minrestinghours, bool circ);
 4361 
 4362     QString getXmlDescription(Rules& r);
 4363 
 4364     bool computeInternalStructure(QWidget* parent, Rules& r);
 4365 
 4366     bool hasInactiveActivities(Rules& r);
 4367 
 4368     QString getDescription(Rules& r);
 4369 
 4370     QString getDetailedDescription(Rules& r);
 4371 
 4372     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4373 
 4374     bool isRelatedToActivity(Rules& r, Activity* a);
 4375     
 4376     bool isRelatedToTeacher(Teacher* t);
 4377 
 4378     bool isRelatedToSubject(Subject* s);
 4379 
 4380     bool isRelatedToActivityTag(ActivityTag* s);
 4381     
 4382     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4383 
 4384     bool hasWrongDayOrHour(Rules& r);
 4385     bool canRepairWrongDayOrHour(Rules& r);
 4386     bool repairWrongDayOrHour(Rules& r);
 4387 };
 4388 
 4389 class ConstraintStudentsSetMaxSpanPerDay: public TimeConstraint{
 4390     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMaxSpanPerDay)
 4391 
 4392 public:
 4393     int maxSpanPerDay;
 4394     
 4395     /**
 4396     The name of the students set for this constraint
 4397     */
 4398     QString students;
 4399 
 4400     //internal redundant data
 4401 
 4402     /**
 4403     The number of subgroups
 4404     */
 4405     //int nSubgroups;
 4406 
 4407     /**
 4408     The subgroups
 4409     */
 4410     QList<int> iSubgroupsList;
 4411 
 4412     ConstraintStudentsSetMaxSpanPerDay();
 4413 
 4414     ConstraintStudentsSetMaxSpanPerDay(double wp, int maxspan, const QString& sn);
 4415 
 4416     bool computeInternalStructure(QWidget* parent, Rules& r);
 4417 
 4418     bool hasInactiveActivities(Rules& r);
 4419 
 4420     QString getXmlDescription(Rules& r);
 4421 
 4422     QString getDescription(Rules& r);
 4423 
 4424     QString getDetailedDescription(Rules& r);
 4425 
 4426     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4427 
 4428     bool isRelatedToActivity(Rules& r, Activity* a);
 4429     
 4430     bool isRelatedToTeacher(Teacher* t);
 4431 
 4432     bool isRelatedToSubject(Subject* s);
 4433 
 4434     bool isRelatedToActivityTag(ActivityTag* s);
 4435     
 4436     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4437 
 4438     bool hasWrongDayOrHour(Rules& r);
 4439     bool canRepairWrongDayOrHour(Rules& r);
 4440     bool repairWrongDayOrHour(Rules& r);
 4441 };
 4442 
 4443 class ConstraintStudentsMaxSpanPerDay: public TimeConstraint{
 4444     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMaxSpanPerDay)
 4445 
 4446 public:
 4447     int maxSpanPerDay;
 4448     
 4449     ConstraintStudentsMaxSpanPerDay();
 4450 
 4451     ConstraintStudentsMaxSpanPerDay(double wp, int maxspan);
 4452 
 4453     bool computeInternalStructure(QWidget* parent, Rules& r);
 4454 
 4455     bool hasInactiveActivities(Rules& r);
 4456 
 4457     QString getXmlDescription(Rules& r);
 4458 
 4459     QString getDescription(Rules& r);
 4460 
 4461     QString getDetailedDescription(Rules& r);
 4462 
 4463     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4464 
 4465     bool isRelatedToActivity(Rules& r, Activity* a);
 4466     
 4467     bool isRelatedToTeacher(Teacher* t);
 4468 
 4469     bool isRelatedToSubject(Subject* s);
 4470 
 4471     bool isRelatedToActivityTag(ActivityTag* s);
 4472     
 4473     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4474 
 4475     bool hasWrongDayOrHour(Rules& r);
 4476     bool canRepairWrongDayOrHour(Rules& r);
 4477     bool repairWrongDayOrHour(Rules& r);
 4478 };
 4479 
 4480 class ConstraintStudentsSetMinRestingHours: public TimeConstraint{
 4481     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinRestingHours)
 4482 
 4483 public:
 4484     int minRestingHours;
 4485     
 4486     bool circular;
 4487     
 4488     /**
 4489     The name of the students set for this constraint
 4490     */
 4491     QString students;
 4492 
 4493     //internal redundant data
 4494 
 4495     /**
 4496     The number of subgroups
 4497     */
 4498     //int nSubgroups;
 4499 
 4500     /**
 4501     The subgroups
 4502     */
 4503     QList<int> iSubgroupsList;
 4504 
 4505     ConstraintStudentsSetMinRestingHours();
 4506 
 4507     ConstraintStudentsSetMinRestingHours(double wp, int minrestinghours, bool circ, const QString& sn);
 4508 
 4509     bool computeInternalStructure(QWidget* parent, Rules& r);
 4510 
 4511     bool hasInactiveActivities(Rules& r);
 4512 
 4513     QString getXmlDescription(Rules& r);
 4514 
 4515     QString getDescription(Rules& r);
 4516 
 4517     QString getDetailedDescription(Rules& r);
 4518 
 4519     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4520 
 4521     bool isRelatedToActivity(Rules& r, Activity* a);
 4522     
 4523     bool isRelatedToTeacher(Teacher* t);
 4524 
 4525     bool isRelatedToSubject(Subject* s);
 4526 
 4527     bool isRelatedToActivityTag(ActivityTag* s);
 4528     
 4529     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4530 
 4531     bool hasWrongDayOrHour(Rules& r);
 4532     bool canRepairWrongDayOrHour(Rules& r);
 4533     bool repairWrongDayOrHour(Rules& r);
 4534 };
 4535 
 4536 class ConstraintStudentsMinRestingHours: public TimeConstraint{
 4537     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinRestingHours)
 4538 
 4539 public:
 4540     int minRestingHours;
 4541     
 4542     bool circular;
 4543     
 4544     ConstraintStudentsMinRestingHours();
 4545 
 4546     ConstraintStudentsMinRestingHours(double wp, int minrestinghours, bool circ);
 4547 
 4548     bool computeInternalStructure(QWidget* parent, Rules& r);
 4549 
 4550     bool hasInactiveActivities(Rules& r);
 4551 
 4552     QString getXmlDescription(Rules& r);
 4553 
 4554     QString getDescription(Rules& r);
 4555 
 4556     QString getDetailedDescription(Rules& r);
 4557 
 4558     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4559 
 4560     bool isRelatedToActivity(Rules& r, Activity* a);
 4561     
 4562     bool isRelatedToTeacher(Teacher* t);
 4563 
 4564     bool isRelatedToSubject(Subject* s);
 4565 
 4566     bool isRelatedToActivityTag(ActivityTag* s);
 4567     
 4568     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4569 
 4570     bool hasWrongDayOrHour(Rules& r);
 4571     bool canRepairWrongDayOrHour(Rules& r);
 4572     bool repairWrongDayOrHour(Rules& r);
 4573 };
 4574 
 4575 class ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags: public TimeConstraint{
 4576     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags)
 4577 
 4578 public:
 4579     int minGaps;
 4580 
 4581     QString students;
 4582     
 4583     QString firstActivityTag;
 4584     QString secondActivityTag;
 4585 
 4586     //internal variables
 4587 
 4588     QList<int> canonicalSubgroupsList;
 4589     
 4590     int _firstActivityTagIndex;
 4591     int _secondActivityTagIndex;
 4592 
 4593     ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags();
 4594 
 4595     ConstraintStudentsSetMinGapsBetweenOrderedPairOfActivityTags(double wp, const QString& _students, int _minGaps, const QString& _firstActivityTag, const QString& _secondActivityTag);
 4596 
 4597     bool computeInternalStructure(QWidget* parent, Rules& r);
 4598 
 4599     bool hasInactiveActivities(Rules& r);
 4600 
 4601     QString getXmlDescription(Rules& r);
 4602 
 4603     QString getDescription(Rules& r);
 4604 
 4605     QString getDetailedDescription(Rules& r);
 4606 
 4607     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4608 
 4609     bool isRelatedToActivity(Rules& r, Activity* a);
 4610     
 4611     bool isRelatedToTeacher(Teacher* t);
 4612 
 4613     bool isRelatedToSubject(Subject* s);
 4614 
 4615     bool isRelatedToActivityTag(ActivityTag* s);
 4616     
 4617     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4618 
 4619     bool hasWrongDayOrHour(Rules& r);
 4620     bool canRepairWrongDayOrHour(Rules& r);
 4621     bool repairWrongDayOrHour(Rules& r);
 4622 };
 4623 
 4624 class ConstraintStudentsMinGapsBetweenOrderedPairOfActivityTags: public TimeConstraint{
 4625     Q_DECLARE_TR_FUNCTIONS(ConstraintStudentsMinGapsBetweenOrderedPairOfActivityTags)
 4626 
 4627 public:
 4628     int minGaps;
 4629 
 4630     QString firstActivityTag;
 4631     QString secondActivityTag;
 4632 
 4633     //internal variables
 4634 
 4635     QList<int> canonicalSubgroupsList;
 4636 
 4637     int _firstActivityTagIndex;
 4638     int _secondActivityTagIndex;
 4639 
 4640     ConstraintStudentsMinGapsBetweenOrderedPairOfActivityTags();
 4641 
 4642     ConstraintStudentsMinGapsBetweenOrderedPairOfActivityTags(double wp, int _minGaps, const QString& _firstActivityTag, const QString& _secondActivityTag);
 4643 
 4644     bool computeInternalStructure(QWidget* parent, Rules& r);
 4645 
 4646     bool hasInactiveActivities(Rules& r);
 4647 
 4648     QString getXmlDescription(Rules& r);
 4649 
 4650     QString getDescription(Rules& r);
 4651 
 4652     QString getDetailedDescription(Rules& r);
 4653 
 4654     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4655 
 4656     bool isRelatedToActivity(Rules& r, Activity* a);
 4657     
 4658     bool isRelatedToTeacher(Teacher* t);
 4659 
 4660     bool isRelatedToSubject(Subject* s);
 4661 
 4662     bool isRelatedToActivityTag(ActivityTag* s);
 4663     
 4664     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4665 
 4666     bool hasWrongDayOrHour(Rules& r);
 4667     bool canRepairWrongDayOrHour(Rules& r);
 4668     bool repairWrongDayOrHour(Rules& r);
 4669 };
 4670 
 4671 class ConstraintTeacherMinGapsBetweenOrderedPairOfActivityTags: public TimeConstraint{
 4672     Q_DECLARE_TR_FUNCTIONS(ConstraintTeacherMinGapsBetweenOrderedPairOfActivityTags)
 4673 
 4674 public:
 4675     int minGaps;
 4676 
 4677     QString teacher;
 4678     
 4679     QString firstActivityTag;
 4680     QString secondActivityTag;
 4681 
 4682     //internal variables
 4683     
 4684     QList<int> canonicalTeachersList;
 4685 
 4686     int _firstActivityTagIndex;
 4687     int _secondActivityTagIndex;
 4688 
 4689     ConstraintTeacherMinGapsBetweenOrderedPairOfActivityTags();
 4690 
 4691     ConstraintTeacherMinGapsBetweenOrderedPairOfActivityTags(double wp, const QString& _teacher, int _minGaps, const QString& _firstActivityTag, const QString& _secondActivityTag);
 4692 
 4693     bool computeInternalStructure(QWidget* parent, Rules& r);
 4694 
 4695     bool hasInactiveActivities(Rules& r);
 4696 
 4697     QString getXmlDescription(Rules& r);
 4698 
 4699     QString getDescription(Rules& r);
 4700 
 4701     QString getDetailedDescription(Rules& r);
 4702 
 4703     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4704 
 4705     bool isRelatedToActivity(Rules& r, Activity* a);
 4706     
 4707     bool isRelatedToTeacher(Teacher* t);
 4708 
 4709     bool isRelatedToSubject(Subject* s);
 4710 
 4711     bool isRelatedToActivityTag(ActivityTag* s);
 4712     
 4713     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4714 
 4715     bool hasWrongDayOrHour(Rules& r);
 4716     bool canRepairWrongDayOrHour(Rules& r);
 4717     bool repairWrongDayOrHour(Rules& r);
 4718 };
 4719 
 4720 class ConstraintTeachersMinGapsBetweenOrderedPairOfActivityTags: public TimeConstraint{
 4721     Q_DECLARE_TR_FUNCTIONS(ConstraintTeachersMinGapsBetweenOrderedPairOfActivityTags)
 4722 
 4723 public:
 4724     int minGaps;
 4725 
 4726     QString firstActivityTag;
 4727     QString secondActivityTag;
 4728 
 4729     //internal variables
 4730 
 4731     QList<int> canonicalTeachersList;
 4732 
 4733     int _firstActivityTagIndex;
 4734     int _secondActivityTagIndex;
 4735 
 4736     ConstraintTeachersMinGapsBetweenOrderedPairOfActivityTags();
 4737 
 4738     ConstraintTeachersMinGapsBetweenOrderedPairOfActivityTags(double wp, int _minGaps, const QString& _firstActivityTag, const QString& _secondActivityTag);
 4739 
 4740     bool computeInternalStructure(QWidget* parent, Rules& r);
 4741 
 4742     bool hasInactiveActivities(Rules& r);
 4743 
 4744     QString getXmlDescription(Rules& r);
 4745 
 4746     QString getDescription(Rules& r);
 4747 
 4748     QString getDetailedDescription(Rules& r);
 4749 
 4750     double fitness(Solution& c, Rules& r, QList<double>& cl, QList<QString>& dl, FakeString* conflictsString=NULL);
 4751 
 4752     bool isRelatedToActivity(Rules& r, Activity* a);
 4753     
 4754     bool isRelatedToTeacher(Teacher* t);
 4755 
 4756     bool isRelatedToSubject(Subject* s);
 4757 
 4758     bool isRelatedToActivityTag(ActivityTag* s);
 4759     
 4760     bool isRelatedToStudentsSet(Rules& r, StudentsSet* s);
 4761 
 4762     bool hasWrongDayOrHour(Rules& r);
 4763     bool canRepairWrongDayOrHour(Rules& r);
 4764     bool repairWrongDayOrHour(Rules& r);
 4765 };
 4766 
 4767 #endif