Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Logical constraints with the keyword forall

  • 1.  Logical constraints with the keyword forall

    Posted Fri March 13, 2009 05:43 PM

    Originally posted by: SystemAdmin


    [teddy said:]

    Hello everyone,

    I am a new user on CPLEX and i have a problem for logical constraints.
    Does anybody know how i can write disjunctive constraints containing the keyword forall?

    My example is like the folowing one :
    [quote=Code:]
    forall( i in range1) forall( j in range2)
    (
    forall(k in range3)
        f(k)<=Num1 //first constraints<br />)
    ||
    (
    forall( l in range4)
        g(l)<=Num2 //second constraints<br />)
    ||
    (Cstr1) //other constraints

    //f, g linear function
           


    I get the error : "syntax error, unexpected forall" which refers to the 3rd "forall".

    Thanks a lot.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Logical constraints with the keyword forall

    Posted Fri March 13, 2009 10:39 PM

    Originally posted by: SystemAdmin


    [jfk said:]

    hello,
    I suppose you want to have 3 sets of constraint to be disjunctive or should I say not enforced?
    you can definitely do the following, it works:

    //using CP;
    range Range = 1..10;
    dvar int x[Range] in 1..100;

    dexpr int e1[i in 1..3] = sum(j in Range: j!=10) (i*x[j]+(i+1)*x[j+1]);
    dexpr int e2[i in 1..3] = sum(j in Range: j!=1) (i*x[j]-(i-1)*x[j-1]);

    float ub1[1..3] = [1.1, 2.2, 3.3];
    float ub2[1..3] = [3.1, 4.2, 1.3];

    dexpr int y1 = sum(i in 1..3) (e1[i]<= ub1[i]);<br />dexpr int y2 = sum(i in 1..3) (e2[i]<= ub2[i]);<br />
    maximize
      sum(i in Range) x[i];
    subject to {
    y1 + y2 + (x[3]<=55) ==1;<br />}
    }

    I think you have to do something similar if you want to use || ...

    I hope it helps

    cheers

    p.s.
    I hope you don't take it as an insult but what you asked is nothing to do with CPLEX. it is pure OPL. CPLEX is a mathematical programming problem solving engine and it has several API's and model formats what it accepts to solve. Every math programming model written in OPL can be solved by CPLEX in ILOG OPL Studio. Actually the model I wrote for you can be solved by CPO (Constraint programming optimizer) the other engine provided in ILOG OPL Studio -  if you put back the code line saying "using CP;" you will see that it works
    #DecisionOptimization
    #OPLusingCPLEXOptimizer