/*
File rules.cpp
*/
/*
Copyright 2002, 2003 Lalescu Liviu.
This file is part of FET.
FET is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
FET is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FET; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "genetictimetable_defs.h"
#include "rules.h"
#include <string.h>
#include <iostream>
using namespace std;
#include <qdom.h>
#include <qstring.h>
#include <qtranslator.h>
#include <qmessagebox.h>
void Rules::init() //initializes the rules (empty, but with default hours and days)
{
this->subjectsList.setAutoDelete(true);
this->subjectTagsList.setAutoDelete(true);
this->yearsList.setAutoDelete(true);
this->teachersList.setAutoDelete(true);
this->activitiesList.setAutoDelete(true);
this->timeConstraintsList.setAutoDelete(true);
this->spaceConstraintsList.setAutoDelete(true);
this->equipmentsList.setAutoDelete(true);
this->buildingsList.setAutoDelete(true);
this->roomsList.setAutoDelete(true);
//defaults
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");
this->initialized=true;
}
bool Rules::computeInternalStructure()
{
//The order is important - firstly the teachers, subjects and students.
//After that, the equipments.
//After that, the rooms.
//After that, the activities.
//After that, the time constraints.
//After that, initialization of the matrix "roomHasEquipment".
//After that, the space constraints.
int i;
if(this->teachersList.count()>(uint)(MAX_TEACHERS)){
QMessageBox::warning(NULL, QObject::tr("FET information"),
QObject::tr("You have too many teachers.\nPlease talk to the author or increase variable MAX_TEACHERS"));
return false;
}
if(this->subjectsList.count()>(uint)(MAX_SUBJECTS)){
QMessageBox::warning(NULL, QObject::tr("FET information"),
QObject::tr("You have too many subjects.\nPlease talk to the author or increase variable MAX_SUBJECTS"));
return false;
}
int tmpNSubgroups=0;
if(this->yearsList.count()>(uint)(MAX_YEARS)){
QMessageBox::warning(NULL, QObject::tr("FET information"),
QObject::tr("You have too many years.\nPlease talk to the author or increase variable MAX_YEARS"));
return false;
}
for(StudentsYear* sty=this->yearsList.first(); sty; sty=this->yearsList.next()){
if(sty->groupsList.count()>(uint)(MAX_GROUPS_PER_YEAR)){
QMessageBox::warning(NULL, QObject::tr("FET information"),
QObject::tr("You have too many groups per year.\nPlease talk to the author or increase variable MAX_GROUPS_PER_YEAR"));
return false;
}
for(StudentsGroup* stg=sty->groupsList.first(); stg; stg=sty->groupsList.next()){
if(stg->subgroupsList.count()>(uint)(MAX_SUBGROUPS_PER_GROUP)){
QMessageBox::warning(NULL, QObject::tr("FET information"),
QObject::tr("You have too many subgroups per group.\nPlease talk to the author or increase variable MAX_SUBGROUPS_PER_GROUP"));
return false;
}
tmpNSubgroups+=stg->subgroupsList.count();
assert(this->nInternalSubgroups<MAX_TOTAL_SUBGROUPS);
}
}
if(tmpNSubgroups>MAX_TOTAL_SUBGROUPS){
QMessageBox::warning(NULL, QObject::tr("FET information"),
QObject::tr("You have too many total subgroups.\nPlease talk to the author or increase variable MAX_TOTAL_SUBGROUPS"));
return false;
}
int counter=0;
for(Activity* act=this->activitiesList.first(); act; act=this->activitiesList.next())
if(act->active)
counter++;
if(counter>MAX_ACTIVITIES){
QMessageBox::warning(NULL, QObject::tr("FET information"),
QObject::tr("You have too many active activities.\nPlease talk to the author or increase variable MAX_ACTIVITIES"));
return false;
}
if(this->equipmentsList.count()>(uint)(MAX_EQUIPMENTS)){
QMessageBox::warning(NULL, QObject::tr("FET information"),
QObject::tr("You have too many equipments.\nPlease talk to the author or increase variable MAX_EQUIPMENTS"));
return false;
}
if(this->roomsList.count()>(uint)(MAX_ROOMS)){
QMessageBox::warning(NULL, QObject::tr("FET information"),
QObject::tr("You have too many rooms.\nPlease talk to the author or increase variable MAX_ROOMS"));
return false;
}
if(this->buildingsList.count()>(uint)(MAX_BUILDINGS)){
QMessageBox::warning(NULL, QObject::tr("FET information"),
QObject::tr("You have too many buildings.\nPlease talk to the author or increase variable MAX_BUILDINGS"));
return false;
}
assert(this->initialized);
//days and hours
assert(this->nHoursPerDay>0);
assert(this->nDaysPerWeek>0);
this->nHoursPerWeek=this->nHoursPerDay*this->nDaysPerWeek;
//teachers
Teacher* tch;
this->nInternalTeachers=this->teachersList.count();
assert(this->nInternalTeachers<=MAX_TEACHERS);
for(tch=this->teachersList.first(), i=0; tch; tch=this->teachersList.next(), i++)
this->internalTeachersList[i]=tch;
assert(i==this->nInternalTeachers);
//subjects
Subject* sbj;
this->nInternalSubjects=this->subjectsList.count();
assert(this->nInternalSubjects<=MAX_SUBJECTS);
for(sbj=this->subjectsList.first(), i=0; sbj; sbj=this->subjectsList.next(), i++)
this->internalSubjectsList[i]=sbj;
assert(i==this->nInternalSubjects);
//students
this->nInternalSubgroups=0;
assert(this->yearsList.count()<=(uint)(MAX_YEARS));
for(StudentsYear* sty=this->yearsList.first(); sty; sty=this->yearsList.next()){
//if this year has no groups, insert something to simulate the whole year
if(sty->groupsList.count()==0){
StudentsGroup* tmpGroup = new StudentsGroup();
tmpGroup->name = sty->name+" WHOLE YEAR";
tmpGroup->numberOfStudents = sty->numberOfStudents;
sty->groupsList.append(tmpGroup);
}
assert(sty->groupsList.count()<=(uint)(MAX_GROUPS_PER_YEAR));
for(StudentsGroup* stg=sty->groupsList.first(); stg; stg=sty->groupsList.next()){
//if this group has no subgroups, insert something to simulate the whole group
if(stg->subgroupsList.count()==0){
StudentsSubgroup* tmpSubgroup = new StudentsSubgroup();
tmpSubgroup->name = stg->name+" WHOLE GROUP";
tmpSubgroup->numberOfStudents=stg->numberOfStudents;
stg->subgroupsList.append(tmpSubgroup);
}
assert(stg->subgroupsList.count()<=(uint)(MAX_SUBGROUPS_PER_GROUP));
for(StudentsSubgroup* sts=stg->subgroupsList.first(); sts; sts=stg->subgroupsList.next()){
bool existing=false;
for(int i=0; i<this->nInternalSubgroups; i++)
if(this->internalSubgroupsList[i]->name==sts->name){
existing=true;
break;
}
if(!existing){
assert(this->nInternalSubgroups<MAX_TOTAL_SUBGROUPS);
this->internalSubgroupsList[this->nInternalSubgroups++]=sts;
}
}
}
}
//equipments internal list
this->nInternalEquipments=0;
assert(this->equipmentsList.count()<=(uint)(MAX_EQUIPMENTS));
for(Equipment* eq=this->equipmentsList.first(); eq; eq=this->equipmentsList.next())
this->internalEquipmentsList
没有合适的资源?快使用搜索试试~ 我知道了~
paike.rar_paike
共1406个文件
cpp:444个
h:444个
ui:402个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 165 浏览量
2022-09-14
19:31:52
上传
评论
收藏 2.67MB RAR 举报
温馨提示
对学生课表进行排序,结合C++和数据结构思想。
资源推荐
资源详情
资源评论
收起资源包目录
paike.rar_paike (1406个子文件)
fet.1 1KB
fet.1 1KB
AUTHORS 405B
AUTHORS 405B
ChangeLog 29KB
ChangeLog 29KB
COPYING 18KB
COPYING 18KB
rules.cpp 193KB
rules.cpp 193KB
timeconstraint.cpp 168KB
timeconstraint.cpp 168KB
spaceconstraint.cpp 121KB
spaceconstraint.cpp 121KB
timetableallocatehoursroomsform.cpp 51KB
timetableallocatehoursroomsform.cpp 51KB
fetmainform.cpp 46KB
fetmainform.cpp 46KB
timetableallocateroomsform.cpp 39KB
timetableallocateroomsform.cpp 39KB
timetableallocatehoursform.cpp 36KB
timetableallocatehoursform.cpp 36KB
timespacechromosome.cpp 18KB
timespacechromosome.cpp 18KB
addactivityform.cpp 15KB
addactivityform.cpp 15KB
timechromosome.cpp 13KB
timechromosome.cpp 13KB
timetableviewstudentswithrooms2form.cpp 13KB
timetableviewstudentswithrooms2form.cpp 13KB
timetableviewstudentswithroomsform.cpp 12KB
timetableviewstudentswithroomsform.cpp 12KB
fet.cpp 12KB
fet.cpp 12KB
modifyactivityform.cpp 11KB
modifyactivityform.cpp 11KB
alltimeconstraintsform.cpp 11KB
alltimeconstraintsform.cpp 11KB
activity.cpp 11KB
activity.cpp 11KB
timetableviewteacherswithroomsform.cpp 11KB
timetableviewteacherswithroomsform.cpp 11KB
timetableviewteacherswithrooms2form.cpp 11KB
timetableviewteacherswithrooms2form.cpp 11KB
addconstraintactivitiessamestartingtimeform.cpp 10KB
addconstraintactivitiessamestartingtimeform.cpp 10KB
timespacepopulation.cpp 10KB
timespacepopulation.cpp 10KB
timepopulation.cpp 10KB
timepopulation.cpp 10KB
spacepopulation.cpp 10KB
spacepopulation.cpp 10KB
allspaceconstraintsform.cpp 10KB
allspaceconstraintsform.cpp 10KB
timetableviewrooms2form.cpp 9KB
timetableviewrooms2form.cpp 9KB
timetableviewstudentsform.cpp 9KB
timetableviewstudentsform.cpp 9KB
timetableviewroomsform.cpp 9KB
timetableviewroomsform.cpp 9KB
spacechromosome.cpp 9KB
spacechromosome.cpp 9KB
subgroupsform.cpp 8KB
subgroupsform.cpp 8KB
timetableviewteachersform.cpp 8KB
timetableviewteachersform.cpp 8KB
modifyconstraintactivitiespreferredtimesform.cpp 8KB
modifyconstraintactivitiespreferredtimesform.cpp 8KB
Course_Arrangement.cpp 7KB
Course_Arrangement.cpp 7KB
studentsset.cpp 7KB
studentsset.cpp 7KB
activitiesform.cpp 6KB
activitiesform.cpp 6KB
addconstraintactivitiespreferredtimesform.cpp 6KB
addconstraintactivitiespreferredtimesform.cpp 6KB
modifyconstraintstudentssetnotavailableform.cpp 6KB
modifyconstraintstudentssetnotavailableform.cpp 6KB
modifyconstraintstudentssetintervalmaxdaysperweekform.cpp 6KB
modifyconstraintstudentssetintervalmaxdaysperweekform.cpp 6KB
groupsform.cpp 6KB
groupsform.cpp 6KB
addconstraintstudentssetnotavailableform.cpp 5KB
addconstraintstudentssetnotavailableform.cpp 5KB
modifyconstraintteachernotavailableform.cpp 5KB
modifyconstraintteachernotavailableform.cpp 5KB
addconstraintstudentssetintervalmaxdaysperweekform.cpp 5KB
addconstraintstudentssetintervalmaxdaysperweekform.cpp 5KB
subjecttagsform.cpp 5KB
subjecttagsform.cpp 5KB
modifyconstraintactivitypreferredtimeform.cpp 5KB
modifyconstraintactivitypreferredtimeform.cpp 5KB
addconstraintteachernotavailableform.cpp 5KB
addconstraintteachernotavailableform.cpp 5KB
constraintsubjectsubjecttagpreferredroomform.cpp 5KB
constraintsubjectsubjecttagpreferredroomform.cpp 5KB
modifyconstraintsubjectsubjecttagrequireequipmentsform.cpp 5KB
modifyconstraintsubjectsubjecttagrequireequipmentsform.cpp 5KB
modifyconstraintactivitypreferredtimesform.cpp 5KB
modifyconstraintactivitypreferredtimesform.cpp 5KB
共 1406 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15
资源评论
alvarocfc
- 粉丝: 111
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功