rellorolo
rellorolo

Reputation: 1

Include machine downtime during a task using or-tools cp-sat

I want to include downtime in a specific way to, e.g. the Job shop example in the official tutorial using OR-Tools CP-Sat solver with Python. I want to allow a machine to start processing a task, then have downtime, and afterwards continue finishing the same task.

The answer to a similar question here: https://stackoverflow.com/a/75901853/22301210 only shows how we can ensure that a task does not end when the machine is down. The answer given was to include the following

if machine == 1:
    model.AddLinearExpressionInDomain(
        all_tasks[job_id, task_id].end,
        cp_model.Domain.FromIntervals([[0, 2], [4, horizon]]))

However, this implies that the task can still be processed during the downtime, it will simply end afterwards.

The same question as I have was asked here: https://groups.google.com/g/or-tools-discuss/c/ZMHvaoK2Z_Q?pli=1 . The answer given was to include a NewIntervalVar during the downtime:

machine_to_intervals[0].append(model.NewIntervalVar(0, 10, 10, 'weekend_0'))

However, in this situation the machine can't start processing a task before downtime and end it after. It will have to be finished processing it before downtime, or start processing it afterwards.

In case we want to process a task of 4 time units on machine 1, and this machine is down in time interval [2,4]. How can we allow the machine to process it from time 0 to 2, and then continue from 4 to 6?


Edit: I actually want to use it for a more complicated scheduling problem: a flexible job shop with a big amount of tasks and many possible start times and durations of machine downtime. For example, given a dictionary with machine downtime intervals per machine

machine_downtime_intervals = {0: [(2,5)], 1 : [(2,3),(6,7),(9,14)], 2: [(3,5)}

minimize the makespan in a flexible job shop problem, where the duration of a task on an a machine is extended by the machine's downtime.

Upvotes: 0

Views: 290

Answers (1)

Laurent Perron
Laurent Perron

Reputation: 11064

You can extend the duration if it spans across an break, without introducing the break interval.

See the code here: https://github.com/google/or-tools/blob/stable/ortools/sat/docs/scheduling.md#intervals-spanning-over-breaks-in-the-calendar

Upvotes: 0

Related Questions