Decision Optimization

Decision Optimization

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


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

Multiple filters onto a set within a conditional loop

  • 1.  Multiple filters onto a set within a conditional loop

    Posted 04/06/16 12:20 PM

    Originally posted by: Moit1910


    Hi,

     

    I'm quite new to CPLEX and the OPL programming language as well as to programming in general.

    I came across a problem, for witch I can't find a solution within this forum nor elsewhere in the internet.

     

    The problem is:

    How can I put multiple filters onto a set within a conditional loop?

     

    What I want to say is that I have a constraint that shall be declared ∀ i ∈ N\{0}, j ∈ N\{0}, i ≠ j.

     

    I tried the following, giving me the syntax error "unexpected (identifier), expecting ',' or ')':

    range N =0..n

    [...]

    forall (i in N : i>=1)
              forall (j in N : j>= 1 AND j!=i )

     

    I also tried the following, giving me the syntax error "unexpected ':', expecting ',' or ')':

    range N =0..n

    [...]

    forall (i in N : i>=1)
              forall (j in N : j>= 1 : j!=i )

     

    Can anybody please tell me how I can put multiple filters onto a set within such a conditional forall-loop?

     

    Thank you in advance.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Multiple filters onto a set within a conditional loop

    Posted 04/06/16 01:36 PM

    Hi,

    let me give you an example:

    int n=3;
     range N =0..n;

    dvar int x[N] in N;

    subject to
    {
    forall (i in N : i>=1)
              forall (j in N : (j>= 1) && (j!=i) )  x[i]>=x[j];
    }  ;

    regards

     

    https://twitter.com/AlexFleischer1

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Multiple filters onto a set within a conditional loop

    Posted 04/07/16 04:19 AM

    Originally posted by: Moit1910


    Thank you.

    That did it. ;-)


    #DecisionOptimization
    #OPLusingCPLEXOptimizer