Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Can I use tuple key to find a tuple in a tupleset iusing OPLScript?

    Posted Fri November 23, 2012 10:13 AM

    Originally posted by: SystemAdmin


    Can I use tuple key to find a tuple in a tupleset iusing OPLScript? The following line didn't work for me:
    
    OPDModel1.ctDeverseMax[OPDData.relOEs.find(ctn.esp)
    

    Where
    
    ctn.esp
    
    is an
    
    
    int
    
    and
    
    relOEs
    
    is:
    
    tuple rvOE 
    {   key 
    
    int espOE;   string nomOE;   
    
    int espReservoirAmont;   
    
    int espSegmentAval;   
    
    int NonControlable;   
    }   
    {rvOE
    } relOEs = ...;
    


    I receive the following error message: Scripting runtime error: not of type 'IloTuple', "246".
    For your information, ctn.esp=246.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Can I use tuple key to find a tuple in a tupleset iusing OPLScript?

    Posted Sat November 24, 2012 10:19 AM
    Hi,

    instead of find you should use Opl.item

    with item you can use the rank or the key

    regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Can I use tuple key to find a tuple in a tupleset iusing OPLScript?

    Posted Sat November 24, 2012 03:48 PM

    Originally posted by: SystemAdmin


    If I write
    Opl.item(OPDData.relOEs,ctn.esp)
    
    , the function interpret that
    ctn.esp
    
    is an index and not a tuple key. How can I do to tell the compiler that
    ctn.esp
    
    is an index?

    Thank you,

    MB
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Can I use tuple key to find a tuple in a tupleset iusing OPLScript?

    Posted Sat November 24, 2012 10:27 AM

    Originally posted by: SystemAdmin


    Hi Blais,

    Try
    item(OPDData.relOEs,ctn.esp)
    but I think sets do not have to preserve order, keep that in mind.
    There are sorted sets, like
    sorted {rvOE} relOEs = ...;
    but not sure how it works with tuples, I use sorted sets with ints.

    Another approach is to replace the set with an array
    int N = card(OPDData.relOEs);
    rvOE_Array http://i in 1..N = item(OPDData.relOEs, i);

    Regards,
    Zahar
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Can I use tuple key to find a tuple in a tupleset iusing OPLScript?

    Posted Sat November 24, 2012 04:09 PM

    Originally posted by: SystemAdmin


    The function
    OPDData.relOEs.find(ctn.esp)
    
    work well. The error I have come from another part of my code.

    Sorry,

    MB
    #DecisionOptimization
    #OPLusingCPLEXOptimizer