Decision Optimization

Decision Optimization

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


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

Initialization of dynamic size decision variable

  • 1.  Initialization of dynamic size decision variable

    Posted 11/01/16 04:10 AM

    Originally posted by: CPlex_NooBie


    Hey! The following code snippet explains the curiosity:

    {int} M=...;
    tuple t
    {
      int beta;
      int alp;
      int r;
    };
    
    t allData[M]=...;       
    dvar int y[M][1..r][N] in 0..1;
    

    The last line is the problem where the size of the second index depends on 'r' and the value of 'r' depends on M. Hence the solver gives an error 'circular dependency'. How do I initialize the decision variable y?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Initialization of dynamic size decision variable

    Posted 11/01/16 04:25 AM

    Hi,

    you may either use a bigger array like:

    {int} M= {1,2};

    range N=1..2;
    tuple t
    {
      int beta;
      int alp;
      int r;
    };

    t allData[M]=[<1,1,1>,<2,2,2>];

    int maxr=max(m in M) allData[m].r;
           
    dvar int y[M][1..maxr][N] in 0..1;

    subject to
    {
    y[1][1][1]==2;
    }

    or use tuple sets instead since arrays with variable size are not allowed in OPL

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer