I'm trying to modify the job shop example for CP-SAT solver. (https://developers.google.com/optimization/scheduling/job_shop)

I'm limited to 8 hours working day, So I defined a list of NewIntervalVar() to represent non-working 12h everyday and weekend 24h+24h

I add this list to AddNoOverlap() for every machine interval. (Also, is there a better approach? probably I'm already made mistake with this approach)

non_working_intervals = add_non_working_hours(model)
for machine in all_machines:
    model.AddNoOverlap(machine_to_intervals[machine] + non_working_intervals)

And this works fine if all tasks are less than 8 hours.. Obviously, the model can't fit 15h task in 8h gap and return infeasible..

The question is, how I can redefine the model so it can "automatically" start 15h task on one day and finish it the next day (after 12h). For 15h task it should be like: work 0-8 then gap(no work) 9-24 and then 24-31 (finish last 7h of 15h taks).

The only solution that comes to my mind is to split all tasks into smaller chunks before modeling, but then I should add a mechanism so all parts of a single task must go one by one without interruption (also, I don't know if it's possible to implement)


You should look at this example:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.