I'm a student studying optimization using CPLEX. I created a simple stepwise example, but I have some doubts about the results.
dvar float x;
dvar float y;
dexpr float z= piecewise {0->0; 10->0; 0->10; 5->10; 0->20; 5->20; 0} (1,10) x;
dexpr float goal = y+z;
minimize goal;
subject to {
9<=x;
x<=18;
4<=y;
y<=10;
}
In the above formula, I expected x and y to be 9 and 4 respectively, and the solution to yield the expected result of 14. (when x is 9, z becomes 10, so y+z=4+10=14.) However, why does the decision variable show x as 10 and the goal as 19 instead?
I would appreciate your response. Thank you.
Your piecewise is discontinuous, which means for 10 the result is either 10 or 15
what you could do in order to remove this choice is write
and then
gives
and you get x=9