Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Fruit Example, Complex Set Construction

    Posted 07/29/08 08:17 PM

    Originally posted by: SystemAdmin


    [UDOPS said:]

    I have been toying with some samples to learn OPL capabilities. The following sample will run. In the comments is an incomplete statement that I would want to produce a set of the lowest prices. Is there a way to compose this in a single line statement without creating additional named sets or arrays?

    tuple domestic {
    string name;
    float price;
    int source;
    }

    tuple import {
    string name;
    float price;
    }

    tuple retail {
    string name;
    float saleprice;
    }

    {domestic} skus = {<", 2.65, 1>, <", 1.75, 2>, <", 0.5, 2>, <", 1.5, 3>, <", 1.5, 2>, <", 1.6, 1>};

    {import} europe = {<", 1.25>,<", 4.55>, <", 6.77>};

    //merge sets (lists) on two columns
    {retail} sale_all = {<f,x> | <f, x, src> in skus} union europe;

    //intersection of sets, only members in both sets
    {retail} sale_intersection = {<f,x> | <f, x, src> in skus, <f, p> in europe};

    //set of all fruits, lowest price
    {retail} sale_low = {<f.name, 1> | f in skus} union {<f.name, 2> | f in europe};

    //incomplete attempt {retail} sale_low = {<f.name, min()> | f in sale_all};


    //set of all fruits, highest price


    //set of all fruits, average price

    execute{ //display constructed sets, add carriage return between results
    writeln("Intersection "+sale_intersection)
    writeln("\nAll "+sale_all)
    writeln("\nLow "+sale_low)
    };
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Fruit Example, Complex Set Construction

    Posted 07/30/08 02:33 PM

    Originally posted by: SystemAdmin


    [afleischer said:]

    Hi

    what about

    {retail} sale_low= {<f.name, min(<f.name,p> in sale_all) p> | f in sale_all};
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Fruit Example, Complex Set Construction

    Posted 07/30/08 09:31 PM

    Originally posted by: SystemAdmin


    [UDOPS said:]

    Thanks, that works. Now how about the average?

    tuple domestic {
    string name;
    float price;
    string source;
    }

    tuple import {
    string name;
    float price;
    }

    tuple retail {
    string name;
    float saleprice;
    }

    {domestic} skus = {<", 2.65, "OH">, <", 1.75, "CA">, <", 0.5, "CA">, <", 1.5, "TX">, <", 1.5, "CA">, <", 1.6, "OH">};

    {import} europe = {<", 1.25>,<", 4.55>, <", 6.77>};

    //merge sets (lists) on three columns
    {domestic} sale_all = skus union {<n,p,"ER">| <n,p> in europe};

    //intersection of sets, only members in both sets
    {retail} sale_intersection = {<f,x> | <f, x, src> in skus, <f, p> in europe};

    //set of all fruits, lowest price
    {retail} sale_low= {<f.name, min(<f.name,p,src> in sale_all) p> | f in sale_all};

    //set of all fruits, highest price
    {retail} sale_high= {<f.name, max(<f.name,p,src> in sale_all) p> | f in sale_all};


    //set of all fruits, average price
    {retail} sale_avg= {<f.name, sum(<f.name,p,src> in sale_all) p> | f in sale_all};

    //card(A in sale_all: A.name==f.name) does not work

    execute{ //display constructed sets, add carriage return between results
    writeln("Intersection "+sale_intersection)
    writeln("\nAll "+sale_all)
    writeln("\nLow "+sale_low)
    writeln("\nHigh "+sale_high)
    writeln("\nAverage "+sale_avg)
    };
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Fruit Example, Complex Set Construction

    Posted 07/31/08 12:23 AM

    Originally posted by: SystemAdmin


    [afleischer said:]

    Hi

    That could be expressed like this:

    {retail} sale_avg= {<f.name, sum(<f.name,p,src> in sale_all) p/sum(<f.name,p2,src2> in sale_all) 1> | f in sale_all};

    Alex

    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Fruit Example, Complex Set Construction

    Posted 07/31/08 12:31 AM

    Originally posted by: SystemAdmin


    [UDOPS said:]

    That is clever, it never would have occurred to me to sum 1's over the implied iteration of the sum() function.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Fruit Example, Complex Set Construction

    Posted 07/31/08 12:38 AM

    Originally posted by: SystemAdmin


    [UDOPS said:]

    Here is another complex set construction that is not working, but I think you can see what I am attempting:


    {trackexpand} TrackPlan = {<p.block, time, p.capacity, p.time_minimum, maxl(p.no_wait, &#91;o.no_wait | o in Orders: time>=o.time_from && time<=o.time_to])> | p in Profile, time in Ts..Te};

    I want the "wait" element to be the maximum of the current slice and a matching slice of another set, Orders.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Fruit Example, Complex Set Construction

    Posted 07/31/08 01:00 AM

    Originally posted by: SystemAdmin


    [UDOPS said:]

    I thought about this, and although I intend there only be one matching record in the set Orders, it occurred to me that there might be multiple records in a faulty data set, so I tried this:

    {trackexpand} TrackPlan = {<p.block, time, p.capacity, p.time_minimum, maxl(p.no_wait, max(o in Orders: time>=o.time_from && time<=o.time_to) o.no_wait)> | p in Profile, time in Ts..Te};

    and it worked. I guess this is the best method. I thought about "sum", but this is a binary value and I don't want it creeping out of range.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer