ProcessScheduler
ProcessScheduler copied to clipboard
Getting interruption and work amounts play nicely together
Hi @tpaviot,
in #141 and #143 I did stuff with interruptible tasks.
Now I try to make use of the work_amount
attribute of Task
classes, as this would allow me an even more precise scheduling, but I am now stuck at the case of one task having more than one resource assigned.
My goal here is to adjust the busy_intervals
of every worker such that the work amount is exactly covered by all workers for that specific task.
My problem is, on applying a resource constraint, I must know the constraints of all workers, since the individual task durations, i.e. busy intervals, depend on each other.
I did not see a way to solve that with the existing resource constraints, so I tried to write a ResourcesPeriodicallyInterrupted
(note the plural 'Resources') constraint, which takes lists of workers and a list with lists of time intervals and so on. But that in turn forced me to take out the work amount assertion part in solver.py
:
https://github.com/tpaviot/ProcessScheduler/blob/aecdf3d01cfd98263bbf2a21880f47d79fa42b12/processscheduler/solver.py#L246-L261
...and put it directly in ResourcesPeriodicallyInterrupted
with the overlaps inserted, which kind of worked but is far from elegant.
Since I know now that this has already been done in solver.py
: I really like the idea of composing all the solver assertions in solver.py
instead of doing that directly on creating an object, namely a constraint, a task or a worker.
Thereby, one could respect also interdependent object assertions as in the case of work amount assertions.
The negative part is that it would require a lot of work rewriting the code - even at places where it might not be necessary at the moment (e.g. Why not setting the assertion start >= 0
for a task on creation?).
At least, I think it is worth discussing that. What do you think?
(And my apologies for this long text. I appreciate your patience.)