⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timetableallocateroomsform.cpp

📁 基于遗传算法的排课软件源码 根据需要安排合理的课程时间等
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	assert(rooms_schedule_ready);	//Writing the timetable in xml format	QFile file(xmlfilename);	if(!file.open(IO_WriteOnly))		assert(0);	QTextStream tos(&file);	tos << "<" << protect(ROOMS_TIMETABLE_TAG) << ">\n";	for(int i=0; i<gt.rules.nInternalRooms; i++){		tos<<"\n";		tos << "  <Room name=\"" << protect(gt.rules.internalRoomsList[i]->name) << "\">\n";		for(int k=0; k<gt.rules.nDaysPerWeek; k++){			tos << "   <Day name=\"" << protect(gt.rules.daysOfTheWeek[k]) << "\">\n";			for(int j=0; j<gt.rules.nHoursPerDay; j++){				tos << "    <Hour name=\"" << protect(gt.rules.hoursOfTheDay[j]) << "\">\n";				tos<<"     <Week1>";				int ai=rooms_timetable_week1[i][k][j]; //activity index				//Activity* act=gt.rules.activitiesList.at(ai);				if(ai!=UNALLOCATED_ACTIVITY){					Activity* act=&gt.rules.internalActivitiesList[ai];					for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++)						tos << "<Students name=\"" << protect(*it) << "\"></Students>";				}				tos<<"</Week1>\n";				tos<<"     <Week2>";				ai=rooms_timetable_week2[i][k][j]; //activity index				//act=gt.rules.activitiesList.at(ai);				if(ai!=UNALLOCATED_ACTIVITY){					Activity* act=&gt.rules.internalActivitiesList[ai];					for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++)						tos << "<Students name=\"" << protect(*it) << "\"></Students>";				}				tos<<"</Week2>\n";				tos << "    </Hour>\n";			}			tos << "   </Day>\n";		}		tos<<"  </Room>\n";	}	tos<<"\n";	tos << "</" << protect(ROOMS_TIMETABLE_TAG) << ">\n";	file.close();}/**Function writing the students' timetable (with rooms) in html format to a file.Days horizontal.*/void TimetableAllocateRoomsForm::writeStudentsTimetableWithRoomsDaysHorizontalHtml(const QString& htmlfilename){	assert(gt.rules.initialized && gt.rules.internalStructureComputed);	assert(gt.timePopulation.initialized);	assert(students_schedule_ready && teachers_schedule_ready && rooms_schedule_ready);	SpaceChromosome& c=gt.spacePopulation.bestChromosome(gt.rules);	//Now we print the results to an HTML file	QFile file(htmlfilename);	if(!file.open(IO_WriteOnly))		assert(0);	QTextStream tos(&file);	tos<<"<html>\n";	tos<<"<title>"<<protect2(gt.rules.institutionName)<<"</title>\n";	tos<<"<body>\n";		tos<<"<center><h3>"<<protect2(gt.rules.institutionName)<<"</h3></center><br>\n";	for(int subgroup=0; subgroup<gt.rules.nInternalSubgroups; subgroup++){		QString subgroup_name = gt.rules.internalSubgroupsList[subgroup]->name;		tos<<"<p align=\"center\">"<<protect2(subgroup_name)<<"</p>\n";				tos<<"<table border=\"1\" cellpadding=\"6\">"<<endl;		tos<<"<tr>\n<td></td>\n";		for(int j=0; j<gt.rules.nDaysPerWeek; j++)			tos<<"<td>"<<protect2(gt.rules.daysOfTheWeek[j])<<"</td>\n";				tos<<"</tr>\n";		for(int j=0; j<gt.rules.nHoursPerDay; j++){			tos<<"<tr>\n";			tos<<"<td>"<<protect2(gt.rules.hoursOfTheDay[j])<<"</td>\n";						for(int k=0; k<gt.rules.nDaysPerWeek; k++){				tos<<"<td style=\"width:14em;\">\n";								int ai=students_timetable_week1[subgroup][k][j]; //activity index				if(ai!=UNALLOCATED_ACTIVITY){					//Activity* act=gt.rules.activitiesList.at(ai);					Activity* act=&gt.rules.internalActivitiesList[ai];					for(QStringList::Iterator it=act->teachersNames.begin(); it!=act->teachersNames.end(); it++)						tos<<protect2(*it)<<"<br/>";					tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>";										int ri=c.rooms[ai]; //room index					QString roomName;					if(ri==UNALLOCATED_SPACE)						roomName="UNALLOCATED_SPACE";					else						roomName=protect2(gt.rules.roomsList.at(ri)->name);					tos<<roomName<<"<br/>";				}				else					tos<<"&nbsp;";				ai=students_timetable_week2[subgroup][k][j]; //activity index				if(ai!=UNALLOCATED_ACTIVITY){					tos<<"/<br/>";					//Activity* act=gt.rules.activitiesList.at(ai);					Activity* act=&gt.rules.internalActivitiesList[ai];					for(QStringList::Iterator it=act->teachersNames.begin(); it!=act->teachersNames.end(); it++)						tos<<protect2(*it)<<"<br/>";					tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>";					int ri=c.rooms[ai]; //room index					QString roomName;					if(ri==UNALLOCATED_SPACE)						roomName="UNALLOCATED_SPACE";					else						roomName=protect2(gt.rules.roomsList.at(ri)->name);					tos<<roomName<<"<br/>";				}				tos<<"</td>\n";			}						tos<<"</tr>\n";		}				tos<<"</table>\n";	}	tos<<"<p/>"<<endl;	time_t ltime;	tzset();	time(&ltime);	tos<<QObject::tr("Timetable generated with FET %1 on %2").arg(FET_VERSION).arg(ctime(&ltime));						tos<<"</body>\n</html>\n";	file.close();}/**Function writing the students' timetable (with rooms) in html format to a file.Days vertical.*/void TimetableAllocateRoomsForm::writeStudentsTimetableWithRoomsDaysVerticalHtml(const QString& htmlfilename){	assert(gt.rules.initialized && gt.rules.internalStructureComputed);	assert(gt.timePopulation.initialized);	assert(students_schedule_ready && teachers_schedule_ready && rooms_schedule_ready);	SpaceChromosome& c=gt.spacePopulation.bestChromosome(gt.rules);	//Now we print the results to an HTML file	QFile file(htmlfilename);	if(!file.open(IO_WriteOnly))		assert(0);	QTextStream tos(&file);	tos<<"<html>\n";	tos<<"<title>"<<protect2(gt.rules.institutionName)<<"</title>\n";	tos<<"<body>\n";		tos<<"<center><h3>"<<protect2(gt.rules.institutionName)<<"</h3></center><br>\n";	for(int subgroup=0; subgroup<gt.rules.nInternalSubgroups; subgroup++){		QString subgroup_name = gt.rules.internalSubgroupsList[subgroup]->name;		tos<<"<p align=\"center\">"<<protect2(subgroup_name)<<"</p>\n";				tos<<"<table border=\"1\" cellpadding=\"6\">"<<endl;		tos<<"<tr>\n<td></td>\n";		for(int j=0; j<gt.rules.nHoursPerDay; j++)			tos<<"<td>"<<protect2(gt.rules.hoursOfTheDay[j])<<"</td>\n";				tos<<"</tr>\n";		for(int k=0; k<gt.rules.nDaysPerWeek; k++){			tos<<"<tr>\n";			tos<<"<td>"<<protect2(gt.rules.daysOfTheWeek[k])<<"</td>\n";						for(int j=0; j<gt.rules.nHoursPerDay; j++){				tos<<"<td style=\"width:14em;\">\n";								int ai=students_timetable_week1[subgroup][k][j]; //activity index				if(ai!=UNALLOCATED_ACTIVITY){					//Activity* act=gt.rules.activitiesList.at(ai);					Activity* act=&gt.rules.internalActivitiesList[ai];					for(QStringList::Iterator it=act->teachersNames.begin(); it!=act->teachersNames.end(); it++)						tos<<protect2(*it)<<"<br/>";					tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>";										int ri=c.rooms[ai]; //room index					QString roomName;					if(ri==UNALLOCATED_SPACE)						roomName="UNALLOCATED_SPACE";					else						roomName=protect2(gt.rules.roomsList.at(ri)->name);					tos<<roomName<<"<br/>";				}				else					tos<<"&nbsp;";				ai=students_timetable_week2[subgroup][k][j]; //activity index				if(ai!=UNALLOCATED_ACTIVITY){					tos<<"/<br/>";					//Activity* act=gt.rules.activitiesList.at(ai);					Activity* act=&gt.rules.internalActivitiesList[ai];					for(QStringList::Iterator it=act->teachersNames.begin(); it!=act->teachersNames.end(); it++)						tos<<protect2(*it)<<"<br/>";					tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>";					int ri=c.rooms[ai]; //room index					QString roomName;					if(ri==UNALLOCATED_SPACE)						roomName="UNALLOCATED_SPACE";					else						roomName=protect2(gt.rules.roomsList.at(ri)->name);					tos<<roomName<<"<br/>";				}				tos<<"</td>\n";			}						tos<<"</tr>\n";		}				tos<<"</table>\n";	}	tos<<"<p/>"<<endl;	time_t ltime;	tzset();	time(&ltime);	tos<<QObject::tr("Timetable generated with FET %1 on %2").arg(FET_VERSION).arg(ctime(&ltime));						tos<<"</body>\n</html>\n";	file.close();}/**Function writing the teachers' timetable (with rooms) html format to a file (var. 1).Days horizontal.*/void TimetableAllocateRoomsForm::writeTeachersTimetableWithRooms1DaysHorizontalHtml(const QString& htmlfilename){	assert(gt.rules.initialized && gt.rules.internalStructureComputed);	assert(gt.timePopulation.initialized);	assert(students_schedule_ready && teachers_schedule_ready && rooms_schedule_ready);	SpaceChromosome& c=gt.spacePopulation.bestChromosome(gt.rules);	//Writing the timetable in xml format	QFile file(htmlfilename);	if(!file.open(IO_WriteOnly))		assert(0);	QTextStream tos(&file);	tos<<"<html>\n<title>"<<protect2(gt.rules.institutionName)<<"</title>\n";	tos<<"<body>\n";	tos<<"<center><h3>"<<protect2(gt.rules.institutionName)<<"</h3></center><br>\n";	for(int i=0; i<gt.rules.nInternalTeachers; i++){		tos<<"<p align=\"center\">"<<protect2(gt.rules.internalTeachersList[i]->name)<<"</p>\n";		tos<<"<table width=\"100%\" border=\"1\" cellpadding=\"6\">\n";		tos<<"<tr>\n<td></td>\n";		for(int j=0; j<gt.rules.nDaysPerWeek; j++)			tos << "<td>" << protect2(gt.rules.daysOfTheWeek[j]) << "</td>\n";		tos<<"</tr>\n";				for(int j=0; j<gt.rules.nHoursPerDay; j++){			tos<<"<tr>\n";						tos<<"<td>"<<gt.rules.hoursOfTheDay[j]<<"</td>\n";			for(int k=0; k<gt.rules.nDaysPerWeek; k++){				tos<<"<td style=\"width:14em;\">";				int ai=teachers_timetable_week1[i][k][j]; //activity index				if(ai!=UNALLOCATED_ACTIVITY){					Activity* act=&gt.rules.internalActivitiesList[ai];					for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++)						tos << protect2(*it) << "<br/>";											tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>";										int ri=c.rooms[ai]; //room index					QString roomName;					if(ri==UNALLOCATED_SPACE)						roomName="UNALLOCATED_SPACE";					else						roomName=protect2(gt.rules.roomsList.at(ri)->name);					tos<<roomName<<"<br/>";				}				else					tos<<"&nbsp;";				ai=teachers_timetable_week2[i][k][j]; //activity index				if(ai!=UNALLOCATED_ACTIVITY){					Activity* act=&gt.rules.internalActivitiesList[ai];					tos<<"/<br/>\n";					for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++)						tos << protect2(*it) << "<br/>";										tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>";					int ri=c.rooms[ai]; //room index					QString roomName;					if(ri==UNALLOCATED_SPACE)						roomName="UNALLOCATED_SPACE";					else						roomName=protect2(gt.rules.roomsList.at(ri)->name);					tos<<roomName<<"<br/>";				}				tos<<"</td>\n";			}			tos << "</tr>\n";		}		tos<<"</table>\n";	}	tos<<"<p/>"<<endl;	time_t ltime;	tzset();	time(&ltime);	tos<<QObject::tr("Timetable generated with FET %1 on %2").arg(FET_VERSION).arg(ctime(&ltime));	tos<<"</body>\n</html>\n";	file.close();}/**Function writing the teachers' timetable (with rooms) html format to a file (var. 1).Days vertical.*/void TimetableAllocateRoomsForm::writeTeachersTimetableWithRooms1DaysVerticalHtml(const QString& htmlfilename){	assert(gt.rules.initialized && gt.rules.internalStructureComputed);	assert(gt.timePopulation.initialized);	assert(students_schedule_ready && teachers_schedule_ready && rooms_schedule_ready);	SpaceChromosome& c=gt.spacePopulation.bestChromosome(gt.rules);	//Writing the timetable in xml format	QFile file(htmlfilename);	if(!file.open(IO_WriteOnly))		assert(0);	QTextStream tos(&file);	tos<<"<html>\n<title>"<<protect2(gt.rules.institutionName)<<"</title>\n";	tos<<"<body>\n";	tos<<"<center><h3>"<<protect2(gt.rules.institutionName)<<"</h3></center><br>\n";	for(int i=0; i<gt.rules.nInternalTeachers; i++){		tos<<"<p align=\"center\">"<<protect2(gt.rules.internalTeachersList[i]->name)<<"</p>\n";		tos<<"<table width=\"100%\" border=\"1\" cellpadding=\"6\">\n";		tos<<"<tr>\n<td></td>\n";		for(int j=0; j<gt.rules.nHoursPerDay; j++)			tos << "<td>" << protect2(gt.rules.hoursOfTheDay[j]) << "</td>\n";		tos<<"</tr>\n";				for(int k=0; k<gt.rules.nDaysPerWeek; k++){			tos<<"<tr>\n";						tos<<"<td>"<<gt.rules.daysOfTheWeek[k]<<"</td>\n";			for(int j=0; j<gt.rules.nHoursPerDay; j++){				tos<<"<td style=\"width:14em;\">";				int ai=teachers_timetable_week1[i][k][j]; //activity index				//Activity* act=gt.rules.activitiesList.at(ai);				if(ai!=UNALLOCATED_ACTIVITY){					Activity* act=&gt.rules.internalActivitiesList[ai];					for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++)						tos << protect2(*it) << "<br/>";											tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>";										int ri=c.rooms[ai]; //room index					QString roomName;					if(ri==UNALLOCATED_SPACE)						roomName="UNALLOCATED_SPACE";					else						roomName=protect2(gt.rules.roomsList.at(ri)->name);					tos<<roomName<<"<br/>";				}				else					tos<<"&nbsp;";				ai=teachers_timetable_week2[i][k][j]; //activity index				//act=gt.rules.activitiesList.at(ai);				if(ai!=UNALLOCATED_ACTIVITY){					Activity* act=&gt.rules.internalActivitiesList[ai];					tos<<"/<br/>\n";					for(QStringList::Iterator it=act->studentsNames.begin(); it!=act->studentsNames.end(); it++)						tos << protect2(*it) << "<br/>";										tos<<protect2(act->subjectName)<<" "<<protect2(act->subjectTagName)<<"<br/>";					int ri=c.rooms[ai]; //room index					QString roomName;					if(ri==UNALLOCATED_SPACE)						roomName="UNALLOCATED_SPACE";					else						roomName=protect2(gt.rules.roomsList.at(ri)->name);					tos<<roomName<<"<br/>";				}				tos<<"</td>\n";			}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -