Closed tpaviot closed 3 years ago
Merging #20 (b56f01f) into master (dc505a1) will increase coverage by
0.01%
. The diff coverage is98.00%
.
@@ Coverage Diff @@
## master #20 +/- ##
==========================================
+ Coverage 97.82% 97.83% +0.01%
==========================================
Files 20 21 +1
Lines 2209 2358 +149
==========================================
+ Hits 2161 2307 +146
- Misses 48 51 +3
Impacted Files | Coverage Δ | |
---|---|---|
processscheduler/task_constraint.py | 95.54% <92.30%> (-0.68%) |
:arrow_down: |
test/test_schedule_n_task_in_time_interval.py | 99.19% <99.19%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update dc505a1...b56f01f. Read the comment docs.
@dreinon I started implementing the constraint for n tasks in time intervals. The new constraint name is
ScheduleNTasksInTimeIntervals
, you can use it with:cstrt = ps.ScheduleNTasksInTimeIntervals([task_1, task_2, task_3], nb_tasks_to_schedule= 2, list_of_time_intervals = [[1, 10], [13, 20]]) pb.add_constraint(cstrt)
This means the solver will schedule exactly 2 tasks among the list
[task_1, task_2, task_3]
in the slots that are given in the listlist_of_time_intervals
. So far, it does not work as expected: tasks that partially overlap the time intervals are scheduled whereas they should not, I guess it comes from a mistake in the z3 assertion (theAnd
statement does not prevent such tasks to be scheduled).
Thanks Thomas, I'm glad this project is becoming bigger and better :)
I didn't understand well the list of time intervals.
So if I say that
ps.ScheduleNTasksInTimeIntervals([task_1, task_2, task_3], nb_tasks_to_schedule=2, list_of_time_intervals = [[1, 10], [13, 20]])
The functionality we are approaching is that a maximum of 2 tasks will be scheduled between all those time intervals, or that a maximum of 2 tasks will be scheduled in each separate interval?
I mean, in the first case I described, an option would be 1 task between [1,10] and another 1 between [13,20], but it wouldn't be 1 task between [1,10] and 2 between [13,20], whereas in the second option, 1 task between [1,10] and 2 between [13,20] would be an option.
Thanks.
As it is currently implemented, in the previous example, exactly 2 tasks will be scheduled over both intervals. If you want a maximum of 2 tasks, then you have to set the kind
parameter:
cstrt = ps.ScheduleNTasksInTimeIntervals([task_1, task_2, task_3],
nb_tasks_to_schedule= 2,
list_of_time_intervals = [[1, 10], [13, 20]],
kind='atmost')
If you want that a maximum of 2 tasks are scheduled on the first interval, and a maximum on 2 tasks are scheduled on the second interval, then create 2 constraints:
cstrt = ps.ScheduleNTasksInTimeIntervals([task_1, task_2, task_3],
nb_tasks_to_schedule= 2,
list_of_time_intervals = [[1, 10]],
kind='atmost')
cstrt = ps.ScheduleNTasksInTimeIntervals([task_1, task_2, task_3],
nb_tasks_to_schedule= 2,
list_of_time_intervals = [[13, 20]],
kind='atmost')
Got it! Nice approach!!
This pull request introduces 2 alerts when merging 3366009f9a42205ba9b0cba7cbf8baa5ce765cf3 into f8f9c362e81567ae271064c5910c61df9f9279f1 - view on LGTM.com
new alerts:
The current dev branch should work now, but it has to be tested.
Just reviewed tests, new constraint code and new to-do file. Way to go!!
ok, I merge the code into the master branch, we'll see if other fixes are required after a deeper testing.
@dreinon I started implementing the constraint for n tasks in time intervals. The new constraint name is
ScheduleNTasksInTimeIntervals
, you can use it with:This means the solver will schedule exactly 2 tasks among the list
[task_1, task_2, task_3]
in the slots that are given in the listlist_of_time_intervals
. So far, it does not work as expected: tasks that partially overlap the time intervals are scheduled whereas they should not, I guess it comes from a mistake in the z3 assertion (theAnd
statement does not prevent such tasks to be scheduled).