Home > other >  Unable to find the same solution on CPLEX and MATLAB for a quadratic program
Unable to find the same solution on CPLEX and MATLAB for a quadratic program

Time:03-28

I'm trying to solve the following quadratic problem with MATLAB (using quadprog function) and CPLEX. The problem is that MATLAB and CPLEX provided feasible solutions but both solutions didn't match. In fact, CPLEX claims that the obtained solution is optimal while the solution obtained with MATLAB is better in terms of objective.

Minimize obj= 0.5*(1100*x^2   509*y^2   33*z^2   1060*x*y   252*y*z   260*z*x)- 60*x- 36*y - 11*z

Subject to:
-x-y z <= 10
-x y-z <= 10
-x y z <= 10
x-y-z <= 10
x-y z <= 10
x y-z <= 10
x y z <= 10
-x-y-z <= 10
x,y and z are real numbers.

In matlab, I got: obj=-3, x=0.0436, y=-0.2670, z=1.1830
In CPLEX, I got: obj=-2.07, x=0.028, y=0.000, z=0.222

I don't understand why.

I tried to solve the problem with MATLAB and CPLEX but the solutions didn't match.

CodePudding user response:

which cplex version have you tried ?

I wrote

dvar float x;
dvar float y;
dvar float z;

minimize 0.5*(1100*x^2   509*y^2   33*z^2   1060*x*y   252*y*z   260*z*x)- 60*x- 36*y - 11*z;

subject to
{
-x-y z <= 10;
-x y-z <= 10;
-x y z <= 10;
x-y-z <= 10;
x-y z <= 10;
x y-z <= 10;
x y z <= 10;
-x-y-z <= 10;
}

in OPL CPLEX and got obj -3

x = 0.043662;
y = -0.26761;
z = 1.1831;

and with docplex python I also get the same

from docplex.mp.model import Model

mdl = Model(name='quad')

x=mdl.continuous_var(name='x',lb=-10,ub=10)
y=mdl.continuous_var(name='y',lb=-10,ub=10)
z=mdl.continuous_var(name='z',lb=-10,ub=10)



mdl.minimize(0.5*(1100*x*x   509*y*y   33*z*z   1060*x*y   252*y*z   260*z*x)- 60*x- 36*y - 11*z)


mdl.add(-x-y z <= 10)
mdl.add(-x y-z <= 10)
mdl.add(-x y z <= 10)
mdl.add(x-y-z <= 10)
mdl.add(x-y z <= 10)
mdl.add(x y-z <= 10)
mdl.add(x y z <= 10)
mdl.add(-x-y-z <= 10)

mdl.solve(log_output=True,)

decisionVars=[x,y,z]
for v in decisionVars:
    print(v.name," = ",v.solution_value)

print(mdl.objective_value)
  • Related