Decision Optimization

Decision Optimization

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

 View Only
  • 1.  if Constraint involving decision variable

    Posted Wed July 03, 2013 12:24 PM

    Originally posted by: Matthew Tsang


    Hello,

    I have made the following if-then constraint to my objective function.  The constraint aims to keep S1, a binary decision variable, to stay on the same value for 2 continuous iterations throughout the run.  However, cplex does not allow a decision variable to be involved in such a circumstance (possibly in a if-then statement).  I wonder if there is any alternative way to code this.

     Thank you for your time in advnace!

     

    forall(t in 3..NumIteration)

    {

      if(S1[t-2] != S1[t-1])

          {

          S1[t] == S1[t-1];

          }          

    }


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: if Constraint involving decision variable

    Posted Wed July 03, 2013 07:47 PM

    Is this written in OPL? If so, there's a separate forum for OPL where you might get better help.

    That said, you can try using an indicator constraint. I'm not an OPL user, but I think this might work:

    (S1[t-2] != S1[t-1]) => (S1[t] == S1[t-1]);

    I believe the implication operator (=>) is how you communicate an if-then constraint.

    Paul


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: if Constraint involving decision variable

    Posted Wed July 03, 2013 08:59 PM

    Originally posted by: Matthew Tsang


    Hey Paul,

    Thank you for your reply. What you have written down there seems to work perfectly!  This saves so much time of mine.

    By the way, how do you know "=>" means an if-then statement in cplex? I am suspecting that I am not using the user manual properly since I can't really find this in it..

    And thank you very much again for your help.

    Matthew


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: if Constraint involving decision variable

    Posted Thu July 04, 2013 12:43 AM

    You can find the documentation here or in the list of operators. The foodmanufact.mod example shipped with CPLEX also uses this operator.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: if Constraint involving decision variable

    Posted Thu July 04, 2013 10:39 AM

    Originally posted by: Matthew Tsang


    Thank you Daniel. This will be useful for me!

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: if Constraint involving decision variable

    Posted Thu July 04, 2013 09:53 AM

    You're welcome (and thanks Daniel for saving me having to dredge up the link). If it's any consolation, it took me a few minutes scrounging through the OPL docs to confirm what I (vaguely) remembered about the implication operator -- and I knew what I was looking for.


    #CPLEXOptimizers
    #DecisionOptimization