I have this simple optimization problem with 4 variables and I want to maximize a simple objective.
dvar float+ x1;
dvar float+ x2;
dvar float+ x3;
dvar float+ x4;
maximize -0.4311513304710388 * x1 + 0.7867446541786194 * x2 +
0.9110395312309265 * x3 + 0.130537211894989 * x4;
subject to {
-1 <= x1 <= 1;
-1 <= x2 <= 1;
-1 <= x3 <= 1;
-1 <= x4 <= 1;
}
The optimal answer should be x1 = -1 and x2 = x3 = x4 = 1 resulting in total value of 2.2594727277755737. But CPLEX somehow always ignores the variables with negative coefficients and just chooses x1 = 0 and x2 = x3 = x4 = 1 and gives answer as 1.82832139730453. What am I doing wrong here?
dvar float+ x1;declaresx1as a non-negativefloat. Similarly for the other variables. - njuffa