Decision Optimization

Decision Optimization

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


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

ILOG Script - get data from a set

  • 1.  ILOG Script - get data from a set

    Posted 11/25/09 11:36 AM

    Originally posted by: Boonyawat


    Hi,

    Here is my problem.

    In OPL, I declare a set of tuple like...

    tuple T{
    string A;
    int B;
    };
    {T} SET_of_T=...;

    Also, in OPL, I declare array.

    int Result[T];
    Now, I have a scripting that I would like to assign a value B to array Result.

    execute{

    for (i in T)
    Result[i]= ??????????????
    };
    };

    The questio is what should I put in in the ????????????. I want Result[i]= B, where B is in the tuple of i. Note that I simplies the problem so that it is easy and breif enough to explain. In my actual model, I need to do some calculations, and if-then statement in my script block. I am stuck at how to assign a value in a set to an array.

    thanks!
    Boon
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: ILOG Script - get data from a set

    Posted 11/26/09 12:17 PM

    Originally posted by: davidoff


    Hi Boon

    In your case , I would not use a script to fill Result, but rather :
    int Result[t in setofT] = t.B;
    


    However, if you actually need a script, this would stand as :

    int Result[setofT];
    execute{
    for(var t in setofT)
       Result[t] = t.B; 
    }
    

    Hope this helps

    David Gravot
    ROSTUDEL operations Research
    www.rostudel.com
    #CPLEXOptimizers
    #DecisionOptimization