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

[Enhancement] More specification in Workload constraint #96

Open dreinon opened 3 years ago

dreinon commented 3 years ago

With the current API of the Workload constraint of a Resource, we can only set a general kind for all time periods.

In my problem, I wanted to express that for a specific time period, the min number of tasks that the resource could be scheduled was m and the max number of tasks was m+n ( where n > 0). I used two workload constraints with the same period but one for min and one for max, but I don't know if they are designed to work well together and might not be the best notation.

I propose that the time periods dict acquires the following structure:

workload = {
    (0, 10): [
        {
            "nb_tasks": 2,
            "kind": "min"
        },
        {
            "nb_tasks": 5,
            "kind": "max"
        }
    ],
    (10, 20): [
        {
            "nb_tasks": 3,
            "kind": "exact"
        }
    ],
    (20, 30): [
        {
            "nb_tasks": 1,
            "kind": "min"
        },
        {
            "nb_tasks": 6,
            "kind": "max"
        }
    ]
}

There would have to be a validation check in the beginning of the constraint that checks that for each time period list either there's only an exact subdict, or there are min and/or max subdicts, but not both at the same time because it doesn't make sense.

What do you think?

tpaviot commented 3 years ago

Ok that's something possible I guess, I looked at the current implementation of the Workload constraint only a few lines need to be added (see https://github.com/tpaviot/ProcessScheduler/blob/master/processscheduler/resource_constraint.py#L124). However this has to be strongly unit tested

dreinon commented 3 years ago

I agree