I'm following this tutorial https://developers.google.com/optimization/scheduling/job_shop of the Job Shop problem as I have a similar task, except I need an extra constraint which I can't figure out how to add. I want to add a constraint that (in the context of the Job Shop problem) means jobs cannot be processed on machines during their downtime. I have their downtime in intervals, for example , Machine 2 is down between 3 and 5 using the time units in the diagram.Example problem But I am unsure how to add it as a constraint.
ortools version 9.3.10497 python version 3.7.0
If I try:
if machine == 2:
model.Add(all_tasks[job_id, task_id].start > 0)
model.Add(all_tasks[job_id, task_id].end < 3)
model.Add(all_tasks[job_id, task_id].start > 5)
then it obviously won't work as it's impossible to satisfy end < 3 and start > 5 simultaneously. How can I add these as a list of or constraints?For example:
if machine == 2:
model.Add((all_tasks[job_id, task_id].start > 0 and all_tasks[job_id, task_id].end < 3) or all_tasks[job_id, task_id].start > 5)
I did try the above but it's expecting a bounded linear expression, and I couldn't find something for what I was looking for. I only started looking at this library today so apologies if I'm missing something obvious, but the docs aren't the best so thought I'd ask here.