-
Notifications
You must be signed in to change notification settings - Fork 25
Description
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
:
ProcessScheduler/processscheduler/solver.py
Lines 246 to 261 in aecdf3d
# work amounts | |
# for each task, compute the total work for all required resources""" | |
for task in self.problem.tasks.values(): | |
if task.work_amount > 0: | |
total_work_for_all_resources = [] | |
for required_resource in task._required_resources: | |
# work contribution for the resource | |
interv_low, interv_up = required_resource._busy_intervals[task] | |
work_contribution = required_resource.productivity * ( | |
interv_up - interv_low | |
) | |
total_work_for_all_resources.append(work_contribution) | |
if total_work_for_all_resources: | |
self.append_z3_assertion( | |
z3.Sum(total_work_for_all_resources) >= task.work_amount | |
) |
...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.)