The results obtained by using quadprog and gurobi are quite different
AnsweredI have an optimization problem, but the results obtained by using quadprog and gurobi are quite different. I debugged for a long time but couldn't find the reason, so I came to ask for help.
See the mat file for the data of optimization problem (In the below link).
https://drive.google.com/file/d/1Xf1AtQ6x3wTIl3xO07yXrn8Rn4VjtcNE/view?usp=sharing
The procedure of quadprog is as follows:
qpoptions = optimset('Display','off');
[x, fval, qpexitflag, ~, Lagmultipliers] = quadprog(qpinfo.H, qpinfo.f,...
qpinfo.A, qpinfo.b, qpinfo.Aeq, qpinfo.beq, [], [], [], qpoptions);
The procedure of Gurobi is as follows:
clear params;
params.outputflag = 0;
params.method = -1;
% full problem
clear model;
model.Q = 0.5*sparse(qpinfo.H);
model.obj = full(qpinfo.f);
model.A = sparse([qpinfo.A;qpinfo.Aeq]);
model.rhs = full([qpinfo.b;qpinfo.beq]);
model.sense = [char('<'*ones(size(qpinfo.A,1),1));char('='*ones(size(qpinfo.Aeq,1),1))];
model.modelsense = 'min';
%%
result = gurobi(model, params);
-
Official comment
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
In Gurobi, the lower bounds on variables are \( 0 \) by default. To solve the same problem as \(\texttt{quadprog}\), explicitly remove the lower bounds on the variables:
model.lb = -Inf(size(qpinfo.f));
You can read more about this in the The model argument section of the Gurobi MATLAB documentation.
0
Post is closed for comments.
Comments
2 comments