timnon / pyschedule

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

Restricting period for resource using range #80

Open contrerasandres opened 5 years ago

contrerasandres commented 5 years ago

I'm using the range method to restrict a resource

R = S.Resource('R',periods=range(0,21,3)

I was expecting this resource to only be available in periods 0, 3, 6, 9, 12, 15, 18.

`from pyschedule import Scenario, solvers, plotters, alt

S = Scenario('nozzle',horizon=20)

two resources

R1 = S.Resource('R1',periods=range(0,21,3)) R2 = S.Resource('R2',periods=range(1,21,3))

T1 = S.Task('T1',length=1,delay_cost=1) T2 = S.Task('T2',length=2,delay_cost=1)

T1 += R1 | R2 T2 += R1 | R2

solvers.mip.solve(S,msg=1) print(S.solution())`

Result: [(T2, R1, 0, 2), (T1, R2, 1, 2)]

I was expecting '[(T2, R1, 0, 3), (T1, R2, 1, 1)]'

Am I using the range function incorrectly?