Decision Optimization

 View Only
Expand all | Collapse all

How to model "If.. Then constraint in MIP with CPLEX

  • 1.  How to model "If.. Then constraint in MIP with CPLEX

    Posted Tue September 29, 2020 12:02 PM
    Hello everyone, 

    I have developed a model and one of the constraint is based on the logic of "If..Then constraint " that I have modeled in MIP ( You can see tha part of the code in the figure below). 
    The problem is when I wanted to impliment this code in CPLEX, the program didn't autorize to write the decision varible like this way. 

    Is there any solution, to resolve this problem ?
    If there is someone who can help me to solve this, I will be grateful. 

    Best regards,


    ------------------------------
    Khaoula
    ------------------------------

    #DecisionOptimization


  • 2.  RE: How to model "If.. Then constraint in MIP with CPLEX

    Posted Tue September 29, 2020 01:23 PM
    Hi,

    you should use logical constraints and not use decision variables in slicing:

    int I=3;
    dvar int w1 in 0..1;
    dvar int L[1..10][1..10] in 0..10;

    subject to
    {
    forall(j in 1..3,N in 1..I) (L[N][j]>=1)=> (w1==1);
    }

    works fine

    regards

    ------------------------------
    ALEX FLEISCHER
    ------------------------------



  • 3.  RE: How to model "If.. Then constraint in MIP with CPLEX

    Posted Tue September 29, 2020 01:35 PM
    Hi, 

    Thank you Alex 

    Best regards,

    ------------------------------
    Khaoula EL MHAMDI
    ------------------------------