Logo Search packages:      
Sourcecode: fet version File versions

bool Rules::read ( const QString &  filename  ) 

Reads the rules from the xml input file "filename". Returns true on success, false on failure (inexistent file or wrong format)

Definition at line 2242 of file rules.cpp.

References ConstraintActivityPreferredRooms::_n_preferred_rooms, ConstraintActivitiesSameRoom::activitiesId, ConstraintActivitiesSameStartingHour::activitiesId, ConstraintActivitiesSameStartingTime::activitiesId, ConstraintActivitiesNotOverlapping::activitiesId, ConstraintMinNDaysBetweenActivities::activitiesId, ConstraintActivityPreferredRooms::activityId, ConstraintActivityPreferredRoom::activityId, ConstraintActivityPreferredTimes::activityId, ConstraintActivityEndsDay::activityId, ConstraintActivityPreferredTime::activityId, Room::addEquipment(), addEquipment(), addGroup(), ConstraintRoomTypeNotAllowedSubjects::addNotAllowedSubject(), ConstraintSubjectSubjectTagRequireEquipments::addRequiredEquipment(), ConstraintSubjectRequiresEquipments::addRequiredEquipment(), addRoom(), addSimpleActivity(), addSpaceConstraint(), addSubgroup(), addSubject(), addSubjectTag(), addTeacher(), addTimeConstraint(), addYear(), Room::capacity, comments, SpaceConstraint::compulsory, TimeConstraint::compulsory, ConstraintRoomNotAvailable::d, ConstraintBreak::d, ConstraintStudentsSetNotAvailable::d, ConstraintTeacherNotAvailable::d, ConstraintActivityPreferredTime::day, ConstraintActivitiesPreferredTimes::days, ConstraintActivityPreferredTimes::days, daysOfTheWeek, equipmentsList, Constraint2ActivitiesGrouped::firstActivityId, Constraint2ActivitiesConsecutive::firstActivityId, ConstraintRoomNotAvailable::h1, ConstraintStudentsSetIntervalMaxDaysPerWeek::h1, ConstraintBreak::h1, ConstraintStudentsSetNotAvailable::h1, ConstraintTeacherNotAvailable::h1, ConstraintRoomNotAvailable::h2, ConstraintStudentsSetIntervalMaxDaysPerWeek::h2, ConstraintBreak::h2, ConstraintStudentsSetNotAvailable::h2, ConstraintTeacherNotAvailable::h2, ConstraintActivityPreferredTime::hour, ConstraintActivitiesPreferredTimes::hours, ConstraintActivityPreferredTimes::hours, hoursOfTheDay, init(), initialized, institutionName, internalStructureComputed, kill(), ConstraintTeacherMaxDaysPerWeek::maxDaysPerWeek, ConstraintTeachersNoMoreThanXHoursContinuously::maxHoursContinuously, ConstraintStudentsSetNHoursDaily::maxHoursDaily, ConstraintStudentsNHoursDaily::maxHoursDaily, ConstraintTeachersSubgroupsNoMoreThanXHoursDaily::maxHoursDaily, ConstraintTeachersNoMoreThanXHoursDaily::maxHoursDaily, ConstraintMinNDaysBetweenActivities::minDays, ConstraintStudentsSetNHoursDaily::minHoursDaily, ConstraintStudentsNHoursDaily::minHoursDaily, ConstraintStudentsSetIntervalMaxDaysPerWeek::n, ConstraintActivitiesSameRoom::n_activities, ConstraintActivitiesSameStartingHour::n_activities, ConstraintActivitiesSameStartingTime::n_activities, ConstraintActivitiesNotOverlapping::n_activities, ConstraintMinNDaysBetweenActivities::n_activities, Room::name, Equipment::name, SubjectTag::name, Subject::name, Teacher::name, nDaysPerWeek, nHoursPerDay, ConstraintActivitiesPreferredTimes::nPreferredTimes, ConstraintActivityPreferredTimes::nPreferredTimes, ConstraintActivityPreferredRoom::roomName, ConstraintTeacherRequiresRoom::roomName, ConstraintRoomNotAvailable::roomName, roomsList, ConstraintActivityPreferredRooms::roomsNames, ConstraintRoomTypeNotAllowedSubjects::roomType, searchStudentsSet(), searchSubject(), searchSubjectTag(), searchTeacher(), Constraint2ActivitiesGrouped::secondActivityId, Constraint2ActivitiesConsecutive::secondActivityId, ConstraintStudentsSetIntervalMaxDaysPerWeek::students, ConstraintStudentsSetNoGaps::students, ConstraintStudentsSetNHoursDaily::students, ConstraintStudentsSetNotAvailable::students, ConstraintActivitiesPreferredTimes::studentsName, ConstraintSubjectSubjectTagRequireEquipments::subjectName, ConstraintSubjectRequiresEquipments::subjectName, ConstraintActivitiesPreferredTimes::subjectName, subjectsList, ConstraintSubjectSubjectTagRequireEquipments::subjectTagName, subjectTagsList, ConstraintTeacherMaxDaysPerWeek::teacher, ConstraintTeacherRequiresRoom::teacherName, ConstraintActivitiesPreferredTimes::teacherName, ConstraintTeacherNotAvailable::teacherName, teachersList, Room::type, SpaceConstraint::weight, TimeConstraint::weight, and yearsList.

{
      QFile file(filename);
      if(!file.open(IO_ReadOnly)){
            return false;
      }
      QDomDocument doc("xml_rules");
      if(!doc.setContent(&file)){
            file.close();
            cout<<"Could not open file - not existing or in use\n";
            return false;
      }
      file.close();

      //Clear old rules, initialize new rules
      if(this->initialized)
            this->kill();
      this->init();

      ////////////////////////////////////////

      //logging part
      QString xmlReadingLog="";
      QString tmp=OUTPUT_DIR+FILE_SEP+XML_PARSING_LOG_FILENAME;
      QFile file2(tmp);
      if(!file2.open(IO_WriteOnly)){
            assert(0);
            exit(1);
      }
      QTextStream logStream(&file2);

      QDomElement elem1=doc.documentElement();
      xmlReadingLog+=" Found "+elem1.tagName()+" tag\n";
      bool okAbove3_12_17=true;
      bool warning=false;
      if(elem1.tagName()!="FET")
            okAbove3_12_17=false;
      else{
            QDomDocumentType dt=doc.doctype();
            if(dt.isNull() || dt.name()!="FET")
                  okAbove3_12_17=false;
            else{
                  QDomAttr a=elem1.attributeNode("version");
                  QString version=a.value();
                  int v[3];
                  //cout<<"version=|"<<version<<"|"<<endl;
                  int t=sscanf((const char*)(version), "%d.%d.%d", &v[0], &v[1], &v[2]);
                  assert(t==3);

                  int w[3];
                  t=sscanf((const char*)(FET_VERSION), "%d.%d.%d", &w[0], &w[1], &w[2]);
                  assert(t==3);
                  
                  if(v[0]>w[0] || (v[0]==w[0] && v[1]>w[1]) || (v[0]==w[0]&&v[1]==w[1]&&v[2]>w[2]))
                        warning=true;
            }
      }
      if(!okAbove3_12_17){ //trying version 3.6.1 to version 3.12.16
            cout<<"Invalid fet 3.12.17 or above - trying older version"<<endl;
            if(elem1.tagName()!=INPUT_FILE_TAG_3_6_1){
                  file2.close();
                  return false;
            }
      }
      else if(warning){
            QMessageBox::warning(NULL, QObject::tr("FET information"), 
             QObject::tr("Trying to open a newer file - please update your FET software to the latest version"));
      }
      
      this->nHoursPerDay=12;
      this->hoursOfTheDay[0]="0";
      this->hoursOfTheDay[1]="1";
      this->hoursOfTheDay[2]="2";
      this->hoursOfTheDay[3]="3";
      this->hoursOfTheDay[4]="4";
      this->hoursOfTheDay[5]="5";
      this->hoursOfTheDay[6]="6";
      this->hoursOfTheDay[7]="7";
      this->hoursOfTheDay[8]="8";
      this->hoursOfTheDay[9]="9";
      this->hoursOfTheDay[10]="10";
      this->hoursOfTheDay[11]="11";
      this->hoursOfTheDay[12]="12";

      this->nDaysPerWeek=5;
      this->daysOfTheWeek[0] = QObject::tr("Monday");
      this->daysOfTheWeek[1] = QObject::tr("Tuesday");
      this->daysOfTheWeek[2] = QObject::tr("Wednesday");
      this->daysOfTheWeek[3] = QObject::tr("Thursday");
      this->daysOfTheWeek[4] = QObject::tr("Friday");

      this->institutionName=QObject::tr("Default institution");
      this->comments=QObject::tr("Default comments");

      for(QDomNode node2=elem1.firstChild(); !node2.isNull(); node2=node2.nextSibling()){
            QDomElement elem2=node2.toElement();
            if(elem2.isNull())
                  xmlReadingLog+="  Null node here\n";
            xmlReadingLog+="  Found "+elem2.tagName()+" tag\n";
            if(elem2.tagName()=="Institution_Name"){
                  this->institutionName=elem2.text();
                  xmlReadingLog+="  Found institution name="+this->institutionName+"\n";
            }
            else if(elem2.tagName()=="Comments"){
                  this->comments=elem2.text();
                  xmlReadingLog+="  Found comments="+this->comments+"\n";
            }
            else if(elem2.tagName()=="Hours_List"){
                  int tmp=0;
                  for(QDomNode node3=elem2.firstChild(); !node3.isNull(); node3=node3.nextSibling()){
                        QDomElement elem3=node3.toElement();
                        if(elem3.isNull()){
                              xmlReadingLog+="   Null node here\n";
                              continue;
                        }
                        xmlReadingLog+="   Found "+elem3.tagName()+" tag\n";
                        if(elem3.tagName()=="Number"){
                              this->nHoursPerDay=elem3.text().toInt();
                              xmlReadingLog+="   Found the number of hours per day = "+
                               QString::number(this->nHoursPerDay)+"\n";
                              assert(this->nHoursPerDay>0);
                        }
                        else if(elem3.tagName()=="Name"){
                              this->hoursOfTheDay[tmp]=elem3.text();
                              xmlReadingLog+="   Found hour "+this->hoursOfTheDay[tmp]+"\n";
                              tmp++;
                        }
                  }
            }
            else if(elem2.tagName()=="Days_List"){
                  int tmp=0;
                  for(QDomNode node3=elem2.firstChild(); !node3.isNull(); node3=node3.nextSibling()){
                        QDomElement elem3=node3.toElement();
                        if(elem3.isNull()){
                              xmlReadingLog+="   Null node here\n";
                              continue;
                        }
                        xmlReadingLog+="   Found "+elem3.tagName()+" tag\n";
                        if(elem3.tagName()=="Number"){
                              this->nDaysPerWeek=elem3.text().toInt();
                              xmlReadingLog+="   Found the number of days per week = "+
                               QString::number(this->nDaysPerWeek)+"\n";
                              assert(this->nDaysPerWeek>0);
                        }
                        else if(elem3.tagName()=="Name"){
                              this->daysOfTheWeek[tmp]=elem3.text();
                              xmlReadingLog+="   Found day "+this->daysOfTheWeek[tmp]+"\n";
                              tmp++;
                        }
                  }
                  assert(tmp==this->nDaysPerWeek);
            }
            else if(elem2.tagName()=="Teachers_List"){
                  int tmp=0;
                  for(QDomNode node3=elem2.firstChild(); !node3.isNull(); node3=node3.nextSibling()){
                        QDomElement elem3=node3.toElement();
                        if(elem3.isNull()){
                              xmlReadingLog+="   Null node here\n";
                              continue;
                        }
                        xmlReadingLog+="   Found "+elem3.tagName()+" tag\n";
                        if(elem3.tagName()=="Teacher"){
                              Teacher* teacher=new Teacher();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Name"){
                                          teacher->name=elem4.text();
                                          xmlReadingLog+="    Read teacher name: "+teacher->name+"\n";
                                    }
                              }
                              bool tmp2=this->addTeacher(teacher);
                              assert(tmp2==true);
                              tmp++;
                              xmlReadingLog+="   Teacher added\n";
                        }
                  }
                  assert((uint)(tmp)==this->teachersList.count());
                  xmlReadingLog+="  Added "+QString::number(tmp)+" teachers\n";
            }
            else if(elem2.tagName()=="Subjects_List"){
                  int tmp=0;
                  for(QDomNode node3=elem2.firstChild(); !node3.isNull(); node3=node3.nextSibling()){
                        QDomElement elem3=node3.toElement();
                        if(elem3.isNull()){
                              xmlReadingLog+="   Null node here\n";
                              continue;
                        }
                        xmlReadingLog+="   Found "+elem3.tagName()+" tag\n";
                        if(elem3.tagName()=="Subject"){
                              Subject* subject=new Subject();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Name"){
                                          subject->name=elem4.text();
                                          xmlReadingLog+="    Read subject name: "+subject->name+"\n";
                                    }
                              }
                              bool tmp2=this->addSubject(subject);
                              assert(tmp2==true);
                              tmp++;
                              xmlReadingLog+="   Subject inserted\n";
                        }
                  }
                  assert((uint)(tmp)==this->subjectsList.count());
                  xmlReadingLog+="  Added "+QString::number(tmp)+" subjects\n";
            }
            else if(elem2.tagName()=="Subject_Tags_List"){
                  int tmp=0;
                  for(QDomNode node3=elem2.firstChild(); !node3.isNull(); node3=node3.nextSibling()){
                        QDomElement elem3=node3.toElement();
                        if(elem3.isNull()){
                              xmlReadingLog+="   Null node here\n";
                              continue;
                        }
                        xmlReadingLog+="   Found "+elem3.tagName()+" tag\n";
                        if(elem3.tagName()=="Subject_Tag"){
                              SubjectTag* subjectTag=new SubjectTag();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Name"){
                                          subjectTag->name=elem4.text();
                                          xmlReadingLog+="    Read subject tag name: "+subjectTag->name+"\n";
                                    }
                              }
                              bool tmp2=this->addSubjectTag(subjectTag);
                              assert(tmp2==true);
                              tmp++;
                              xmlReadingLog+="   Subject tag inserted\n";
                        }
                  }
                  assert((uint)(tmp)==this->subjectTagsList.count());
                  xmlReadingLog+="  Added "+QString::number(tmp)+" subject tags\n";
            }
            else if(elem2.tagName()=="Students_List"){
                  int ny=0;
                  for(QDomNode node3=elem2.firstChild(); !node3.isNull(); node3=node3.nextSibling()){
                        QDomElement elem3=node3.toElement();
                        if(elem3.isNull()){
                              xmlReadingLog+="   Null node here\n";
                              continue;
                        }
                        xmlReadingLog+="   Found "+elem3.tagName()+" tag\n";
                        if(elem3.tagName()=="Year"){
                              StudentsYear* sty=new StudentsYear();
                              int ng=0;

                              bool tmp2=this->addYear(sty);
                              assert(tmp2==true);
                              ny++;

                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Name"){
                                          sty->name=elem4.text();
                                          xmlReadingLog+="    Read year name: "+sty->name+"\n";
                                    }
                                    else if(elem4.tagName()=="Number_of_Students"){
                                          sty->numberOfStudents=elem4.text().toInt();
                                          xmlReadingLog+="    Read year number of students: "+QString::number(sty->numberOfStudents)+"\n";
                                    }
                                    else if(elem4.tagName()=="Group"){
                                          StudentsGroup* stg=new StudentsGroup();
                                          int ns=0;

                                          bool tmp4=this->addGroup(sty->name, stg);
                                          assert(tmp4==true);
                                          ng++;

                                          for(QDomNode node5=elem4.firstChild(); !node5.isNull(); node5=node5.nextSibling()){
                                                QDomElement elem5=node5.toElement();
                                                if(elem5.isNull()){
                                                      xmlReadingLog+="     Null node here\n";
                                                      continue;
                                                }
                                                xmlReadingLog+="     Found "+elem5.tagName()+" tag\n";
                                                if(elem5.tagName()=="Name"){
                                                      stg->name=elem5.text();
                                                      xmlReadingLog+="     Read group name: "+stg->name+"\n";
                                                }
                                                else if(elem5.tagName()=="Number_of_Students"){
                                                      stg->numberOfStudents=elem5.text().toInt();
                                                      xmlReadingLog+="     Read group number of students: "+QString::number(stg->numberOfStudents)+"\n";
                                                }
                                                else if(elem5.tagName()=="Subgroup"){
                                                      StudentsSubgroup* sts=new StudentsSubgroup();

                                                      bool tmp6=this->addSubgroup(sty->name, stg->name, sts);
                                                      assert(tmp6==true);
                                                      ns++;

                                                      for(QDomNode node6=elem5.firstChild(); !node6.isNull(); node6=node6.nextSibling()){
                                                            QDomElement elem6=node6.toElement();
                                                            if(elem6.isNull()){
                                                                  xmlReadingLog+="     Null node here\n";
                                                                  continue;
                                                            }
                                                            xmlReadingLog+="     Found "+elem6.tagName()+" tag\n";
                                                            if(elem6.tagName()=="Name"){
                                                                  sts->name=elem6.text();
                                                                  xmlReadingLog+="     Read subgroup name: "+sts->name+"\n";
                                                            }
                                                            else if(elem6.tagName()=="Number_of_Students"){
                                                                  sts->numberOfStudents=elem6.text().toInt();
                                                                  xmlReadingLog+="     Read subgroup number of students: "+QString::number(sts->numberOfStudents)+"\n";
                                                            }
                                                      }
                                                }
                                          }
                                          assert((uint)(ns) == stg->subgroupsList.count());
                                          xmlReadingLog+="    Added "+QString::number(ns)+" subgroups\n";
                                    }
                              }
                              assert((uint)(ng) == sty->groupsList.count());
                              xmlReadingLog+="   Added "+QString::number(ng)+" groups\n";
                        }
                  }
                  xmlReadingLog+="  Added "+QString::number(ny)+" years\n";
                  assert(this->yearsList.count()==(uint)(ny));
            }
            else if(elem2.tagName()=="Activities_List"){
                  int na=0;
                  for(QDomNode node3=elem2.firstChild(); !node3.isNull(); node3=node3.nextSibling()){
                        QDomElement elem3=node3.toElement();
                        if(elem3.isNull()){
                              xmlReadingLog+="   Null node here\n";
                              continue;
                        }
                        xmlReadingLog+="   Found "+elem3.tagName()+" tag\n";
                        if(elem3.tagName()=="Activity"){
                              bool correct=true;
                        
                              QString tn="";
                              QStringList tl;
                              QString sjn="";
                              QString stgn="";
                              QString stn="";
                              QStringList stl;
                              int p=PARITY_NOT_INITIALIZED;
                              int td=-1;
                              int d=-1;
                              int id=-1;
                              int gid=-1;
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="   Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weekly"){
                                          xmlReadingLog+="    Current activity is weekly\n";
                                          assert(p==PARITY_NOT_INITIALIZED);
                                          p=PARITY_WEEKLY;
                                    }
                                    else if(elem4.tagName()=="Biweekly"){
                                          xmlReadingLog+="    Current activity is biweekly\n";
                                          assert(p==PARITY_NOT_INITIALIZED);
                                          p=PARITY_BIWEEKLY;
                                    }
                                    else if(elem4.tagName()=="Teacher"){
                                          tn=elem4.text();
                                          xmlReadingLog+="    Crt. activity teacher="+tn+"\n";
                                          tl.append(tn);
                                          if(this->searchTeacher(tn)<0)
                                                correct=false;
                                    }
                                    else if(elem4.tagName()=="Subject"){
                                          sjn=elem4.text();
                                          xmlReadingLog+="    Crt. activity subject="+sjn+"\n";
                                          if(this->searchSubject(sjn)<0)
                                                correct=false;
                                    }
                                    else if(elem4.tagName()=="Subject_Tag"){
                                          stgn=elem4.text();
                                          xmlReadingLog+="    Crt. activity subject tag="+stgn+"\n";
                                          if(this->searchSubjectTag(stgn)<0 && stgn!="")
                                                correct=false;
                                    }
                                    else if(elem4.tagName()=="Students"){
                                          stn=elem4.text();
                                          xmlReadingLog+="    Crt. activity students+="+stn+"\n";
                                          stl.append(stn);
                                          if(this->searchStudentsSet(stn)==NULL)
                                                correct=false;
                                    }
                                    else if(elem4.tagName()=="Duration"){
                                          d=elem4.text().toInt();
                                          xmlReadingLog+="    Crt. activity duration="+QString::number(d)+"\n";
                                    }
                                    else if(elem4.tagName()=="Total_Duration"){
                                          td=elem4.text().toInt();
                                          xmlReadingLog+="    Crt. activity total duration="+QString::number(td)+"\n";
                                    }
                                    else if(elem4.tagName()=="Id"){
                                          id=elem4.text().toInt();
                                          xmlReadingLog+="    Crt. activity id="+QString::number(id)+"\n";
                                    }
                                    else if(elem4.tagName()=="Activity_Group_Id"){
                                          gid=elem4.text().toInt();
                                          xmlReadingLog+="    Crt. activity group id="+QString::number(gid)+"\n";
                                    }
                              }
                              if(correct){
                                    assert(id>=0 && gid>=0);
                                    assert(d>0);
                                    if(td<0)
                                          td=d;
                                    this->addSimpleActivity(id, gid, tl, sjn, stgn, stl,
                                          d, td, p, -1, -1);
                                    na++;
                                    xmlReadingLog+="   Added the activity\n";
                              }
                              else{
                                    xmlReadingLog+="   Activity with id ="+QString::number(id)+" contains invalid data - skipping\n";
                                    QMessageBox::warning(NULL, QObject::tr("FET information"), 
                                     QObject::tr("Activity with id=%1 contains invalid data - skipping").arg(id));
                              }
                        }
                  }
                  xmlReadingLog+="  Added "+QString::number(na)+" activities\n";
            }
            else if(elem2.tagName()=="Equipments_List"){
                  int tmp=0;
                  for(QDomNode node3=elem2.firstChild(); !node3.isNull(); node3=node3.nextSibling()){
                        QDomElement elem3=node3.toElement();
                        if(elem3.isNull()){
                              xmlReadingLog+="   Null node here\n";
                              continue;
                        }
                        xmlReadingLog+="   Found "+elem3.tagName()+" tag\n";
                        if(elem3.tagName()=="Equipment"){
                              Equipment* eq=new Equipment();
                              eq->name="";
                              
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Name"){
                                          eq->name=elem4.text();
                                          xmlReadingLog+="    Read equipment name: "+eq->name+"\n";
                                    }
                              }
                              bool tmp2=this->addEquipment(eq);
                              assert(tmp2==true);
                              tmp++;
                              xmlReadingLog+="   Equipment added\n";
                        }
                  }
                  assert((uint)(tmp)==this->equipmentsList.count());
                  xmlReadingLog+="  Added "+QString::number(tmp)+" equipments\n";
            }
            else if(elem2.tagName()=="Rooms_List"){
                  int tmp=0;
                  for(QDomNode node3=elem2.firstChild(); !node3.isNull(); node3=node3.nextSibling()){
                        QDomElement elem3=node3.toElement();
                        if(elem3.isNull()){
                              xmlReadingLog+="   Null node here\n";
                              continue;
                        }
                        xmlReadingLog+="   Found "+elem3.tagName()+" tag\n";
                        if(elem3.tagName()=="Room"){
                              Room* rm=new Room();
                              rm->name="";
                              rm->type="";
                              rm->capacity=1000; //infinite, if not specified
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Name"){
                                          rm->name=elem4.text();
                                          xmlReadingLog+="    Read room name: "+rm->name+"\n";
                                    }
                                    else if(elem4.tagName()=="Type"){
                                          rm->type=elem4.text();
                                          xmlReadingLog+="    Read room type: "+rm->type+"\n";
                                    }
                                    else if(elem4.tagName()=="Capacity"){
                                          rm->capacity=elem4.text().toInt();
                                          xmlReadingLog+="    Read room capacity: "+QString::number(rm->capacity)+"\n";
                                    }
                                    else if(elem4.tagName()=="Equipment"){
                                          rm->addEquipment(elem4.text());
                                          xmlReadingLog+="    Read room equipment: "+elem4.text()+"\n";
                                    }
                              }
                              bool tmp2=this->addRoom(rm);
                              if(!tmp2){
                                    cout<<"Duplicate room - "<<rm->name<<endl;
                                    assert(0);
                                    exit(1);
                              }
                              assert(tmp2==true);
                              tmp++;
                              xmlReadingLog+="   Room added\n";
                        }
                  }
                  assert((uint)(tmp)==this->roomsList.count());
                  xmlReadingLog+="  Added "+QString::number(tmp)+" rooms\n";
            }
            else if(elem2.tagName()=="Time_Constraints_List"){
                  int nc=0;
                  TimeConstraint *crt_constraint;
                  for(QDomNode node3=elem2.firstChild(); !node3.isNull(); node3=node3.nextSibling()){
                        crt_constraint=NULL;
                        QDomElement elem3=node3.toElement();
                        if(elem3.isNull()){
                              xmlReadingLog+="   Null node here\n";
                              continue;
                        }
                        xmlReadingLog+="   Found "+elem3.tagName()+" tag\n";
                        if(elem3.tagName()=="ConstraintBasicCompulsoryTime"){
                              ConstraintBasicCompulsoryTime* cn=new ConstraintBasicCompulsoryTime();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintTeacherNotAvailable"){
                              ConstraintTeacherNotAvailable* cn=new ConstraintTeacherNotAvailable();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Teacher_Name"){
                                          cn->teacherName=elem4.text();
                                          xmlReadingLog+="    Read teacher name="+cn->teacherName+"\n";
                                    }
                                    else if(elem4.tagName()=="Day"){
                                          for(cn->d=0; cn->d<this->nDaysPerWeek; cn->d++)
                                                if(this->daysOfTheWeek[cn->d]==elem4.text())
                                                      break;
                                          assert(cn->d<this->nDaysPerWeek);
                                          xmlReadingLog+="    Crt. day="+this->daysOfTheWeek[cn->d]+"\n";
                                    }
                                    else if(elem4.tagName()=="Start_Hour"){
                                          for(cn->h1=0; cn->h1 < this->nHoursPerDay; cn->h1++)
                                                if(this->hoursOfTheDay[cn->h1]==elem4.text())
                                                      break;
                                          assert(cn->h1>=0 && cn->h1 < this->nHoursPerDay);
                                          xmlReadingLog+="    Start hour="+this->hoursOfTheDay[cn->h1]+"\n";
                                    }
                                    else if(elem4.tagName()=="End_Hour"){
                                          for(cn->h2=0; cn->h2 < this->nHoursPerDay; cn->h2++)
                                                if(this->hoursOfTheDay[cn->h2]==elem4.text())
                                                      break;
                                          assert(cn->h2>0 && cn->h2 <= this->nHoursPerDay);
                                          xmlReadingLog+="    End hour="+this->hoursOfTheDay[cn->h2]+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintTeacherMaxDaysPerWeek"){
                              ConstraintTeacherMaxDaysPerWeek* cn=new ConstraintTeacherMaxDaysPerWeek();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Teacher_Name"){
                                          cn->teacher=elem4.text();
                                          xmlReadingLog+="    Read teacher name="+cn->teacher+"\n";
                                    }
                                    else if(elem4.tagName()=="Max_Days_Per_Week"){
                                          cn->maxDaysPerWeek=elem4.text().toInt();
                                          assert(cn->maxDaysPerWeek>0 && cn->maxDaysPerWeek <= this->nDaysPerWeek);
                                          xmlReadingLog+="    Max. days per week="+QString::number(cn->maxDaysPerWeek)+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintStudentsSetNotAvailable"){
                              ConstraintStudentsSetNotAvailable* cn=new ConstraintStudentsSetNotAvailable();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Day"){
                                          for(cn->d=0; cn->d<this->nDaysPerWeek; cn->d++)
                                                if(this->daysOfTheWeek[cn->d]==elem4.text())
                                                      break;
                                          assert(cn->d<this->nDaysPerWeek);
                                          xmlReadingLog+="    Crt. day="+this->daysOfTheWeek[cn->d]+"\n";
                                    }
                                    else if(elem4.tagName()=="Start_Hour"){
                                          for(cn->h1=0; cn->h1 < this->nHoursPerDay; cn->h1++)
                                                if(this->hoursOfTheDay[cn->h1]==elem4.text())
                                                      break;
                                          assert(cn->h1>=0 && cn->h1 < this->nHoursPerDay);
                                          xmlReadingLog+="    Start hour="+this->hoursOfTheDay[cn->h1]+"\n";
                                    }
                                    else if(elem4.tagName()=="End_Hour"){
                                          for(cn->h2=0; cn->h2 < this->nHoursPerDay; cn->h2++)
                                                if(this->hoursOfTheDay[cn->h2]==elem4.text())
                                                      break;
                                          assert(cn->h2>0 && cn->h2 <= this->nHoursPerDay);
                                          xmlReadingLog+="    End hour="+this->hoursOfTheDay[cn->h2]+"\n";
                                    }
                                    else if(elem4.tagName()=="Students"){
                                          cn->students=elem4.text();
                                          xmlReadingLog+="    Read students name="+cn->students+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintMinNDaysBetweenActivities"){
                              ConstraintMinNDaysBetweenActivities* cn=new ConstraintMinNDaysBetweenActivities();
                              int n_act=0;
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Number_of_Activities"){
                                          cn->n_activities=elem4.text().toInt();
                                          xmlReadingLog+="    Read n_activities="+QString::number(cn->n_activities)+"\n";
                                    }
                                    else if(elem4.tagName()=="Activity_Id"){
                                          cn->activitiesId[n_act]=elem4.text().toInt();
                                          xmlReadingLog+="    Read activity id="+QString::number(cn->activitiesId[n_act])+"\n";
                                          n_act++;
                                    }
                                    else if(elem4.tagName()=="MinDays"){
                                          cn->minDays=elem4.text().toInt();
                                          xmlReadingLog+="    Read MinDays="+QString::number(cn->minDays)+"\n";
                                    }
                              }
                              assert(n_act==cn->n_activities);
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintActivitiesNotOverlapping"){
                              ConstraintActivitiesNotOverlapping* cn=new ConstraintActivitiesNotOverlapping();
                              int n_act=0;
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Number_of_Activities"){
                                          cn->n_activities=elem4.text().toInt();
                                          xmlReadingLog+="    Read n_activities="+QString::number(cn->n_activities)+"\n";
                                    }
                                    else if(elem4.tagName()=="Activity_Id"){
                                          cn->activitiesId[n_act]=elem4.text().toInt();
                                          xmlReadingLog+="    Read activity id="+QString::number(cn->activitiesId[n_act])+"\n";
                                          n_act++;
                                    }
                              }
                              assert(n_act==cn->n_activities);
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintActivitiesSameStartingTime"){
                              ConstraintActivitiesSameStartingTime* cn=new ConstraintActivitiesSameStartingTime();
                              int n_act=0;
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Number_of_Activities"){
                                          cn->n_activities=elem4.text().toInt();
                                          xmlReadingLog+="    Read n_activities="+QString::number(cn->n_activities)+"\n";
                                    }
                                    else if(elem4.tagName()=="Activity_Id"){
                                          cn->activitiesId[n_act]=elem4.text().toInt();
                                          xmlReadingLog+="    Read activity id="+QString::number(cn->activitiesId[n_act])+"\n";
                                          n_act++;
                                    }
                              }
                              assert(cn->n_activities==n_act);
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintActivitiesSameStartingHour"){
                              ConstraintActivitiesSameStartingHour* cn=new ConstraintActivitiesSameStartingHour();
                              int n_act=0;
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Number_of_Activities"){
                                          cn->n_activities=elem4.text().toInt();
                                          xmlReadingLog+="    Read n_activities="+QString::number(cn->n_activities)+"\n";
                                    }
                                    else if(elem4.tagName()=="Activity_Id"){
                                          cn->activitiesId[n_act]=elem4.text().toInt();
                                          xmlReadingLog+="    Read activity id="+QString::number(cn->activitiesId[n_act])+"\n";
                                          n_act++;
                                    }
                              }
                              assert(cn->n_activities==n_act);
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintTeachersNoMoreThanXHoursContinuously"){
                              ConstraintTeachersNoMoreThanXHoursContinuously* cn=new ConstraintTeachersNoMoreThanXHoursContinuously();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Maximum_Hours_Continuously"){
                                          cn->maxHoursContinuously=elem4.text().toInt();
                                          xmlReadingLog+="    Read maxHoursContinuously="+QString::number(cn->maxHoursContinuously)+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintTeachersNoMoreThanXHoursDaily"){
                              ConstraintTeachersNoMoreThanXHoursDaily* cn=new ConstraintTeachersNoMoreThanXHoursDaily();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Maximum_Hours_Daily"){
                                          cn->maxHoursDaily=elem4.text().toInt();
                                          xmlReadingLog+="    Read maxHoursDaily="+QString::number(cn->maxHoursDaily)+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintTeachersSubgroupsNoMoreThanXHoursDaily"){
                              ConstraintTeachersSubgroupsNoMoreThanXHoursDaily* cn=new ConstraintTeachersSubgroupsNoMoreThanXHoursDaily();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Maximum_Hours_Daily"){
                                          cn->maxHoursDaily=elem4.text().toInt();
                                          xmlReadingLog+="    Read maxHoursDaily="+QString::number(cn->maxHoursDaily)+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintStudentsNHoursDaily"){
                              ConstraintStudentsNHoursDaily* cn=new ConstraintStudentsNHoursDaily();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="MaxHoursDaily"){
                                          cn->maxHoursDaily=elem4.text().toInt();
                                          xmlReadingLog+="    Read maxHoursDaily="+QString::number(cn->maxHoursDaily)+"\n";
                                    }
                                    else if(elem4.tagName()=="MinHoursDaily"){
                                          cn->minHoursDaily=elem4.text().toInt();
                                          xmlReadingLog+="    Read minHoursDaily="+QString::number(cn->minHoursDaily)+"\n";
                                    }
                              }
                              assert(cn->maxHoursDaily>=0 || cn->minHoursDaily>=0);
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintStudentsSetNHoursDaily"){
                              ConstraintStudentsSetNHoursDaily* cn=new ConstraintStudentsSetNHoursDaily();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="MaxHoursDaily"){
                                          cn->maxHoursDaily=elem4.text().toInt();
                                          xmlReadingLog+="    Read maxHoursDaily="+QString::number(cn->maxHoursDaily)+"\n";
                                    }
                                    else if(elem4.tagName()=="MinHoursDaily"){
                                          cn->minHoursDaily=elem4.text().toInt();
                                          xmlReadingLog+="    Read minHoursDaily="+QString::number(cn->minHoursDaily)+"\n";
                                    }
                                    else if(elem4.tagName()=="Students"){
                                          cn->students=elem4.text();
                                          xmlReadingLog+="    Read students name="+cn->students+"\n";
                                    }
                              }
                              assert(cn->maxHoursDaily>=0 || cn->minHoursDaily>=0);
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintActivityPreferredTime"){
                              ConstraintActivityPreferredTime* cn=new ConstraintActivityPreferredTime();
                              cn->day = cn->hour = -1;
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Activity_Id"){
                                          cn->activityId=elem4.text().toInt();
                                          xmlReadingLog+="    Read activity id="+QString::number(cn->activityId)+"\n";
                                    }
                                    else if(elem4.tagName()=="Preferred_Day"){
                                          for(cn->day=0; cn->day<this->nDaysPerWeek; cn->day++)
                                                if(this->daysOfTheWeek[cn->day]==elem4.text())
                                                      break;
                                          assert(cn->day<this->nDaysPerWeek);
                                          xmlReadingLog+="    Preferred day="+this->daysOfTheWeek[cn->day]+"\n";
                                    }
                                    else if(elem4.tagName()=="Preferred_Hour"){
                                          for(cn->hour=0; cn->hour < this->nHoursPerDay; cn->hour++)
                                                if(this->hoursOfTheDay[cn->hour]==elem4.text())
                                                      break;
                                          assert(cn->hour>=0 && cn->hour < this->nHoursPerDay);
                                          xmlReadingLog+="    Preferred hour="+this->hoursOfTheDay[cn->hour]+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintActivityEndsDay"){
                              ConstraintActivityEndsDay* cn=new ConstraintActivityEndsDay();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Activity_Id"){
                                          cn->activityId=elem4.text().toInt();
                                          xmlReadingLog+="    Read activity id="+QString::number(cn->activityId)+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintActivityPreferredTimes"){
                              ConstraintActivityPreferredTimes* cn=new ConstraintActivityPreferredTimes();
                              cn->nPreferredTimes=0;
                              int i;
                              for(i=0; i<MAX_N_CONSTRAINT_ACTIVITY_PREFERRED_TIMES; i++){
                                    cn->days[i] = cn->hours[i] = -1;
                              }
                              i=0;
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Activity_Id"){
                                          cn->activityId=elem4.text().toInt();
                                          xmlReadingLog+="    Read activity id="+QString::number(cn->activityId)+"\n";
                                    }
                                    else if(elem4.tagName()=="Number_of_Preferred_Times"){
                                          cn->nPreferredTimes=elem4.text().toInt();
                                          xmlReadingLog+="    Read number of preferred times="+QString::number(cn->nPreferredTimes)+"\n";
                                    }
                                    else if(elem4.tagName()=="Preferred_Time"){
                                          xmlReadingLog+="    Read: preferred time\n";

                                          for(QDomNode node5=elem4.firstChild(); !node5.isNull(); node5=node5.nextSibling()){
                                                QDomElement elem5=node5.toElement();
                                                if(elem5.isNull()){
                                                      xmlReadingLog+="    Null node here\n";
                                                      continue;
                                                }
                                                xmlReadingLog+="    Found "+elem5.tagName()+" tag\n";
                                                if(elem5.tagName()=="Preferred_Day"){
                                                      for(cn->days[i]=0; cn->days[i]<this->nDaysPerWeek; cn->days[i]++)
                                                            if(this->daysOfTheWeek[cn->days[i]]==elem5.text())
                                                                  break;
                                                      assert(cn->days[i]<this->nDaysPerWeek);
                                                      xmlReadingLog+="    Preferred day="+this->daysOfTheWeek[cn->days[i]]+"("+QString::number(i)+")"+"\n";
                                                }
                                                else if(elem5.tagName()=="Preferred_Hour"){
                                                      for(cn->hours[i]=0; cn->hours[i] < this->nHoursPerDay; cn->hours[i]++)
                                                            if(this->hoursOfTheDay[cn->hours[i]]==elem5.text())
                                                                  break;
                                                      assert(cn->hours[i]>=0 && cn->hours[i] < this->nHoursPerDay);
                                                      xmlReadingLog+="    Preferred hour="+this->hoursOfTheDay[cn->hours[i]]+"\n";
                                                }
                                          }

                                          i++;
                                    }
                              }
                              assert(i==cn->nPreferredTimes);
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintBreak"){
                              ConstraintBreak* cn=new ConstraintBreak();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Day"){
                                          for(cn->d=0; cn->d<this->nDaysPerWeek; cn->d++)
                                                if(this->daysOfTheWeek[cn->d]==elem4.text())
                                                      break;
                                          assert(cn->d<this->nDaysPerWeek);
                                          xmlReadingLog+="    Crt. day="+this->daysOfTheWeek[cn->d]+"\n";
                                    }
                                    else if(elem4.tagName()=="Start_Hour"){
                                          for(cn->h1=0; cn->h1 < this->nHoursPerDay; cn->h1++)
                                                if(this->hoursOfTheDay[cn->h1]==elem4.text())
                                                      break;
                                          assert(cn->h1>=0 && cn->h1 < this->nHoursPerDay);
                                          xmlReadingLog+="    Start hour="+this->hoursOfTheDay[cn->h1]+"\n";
                                    }
                                    else if(elem4.tagName()=="End_Hour"){
                                          for(cn->h2=0; cn->h2 < this->nHoursPerDay; cn->h2++)
                                                if(this->hoursOfTheDay[cn->h2]==elem4.text())
                                                      break;
                                          assert(cn->h2>0 && cn->h2 <= this->nHoursPerDay);
                                          xmlReadingLog+="    End hour="+this->hoursOfTheDay[cn->h2]+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintTeachersNoGaps"){
                              ConstraintTeachersNoGaps* cn=new ConstraintTeachersNoGaps();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintStudentsNoGaps"){
                              ConstraintStudentsNoGaps* cn=new ConstraintStudentsNoGaps();
                              bool compulsory_read=false;
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                          compulsory_read=true;
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintStudentsSetNoGaps"){
                              ConstraintStudentsSetNoGaps* cn=new ConstraintStudentsSetNoGaps();
                              bool compulsory_read=false;
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                          compulsory_read=true;
                                    }
                                    else if(elem4.tagName()=="Students"){
                                          cn->students=elem4.text();
                                          xmlReadingLog+="    Read students name="+cn->students+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintStudentsEarly"){
                              ConstraintStudentsEarly* cn=new ConstraintStudentsEarly();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintStudentsSetIntervalMaxDaysPerWeek"){
                              ConstraintStudentsSetIntervalMaxDaysPerWeek* cn=new ConstraintStudentsSetIntervalMaxDaysPerWeek();
                              assert(cn!=NULL);
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Start_Hour"){
                                          for(cn->h1=0; cn->h1 < this->nHoursPerDay; cn->h1++)
                                                if(this->hoursOfTheDay[cn->h1]==elem4.text())
                                                      break;
                                          assert(cn->h1>=0 && cn->h1 < this->nHoursPerDay);
                                          xmlReadingLog+="    Start hour="+this->hoursOfTheDay[cn->h1]+"\n";
                                    }
                                    else if(elem4.tagName()=="End_Hour"){
                                          for(cn->h2=0; cn->h2 < this->nHoursPerDay; cn->h2++)
                                                if(this->hoursOfTheDay[cn->h2]==elem4.text())
                                                      break;
                                          assert(cn->h2>0 && cn->h2 <= this->nHoursPerDay);
                                          xmlReadingLog+="    End hour="+this->hoursOfTheDay[cn->h2]+"\n";
                                    }
                                    else if(elem4.tagName()=="Students"){
                                          cn->students=elem4.text();
                                          xmlReadingLog+="    Read students name="+cn->students+"\n";
                                    }
                                    if(elem4.tagName()=="Max_Intervals"){
                                          cn->n=elem4.text().toInt();
                                          xmlReadingLog+="    Adding max intervals="+QString::number(cn->n)+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="Constraint2ActivitiesConsecutive"){
                              Constraint2ActivitiesConsecutive* cn=new Constraint2ActivitiesConsecutive();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="First_Activity_Id"){
                                          cn->firstActivityId=elem4.text().toInt();
                                          xmlReadingLog+="    Read first activity id="+QString::number(cn->firstActivityId)+"\n";
                                    }
                                    else if(elem4.tagName()=="Second_Activity_Id"){
                                          cn->secondActivityId=elem4.text().toInt();
                                          xmlReadingLog+="    Read second activity id="+QString::number(cn->secondActivityId)+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="Constraint2ActivitiesGrouped"){
                              Constraint2ActivitiesGrouped* cn=new Constraint2ActivitiesGrouped();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="First_Activity_Id"){
                                          cn->firstActivityId=elem4.text().toInt();
                                          xmlReadingLog+="    Read first activity id="+QString::number(cn->firstActivityId)+"\n";
                                    }
                                    else if(elem4.tagName()=="Second_Activity_Id"){
                                          cn->secondActivityId=elem4.text().toInt();
                                          xmlReadingLog+="    Read second activity id="+QString::number(cn->secondActivityId)+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintActivitiesPreferredTimes"){
                              ConstraintActivitiesPreferredTimes* cn=new ConstraintActivitiesPreferredTimes();
                              cn->nPreferredTimes=0;
                              int i;
                              for(i=0; i<MAX_N_CONSTRAINT_ACTIVITIES_PREFERRED_TIMES; i++){
                                    cn->days[i] = cn->hours[i] = -1;
                              }
                              cn->teacherName="";
                              cn->studentsName="";
                              cn->subjectName="";
                              
                              i=0;
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Teacher_Name"){
                                          cn->teacherName=elem4.text();
                                          xmlReadingLog+="    Read teacher name="+cn->teacherName+"\n";
                                    }
                                    else if(elem4.tagName()=="Students_Name"){
                                          cn->studentsName=elem4.text();
                                          xmlReadingLog+="    Read students name="+cn->studentsName+"\n";
                                    }
                                    else if(elem4.tagName()=="Subject_Name"){
                                          cn->subjectName=elem4.text();
                                          xmlReadingLog+="    Read subject name="+cn->subjectName+"\n";
                                    }
                                    else if(elem4.tagName()=="Number_of_Preferred_Times"){
                                          cn->nPreferredTimes=elem4.text().toInt();
                                          xmlReadingLog+="    Read number of preferred times="+QString::number(cn->nPreferredTimes)+"\n";
                                    }
                                    else if(elem4.tagName()=="Preferred_Time"){
                                          xmlReadingLog+="    Read: preferred time\n";

                                          for(QDomNode node5=elem4.firstChild(); !node5.isNull(); node5=node5.nextSibling()){
                                                QDomElement elem5=node5.toElement();
                                                if(elem5.isNull()){
                                                      xmlReadingLog+="    Null node here\n";
                                                      continue;
                                                }
                                                xmlReadingLog+="    Found "+elem5.tagName()+" tag\n";
                                                if(elem5.tagName()=="Preferred_Day"){
                                                      for(cn->days[i]=0; cn->days[i]<this->nDaysPerWeek; cn->days[i]++)
                                                            if(this->daysOfTheWeek[cn->days[i]]==elem5.text())
                                                                  break;
                                                      assert(cn->days[i]<this->nDaysPerWeek);
                                                      xmlReadingLog+="    Preferred day="+this->daysOfTheWeek[cn->days[i]]+"("+QString::number(i)+")"+"\n";
                                                }
                                                else if(elem5.tagName()=="Preferred_Hour"){
                                                      for(cn->hours[i]=0; cn->hours[i] < this->nHoursPerDay; cn->hours[i]++)
                                                            if(this->hoursOfTheDay[cn->hours[i]]==elem5.text())
                                                                  break;
                                                      assert(cn->hours[i]>=0 && cn->hours[i] < this->nHoursPerDay);
                                                      xmlReadingLog+="    Preferred hour="+this->hoursOfTheDay[cn->hours[i]]+"\n";
                                                }
                                          }

                                          i++;
                                    }
                              }
                              assert(i==cn->nPreferredTimes);
                              crt_constraint=cn;
                        }


                        assert(crt_constraint!=NULL);
                        bool tmp=this->addTimeConstraint(crt_constraint);
                        assert(tmp);
                        nc++;
                  }
                  xmlReadingLog+="  Added "+QString::number(nc)+" time constraints\n";
            }
            else if(elem2.tagName()=="Space_Constraints_List"){
                  int nc=0;
                  SpaceConstraint *crt_constraint;
                  for(QDomNode node3=elem2.firstChild(); !node3.isNull(); node3=node3.nextSibling()){
                        crt_constraint=NULL;
                        QDomElement elem3=node3.toElement();
                        if(elem3.isNull()){
                              xmlReadingLog+="   Null node here\n";
                              continue;
                        }
                        xmlReadingLog+="   Found "+elem3.tagName()+" tag\n";
                        if(elem3.tagName()=="ConstraintBasicCompulsorySpace"){
                              ConstraintBasicCompulsorySpace* cn=new ConstraintBasicCompulsorySpace();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintRoomNotAvailable"){
                              ConstraintRoomNotAvailable* cn=new ConstraintRoomNotAvailable();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Room_Name"){
                                          cn->roomName=elem4.text();
                                          xmlReadingLog+="    Read room name="+cn->roomName+"\n";
                                    }
                                    else if(elem4.tagName()=="Day"){
                                          for(cn->d=0; cn->d<this->nDaysPerWeek; cn->d++)
                                                if(this->daysOfTheWeek[cn->d]==elem4.text())
                                                      break;
                                          assert(cn->d<this->nDaysPerWeek);
                                          xmlReadingLog+="    Crt. day="+this->daysOfTheWeek[cn->d]+"\n";
                                    }
                                    else if(elem4.tagName()=="Start_Hour"){
                                          for(cn->h1=0; cn->h1 < this->nHoursPerDay; cn->h1++)
                                                if(this->hoursOfTheDay[cn->h1]==elem4.text())
                                                      break;
                                          assert(cn->h1>=0 && cn->h1 < this->nHoursPerDay);
                                          xmlReadingLog+="    Start hour="+this->hoursOfTheDay[cn->h1]+"\n";
                                    }
                                    else if(elem4.tagName()=="End_Hour"){
                                          for(cn->h2=0; cn->h2 < this->nHoursPerDay; cn->h2++)
                                                if(this->hoursOfTheDay[cn->h2]==elem4.text())
                                                      break;
                                          assert(cn->h2>0 && cn->h2 <= this->nHoursPerDay);
                                          xmlReadingLog+="    End hour="+this->hoursOfTheDay[cn->h2]+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintRoomTypeNotAllowedSubjects"){
                              ConstraintRoomTypeNotAllowedSubjects* cn=new ConstraintRoomTypeNotAllowedSubjects();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Room_Type"){
                                          cn->roomType=elem4.text();
                                          xmlReadingLog+="    Read room type="+cn->roomType+"\n";
                                    }
                                    else if(elem4.tagName()=="Subject"){
                                          cn->addNotAllowedSubject(elem4.text());
                                          xmlReadingLog+="    Read not allowed subject="+elem4.text()+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintSubjectRequiresEquipments"){
                              ConstraintSubjectRequiresEquipments* cn=new ConstraintSubjectRequiresEquipments();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Subject"){
                                          cn->subjectName=elem4.text();
                                          xmlReadingLog+="    Read subject="+cn->subjectName+"\n";
                                    }
                                    else if(elem4.tagName()=="Equipment"){
                                          cn->addRequiredEquipment(elem4.text());
                                          xmlReadingLog+="    Read required equipment="+elem4.text()+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintSubjectSubjectTagRequireEquipments"){
                              ConstraintSubjectSubjectTagRequireEquipments* cn=new ConstraintSubjectSubjectTagRequireEquipments();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Subject"){
                                          cn->subjectName=elem4.text();
                                          xmlReadingLog+="    Read subject="+cn->subjectName+"\n";
                                    }
                                    else if(elem4.tagName()=="Subject_Tag"){
                                          cn->subjectTagName=elem4.text();
                                          xmlReadingLog+="    Read subject tag="+cn->subjectTagName+"\n";
                                    }
                                    else if(elem4.tagName()=="Equipment"){
                                          cn->addRequiredEquipment(elem4.text());
                                          xmlReadingLog+="    Read required equipment="+elem4.text()+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintTeacherRequiresRoom"){
                              ConstraintTeacherRequiresRoom* cn=new ConstraintTeacherRequiresRoom();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Teacher"){
                                          cn->teacherName=elem4.text();
                                          xmlReadingLog+="    Read teacher="+cn->teacherName+"\n";
                                    }
                                    else if(elem4.tagName()=="Room"){
                                          cn->roomName=elem4.text();
                                          xmlReadingLog+="    Read room="+elem4.text()+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintMinimizeNumberOfRoomsForStudents"){
                              ConstraintMinimizeNumberOfRoomsForStudents* cn=new ConstraintMinimizeNumberOfRoomsForStudents();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintActivityPreferredRoom"){
                              ConstraintActivityPreferredRoom* cn=new ConstraintActivityPreferredRoom();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Activity_Id"){
                                          cn->activityId=elem4.text().toInt();
                                          xmlReadingLog+="    Read activity id="+QString::number(cn->activityId)+"\n";
                                    }
                                    else if(elem4.tagName()=="Room"){
                                          cn->roomName=elem4.text();
                                          xmlReadingLog+="    Read room="+elem4.text()+"\n";
                                    }
                              }
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintActivityPreferredRooms"){
                              ConstraintActivityPreferredRooms* cn=new ConstraintActivityPreferredRooms();
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Activity_Id"){
                                          cn->activityId=elem4.text().toInt();
                                          xmlReadingLog+="    Read activity id="+QString::number(cn->activityId)+"\n";
                                    }
                                    else if(elem4.tagName()=="Number_of_Preferred_Rooms"){
                                          cn->_n_preferred_rooms=elem4.text().toInt();
                                          xmlReadingLog+="    Read year number of preferred rooms: "+QString::number(cn->_n_preferred_rooms)+"\n";
                                          assert(cn->_n_preferred_rooms>=2);
                                    }
                                    else if(elem4.tagName()=="Preferred_Room"){
                                          cn->roomsNames.append(elem4.text());
                                          xmlReadingLog+="    Read room="+elem4.text()+"\n";
                                    }
                              }
                              assert((uint)cn->_n_preferred_rooms==cn->roomsNames.count());
                              crt_constraint=cn;
                        }
                        if(elem3.tagName()=="ConstraintActivitiesSameRoom"){
                              ConstraintActivitiesSameRoom* cn=new ConstraintActivitiesSameRoom();
                              int n_act=0;
                              for(QDomNode node4=elem3.firstChild(); !node4.isNull(); node4=node4.nextSibling()){
                                    QDomElement elem4=node4.toElement();
                                    if(elem4.isNull()){
                                          xmlReadingLog+="    Null node here\n";
                                          continue;
                                    }
                                    xmlReadingLog+="    Found "+elem4.tagName()+" tag\n";
                                    if(elem4.tagName()=="Weight"){
                                          cn->weight=elem4.text().toDouble();
                                          xmlReadingLog+="    Adding weight="+QString::number(cn->weight)+"\n";
                                    }
                                    else if(elem4.tagName()=="Compulsory"){
                                          if(elem4.text()=="yes"){
                                                cn->compulsory=true;
                                                xmlReadingLog+="    Current constraint is compulsory\n";
                                          }
                                          else{
                                                cn->compulsory=false;
                                                xmlReadingLog+="    Current constraint is not compulsory\n";
                                          }
                                    }
                                    else if(elem4.tagName()=="Number_of_Activities"){
                                          cn->n_activities=elem4.text().toInt();
                                          xmlReadingLog+="    Read n_activities="+QString::number(cn->n_activities)+"\n";
                                    }
                                    else if(elem4.tagName()=="Activity_Id"){
                                          cn->activitiesId[n_act]=elem4.text().toInt();
                                          xmlReadingLog+="    Read activity id="+QString::number(cn->activitiesId[n_act])+"\n";
                                          n_act++;
                                    }
                              }
                              assert(cn->n_activities==n_act);
                              crt_constraint=cn;
                        }

                        assert(crt_constraint!=NULL);
                        bool tmp=this->addSpaceConstraint(crt_constraint);
                        assert(tmp);
                        nc++;
                  }
                  xmlReadingLog+="  Added "+QString::number(nc)+" space constraints\n";
            }
      }

      this->internalStructureComputed=false;

      logStream<<xmlReadingLog;
      file2.close();

      ////////////////////////////////////////

      return true;
}


Generated by  Doxygen 1.6.0   Back to index