Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

extract from tuple

  • 1.  extract from tuple

    Posted Tue June 14, 2016 02:36 AM

    Originally posted by: sandeepsinghchauhan


    tuple TP
    {
       key int p;
       key int l ;
       float Cost;
    }
    {TP} PL  = ...;

    p   l    Cost

    1    1       10

    1     2       30

    1     3       40

    2     1       230

    2     2       90

    2     3       130

     

    dexpr float X[pl in PL] =  (pl.Cost * L[pl.p] + pl.Cost * M[pl.p] + pl.Cost * H[pl.p]) ;

    i want to multiply L only with cost values whose l are 1, M with whose l values are 2 and H with when l are3.

    how can i do this

    please help


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: extract from tuple

    Posted Thu June 23, 2016 07:26 AM

    Hi,

    Let me give you a small example you could improve:

     

    tuple TP
    {
       key int p;
       key int l ;
       float Cost;
    }
    {TP} PL  = {
    <1  ,  1    ,   10>,
    <1  ,   2   ,    30>,
    <1   ,  3   ,    40>,
    <2   ,  1   ,    230>,
    <2  ,   2   ,    90>,
    <2  ,   3   ,    130>
    };

    int L[i in 1..5]=i;
    int M[i in 1..5]=10*i;
    int H[i in 1..5]=100*i;

     
    dvar float res;
    dexpr float X[pl in PL] =  (pl.Cost* L[pl.p] + pl.Cost * M[pl.p] + pl.Cost * H[pl.p]) ;

    subject to
    {
    res==X[first(PL)];
    }

     

    execute
    {
    writeln(res);
    }

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer