Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

OPL Linking/Implicitly Defined Variable

  • 1.  OPL Linking/Implicitly Defined Variable

    Posted Sun June 26, 2016 09:40 AM

    Originally posted by: dmgoldberg


    I am working on a nonlinear optimization problem wherein a variable needs to be defined as a function of some constraints and the objective function, but this variable is not a decision variable. While I define decision variables at the top of my script like:

    dvar float X111;

    I am under the impression that doing the same with the implicitly defined variable will also implicitly assign the value of the variable to be 0, for example:

    float E1; /*Functionally equivalent to float E1 = 0; (?)*/

    Moreover, although I have tried to define these implicitly defined variables, E1 and E2, as decision variables, doing so gets me an error message: "CPLEX(default) cannot extract expression..." on the objective, c7, and c8 (below). In the current form with E1 and E2 declared as floats, the model will run, but my solution is not correct and comes out as having an optimal value of 0, which is not the answer that would be reached if the variables were successfully implicitly defined. I have not worked with OPL before, so I am unsure how to model the variable as a function of the constraints without running into this issue.

    Is there a workaround or alternative for this issue?

     

    The full formulation is as follows (again, I want E1 and E2 to be implicitly defined but not decision variables):

    dvar float X111;

    dvar float X121;

    dvar float X112;

    dvar float X122;

    float E1;

    float E2;

    maximize

    (ln(200 / (200 - E1)))^0.25 + (ln(300 / (300 - E2)))^1;

    subject to {

    c1: X111 >= 0;

    c2: X121 >= 0;

    c3: X112 >= 0;

    c4: X122 >= 0;

    c5: 1 * X111 + 2 * X121 + 3 * X112 + 4 * X122 <= 20000000;

    c6: X111 / 4 + X121 / 2 + X112 / 4 + X122 / 2 <= 100;

    c7: 0.3 * X111 + 0.5 * X121 == ((1 - 1) * E1) + (1 * 200 * ln(200 / (200 - E1)));

    c8: 0.4 * X112 + 0.9 * X122 == ((1 - 1) * E2) + (1 * 300 * ln(300 / (300 - E2)));

    }

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: OPL Linking/Implicitly Defined Variable

    Posted Mon June 27, 2016 04:48 AM

    Hi,

    you get a cannot extract because your problem is not linear.

    I d rather use CPO and write:

    using CP;

    int scale=1000;
    float tolerance=0.01;
    range r=-100*scale..100*scale;

    execute
    {
    cp.param.timelimit=60;
    }

    dvar int scaleX111 in r;
    dvar int scaleX121 in r;
    dvar int scaleX112 in r;
    dvar int scaleX122 in r;
    dvar int scaleE1 in 0..100*scale;
    dvar int scaleE2 in 0..100*scale;

        dexpr float X111=scaleX111/scale;

        dexpr float X121=scaleX121/scale;;

        dexpr float X112=scaleX112/scale;;

        dexpr float X122=scaleX122/scale;;

        dexpr float E1=scaleE1/scale;;

        dexpr float E2=scaleE2/scale;;

        maximize

        (ln(200 / (200 - E1)))^0.25 + (ln(300 / (300 - E2)))^1;

        subject to {

        c1: X111 >= 0;

        c2: X121 >= 0;

        c3: X112 >= 0;

        c4: X122 >= 0;

        c5: 1 * X111 + 2 * X121 + 3 * X112 + 4 * X122 <= 20000000;

        c6: X111 / 4 + X121 / 2 + X112 / 4 + X122 / 2 <= 100;

        c7: abs(0.3 * X111 + 0.5 * X121 - ((1 - 1) * E1) - (1 * 200 * ln(200 / (200 - E1))))<=tolerance;

        c8: abs(0.4 * X112 + 0.9 * X122 - ((1 - 1) * E2) - (1 * 300 * ln(300 / (300 - E2)))) <=tolerance;

        }
     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer