79209733

Date: 2024-11-21 05:01:25
Score: 0.5
Natty:
Report link

This is an older question, so I don’t know whether you have been able to find a satisfactory answer.

Referring to the example from the ortools documentation you used, just add the cumulative constraint while keeping everything else the same (as each and any of the other constraints are still valid):

capacity = 2  # Maximum capacity of 2 machines in use at any time 
model.add_cumulative(
    [all_tasks[job_id, task_id].interval for job_id, job in enumerate(jobs_data) for task_id, task in enumerate(job)],
    [1] * len(all_tasks),  # Demand of 1 for every interval
    capacity
)

… basically, CP-SAT syntax of what Sascha explained

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Anonymous