Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  if constraint

    Posted 11/26/11 11:12 AM

    Originally posted by: John85655


    Hi,
    is it possible and how can I implement an "or" in an if constraint
    eg:

    forall(s in S, t in T)
    if (t mod 3 == 0)
    x[s][t]+x[s]t-1 ==0
    or
    x[s][t]+x[s]t-2 ==0
    or
    x[s]t-1+x[s]t-2 ==0;

    I know that there does not exist the word or in OPL, but what can i write instead?
    Or does anyone has a better idea to implement this??

    Many thanks for your help!!
    John
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: if constraint

    Posted 11/26/11 11:54 AM

    Originally posted by: SystemAdmin


    How is x declared (real/integer/binary, nonnegative/unrestricted)?

    It would help if you surrounded your code with {code} tags, to prevent the forum software from getting creative in its interpretation of what you are writing. It's also a good idea to check the Preview tab before posting.

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: if constraint

    Posted 11/27/11 05:39 AM

    Originally posted by: SystemAdmin


    HI,

    {
    ...
    dvar int+ xhttp://1...ihttp://1...j;
    ...
    forall(s in S, t in T)
    if (t mod 3 == 0)
    x[s][t]+x[s]t-1 ==0
    or
    x[s][t]+x[s]t-2 ==0
    or
    x[s]t-1+x[s]t-2 ==0;
    ...
    }
    I hope it is more understandable now. I just want to have two of these values x[s][t],x[s]t-1 and x[s]t-2 to equal 0.

    Thank you!!
    John
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: if constraint

    Posted 11/27/11 05:41 AM

    Originally posted by: SystemAdmin


    HI,
    ...
    { dvar int+ xhttp://1...ihttp://1...j;}
    ...
    forall(s in S, t in T)
    if (t mod 3 == 0)
    {x[s][t]+x[s]t-1 ==0}
    or
    {x[s][t]+x[s]t-2 ==0}
    or
    {x[s]t-1+x[s]t-2 ==0;}
    ...

    I hope it is more understandable now. I just want to have two of these values x[s][t],x[s]t-1 and x[s]t-2 to equal 0.

    Thank you!!
    John
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: if constraint

    Posted 11/27/11 05:44 AM

    Originally posted by: SystemAdmin


    HI,
    dvar int+ x[1...i][1...j];
    ...
    forall(s in S, t in T)
    if (t mod 3 == 0)
    x[s][t]+x[s][t-1] ==0
    or
    x[s][t]+x[s][t-2] ==0
    or
    x[s]t-1+x[s][t-2] ==0;
    ...
    

    I hope it is more understandable now. I just want to have two of these values x[s][t],x[s] t-1 and x[s] t-2 to equal 0.

    Thank you!!
    John
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: if constraint

    Posted 11/27/11 12:30 PM
    Hi

    let me give you an example:

    dvar int+ x[1..i][1..j];
     
    subject to
    {
    forall(s in S, t in T)
    if (t mod 3 == 0)
    ((x[s][t]+x[s][t-1] ==0)
    ||
    (x[s][t]+x[s][t-2] ==0)
    ||
    (x[s][t]-1+x[s][t-2] ==0));
    }
    


    Regards
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: if constraint

    Posted 11/28/11 02:17 AM

    Originally posted by: John85655


    Thanks a lot. It is working!
    #CPLEXOptimizers
    #DecisionOptimization