tpaviot / ProcessScheduler

A Python package for automatic and optimized resource scheduling
https://processscheduler.github.io/
GNU General Public License v3.0
59 stars 17 forks source link

Tasks that will be scheduled in a certain time interval for a certain resource #82

Closed dreinon closed 3 years ago

dreinon commented 3 years ago

Hi, following the #80 issue, it would be nice to have an iterator-kind expression that lets you work with the tasks of a resource that will be schedules between an specified time interval.

This would allow many things. For instance, if days are represented in the problem as a partition of the time, then we would be able to apply constraints only to the tasks that will be scheduled in a specific day.

tpaviot commented 3 years ago

Perhaps another way to see the problem would be to add a restriction to constraints, for example, a constraint that applies if and only if a task is scheduled within a given time interval

dreinon commented 3 years ago

Right, well, it was just an example, I actually need it in order to compute an expression related to tasks starts and ends from a specific time interval. I need to use this expression in an indicator

dreinon commented 3 years ago

The expression is about tasks distance in a time interval. It's a loss indicator that gets all the tasks of a resource in a certain time interval, goes through the tasks two by two in order, and sums 1 if they are not consecutive (task[i].end != task[i+1].start) or 0 if they are.

dreinon commented 3 years ago

My point is that if the solver minimizes this indicator, then there won't be as many tasks that are not contiguous, but with the constraint mentioned at #83, this might get solved.

tpaviot commented 3 years ago

Just to go on with the issue title, to get the tasks that are scheduled in a time interval for a certain resource, you can use the busy_intervals dict for which keys are tasks:

worker = Worker('myWorker')

for task in worker.busy_interval:
    task_is_scheduled_in_this_interval = And(task.start >= bound_min, task.end<=bound_max)
dreinon commented 3 years ago

task_is_scheduled_in_this_interval would be a BoolRef that wouldn't become a bool until problem is solved right?

tpaviot commented 3 years ago

right.

dreinon commented 3 years ago

Ok thanks! Closing this issue.