Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  set in tuples

    Posted 05/24/16 11:06 AM

    Originally posted by: sandeepsinghchauhan


    int KMin[p in A] = 1;
    int KMax[p in B] = p.Unit;
    {int}Us[p in C] = asSet(KMin[p]..KMax[p]);

    will give me some sets

    p.p           l                      Value
    1              1           {1 2 3 4 5 6 7 8 9 10}
    1              2                  {1 2 3 4 5}

    ..........etc

    tuple E
    {
      key T p;
      key int l;
      int Us;
    }  
    {E} D = ...;

    my question how can i use my sets of Us in place of int Us to give values as in set 

    please help


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: set in tuples

    Posted 05/25/16 02:41 AM

    Hi,

    let me give you a small example:

    range A=1..5;


    tuple t
    {
    int Unit;
    }

    {t} B={<1>,<2>};

     

    int KMin[p in B] = 1;
    int KMax[p in B] = p.Unit;

    {int}Us[p in B] = asSet(KMin[p]..KMax[p]);

    tuple E
    {
      key t p;
      key int l;
      int Us;
    }  
    {E} D = {<p,Us+1,Us> | p in B, Us in  asSet(KMin[p]..KMax[p])};

    execute
    {
    writeln(Us);
    writeln(D);
    }

    which gives

    [{1} {1 2}]
     {<<1> 2 1> <<2> 2 1> <<2> 3 2>}

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: set in tuples

    Posted 05/25/16 03:28 AM

    Originally posted by: sandeepsinghchauhan


    thanks for your valuable reply.

     

    {E} D = {<p,Us+1,Us> | p in B, Us in  asSet(KMin[p]..KMax[p])};

    In this equation my 'key int l' values varies with Us+1 which is not the case actually my l values vary as 

    p.p           l                      Value
    1              1           {1 2 3 4 5 6 7 8 9 10}
    1              2                  {1 2 3 4 5}

    1              3                {1 2 3 4 5 6 7}

    2              1                   {1 2 3 4 }

    2              2                     {1 2}

    .........  so on

    means it my Us values related with l but not in Us+1 manner

    please help

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: set in tuples

    Posted 05/25/16 04:20 AM

    Hi,

    the goal was to help you manage with the syntax.

    range A=1..5;


    tuple t
    {
    int Unit;
    }

    {t} B={<1>,<2>};

     

    int KMin[p in B] = 1;
    int KMax[p in B] = p.Unit;

    {int}Us[p in B] = asSet(KMin[p]..KMax[p]);

    tuple E
    {
      t p;
      int l;
      int Us;
    }  
    {E} D = {<p,l,Us> | p in B, l in 1..3,Us in  asSet(KMin[p]..KMax[p])};

    execute
    {
    writeln(Us);
    writeln(D);
    }

    gives

    [{1} {1 2}]
     {<<1> 1 1> <<1> 2 1> <<1> 3 1> <<2> 1 1> <<2> 1 2> <<2> 2 1>
         <<2> 2 2> <<2> 3 1> <<2> 3 2>}

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: set in tuples

    Posted 05/25/16 05:44 AM

    Originally posted by: sandeepsinghchauhan


    {E} D = {<pl.p,pl.l,Us> |pl in Pro:pl.l < maxLevel[pl.p], Us in  asSet(KMin[pl]..KMax[pl])};

    ERROR


    Duplicate key "<<1>, 1>" in "D".  

    please help

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: set in tuples

    Posted 05/25/16 02:53 PM

    Hi,

    in my second example, I wrote

    tuple E
    {
      t p;
      int l;
      int Us;
    }  

    without the keyword key. Are you sure you removed it ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: set in tuples

    Posted 05/25/16 03:01 PM

    Originally posted by: sandeepsinghchauhan


    because with key i am getting error so i removed it


    #DecisionOptimization
    #OPLusingCPLEXOptimizer