How to implement a time interval disable in the example Project Job Scheduling?

41 views
Skip to first unread message

Kent Zhang

unread,
Mar 18, 2022, 11:09:09 AM3/18/22
to OptaPlanner development
Hello, Teams,

In the Project Job Scheduling example, how to disable a time interval? The jobs are not started and not work during this period.

For example, in a factory, weekends (Saturday and Sunday) do not work. Therefore, startDate and endDate need to be restricted as follows:

  1. If a startDate located on the weekend, the startDate will be postponed to the next Monday.
  2. If an endDate is located on a weekend, extend the duration of the job, let it ends at the next week's work-day.

For 1st case above, I can add a hard constraint that penalizes startDate when it is located on weekends. But for the 2nd case, there is no way to think of it. I have tried adding a judgment to the getEndDate method of Allocation - if the endDate is located on the weekend, the duration of the job will be extended by 2 days. But it triggers an Score Corruption exception.

So, do you guys have a better idea to achieve this requirement?

Many thanks in advance!
Reply all
Reply to author
Forward
0 new messages