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