Several tasks need to run repeatedly in a channel, one at a time, over a repeating time frame of length $T$. Associated to each task $i$ is the duration $L_i$ the task will take to run, and a maximum time $M_i$ between successive runs of the task. Note that task instances need not be evenly spaced; the time between any pair of instances of the same task $i$ is independent, but in each case not more than $M_i$. Since this is a rolling timeframe, the first instance of the task succeeds the last. Assume the pattern repeats every cycle of the frame.
For example suppose we have three tasks:
- Red with $L_r = 2$, $M_r = 6$
- Blue with $L_b = 1$, $M_b = 3$
- Green with $L_g = 1$, $M_g = 4$
An acceptable solution is shown below, having a total frame length of 14. I would like to maximize the time between tasks ideally (or the amount of unallocated (white) time per frame length). Although I've used simple numbers here, Im really wanting task lengths and spaces that might be thousands of time units, hence hoping to use intervals.
Is there a common CP paradigm that is well suited to this problem? Does Google ortools support it?
When thinking about this problem using intervals I'm immediately confronted with a problem; I don't know how many intervals to assign to each task in any frame, since collisions would cause remaining intervals to be dragged forward, leaving more time at the end of the frame. So I'm thinking about some variable length list of intervals. Is there such a thing in ortools or another library?