0

When I was trying to solve a very simple bin packing problem, the Gurobi solver just won't work. I do try some very simple optimization problem with 1 inequality constraint with Gurobi and it works. But it always return NA for little complicated ones. I am quite frustrated. Highly appreciate for help if anyone can help

%% By Linear programming
clear;clc;
weight = [4,4,5,7]';
cvx_begin
cvx_solver SDPT3
variables I(4,1) X(4,4)
minimize sum(I)
subject to
    X * weight <= 10 * I;
    sum(X) == [1,1,1,1];
    X >= 0
    X <= 1
    I >= 0
    I <= 1
cvx_end

X
I

%% By Integer programming
clear;clc;
weight = [4,4,5,7]';
cvx_begin
cvx_solver Gurobi
variables I(4,1) X(4,4)
minimize sum(I)
subject to
    X * weight <= 10 * I
    sum(X) == [1,1,1,1]
    X >= 0
    X <= 1
    I >= 0
    I <= 1
cvx_end

X
I

And this is the error message

 
Calling Gurobi 9.00: 44 variables, 28 equality constraints
------------------------------------------------------------
------------------------------------------------------------
Status: Error
Optimal value (cvx_optval): NaN
 
Error using cvx_end (line 267)
model.quadcon must be a struct array with fields q, and rhs
Ray Jio
  • 21
  • 2
  • It seems you need to specify the `quadcons` argument when using cvx. You might want to use Gurobi standalone for these problems. – mattmilten Dec 16 '20 at 13:28
  • @mattmilten I don't quite get it. So how to use quadcons in this case? BTW I just find that my friends can run the exact code on his Matlab. – Ray Jio Dec 17 '20 at 10:38
  • Uhh, it's stressful to solve it. And I just googled my own question lol – Ray Jio Dec 17 '20 at 10:43

1 Answers1

0

Try use these commands instead of Gurobi solver

cvx_solver Gurobi_3

or

cvx_solver Gurobi_2

Seems using Gurobi as external solver of cvx is not a wise choice. See: http://ask.cvxr.com/t/cvx-with-gurobi-error-warning/7072/3. They have reported the bug a few months ago.

Ray Jio
  • 21
  • 2