Class Scheduling algorithm to show best match with criteria?

冷暖自知 提交于 2020-01-01 07:05:11

问题


I am looking to create a system where you can input the courses (3-7 courses) that you want to take at a college and then select preferences (Morning, Day, Evening, Night / M, T, W, TR, F).

I need a way so that when the program queries the database (MySQL) it returns the best possible schedule that was made according to those parameters. I am writing it in php.

Does any one know the best way to do this? Or a link to some sample code I could understand it from?


回答1:


It's NP-complete.

If you want something simple and fast, write a construction heuristic like First Fit Decreasing. Simply put, it orders the courses according to difficulty (student size, ...) and assign them one at a time at the best remaining timeslot and room. You could easily do this in PHP.

If you want to do it right, like @malejpavouk said, use a CP library. It will first use a construction heuristic and then does metaheuristics like tabu search, simulated annealing, ... Here's a open source course scheduling implementation in Java. Look for a good PHP CP library.




回答2:


You might want to try some constraint programming (CSP) library.... In CSP you state the problem (usually NP Hard) and the library solves it using some heuristics (simulated annealing, taboo search) or an exhaustive DFS with some tricks (arc consistency ,search space shaving)... It can solve NPC problems with thousands of variables...but its somehow tricky to set the "fine" parameters of the black-box system...




回答3:


This is a hard optimization problem. Here's a proposed heuristic (with random jumps).

  1. Get a set of constraints (preferences).
  2. And a set of courses.
  3. Get possible times of the chosen courses using a MySQL query.
  4. Choose a feasible set of courses.
  5. Score the set according to the constraints.
  6. If the score is good enough, stop.
  7. Otherwise, change the hours of one course, chosen at random.
  8. return to step 4.


来源:https://stackoverflow.com/questions/7705782/class-scheduling-algorithm-to-show-best-match-with-criteria

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!