timnon / pyschedule

pyschedule - resource scheduling in python
Apache License 2.0
295 stars 61 forks source link

Group tasks with different duration #79

Open ollamh opened 5 years ago

ollamh commented 5 years ago

Hi @timnon !

I have another question (and possible bug) when using tasks grouping:

       import pyschedule
       s = pyschedule.Scenario('test_periods', horizon=400)
       t1 = s.Task('Graphics_1', length=4, delay_cost=1 , group='1')
       t2 = s.Task('Graphics_2', length=2, delay_cost=1, group='1')
       t3 = s.Task('Graphics_3', length=4, delay_cost=1,group='1')
       t4 = s.Task('Graphics_4', length=4, delay_cost=1,group='2')
       t5 = s.Task('Graphics_5', length=1, delay_cost=1,group='2')
       t6 = s.Task('Graphics_6', length=2, delay_cost=1)
       t7 = s.Task('Graphics_7', length=2, delay_cost=1)

       resource1 = s.Resource('Dep', periods=range(0,400))
       resource2 = s.Resource('Deep', periods=range(0,400))
       resource3 = s.Resource('Deeep', periods=range(0,400))

       s += t6 > t5
       s += t6 > t4
       s += t6 > t3
       s += t6 > t2
       s += t6 > t1
       s += t7 > t6
       t1 += resource1
       t2 += resource1
       t3 += resource1
       t4 += resource1
       t5 += resource1
       t6 += resource2
       t7 += resource3

       pyschedule.solvers.mip.solve(s, kind='CBC', msg=1, ratio_gap=1.2)
       print(s.solution())
       pyschedule.plotters.matplotlib.plot(
           s, resource_height=100.0)

I create manually a group of tasks of different duration, but when I get the results I see gaps between tasks in the same group, as the code logic assumes that all tasks in the group have equal duration. Is it a bug?