schedulingcplexcpdocplex

CPLEX CP Scheduling problems: Float Times in Interval Variables


I have been carrying out experiments with CPLEX ILOC CP Optimizer using **docplex for Python ** in the field of scheduling. However, as far as CPLEX doc states, interval variables must be defined by integer values (start, duration, end).

Thus, my question is about the possibility of introducing float values for times in docplex, since in my case activities average durations are defined by floating-point numbers. As far as I know, I have not found any source that talks about how to work it around.

Thanks in advance.


Solution

  • with CPOptimizer you can use decimal decision variables as a workaround.

    from docplex.cp.model import CpoModel
    
    mdl = CpoModel(name='buses')
    
    #now suppose we can book a % of buses not only complete buses
    
    scale=100
    scalenbbus40 = mdl.integer_var(0,1000,name='scalenbBus40')
    scalenbbus30 = mdl.integer_var(0,1000,name='scalenbBus30')
    
    nbbus40= scalenbbus40 / scale
    nbbus30= scalenbbus30 / scale
    
     
    
    mdl.add(nbbus40*40 + nbbus30*30 >= 310)
    mdl.minimize(nbbus40*500 + nbbus30*400)
    
    msol=mdl.solve()
    
    print(msol[scalenbbus40]/scale," buses 40 seats")
    print(msol[scalenbbus30]/scale," buses 30 seats")