Decision Optimization

Decision Optimization

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


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

How to define a sequence in a range (CPLEX OPL)

  • 1.  How to define a sequence in a range (CPLEX OPL)

    Posted 12/07/16 04:46 PM

    Originally posted by: WillemUilhoorn


    All,

    I have  a question about defining a sequence from a range. For example:

    I have a range for my items with 

    range i = 1..n;
    

    And have a binary decision variable (later used in constraints) 

    dvar int xp[i][k];   //BIN 1 if item i is right of item k
    

    which is about the relative placement of an item in a packing problem. The k however, indicates here the item k that comes after item i. So in fact, it is i+1 in the same range. How can I define this in CPLEX OPL?

    Any ideas? Many thanks in advance


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: How to define a sequence in a range (CPLEX OPL)

    Posted 12/08/16 05:09 AM

    Hi,
    small code to start with:

     


    int n=4;
    range i = 1..n;
    range k=2..n+1;
    dvar boolean xp[i][k];
    subject to
    {
    forall(ii in i) forall(kk in 2..ii) xp[ii][kk]==0;
    forall(ii in i) sum(kk in k) xp[ii][kk]==1;
    }


    regards

     


    #CPLEXOptimizers
    #DecisionOptimization