Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Problem about Indicator constraints in OPL

  • 1.  Problem about Indicator constraints in OPL

    Posted 03/28/16 11:42 PM

    Originally posted by: jiaodaxiaozi


    Hi

    I wrote the following indicator constraints in OPL :

    indicatorconstraint = forall (l in L, t in T)     t - 1 - delta_a[l] == 0 => ind[l][t] == 1;

    Here the results is:

    ind =  [[0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
             [0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]]

    The value of delta_a[l] = 1 and delta[2] = 2, so I expecting the value of ind is:

    ind =  [[0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
             [0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]

    so how cplex deals with the indicator constraints, I don't understand.

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Problem about Indicator constraints in OPL

    Posted 03/29/16 03:12 AM

    Hi,

    do not you mix imply and equivalent ?

    range L=1..2;
    range T=1..4;

    dvar boolean ind[L][T];
    dvar int delta_a[L];

    maximize sum(l in L,t in T) ind[l][t];
    subject to
    {
    indicatorconstraint :forall (l in L, t in T)     (t - 1 - delta_a[l] == 0) => (ind[l][t] == 1);
    delta_a[1] == 1;
    delta_a[2] == 2;
    }

    execute
    {
    writeln(ind);
    }

    gives

     

    [[1 1 1 1]
             [1 1 1 1]]

    but if we change

    indicatorconstraint :forall (l in L, t in T)     (t - 1 - delta_a[l] == 0) => (ind[l][t] == 1);

    into

    indicatorconstraint :forall (l in L, t in T)     (t - 1 - delta_a[l] == 0) == (ind[l][t] == 1);

    then we get

    [[0 1 0 0]
             [0 0 1 0]]

    regards

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Problem about Indicator constraints in OPL

    Posted 03/29/16 04:25 AM

    Originally posted by: jiaodaxiaozi


    Hi Alex,

    I tried " indicatorconstraint :forall (l in L, t in T)     (t - 1 - delta_a[l] == 0) == (ind[l][t] == 1); " , and it works, thanks for your kind help!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer