高校自动排课系统(共11页).docx
《高校自动排课系统(共11页).docx》由会员分享,可在线阅读,更多相关《高校自动排课系统(共11页).docx(11页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上/简化版高校自动排课系统/排课任务简化后包含:年级专业(教学班级,如计科13)、课程名称、任课教师、上课地点和时间/教学班级简化为不分人数,不分专业方向。/上课教室简化为不分理论课、实验课,不分教室容纳人数,不分是否多媒体。/上课时段简化为:一周五天,周一到周五,白天上课,上午四节,下午四节,/12(8:009:400)、34(10:0011:40)、56(14:0015:40)、78(16:0017:40)/为了便于处理,将五天的所有上课时段用数字019表示/上课地点和时间组合成一个整数数组(位集,bitset),每20个为1组为一个教室的上课时段安排/约束条件:1
2、、教学班级的上课时间不能冲突/2、每个教室不能同时安排多个教学班级上课/3、任课教师的上课时间不能冲突/#include #include #include #include #include #include #include #include using namespace std;/原始数据文件中的每一行数据的数据结构struct schedule string grade_special; /年级专业string course; /课程名称string teacher; /任课教师string total_hour; /总学时string teach_hour; /讲课学时string
3、 experiment_hour; /实验学时string practice_hour; /课程实践学时string credit; /学分string week_hour; /周学时string start_stop; /起止周string speciality_orientation; /专业方向string person_num; /人数;/排课任务的数据结构struct arrange arrange(string gs, string c, string t, int ct = -1) : grade_special(gs), course(c), teacher(t), class
4、room_time(ct) string grade_special;/年级专业string course;/课程名称string teacher;/任课教师/string classroom;/上课地点/string time;/上课时间int classroom_time;/上课地点、时间;/教师倒排表数据结构,通过教师姓名找到该教师的排课情况struct teacher_inverted teacher_inverted(string tea, int cl = -1, int ar = -1) : teacher(tea), class_loc(cl), arrange_loc(ar)
5、 string teacher;int class_loc;int arrange_loc;/教室倒排表数据结构,通过教室名称查找该教室的排课情况struct classroom_inverted classroom_inverted(string cr, int cl = -1, int ar = -1) : classroom(cr), class_loc(cl), arrange_loc(ar) string classroom;int class_loc;int arrange_loc;int main(int argc, char* argv) if (argc != 3) cout
6、 程序调用格式错误!n调用格式:csp 排课计划文件 可用教室文件n;return 0;ifstream infile(argv1);vector plan;string s;getline(infile, s);while (getline(infile, s) schedule sch;istringstream record(s);record sch.grade_special sch.course sch.teacher sch.total_hour sch.teach_hour sch.experiment_hour sch.practice_hour sch.credit sch
7、.week_hour sch.start_stop sch.speciality_orientation sch.person_num;plan.push_back(sch);infile.close();vectorvector arranges; /整个系的排课安排vector arr; /一个班的排课安排string gs(); /教学班级for (auto it = plan.begin(); it != plan.end(); +it) if (gs != it-grade_special) if (!arr.empty() arranges.push_back(arr); /教学计
8、划按教学班级顺序排列arr.clear();gs = it-grade_special;arr.push_back(arrange(it-grade_special, it-course, it-teacher);arranges.push_back(arr);vectorvector teachers; /教师数组for (unsigned i = 0; i arranges.size(); +i) for (unsigned j = 0; j arrangesi.size(); +j) string tea = arrangesij.teacher;if (tea = 未定) contin
9、ue;unsigned k = 0;for (; k teachers.size(); +k) if (teachersk0.teacher = tea) teachersk.push_back(teacher_inverted(tea, i, j);break;if (k = teachers.size() vector ti; /一个教师的排课信息倒排表ti.push_back(teacher_inverted(tea, i, j);teachers.push_back(ti);const int N = 256;bitset ct; /教室时段的分配状况infile.open(argv2
10、);vector classrooms;/教室数组while (getline(infile, s) classrooms.push_back(s);infile.close();unsigned arrange_num = plan.size(); /待排课数目unsigned class_num = arranges.size(); /教学班级数目unsigned classroom_num = classrooms.size(); /教室数目uniform_int_distribution u(0, classroom_num * 20 - 1); /为教室时段分配随机数default_
11、random_engine e(time(0);vector class_loc(class_num, 0); /教学班级已分配状况unsigned class_cur = 0; /待分配的教学班级序号,轮流为每个班级排课,一次安排一个班的一门课for (unsigned n = 0; n arrange_num; +n) unsigned k = u(e);/如果某个班级的排课任务已经分配完成,则选择下一个班级继续排课while (class_locclass_cur = arrangesclass_cur.size() class_cur = (class_cur + 1) % class
12、_num;/找到待排课任务的对应教师string tea = arrangesclass_curclass_locclass_cur.teacher;unsigned i = 0;for (; i teachers.size(); +i) if (tea = teachersi0.teacher) break;/找出与该教师无时间冲突的时段do do while (ct.test(k) k = (k + 1) % (classroom_num * 20); unsigned m = 0;for (; m class_locclass_cur; +m) if (arrangesclass_cur
13、m.classroom_time % 20 = k % 20) break;if (m = class_locclass_cur) break; /如果与前面已安排的该班级时间无冲突,则k可用k = (k + 1) % (classroom_num * 20); /如果有冲突则检查下一个教室时段是否可用 while (1);if (i = teachers.size() break; /教师未定unsigned j = 0;for (; j teachersi.size(); +j) int m = arrangesteachersij.class_locteachersij.arrange_
14、loc.classroom_time;if (m != -1 & (m % 20 = k % 20) break;if (j = teachersi.size() break; /如果与该教师的时间无冲突,则k可用k = (k + 1) % (classroom_num * 20); /如果有冲突则检查下一个教室时段是否可用 while (1);/排课arrangesclass_curclass_locclass_cur.classroom_time = k;ct.set(k);/将当前班级的排课号+1+class_locclass_cur;/将待排课班级号+1class_cur = (cla
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 高校 自动 系统 11
限制150内