Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  CPLEX grammar for scheduling case

    Posted Tue July 05, 2022 12:36 PM
    Dear All,
    I am trying to create a scheduling for semiconductor cluster tool by using CPLEX library (python).
    However I encountered error for the constraint.

    Here is the code:

    m = Model(name='Scheduling')
    inf = docplex.cp.expression.INFINITY
    bigM= 1000000

    url = None
    key = None
    numbers = range(1, math.factorial(6))
    K = [number for number in range(1, math.factorial(6)+1)] #720
    totalK = len(K)


    xi = m.continuous_var(name = 'xi', lb = 0)
    xj = m.continuous_var(name = 'xj', lb = 0)
    obj_lambda = m.continuous_var(name = 'lambd', lb = 0)

    P = 8 
    T = 6 
    r1 = 100 
    r2 = 200 
    v = 1 
    w = 1 

    PLACES = ([("p1", v+w,0None),
               ("p2", w+r1,0None),
               ("p3"0,1None),
               ("p4", v+w,0None),
               ("p5", w+r2,0None),
               ("p6"0,1None),
               ("p7", w+v,0None),
               ("p8"01None)])

    for k in K:
      for p in PLACES:
        m.add_constraint(xj[k] - xi[k] >= p(1) - p(2)*obj_lambda) 
    TypeError: 'Var' object is not subscriptable

    Can anyone help me, please? Thank you in advance.


    ------------------------------
    Nicholas Nicholas
    ------------------------------

    #DecisionOptimization


  • 2.  RE: CPLEX grammar for scheduling case

    Posted Tue July 05, 2022 12:58 PM
    Hi,

    from docplex.mp.model import Model
    import math
    
    m = Model(name='Scheduling')
    
    K = [number for number in range(1, math.factorial(6)+1)] #720
    totalK = len(K)
    
    xi = m.continuous_var_list(totalK+1,name = 'xi', lb = 0)
    xj = m.continuous_var_list(totalK+1,name = 'xj', lb = 0)
    
     
    
    P = 8 
    T = 6 
    r1 = 100 
    r2 = 200 
    v = 1 
    w = 1 
    
    PLACES = ([("p1", v+w,0, None),
               ("p2", w+r1,0, None),
               ("p3", 0,1, None),
               ("p4", v+w,0, None),
               ("p5", w+r2,0, None),
               ("p6", 0,1, None),
               ("p7", w+v,0, None),
               ("p8", 0, 1, None)])
    
    for k in K:
      for p in PLACES:
        m.add_constraint(xj[k] - xi[k] >= p[1] - p[2]) ​


    works fine

    continuous_var is a scalar variable but you seem to need an array instead



    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------