Class Scheduling algorithm to show best match with criteria?

廉价感情. 提交于 2019-12-03 20:31:45

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.

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...

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