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 create subset for unordered nodes

  • 1.  How to create subset for unordered nodes

    Posted 12/05/14 03:55 PM

    Originally posted by: viva0521


    Hi, there

    I have a problem that contains 29 nodes, some of which are connected to form a certain network.

    Let's say, 1st set = AllNodes, consists of two categories nodes, say "H" and "R" nodes, I want create 2 subset with different cost functions. I realized that I need a tuple for creating subset, however, my nodes sequence are randomly distributed as follows:

    I(node)/1...29/

    H(node)/1,2,3,4,5,6,7,8,9,11,14,16,19,22,24,27/
     
    R(node)/10,12,13,15,17,18,20,21,23,25,26,28,29/

    Moreover, I want to use different index across all the node for set I, use I(i,j) for first set, H(k,m) for second set and R(p,q) for the last one. 

    How can i achieve this? Any comment is highly appreciated!  Thanks in advance! 


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: How to create subset for unordered nodes

    Posted 12/06/14 05:28 AM

    Hi,

    you could do the following:

    {int} I=asSet(1..29);

     

     

    {int} H={1,2,3,4,5,6,7,8,9,11,14,16,19,22,24,27};

     

    {int} R={10,12,13,15,17,18,20,21,23,25,26,28,29};

     

    tuple ti

    {

    int element;

    int fromH;

    }

     

    {ti} I2={ <e,(e in H)> | e in I};

     

    execute

    {

    writeln(I2);

    }

     

    assert forall(i in I2:i.fromH==1) (i.element in H);

    assert forall(i in I2:i.fromH==0) (i.element in R);

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer