tpaviot / ProcessScheduler

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

Priorty may not be working #127

Closed Pfizer-BradleyBare closed 1 year ago

Pfizer-BradleyBare commented 1 year ago

Hi,

Great project! I am starting to implement priority and for some reason am having trouble. I've modified the example program to show my issue. I have added a worker then added a priority. For some reason my priority setting is not followed. What am I missing here?

import processscheduler as ps

pb = ps.SchedulingProblem("HelloWorldProcessScheduler")

task_world = ps.FixedDurationTask("World", duration=2, priority=1000)
task_hello = ps.FixedDurationTask("Hello", duration=2)

w = ps.Worker("Worker")

task_hello.add_required_resource(w)
task_world.add_required_resource(w)

solver = ps.SchedulingSolver(pb)
solution = solver.solve()

solution.render_gantt_matplotlib()
Pfizer-BradleyBare commented 1 year ago

Figured it out. Needed to add the following before the solve line.

import processscheduler as ps

# a simple problem, without horizon (solver will find it)
pb = ps.SchedulingProblem("HelloWorldProcessScheduler")
# add two tasks
task_world = ps.FixedDurationTask("World", duration=2, priority=3)
task_hello = ps.FixedDurationTask("Hello", duration=2, priority=2)

w = ps.Worker("Worker")

task_hello.add_required_resource(w)
task_world.add_required_resource(w)

# solve
pb.add_objective_priorities()
solver = ps.SchedulingSolver(pb)
solution = solver.solve()

# display solution, ascii or matplotlib gantt diagram
solution.render_gantt_matplotlib()
Pfizer-BradleyBare commented 1 year ago

Added pb.add_objective_priorities()