tpaviot / ProcessScheduler

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

Resources with Shift Breaks #124

Closed itopaloglu83 closed 4 weeks ago

itopaloglu83 commented 1 year ago

First of all, thank you for such a good library.

I'm trying to create a schedule where resources have shift breaks. I tried both ResourceUnavailable and also Productivity but no avail. The premise is simple yet elusive, the worker takes a lunch break between the hours of 4 and 5. In a fact, I'm oversimplifying the issue of multiple workers and machines with different shifts.

Here's the example code.

from processscheduler import *

problem = SchedulingProblem("ShiftBreaks", horizon=10)

worker = Worker("Worker")

task = FixedDurationTask("Task", 5)
task.add_required_resource(worker)

# Lunch break.
ResourceUnavailable(worker, [(4, 5)])

solver = SchedulingSolver(problem)
solution = solver.solve()

solution.render_gantt_matplotlib()

The default solution.

Figure_1

The ideal schedule would be where either a) the task is split into 2 tasks (complicated solution) to achieve the total work time needed or b) having a mechanism where the task duration is updated to 6 due to worker being unavailable for 1 hour during lunch.

Option A: Figure_1

Option B: Figure_1

Any advice is much appreciated. Thank you.

tpaviot commented 1 year ago

Thank you for your feedback.

As far as I understand, although options A and B come from different thinking, the result is the same (Gantt diagrams are similar). In both cases, the task is split into two shorter tasks. Currently, a task cannot be split into smaller subtasks, it necessarily has to be monolithic. I agree that this type of task is missing from the library.

As is, you can create two tasks and add a constraint such that task_duration_1 + task_duration_2 = task_duration I think that would do the job

itopaloglu83 commented 1 year ago

Although both option A and option B yield the same Gantt chart in this example, there is a fundamental difference.

Option A: The task can be split into arbitrary number of parts and the resource might switch between tasks under particular circumstances. e.g. the worker works on a fixed task to completion, takes the breakable task and works on it for a while, and then works on another fixed task to completion and returns back to the breakable task.

Option B: The task is monolithic block where the worker starts working on it to completion. However, the task duration must be extended to accommodate the fact that the worker is unable to produce any parts during the shift break, may it be lunch or end of shift for that day. This is slightly different than splitting the task in a sense that the work is continuous and will not be interrupted by any other task.

tpaviot commented 1 year ago

In the current status of PR #125, I guess the implementation is related to option A. Option B needs another class to be represented.