Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Errors found when using indicator constraints for setting up binary variables in Cplex

    Posted 08/18/16 07:05 PM

    Originally posted by: NaomiLearnCplex


    Hello,

    I found some information from website indicating that cplex support "indicator constraints" which allow variables in the conditions. That suits my needs to set up conditions for binary variables f_ij, in particular, f_ij=1 when x_ij>0, and f_ij=0 when x_ij=0. f_ij and x_ij are decision variables.

    However, when I use implication operator "->" or "==>", there are always errors. Can someone help me with this question? 

    Below are some of my scripts:

    // define decision variables

    dvar int+ x[Sites][Days]; 

    dvar boolean f[Sites][Days]; 

    // define objective

    dexpr float SiteAllocation = sum(i in Sites,t in Days)x[i][t]*(0.5*Parameter[i]);
    maximize SiteAllocation;

     

    subject to {

    Constr01:

    forall (i in Sites, t in Days)

    f[i][t]==0 -> x[i][t]==0;

    f[i][t]==1 -> x[i][t]>0

     

    Constr02:

    forall(i in Sites, t in Days_less)
       f[i][t]+f[i][t+1]+f[i][t+2]+f[i][t+3]+f[i][t+4] <= 1;

    }
      

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Errors found when using indicator constraints for setting up binary variables in Cplex

    Posted 08/19/16 03:12 AM

    Originally posted by: BoJensen


    This question belongs to the OPL forum please ask it there, thank you.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Errors found when using indicator constraints for setting up binary variables in Cplex

    Posted 08/19/16 08:45 AM

    Originally posted by: VincentBeraudier


    You have to use => to set logical constraints.

    So your code becomes:

    forall (i in Sites, t in Days){

    f[i][t]==0 => x[i][t]==0;

    f[i][t]==1 => x[i][t]>=1;

    }

     

    > is not a valid operator for integer variable in OPL, so you have to use >=

    (You have to use {} if you want to share the same generator for a list of constraints.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Errors found when using indicator constraints for setting up binary variables in Cplex

    Posted 08/19/16 01:59 PM

    Originally posted by: NaomiLearnCplex


    Hi Vincent,

    It helps, thank you!

     


    #CPLEXOptimizers
    #DecisionOptimization