Back to index

fet  5.18.0
Public Member Functions | Public Attributes
ConstraintStudentsMaxHoursDaily Class Reference

#include <timeconstraint.h>

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

List of all members.

Public Member Functions

 ConstraintStudentsMaxHoursDaily ()
 ConstraintStudentsMaxHoursDaily (double wp, int maxnh)
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 maxHoursDaily
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 1580 of file timeconstraint.h.


Constructor & Destructor Documentation

Definition at line 6701 of file timeconstraint.cpp.

Definition at line 6708 of file timeconstraint.cpp.


Member Function Documentation

Implements TimeConstraint.

Definition at line 6885 of file timeconstraint.cpp.

{
       assert(hasWrongDayOrHour(r));
       
       return true;
}

Here is the call graph for this function:

bool ConstraintStudentsMaxHoursDaily::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 6715 of file timeconstraint.cpp.

{
       Q_UNUSED(parent);
       Q_UNUSED(r);
       
       return true;
}
double ConstraintStudentsMaxHoursDaily::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 6786 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 tmp;
       int too_much;
       
       assert(this->maxHoursDaily>=0);

       if(1){
              too_much=0;
              for(int i=0; i<r.nInternalSubgroups; i++)
                     for(int j=0; j<r.nDaysPerWeek; j++){
                            tmp=0;
                            for(int k=0; k<r.nHoursPerDay; k++){
                                   //OLD COMMENT
                                   //Here we want to see if we have a weekly activity or a 2 weeks activity
                                   //We don't do tmp+=subgroupsMatrix[i][j][k] because we already counted this as a hard hitness
                                   if(subgroupsMatrix[i][j][k]>=1)
                                          tmp++;
                            }
                            if(this->maxHoursDaily>=0 && tmp > this->maxHoursDaily){ //we would like no more than maxHoursDaily hours per day.
                                   too_much += 1; //tmp - this->maxHoursDaily;

                                   if(conflictsString!=NULL){
                                          QString s=tr("Time constraint students max hours daily broken for subgroup: %1, day: %2, lenght=%3, conflict increase=%4")
                                           .arg(r.internalSubgroupsList[i]->name)
                                           .arg(r.daysOfTheWeek[j])
                                           .arg(CustomFETString::number(tmp))
                                           .arg(CustomFETString::number(weightPercentage/100*1));
                                           
                                          dl.append(s);
                                          cl.append(weightPercentage/100*1);
                                   
                                          *conflictsString+= s+"\n";
                                   }
                            }
                     }
       }

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

Here is the call graph for this function:

Returns a small description string for this constraint.

Implements TimeConstraint.

Definition at line 6745 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;
       s+=tr("Students max hours daily");s+=", ";
       s+=tr("WP:%1\%", "Weight percentage").arg(CustomFETString::number(this->weightPercentage));s+=", ";
       s+=tr("MH:%1", "Max hours (daily)").arg(this->maxHoursDaily);

       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 6765 of file timeconstraint.cpp.

{
       Q_UNUSED(r);

       QString s=tr("Time constraint");s+="\n";
       s+=tr("All students must respect the maximum number of hours daily");s+="\n";
       s+=tr("Weight (percentage)=%1\%").arg(CustomFETString::number(this->weightPercentage));s+="\n";
       s+=tr("Maximum hours daily=%1").arg(this->maxHoursDaily);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:

Returns an XML description of this constraint.

Implements TimeConstraint.

Definition at line 6729 of file timeconstraint.cpp.

{
       Q_UNUSED(r);

       QString s="<ConstraintStudentsMaxHoursDaily>\n";
       s+="   <Weight_Percentage>"+CustomFETString::number(this->weightPercentage)+"</Weight_Percentage>\n";
       if(this->maxHoursDaily>=0)
              s+="   <Maximum_Hours_Daily>"+CustomFETString::number(this->maxHoursDaily)+"</Maximum_Hours_Daily>\n";
       else
              assert(0);
       s+="   <Active>"+trueFalse(active)+"</Active>\n";
       s+="   <Comments>"+protect(comments)+"</Comments>\n";
       s+="</ConstraintStudentsMaxHoursDaily>\n";
       return s;
}

Here is the call graph for this function:

Implements TimeConstraint.

Definition at line 6723 of file timeconstraint.cpp.

{
       Q_UNUSED(r);
       return false;
}

Implements TimeConstraint.

Definition at line 6877 of file timeconstraint.cpp.

{
       if(maxHoursDaily>r.nHoursPerDay)
              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 6840 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 6862 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 6869 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 6855 of file timeconstraint.cpp.

{
       Q_UNUSED(s);

       return false;
}

Returns true if this constraint is related to this teacher.

Implements TimeConstraint.

Definition at line 6848 of file timeconstraint.cpp.

{
       Q_UNUSED(t);

       return false;
}

Implements TimeConstraint.

Definition at line 6892 of file timeconstraint.cpp.

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 1584 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: