当我试图解决一个非常简单的装箱问题时,Gurobi求解器根本不起作用。我确实尝试了一些非常简单的带有1不等式约束的Gurobi优化问题,它是有效的。但对于复杂的小问题,它总是返回NA。我很沮丧。如果有人能帮助,非常感谢您的帮助
%% 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
这是错误信息
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
尝试使用这些命令而不是Gurobi求解器
cvx_solver Gurobi_3
或
cvx_solver Gurobi_2
使用Gurobi作为cvx的外部求解器似乎不是一个明智的选择。请参阅:http://ask.cvxr.com/t/cvx-with-gurobi-error-warning/7072/3.他们几个月前就报告了这个错误。