Back to index

fet  5.18.0
Public Member Functions | Public Attributes
ConstraintStudentsIntervalMaxDaysPerWeek Class Reference

#include <timeconstraint.h>

Inheritance diagram for ConstraintStudentsIntervalMaxDaysPerWeek:
Inheritance graph
[legend]
Collaboration diagram for ConstraintStudentsIntervalMaxDaysPerWeek:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ConstraintStudentsIntervalMaxDaysPerWeek ()
 ConstraintStudentsIntervalMaxDaysPerWeek (double wp, int maxnd, int sh, int eh)
bool computeInternalStructure (QWidget *parent, Rules &r)
 Computes the internal structure for this constraint.
bool hasInactiveActivities (Rules &r)
QString getXmlDescription (Rules &r)
 Returns an XML description of this constraint.
QString getDescription (Rules &r)
 Returns a small description string for this constraint.
QString getDetailedDescription (Rules &r)
 Returns a detailed description string for this constraint.
double fitness (Solution &c, Rules &r, QList< double > &cl, QList< QString > &dl, QString *conflictsString=NULL)
 The function that calculates the fitness of a solution, according to this constraint.
bool isRelatedToActivity (Rules &r, Activity *a)
 Returns true if this constraint is related to this activity.
bool isRelatedToTeacher (Teacher *t)
 Returns true if this constraint is related to this teacher.
bool isRelatedToSubject (Subject *s)
 Returns true if this constraint is related to this subject.
bool isRelatedToActivityTag (ActivityTag *s)
 Returns true if this constraint is related to this activity tag.
bool isRelatedToStudentsSet (Rules &r, StudentsSet *s)
 Returns true if this constraint is related to this students set.
bool hasWrongDayOrHour (Rules &r)
bool canRepairWrongDayOrHour (Rules &r)
bool repairWrongDayOrHour (Rules &r)

Public Attributes

int maxDaysPerWeek
 The number of maximum allowed working days per week.
int startHour
int endHour
double weightPercentage
 The percentage weight of this constraint, 100% compulsory, 0% non-compulsory.
bool active
QString comments
int type
 Specifies the type of this constraint (using the above constants).

Detailed Description

Definition at line 3183 of file timeconstraint.h.


Constructor & Destructor Documentation

Definition at line 15233 of file timeconstraint.cpp.

        : TimeConstraint(wp)
{
       this->maxDaysPerWeek=maxnd;
       this->type=CONSTRAINT_STUDENTS_INTERVAL_MAX_DAYS_PER_WEEK;
       this->startHour=sh;
       this->endHour=eh;
       assert(sh<eh);
       assert(sh>=0);
}

Member Function Documentation

Implements TimeConstraint.

Definition at line 15453 of file timeconstraint.cpp.

{
       assert(hasWrongDayOrHour(r));
       
       if(this->startHour<r.nHoursPerDay && this->endHour<=r.nHoursPerDay)
              return true;

       return false;
}

Here is the call graph for this function:

bool ConstraintStudentsIntervalMaxDaysPerWeek::computeInternalStructure ( QWidget *  parent,
Rules r 
) [virtual]

Computes the internal structure for this constraint.

It returns false if the constraint is an activity related one and it depends on only inactive activities.

Implements TimeConstraint.

Definition at line 15244 of file timeconstraint.cpp.

{
       if(this->startHour>=this->endHour){
              QMessageBox::warning(parent, tr("FET warning"),
               tr("Constraint teacher interval max days per week is wrong because start hour >= end hour."
               " Please correct it. Constraint is:\n%1").arg(this->getDetailedDescription(r)));

              return false;
       }
       if(this->startHour<0){
              QMessageBox::warning(parent, tr("FET warning"),
               tr("Constraint teacher interval max days per week is wrong because start hour < first hour or the day."
               " Please correct it. Constraint is:\n%1").arg(this->getDetailedDescription(r)));

              return false;
       }
       if(this->endHour>r.nHoursPerDay){
              QMessageBox::warning(parent, tr("FET warning"),
               tr("Constraint teacher interval max days per week is wrong because end hour > number of hours per day."
               " Please correct it. Constraint is:\n%1").arg(this->getDetailedDescription(r)));

              return false;
       }

       return true;
}

Here is the call graph for this function:

double ConstraintStudentsIntervalMaxDaysPerWeek::fitness ( Solution c,
Rules r,
QList< double > &  cl,
QList< QString > &  dl,
QString *  conflictsString = NULL 
) [virtual]

The function that calculates the fitness of a solution, according to this constraint.

We need the rules to compute this fitness factor. If conflictsString!=NULL, it will be initialized with a text explaining where this restriction is broken.

Implements TimeConstraint.

Definition at line 15351 of file timeconstraint.cpp.

{
       //if the matrices subgroupsMatrix and teachersMatrix are already calculated, do not calculate them again!
       if(!c.teachersMatrixReady || !c.subgroupsMatrixReady){
              c.teachersMatrixReady=true;
              c.subgroupsMatrixReady=true;
              subgroups_conflicts = c.getSubgroupsMatrix(r, subgroupsMatrix);
              teachers_conflicts = c.getTeachersMatrix(r, teachersMatrix);

              c.changedForMatrixCalculation=false;
       }

       int nbroken;
       
       nbroken=0;
       
       for(int sbg=0; sbg<r.nInternalSubgroups; sbg++){
              bool ocDay[MAX_DAYS_PER_WEEK];
              for(int d=0; d<r.nDaysPerWeek; d++){
                     ocDay[d]=false;
                     for(int h=startHour; h<endHour; h++){
                            if(subgroupsMatrix[sbg][d][h]>0){
                                   ocDay[d]=true;
                            }
                     }
              }
              int nOcDays=0;
              for(int d=0; d<r.nDaysPerWeek; d++)
                     if(ocDay[d])
                            nOcDays++;
              if(nOcDays > this->maxDaysPerWeek){
                     nbroken+=nOcDays-this->maxDaysPerWeek;

                     if((nOcDays-this->maxDaysPerWeek)>0){
                            QString s= tr("Time constraint students interval max days per week broken for subgroup: %1, allowed %2 days, required %3 days.")
                             .arg(r.internalSubgroupsList[sbg]->name)
                             .arg(this->maxDaysPerWeek)
                             .arg(nOcDays);
                            s+=" ";
                            s += tr("This increases the conflicts total by %1")
                             .arg(CustomFETString::number((nOcDays-this->maxDaysPerWeek)*weightPercentage/100));
                      
                            dl.append(s);
                            cl.append((nOcDays-this->maxDaysPerWeek)*weightPercentage/100);
              
                            *conflictsString += s+"\n";
                     }
              }
       }

       if(weightPercentage==100)
              assert(nbroken==0);
       return weightPercentage/100 * nbroken;
}

Here is the call graph for this function:

Returns a small description string for this constraint.

Implements TimeConstraint.

Definition at line 15298 of file timeconstraint.cpp.

                                                                        {
       Q_UNUSED(r);

       QString begin=QString("");
       if(!active)
              begin="X - ";
              
       QString end=QString("");
       if(!comments.isEmpty())
              end=", "+tr("C: %1", "Comments").arg(comments);
              
       QString s=tr("Students interval max days per week");s+=", ";
       s+=tr("WP:%1\%", "Abbreviation for weight percentage").arg(CustomFETString::number(this->weightPercentage));s+=", ";
       s+=tr("ISH:%1", "Abbreviation for interval start hour").arg(r.hoursOfTheDay[this->startHour]);
       s+=", ";
       if(this->endHour<r.nHoursPerDay)
              s+=tr("IEH:%1", "Abbreviation for interval end hour").arg(r.hoursOfTheDay[this->endHour]);
       else
              s+=tr("IEH:%1", "Abbreviation for interval end hour").arg(tr("End of the day"));
       s+=", ";
       s+=tr("MD:%1", "Abbreviation for max days").arg(this->maxDaysPerWeek);

       return begin+s+end;
}

Here is the call graph for this function:

Returns a detailed description string for this constraint.

Implements TimeConstraint.

Definition at line 15323 of file timeconstraint.cpp.

                                                                                {
       Q_UNUSED(r);

       QString s=tr("Time constraint");s+="\n";
       s+=tr("All students respect working in an hourly interval a maximum number of days per week");s+="\n";
       s+=tr("Weight (percentage)=%1\%").arg(CustomFETString::number(this->weightPercentage));s+="\n";
       s+=tr("Interval start hour=%1").arg(r.hoursOfTheDay[this->startHour]);s+="\n";

       if(this->endHour<r.nHoursPerDay)
              s+=tr("Interval end hour=%1").arg(r.hoursOfTheDay[this->endHour]);
       else
              s+=tr("Interval end hour=%1").arg(tr("End of the day"));
       s+="\n";

       s+=tr("Maximum days per week=%1").arg(this->maxDaysPerWeek);s+="\n";

       if(!active){
              s+=tr("Active=%1", "Refers to a constraint").arg(yesNoTranslated(active));
              s+="\n";
       }
       if(!comments.isEmpty()){
              s+=tr("Comments=%1").arg(comments);
              s+="\n";
       }

       return s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Returns an XML description of this constraint.

Implements TimeConstraint.

Definition at line 15277 of file timeconstraint.cpp.

{
       Q_UNUSED(r);

       QString s="<ConstraintStudentsIntervalMaxDaysPerWeek>\n";
       s+="   <Weight_Percentage>"+CustomFETString::number(this->weightPercentage)+"</Weight_Percentage>\n";
       s+="   <Interval_Start_Hour>"+protect(r.hoursOfTheDay[this->startHour])+"</Interval_Start_Hour>\n";
       if(this->endHour < r.nHoursPerDay){
              s+="   <Interval_End_Hour>"+protect(r.hoursOfTheDay[this->endHour])+"</Interval_End_Hour>\n";
       }
       else{
              s+="   <Interval_End_Hour></Interval_End_Hour>\n";
              s+="   <!-- Interval_End_Hour void means the end of the day (which has no name) -->\n";
       }
       s+="   <Max_Days_Per_Week>"+CustomFETString::number(this->maxDaysPerWeek)+"</Max_Days_Per_Week>\n";
       s+="   <Active>"+trueFalse(active)+"</Active>\n";
       s+="   <Comments>"+protect(comments)+"</Comments>\n";
       s+="</ConstraintStudentsIntervalMaxDaysPerWeek>\n";
       return s;
}

Here is the call graph for this function:

Implements TimeConstraint.

Definition at line 15271 of file timeconstraint.cpp.

{
       Q_UNUSED(r);
       return false;
}

Implements TimeConstraint.

Definition at line 15441 of file timeconstraint.cpp.

{
       if(this->startHour>=r.nHoursPerDay)
              return true;
       if(this->endHour>r.nHoursPerDay)
              return true;
       if(this->maxDaysPerWeek>r.nDaysPerWeek)
              return true;
       
       return false;
}

Here is the caller graph for this function:

Returns true if this constraint is related to this activity.

Implements TimeConstraint.

Definition at line 15406 of file timeconstraint.cpp.

{
       Q_UNUSED(r);
       Q_UNUSED(a);

       return false;
}

Returns true if this constraint is related to this activity tag.

Implements TimeConstraint.

Definition at line 15427 of file timeconstraint.cpp.

{
       Q_UNUSED(s);

       return false;
}

Returns true if this constraint is related to this students set.

Implements TimeConstraint.

Definition at line 15434 of file timeconstraint.cpp.

{
       Q_UNUSED(r);
       Q_UNUSED(s);
       return true;
}

Returns true if this constraint is related to this subject.

Implements TimeConstraint.

Definition at line 15420 of file timeconstraint.cpp.

{
       Q_UNUSED(s);

       return false;
}

Returns true if this constraint is related to this teacher.

Implements TimeConstraint.

Definition at line 15414 of file timeconstraint.cpp.

{
       Q_UNUSED(t);
       return false;
}

Implements TimeConstraint.

Definition at line 15463 of file timeconstraint.cpp.

{
       assert(hasWrongDayOrHour(r));

       assert(this->startHour<r.nHoursPerDay && this->endHour<=r.nHoursPerDay);

       if(this->maxDaysPerWeek>r.nDaysPerWeek)
              this->maxDaysPerWeek=r.nDaysPerWeek;

       return true;
}

Here is the call graph for this function:


Member Data Documentation

bool TimeConstraint::active [inherited]

Definition at line 146 of file timeconstraint.h.

QString TimeConstraint::comments [inherited]

Definition at line 148 of file timeconstraint.h.

Definition at line 3194 of file timeconstraint.h.

The number of maximum allowed working days per week.

Definition at line 3190 of file timeconstraint.h.

Definition at line 3192 of file timeconstraint.h.

int TimeConstraint::type [inherited]

Specifies the type of this constraint (using the above constants).

Definition at line 153 of file timeconstraint.h.

The percentage weight of this constraint, 100% compulsory, 0% non-compulsory.

Definition at line 144 of file timeconstraint.h.


The documentation for this class was generated from the following files: