Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Multidimensional Ranges

    Posted 06/11/15 07:34 AM

    Originally posted by: gregman


    Dear Cplex-Community,

     

    I am currently struggling with the following problem:


    given a set p = {1,2}

    given a set of ranges W_i

    Since W_i is dependent on p, W_2 is supposed to be 1..6, W_1=3..5 and both are dependent on p, respectively. It is not possible to create 2 separate simple ranges. 

    -Is it possible to create a set of ranges W_i in Cplex with different starting and ending points?

     

     

    -Furthermore, could you give me the syntax for a max() formula inside a sum?

    Example: sum (a in 1..max(b,c) ).

     

    Thanks a lot,

    Greg

     

     

     

     

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Multidimensional Ranges

    Posted 06/11/15 08:51 AM

    Hi,

    a small example for you:

    int rangemin[1..2]=[2,3];
    int rangemax[1..2]=[4,5];

    int b=4;
    int c=5;

    int d=sum (a in 1..maxl(b,c)) 1;

    execute
    {
    writeln(rangemin,rangemax);

    writeln(d);
    }

    which gives

     

    [2 3] [4 5]
    5

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Multidimensional Ranges

    Posted 06/11/15 05:10 PM

    Originally posted by: gregman


    Hello Alex and the rest of you,

    thanks a lot for your reply. Unfortunately, it does not solve my problem, maybe because I wasn't precise enough.

    - What you proposed for my first problem are arrays but what I need are ranges:

    range A1 = 1,2,3,4,5,6,7 which is equal to range A1 = 1..7

    range A2 = 2,3,4,5,6 (or 2..6)

    range A3 = 3,4,5,6,7

    Is it possible to create only one multi-dimensional range A_i = {A1,A2,A3} that obtains all given ranges instead of creating i separate ranges so that I can use e.g. forall (i in I, j in A(i) )

     

    - For the max-problem I need a syntax that allows me to code the following part:

    forall (i in I) sum (j in 1.. max(i,b)) ...

    The max-function has to be directly integrated in the sum statement because it is dependent on the current state of the loop index i inside forall.

    Is there a synthax for that?

     

    Thank you very much.

     

    Greg


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Multidimensional Ranges

    Posted 06/12/15 04:03 AM

    Hi

    int rangemin[1..2]=[2,3];
    int rangemax[1..2]=[4,5];

    {int} ranges[i in 1..2]=asSet(rangemin[i]..rangemax[i]);

    int b=4;
    int c=5;

    int d=sum (a in 1..maxl(b,c)) 1;

    range I=1..10;
    dvar int x[I];
    subject to
    {
    forall (i in I) sum (j in 1.. maxl(i,b)) x[j]<=i;
    }

    execute
    {
    writeln(ranges);

    writeln(d);
    }

     

    Instead of arrays of ranges you may use array of sets.

    Again, for the max, as written before you should use maxl

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer