Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

sum with index?

  • 1.  sum with index?

    Posted Wed February 26, 2014 01:40 PM

    Originally posted by: arjaree


    Hi there,

    I have a problem in using summation. One index of my 3D-decision variable is depending on another index. And I need to use summation for that variable. Is it possible to code that?

    decision variable = Inv[i][b][t]

    b in 1..M[i]

    therefore,

    forall (i in I, t in T)

    sum(b in M[i]) (Inv[i][b][t]) == demand[i][t] + order[i][t] 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: sum with index?

    Posted Thu February 27, 2014 11:51 AM

    Hi,

    let me give you an example:

    range I=1..2;
    range T=1..2;
    {int}   M[I]=[{1,2}, {2}];

    {int} B=union (i in I) M[i];

    int demand[I][T];
    int order[I][T];

    dvar int Inv[I][B][T];

    subject to
    {

    forall (i in I, t in T)

    sum(b in M[i]) (Inv[i][b][t]) == demand[i][t] + order[i][t] ;
    }

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: sum with index?

    Posted Fri February 28, 2014 12:47 PM

    Originally posted by: arjaree


    Hi,

    Thanks a million for your help, Alex. Now I'm facing some more problems.

    1. I can't use      forall (b in M[i]) ....what is the correct way of coding that?

    2. Let   {int} X[I]=[{2}, {3}];

                 {int} C=union (i in I) X[i];

        then I can't use    sum(i in I, t in T) (Inv[i][X[i]][t];         

    3. If i have one extra array dimension (makes it to be 4D) and this b-index is depending on both the i-index and this new index-r as well...will it also works the same way?

    Thanks for your help in advance

    Kind Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: sum with index?

    Posted Fri February 28, 2014 01:03 PM

    Originally posted by: arjaree


    for clarification,

    in 2...X[I] contains maximum numbers from each M[I]

     

    thanks


    #DecisionOptimization
    #OPLusingCPLEXOptimizer