Decision Optimization

Expand all | Collapse all

Assertion error in remove_constraint of docplex

  • 1.  Assertion error in remove_constraint of docplex

    Posted 26 days ago
      |   view attached
    I have used remove_constraint method of docplex before but for a specific model it keep giving me the following assertion error that I have no idea how to fix:

    "assert len(cpx_terms) == len(mdl_terms)

    AssertionError"

    Here is a snippet of my code:

    # Obj 2

    Obj2_ptr = MODEL.add_constraint(Y[1] ==

    T*sum(sum(ins.M_r[r]*ins.FF_r[r]*D_rij[(r,i,j)] for (i,j) in ins.AA_r[r]) for r in ins.RR))

    # Obj 1

    a = MODEL.add_constraint(Y[0] == ins.C_inv*(sum(Y_i[i] for i in ins.NN)

    + sum(Z_i[i]-sum(X_ij[(w,i)] for w in ins.NN if (w,i) in ins.AA) for i in ins.NN_s) )

    + ins.C_con*ins.l*sum(X_ij[i] for i in ins.AA) )

    MODEL.remove_constraint(Obj2_ptr)

    you can find the runnable code in the attachment.

    ------------------------------
    Vahid Mahmoodian
    ------------------------------

    Attachment(s)

    zip
    RunnableInstance.zip   18 KB 1 version


  • 2.  RE: Assertion error in remove_constraint of docplex

    Posted 26 days ago
    Which version of docplex and cplex are you running?

    ------------------------------
    Vincent Beraudier
    ------------------------------



  • 3.  RE: Assertion error in remove_constraint of docplex

    Posted 26 days ago
    I was using version 2.14.0 and you are right. It is fixed in the newer versions. Thank you!

    ------------------------------
    Vahid Mahmoodian
    ------------------------------