Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  traverse tuples in OPL

    Posted 03/14/12 12:05 PM

    Originally posted by: HuiD


    I've defined a tuple like this

    tuple a{
    int m;
    string n;
    }

    {a} someA = {<1, "1">, <2, “2”>, <3, "3">};

    How am I suppose to traverse the tuple set? Like, find the tuple with the maximum "m" in all three tuples in the set. I'm using OPL IDE, not with C++.

    I can't find relevant content in the manual or the forum. Thanks!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: traverse tuples in OPL

    Posted 03/14/12 12:11 PM

    Originally posted by: SystemAdmin


    One way of doing it is, sorting the tuple and getting the first element, see the following post:

    http://www.ibm.com/developerworks/forums/thread.jspa?threadID=419294

    Hope this helps,

    Mehmet.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: traverse tuples in OPL

    Posted 03/14/12 03:52 PM

    Originally posted by: HuiD


    That post gave example on how to use the functions.

    I want to compare the element of each tuple and assign value to a matrix indicating the relations of the tuples.

    int N = ...; //the number of schedules
    tuple duration {
    int t1;
    int t2;
    }

    {duration} schedule = ...;

    int overlaphttp://1..Nhttp://1..N;

    If two tuple a and b in schedule and a.t1 < b.t2 < a.t2, I assign overlap[a][b] = 1; so I need to traverse each tuple in the set.

    How can I do that? Thanks!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: traverse tuples in OPL

    Posted 03/14/12 03:54 PM

    Originally posted by: HuiD


    the overlap is a matrix

    int overlap[N][N]
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: traverse tuples in OPL

    Posted 03/14/12 05:03 PM

    Originally posted by: SystemAdmin


    I am not very clear about your question. overlap is defined as

    int overlap[N][N]
    


    but you are trying to calculate it in terms of sets a and b?

    int overlap[a][b]
    


    If the second case is true, then the following maybe helpful

    tuple duration { 
            int t1;
            int t2;
    }; 
     
    {duration} seta = { <1,10>}; 
    {duration} setb = { <1,5>};
     
    int overlap[a in seta][b in setb] = (a.t1<b.t2 && b.t2 < a.t2) ? 1 : 0;
    

    #DecisionOptimization
    #OPLusingCPLEXOptimizer