每个人都熟悉计算机科学中的调度问题。
我并不是要求这个问题的算法。
我只想制定我在学校一个学期的个人时间表
您可以假设如下:
我想要的只是一些关于如何创建有效时间表的提示/线索,更重要的是,最佳时间表。
想一想,最佳的时间表是什么?
就我个人而言,这些类(class)来自 2 个不同的院系,但我已经能够创建一个包含如下信息的 csv 文件:
M 16:35:00 17:25:00 PHIL 375 Existentialism. 14:35:00 15:55:00 COMP 350 Numerical Computing. 14:35:00 15:55:00 COMP 208 Computers in Engineering. 14:35:00 15:25:00 PHIL 306 Philosophy of Mind. 14:35:00 15:25:00 PHIL 200 Introduction to Philosophy ..etc
如您所见,所有内容均按开始时间排序(倒置),但存在冲突。一周中的所有其他日子也是如此。
如何创建有效/最佳的时间表?我应该考虑哪些事情?
更多信息:
这是我最初认为应该考虑的事情:
缺少什么吗?
最佳答案
对于这种规模 - 我不会太努力地避免简单的编程暴力解决方案。
从 25 门类(class)列表中选择 5 门类(class)有 25!/(20!*5!)=53130
种不同的可能性。通过简单地检查所有类(class),并获得最好的 - 一个最佳方案解决方案得到保证。对于任何现代机器来说,这种规模的运行时间也不是问题。
一个backtracking解决方案非常简单 - “猜测”要添加的类(class),递归调用,直到列表完整为止,评估解决方案。当您从递归返回时 - 检查选择类(class)的不同可能性。
伪代码:
best = 0
bestSol = nil
findCalendar(courses,candidate,i):
if (take.size() == 5):
t = evaluate(candidate)
if (t > best):
best = t
bestSol = copy(candidate)
return
else if (i == courses.size()):
//another stop clause, for non-feasible solutions (less then 5 were selected)
return
for each j in range(i,courses.size()):
candidate.add(courses[j]) //add this course to the candidate
fidnCalendar(courses,candidate,j+1) //recurse to find the next courses for this candidate
candidate.removeLast() //cklean up environment before next candidates
使用 findCalendar(myCourses,[],0)
调用,算法完成后 - bestSol
将保存最佳日历,其值为 最好的
关于创建我的个人学校时间表的算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12190523/