Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Using dexpr (Decision Expressions), Flow Control More Efficient/Readable

    Posted 06/11/10 11:45 AM

    Originally posted by: UDOPS


    The distribution example for Lagrangian relaxation has the following pieces,

    in the flow control:

    norm = 0;
    for(i in thisOplModel.cities) {
    slack[i] = 0;
    for (var j in thisOplModel.cities) {
    slack[i]+= m2.Ship[j][i];
    }
    slack[i] -= thisOplModel.request[i];
    norm += Opl.pow(slack[i],2);
    }

    in the related model:

    dexpr float lagrangian_obj = sum(i in cities, j in cities) ship_costi,j * Shipi,j
    + sum(j in cities) mult[j] * (request[j] - sum(i in cities) Shipi,j);

    Do you think I could rewrite this as below? In addition to making it easier to read, would it be more efficient?

    in the model:

    dexpr float request_slackj in cities=sum(j in cities)(request[j] - sum(i in cities) Shipi,j)

    dexpr float lagrangian_obj = sum(i in cities, j in cities) ship_costi,j * Shipi,j
    + sum(j in cities) mult[j] * request_slack[j];

    changing the flow control:

    norm = 0;
    for(i in thisOplModel.cities) {
    norm += Opl.pow(request_slack[i],2);
    }
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Using dexpr (Decision Expressions), Flow Control More Efficient/Readable

    Posted 06/11/10 12:21 PM

    Originally posted by: UDOPS


    Tried it: it allowed the dexpr change, but flow control did not like the use of dexpr "request_slack[]". Why not?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Using dexpr (Decision Expressions), Flow Control More Efficient/Readable

    Posted 06/11/10 03:34 PM

    Originally posted by: SystemAdmin


    Have you tries "thisOplModel.request_slack[]"?

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Using dexpr (Decision Expressions), Flow Control More Efficient/Readable

    Posted 06/13/10 01:43 PM

    Originally posted by: UDOPS


    Yes, specific to my modification:

    /*for(i in thisOplModel.cities) {
    slack[i] = 0;
    for (var j in thisOplModel.cities) {
    slack[i]+= m2.Ship[j][i];
    }
    slack[i] -= thisOplModel.request[i];
    norm += Opl.pow(slack[i],2);
    } */

    for (i in thisOplModel.cities) {
    slack[i]+= m2.request_slack[i];
    norm += Opl.pow(slack[i],2);
    }
    The commented portion is original, and works. The live portion runs, but returns a yellow warning "Not a model element "j", use 'var' to declare local scripting variables", and the values calculated are not the same.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Using dexpr (Decision Expressions), Flow Control More Efficient/Readable

    Posted 06/15/10 06:30 AM

    Originally posted by: SystemAdmin


    I'm confused. There is no "j" in the uncommented part ...

    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Using dexpr (Decision Expressions), Flow Control More Efficient/Readable

    Posted 06/15/10 05:35 PM

    Originally posted by: UDOPS


    Yes, exactly. The "j" referred to in the error message does not exist in any portion of the code that I think is relevant.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Using dexpr (Decision Expressions), Flow Control More Efficient/Readable

    Posted 06/16/10 01:52 AM

    Originally posted by: SystemAdmin


    I suppose that
    (*) the problem originates from somewhere else
    (*) the problem cannot be resolved without having a look at the complete model.

    Just my 2 cents.

    Have you tried to comment the "active block" in your snippet?
    Does the problem still occur?

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer