Search code examples
optaplanner

Optaplanner needs to put entries on each day


I have a weekly timetable where I let Optaplanner add the entries. Sometimes it finds out that it will only add entries on 4 out of 5 available days. How should I write my rule for checking if there is at least 1 entry per day in the timetable? enter image description here


Solution

  • Results like that usually call for an experiment. What happens if you put the lesson to Wednesday manually, and then run scoring again? My expectation is that some constraint will be broken, and the weight of that constrant will be relatively heavy. Therefore OptaPlanner prefers avoiding that day.

    Assuming your constraints are well balanced and they don't interfere with one another this way, there are some other ways how you can get a better result:

    1. Run OptaPlanner for longer,
    2. improve performance of your scoring so that it does more in the same amount of time
    3. or introduce more variety into the solver by introducing more move types.

    The second can be achieved by improving your DRL (which I know you use from an earlier answer), or by enabling multi-threaded solving.

    The third can be achieved by enabling all the generic moves (change, swap, pillar change, pillar swap) and, if insufficient, implementing custom moves for some more complex changes.

    That said, my money is on poorly balanced constraints.

    EDIT: If you absolutely need to make sure the lessons are balanced between days, you may want to look into fairness. The OptaPlanner Tennis example shows that in practice.