Back to index

fet  5.18.0
Public Member Functions | Public Attributes
ConstraintTeacherMinHoursDaily Class Reference

#include <timeconstraint.h>

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

List of all members.

Public Member Functions

 ConstraintTeacherMinHoursDaily ()
 ConstraintTeacherMinHoursDaily (double wp, int minhours, const QString &teacher, bool _allowEmptyDays)
QString getXmlDescription (Rules &r)
 Returns an XML description of this constraint.
bool computeInternalStructure (QWidget *parent, Rules &r)
 Computes the internal structure for this constraint.
bool hasInactiveActivities (Rules &r)
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 minHoursDaily
 The minimum hours daily.
QString teacherName
int teacher_ID
bool allowEmptyDays
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 2977 of file timeconstraint.h.


Constructor & Destructor Documentation

Definition at line 13771 of file timeconstraint.cpp.

ConstraintTeacherMinHoursDaily::ConstraintTeacherMinHoursDaily ( double  wp,
int  minhours,
const QString &  teacher,
bool  _allowEmptyDays 
)

Definition at line 13779 of file timeconstraint.cpp.

 : TimeConstraint(wp)
 {
       assert(minhours>0);
       this->minHoursDaily=minhours;
       this->teacherName=teacher;
       
       this->allowEmptyDays=_allowEmptyDays;

       this->type=CONSTRAINT_TEACHER_MIN_HOURS_DAILY;
}

Member Function Documentation

Implements TimeConstraint.

Definition at line 13992 of file timeconstraint.cpp.

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

Here is the call graph for this function:

bool ConstraintTeacherMinHoursDaily::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 13791 of file timeconstraint.cpp.

{
       this->teacher_ID=r.searchTeacher(this->teacherName);
       assert(this->teacher_ID>=0);
       
       if(allowEmptyDays==false){
              QString s=tr("Cannot generate a timetable with a constraint teacher min hours daily with allow empty days=false. Please modify it,"
                     " so that it allows empty days. If you need a facility like that, please use constraint teacher min days per week");
              s+="\n\n";
              s+=tr("Constraint is:")+"\n"+this->getDetailedDescription(r);
              QMessageBox::warning(parent, tr("FET warning"), s);
              
              return false;
       }
       
       return true;
}

Here is the call graph for this function:

double ConstraintTeacherMinHoursDaily::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 13875 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;
       }
       
       assert(this->allowEmptyDays==true);

       int nbroken;

       //without logging
       if(conflictsString==NULL){
              nbroken=0;
              int i=this->teacher_ID;
              for(int d=0; d<r.nDaysPerWeek; d++){
                     int n_hours_daily=0;
                     for(int h=0; h<r.nHoursPerDay; h++)
                            if(teachersMatrix[i][d][h]>0)
                                   n_hours_daily++;

                     if(n_hours_daily>0 && n_hours_daily<this->minHoursDaily){
                            nbroken++;
                     }
              }
       }
       //with logging
       else{
              nbroken=0;
              int i=this->teacher_ID;
              for(int d=0; d<r.nDaysPerWeek; d++){
                     int n_hours_daily=0;
                     for(int h=0; h<r.nHoursPerDay; h++)
                            if(teachersMatrix[i][d][h]>0)
                                   n_hours_daily++;

                     if(n_hours_daily>0 && n_hours_daily<this->minHoursDaily){
                            nbroken++;

                            if(conflictsString!=NULL){
                                   QString s=(tr(
                                    "Time constraint teacher min %1 hours daily broken for teacher %2, on day %3, length=%4.")
                                    .arg(CustomFETString::number(this->minHoursDaily))
                                    .arg(r.internalTeachersList[i]->name)
                                    .arg(r.daysOfTheWeek[d])
                                    .arg(n_hours_daily)
                                    )
                                    +" "
                                    +
                                    tr("This increases the conflicts total by %1").arg(CustomFETString::number(weightPercentage/100));
                                          
                                   dl.append(s);
                                   cl.append(weightPercentage/100);
                            
                                   *conflictsString+= s+"\n";
                            }
                     }
              }
       }

       if(c.nPlacedActivities==r.nInternalActivities)
              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 13832 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("Teacher min hours daily");s+=", ";
       s+=tr("WP:%1\%", "Weight percentage").arg(CustomFETString::number(this->weightPercentage));s+=", ";
       s+=tr("T:%1", "Teacher").arg(this->teacherName);s+=", ";
       s+=tr("mH:%1", "Minimum hours (daily)").arg(this->minHoursDaily);s+=", ";
       s+=tr("AED:%1", "Allow empty days").arg(yesNoTranslated(this->allowEmptyDays));

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

                                                                      {
       Q_UNUSED(r);

       QString s=tr("Time constraint");s+="\n";
       s+=tr("A teacher must respect the minimum number of hours daily");s+="\n";
       s+=tr("Weight (percentage)=%1\%").arg(CustomFETString::number(this->weightPercentage));s+="\n";
       s+=tr("Teacher=%1").arg(this->teacherName);s+="\n";
       s+=tr("Minimum hours daily=%1").arg(this->minHoursDaily);s+="\n";
       s+=tr("Allow empty days=%1").arg(yesNoTranslated(this->allowEmptyDays));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 13815 of file timeconstraint.cpp.

                                                                 {
       Q_UNUSED(r);

       QString s="<ConstraintTeacherMinHoursDaily>\n";
       s+="   <Weight_Percentage>"+CustomFETString::number(this->weightPercentage)+"</Weight_Percentage>\n";
       s+="   <Teacher_Name>"+protect(this->teacherName)+"</Teacher_Name>\n";
       s+="   <Minimum_Hours_Daily>"+CustomFETString::number(this->minHoursDaily)+"</Minimum_Hours_Daily>\n";
       if(this->allowEmptyDays)
              s+="   <Allow_Empty_Days>true</Allow_Empty_Days>\n";
       else
              s+="   <Allow_Empty_Days>false</Allow_Empty_Days>\n";
       s+="   <Active>"+trueFalse(active)+"</Active>\n";
       s+="   <Comments>"+protect(comments)+"</Comments>\n";
       s+="</ConstraintTeacherMinHoursDaily>\n";
       return s;
}

Here is the call graph for this function:

Implements TimeConstraint.

Definition at line 13809 of file timeconstraint.cpp.

{
       Q_UNUSED(r);
       return false;
}

Implements TimeConstraint.

Definition at line 13984 of file timeconstraint.cpp.

{
       if(minHoursDaily>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 13947 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 13969 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 13976 of file timeconstraint.cpp.

{
       Q_UNUSED(r);
       Q_UNUSED(s);

       return false;
}

Returns true if this constraint is related to this subject.

Implements TimeConstraint.

Definition at line 13962 of file timeconstraint.cpp.

{
       Q_UNUSED(s);

       return false;
}

Returns true if this constraint is related to this teacher.

Implements TimeConstraint.

Definition at line 13955 of file timeconstraint.cpp.

{
       if(this->teacherName==t->name)
              return true;
       return false;
}

Implements TimeConstraint.

Definition at line 13999 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.

Definition at line 2990 of file timeconstraint.h.

QString TimeConstraint::comments [inherited]

Definition at line 148 of file timeconstraint.h.

The minimum hours daily.

Definition at line 2984 of file timeconstraint.h.

Definition at line 2988 of file timeconstraint.h.

Definition at line 2986 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: