Back to index

fet  5.18.0
Public Slots | Public Member Functions | Private Slots
TimetableGenerateMultipleForm Class Reference

#include <timetablegeneratemultipleform.h>

List of all members.

Public Slots

void help ()
void start ()
void stop ()
void closePressed ()

Public Member Functions

 TimetableGenerateMultipleForm (QWidget *parent)
 ~TimetableGenerateMultipleForm ()
void simulationFinished ()
void writeTimetableDataFile ()

Private Slots

void timetableStarted (int timetable)
void timetableGenerated (int timetable, const QString &description, bool ok)
void finished ()
void activityPlaced (int na)

Detailed Description

Definition at line 42 of file timetablegeneratemultipleform.h.


Constructor & Destructor Documentation

Definition at line 175 of file timetablegeneratemultipleform.cpp.

                                                                           : QDialog(parent)
{
       setupUi(this);
       
       currentResultsTextEdit->setReadOnly(true);
       
       startPushButton->setDefault(true);

       connect(startPushButton, SIGNAL(clicked()), this, SLOT(start()));
       connect(stopPushButton, SIGNAL(clicked()), this, SLOT(stop()));
       connect(closePushButton, SIGNAL(clicked()), this, SLOT(closePressed()));
       connect(pushButton4, SIGNAL(clicked()), this, SLOT(help()));

       centerWidgetOnScreen(this);
       restoreFETDialogGeometry(this);
       
       simulation_running_multi=false;

       startPushButton->setEnabled(TRUE);
       stopPushButton->setDisabled(TRUE);
       closePushButton->setEnabled(TRUE);
       minutesGroupBox->setEnabled(TRUE);
       timetablesGroupBox->setEnabled(TRUE);

       connect(&generateMultipleThread, SIGNAL(timetableGenerated(int, const QString&, bool)),
              this, SLOT(timetableGenerated(int, const QString&, bool)));

       connect(&generateMultipleThread, SIGNAL(timetableStarted(int)),
              this, SLOT(timetableStarted(int)));

       connect(&generateMultipleThread, SIGNAL(finished()),
              this, SLOT(finished()));

       connect(&genMulti, SIGNAL(activityPlaced(int)),
              this, SLOT(activityPlaced(int)));
}

Here is the call graph for this function:

Definition at line 212 of file timetablegeneratemultipleform.cpp.

Here is the call graph for this function:


Member Function Documentation

void TimetableGenerateMultipleForm::activityPlaced ( int  na) [private, slot]

Definition at line 443 of file timetablegeneratemultipleform.cpp.

{
       time_t finish_time;
       time(&finish_time);
       int seconds=int(finish_time-start_time);
       int hours=seconds/3600;
       seconds%=3600;
       int minutes=seconds/60;
       seconds%=60;
                     
       int mact=maxActivitiesPlaced;
       int mseconds=genMulti.timeToHighestStage;

       QString s;

       bool zero=false;
       if(mseconds==0)
              zero=true;
       int hh=mseconds/3600;
       mseconds%=3600;
       int mm=mseconds/60;
       mseconds%=60;
       int ss=mseconds;

       QString tim;
       if(hh>0){
              tim+=" ";
              tim+=tr("%1 h", "hours").arg(hh);
       }
       if(mm>0){
              tim+=" ";
              tim+=tr("%1 m", "minutes").arg(mm);
       }
       if(ss>0 || zero){
              tim+=" ";
              tim+=tr("%1 s", "seconds").arg(ss);
       }
       tim.remove(0, 1);
       s+=QString("\n");
       s+=tr("Max placed activities: %1 (at %2)", "%1 represents the maximum number of activities placed, %2 is a time interval").arg(mact).arg(tim);
       
       textLabel->setText(tr("Current timetable: %1 out of %2 activities placed, %3h %4m %5s")
        .arg(na)
        .arg(gt.rules.nInternalActivities)
        .arg(hours)
        .arg(minutes)
        .arg(seconds)+s);
       
       semaphorePlacedActivity.release();
}

Here is the caller graph for this function:

Definition at line 496 of file timetablegeneratemultipleform.cpp.

{
       if(!generateMultipleThread.isRunning())
              this->close();
}

Here is the caller graph for this function:

void TimetableGenerateMultipleForm::finished ( ) [private, slot]

Definition at line 400 of file timetablegeneratemultipleform.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 219 of file timetablegeneratemultipleform.cpp.

{
       QString s2=INPUT_FILENAME_XML.right(INPUT_FILENAME_XML.length()-INPUT_FILENAME_XML.lastIndexOf(FILE_SEP)-1);
       
       if(s2.right(4)==".fet")
              s2=s2.left(s2.length()-4);
       
       QString destDir=OUTPUT_DIR+FILE_SEP+"timetables"+FILE_SEP+s2+"-multi";

       QString s=tr("You can only see generated timetables on the hard disk,"
        " in HTML and XML formats and soft conflicts in text format, or latest timetable in the Timetable/View menu."
        " It is needed that the directory"
        " %1 to be emptied and deleted before proceeding.").arg(QDir::toNativeSeparators(destDir))
        +"\n\n"
        +tr("Note that, for large data, each timetable might occupy more"
        " megabytes of hard disk space,"
        " so make sure you have enough space (you can check the dimension of a single timetable as a precaution).")
        +"\n\n"
        +tr("There are also saved the timetables in .fet format (data + constraints to lock the timetable), so that you can open each of them later.")
        +"\n\n"
        +tr("If you get impossible timetable, please enter menu Generate (single) and see the initial order of evaluation of activities,"
        " this might help.")
        +"\n\n"
        +tr("You can limit the search time, by specifying the maximum number of minutes allowed to spend for each timetable (option %1).").arg("'"+tr("Limit for each timetable")+"'")
        +" "+tr("The maximum and also the predefined value is %1 minutes, which means %2 hours, so virtually unlimited.").arg(60000).arg(1000)
        ;
        
        LongTextMessageBox::largeInformation(this, tr("FET information"), s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 405 of file timetablegeneratemultipleform.cpp.

{
       if(!simulation_running_multi){
              return;
       }

       simulation_running_multi=false;

       QString s2=INPUT_FILENAME_XML.right(INPUT_FILENAME_XML.length()-INPUT_FILENAME_XML.lastIndexOf(FILE_SEP)-1);

       if(s2.right(4)==".fet")
              s2=s2.left(s2.length()-4);
       
       QString destDir=OUTPUT_DIR+FILE_SEP+"timetables"+FILE_SEP+s2+"-multi";
       
       time_t final_time;
       time(&final_time);
       int s=int(final_time-initial_time);
       int h=s/3600;
       s%=3600;
       int m=s/60;
       s%=60;

       QString ms=QString("");
       ms+=TimetableGenerateMultipleForm::tr("Simulation terminated successfully!");
       ms+=QString("\n\n");
       ms+=TimetableGenerateMultipleForm::tr("The results were saved in the directory %1").arg(QDir::toNativeSeparators(destDir));
       ms+=QString("\n\n");
       ms+=TimetableGenerateMultipleForm::tr("Total searching time was %1h %2m %3s").arg(h).arg(m).arg(s);
       QMessageBox::information(this, TimetableGenerateMultipleForm::tr("FET information"), ms);
       
       startPushButton->setEnabled(TRUE);
       stopPushButton->setDisabled(TRUE);
       minutesGroupBox->setEnabled(TRUE);
       timetablesGroupBox->setEnabled(TRUE);
       closePushButton->setEnabled(TRUE);
}

Here is the caller graph for this function:

Definition at line 249 of file timetablegeneratemultipleform.cpp.

                                         {
       nTimetables=timetablesSpinBox->value();
       assert(nTimetables>0);
       timeLimit=60*minutesSpinBox->value(); //seconds
       assert(timeLimit>0);

       QDir dir;
       QString s2=INPUT_FILENAME_XML.right(INPUT_FILENAME_XML.length()-INPUT_FILENAME_XML.lastIndexOf(FILE_SEP)-1);

       if(s2.right(4)==".fet")
              s2=s2.left(s2.length()-4);
       
       QString destDir=OUTPUT_DIR+FILE_SEP+"timetables"+FILE_SEP+s2+"-multi";
       if(dir.exists(destDir)){
              QMessageBox::warning(this, tr("FET information"), tr("Directory %1 exists and might not be empty,"
               " (it might contain old files). You need to manually remove all contents of this directory AND the directory itself (or rename it)"
               " and then you can generate multiple timetables")
               .arg(QDir::toNativeSeparators(destDir)));
               
              return;
       }

       if(!gt.rules.internalStructureComputed){
              if(!gt.rules.computeInternalStructure(this)){
                     QMessageBox::warning(this, TimetableGenerateMultipleForm::tr("FET warning"), TimetableGenerateMultipleForm::tr("Data is wrong. Please correct and try again"));
                     return;
              }
       }

       if(!gt.rules.initialized || gt.rules.activitiesList.isEmpty()){
              QMessageBox::critical(this, TimetableGenerateMultipleForm::tr("FET information"),
                     TimetableGenerateMultipleForm::tr("You have entered simulation with uninitialized rules or 0 activities...aborting"));
              assert(0);
              exit(1);
              return;
       }

       currentResultsTextEdit->setPlainText("");

       bool ok=genMulti.precompute(this);
       if(!ok){
              currentResultsTextEdit->setPlainText(TimetableGenerateMultipleForm::tr("Cannot optimize - please modify your data"));
              currentResultsTextEdit->update();

              QMessageBox::information(this, TimetableGenerateMultipleForm::tr("FET information"),
               TimetableGenerateMultipleForm::tr("Your data cannot be processed - please modify it as instructed."));

              return;
       }

       startPushButton->setDisabled(TRUE);
       stopPushButton->setEnabled(TRUE);
       minutesGroupBox->setDisabled(TRUE);
       timetablesGroupBox->setDisabled(TRUE);
       closePushButton->setDisabled(TRUE);

       simulation_running_multi=true;

       for(int qq=0; qq<gt.rules.nInternalActivities; qq++)
              savedPermutation[qq]=permutation[qq];
              
       genMulti.c.makeUnallocated(gt.rules);

       generateMultipleThread.start();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 357 of file timetablegeneratemultipleform.cpp.

{
       if(!simulation_running_multi){
              return;
       }

       simulation_running_multi=false;

       mutex.lock();
       genMulti.abortOptimization=true;
       mutex.unlock();

       QString s=TimetableGenerateMultipleForm::tr("Simulation interrupted!");
       s+="\n\n";

       QString s2=INPUT_FILENAME_XML.right(INPUT_FILENAME_XML.length()-INPUT_FILENAME_XML.lastIndexOf(FILE_SEP)-1);

       if(s2.right(4)==".fet")
              s2=s2.left(s2.length()-4);
       
       QString destDir=OUTPUT_DIR+FILE_SEP+"timetables"+FILE_SEP+s2+"-multi";

       time_t final_time;
       time(&final_time);
       int sec=int(final_time-initial_time);
       int h=sec/3600;
       sec%=3600;
       int m=sec/60;
       sec%=60;

       s+=TimetableGenerateMultipleForm::tr("The results were saved in the directory %1").arg(QDir::toNativeSeparators(destDir));
       s+="\n\n";
       s+=tr("Total searching time: %1h %2m %3s").arg(h).arg(m).arg(sec);
       
       QMessageBox::information(this, tr("FET information"), s);

       startPushButton->setEnabled(TRUE);
       stopPushButton->setDisabled(TRUE);
       minutesGroupBox->setEnabled(TRUE);
       timetablesGroupBox->setEnabled(TRUE);
       closePushButton->setEnabled(TRUE);
}

Here is the caller graph for this function:

void TimetableGenerateMultipleForm::timetableGenerated ( int  timetable,
const QString &  description,
bool  ok 
) [private, slot]

Definition at line 322 of file timetablegeneratemultipleform.cpp.

{
       TimetableExport::writeRandomSeed(this, timetable, false); //false represents 'before' state

       QString s=QString("");
       s+=tr("Timetable no: %1 => %2").arg(timetable).arg(description);
       currentResultsTextEdit->appendPlainText(s);

       if(ok){
              //needed to get the conflicts string
              QString tmp;
              genMulti.c.fitness(gt.rules, &tmp);
       
              TimetableExport::getStudentsTimetable(genMulti.c);
              TimetableExport::getTeachersTimetable(genMulti.c);
              TimetableExport::getRoomsTimetable(genMulti.c);

              TimetableExport::writeSimulationResults(this, timetable);

              //update the string representing the conflicts
              conflictsStringTitle=tr("Soft conflicts", "Title of dialog");
              conflictsString = "";
              conflictsString+=tr("Total soft conflicts:");
              conflictsString+=" ";
              conflictsString+=CustomFETString::number(best_solution.conflictsTotal);
              conflictsString+="\n";
              conflictsString += tr("Soft conflicts listing (in decreasing order):")+"\n";

              foreach(QString t, best_solution.conflictsDescriptionList)
                     conflictsString+=t+"\n";
       }

       semaphoreTimetableFinished.release();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TimetableGenerateMultipleForm::timetableStarted ( int  timetable) [private, slot]

Definition at line 315 of file timetablegeneratemultipleform.cpp.

{
       TimetableExport::writeRandomSeed(this, timetable, true); //true represents 'before' state
       
       semaphoreTimetableStarted.release();
}

Here is the call graph for this function:

Here is the caller graph for this function:


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