Decision Optimization

Decision Optimization

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


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

How to filter elements from a tuple to an array??

  • 1.  How to filter elements from a tuple to an array??

    Posted 11/15/13 09:26 AM

    Originally posted by: ikucukkoc


    Hello

    my question is about filtering data from a tuple to an array. Assume a tuple:

    tuple demand { 
      int h; //Line No
      key string j; //Model Name
      float d; //Task Time
    }
    {demand} Demands =...;

    Demands = { //h, j, d

    <1, A, 10>, 
    <1, B, 40>,
    <1, C, 10>, 
    <2, D, 20>, 
    <2, E, 10>,  
    };

    And I want to filter d column from Demands tuple to obtain "PropDemandsArray[Models]" array as below:

    PropDemandsArray = [10, 40, 10, 20, 10];

    Is that possible please? Is there an easy way to do that?

    Many thanks.

    Regards.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: How to filter elements from a tuple to an array??

    Posted 11/15/13 12:35 PM

    Hi,

    {string} Models={e.j | e in Demands};
       
     float PropDemandsArray[m in Models]=first({e.d | e in Demands : e.j==m});
     
     execute
     {
       writeln(PropDemandsArray);
     } 

    gives

    [10 40 10 20 10]
     

     

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: How to filter elements from a tuple to an array??

    Posted 11/17/13 03:46 PM

    Originally posted by: ikucukkoc


    Hi

    Many thanks for the answer.

    Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer