tpaviot / ProcessScheduler

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

Unavailable task constraint #4

Closed dreinon closed 3 years ago

dreinon commented 3 years ago

Is there a way to define tasks that can’t be done in certain periods of time, like the resources?

In some way, something like the ResourceUnavailable constraint, but for tasks.

This is because I have lots of time periods where the task can’t be executed.

Thanks :)

tpaviot commented 3 years ago

You can use boolean operations to build specific constraints, see https://processscheduler.readthedocs.io/en/latest/first_order_logic_constraints.html

For example, if you want a task T do not be scheduled from 3 to 8, then you can try:

not_(and_(TaskStartAfter(T, 3), TaskEndBefore(T, 8))

Boolean ops can be nested. If you have two forbidden slots [2,4] and [6,8], then

and_(not_(and_(TaskStartAfter(T, 2), TaskEndBefore(T, 4)), not_(and_(TaskStartAfter(T, 6), TaskEndBefore(T, 8)))
dreinon commented 3 years ago

You can use boolean operations to build specific constraints, see https://processscheduler.readthedocs.io/en/latest/first_order_logic_constraints.html

For example, if you want a task T do not be scheduled from 3 to 8, then you can try:

not_(and_(TaskStartAfter(T, 3), TaskEndBefore(T, 8))

Boolean ops can be nested. If you have two forbidden slots [2,4] and [6,8], then

and_(not_(and_(TaskStartAfter(T, 2), TaskEndBefore(T, 4)), not_(and_(TaskStartAfter(T, 6), TaskEndBefore(T, 8)))

Nice way implying logic!

In the docs, there are two functions for both TaskStartAfter and TaskEndbefore. They are:

Since what I want is a 'TaskNotStartBeforeStrict', I should use not_ with TaskStartAfterLax, since the negation of >= is <, and same in the end part right?

Thanks :)