0
我想在Matlab中使用Gurobi求解器,但我不知道如何计算所需的矩阵(qrow和qcol)。Gurobi求解器在matlab中
仅供参考,我正在复制文档中提供的示例。
0.5 x^2 - xy + y^2 - 2x - 6y
受到
x + y <= 2
-x + 2y <= 2, 2x + y <= 3, x >= 0, y >= 0
c = [-2 -6]; % objective linear term
objtype = 1; % minimization
A = sparse([1 1; -1 2; 2 1]); % constraint coefficients
b = [2; 2; 3]; % constraint right-hand side
lb = []; % [ ] means 0 lower bound
ub = []; % [ ] means inf upper bound
contypes = '$<<
vtypes = [ ]; % [ ] means all variables are continuous
QP.qrow = int32([0 0 1]); % indices of x, x, y as in (0.5 x^2 - xy + y^2); use int64 if sizeof(int) is 8 for you system
QP.qcol = int32([0 1 1]); % indices of x, y, y as in (0.5 x^2 - xy + y^2); use int64 if sizeof(int) is 8 for you system
QP.qval = [0.5 -1 1]; % coefficients of (0.5 x^2 - xy + y^2)
这是否意味着,如果我有4个决策变量不是我应该使用0,1,2,3作为我的决策变量指标X_1,X_2,X_3,X_4 。?
感谢
注:我试图用mathurl.com,但我不明白如何以正确的格式显示,它会显示为乳胶文字书写。对于这个符号很抱歉。
非常感谢。 – user649046 2011-03-12 20:39:36
@ user649046:如果您发现我的回答有用,您可能会喜欢投票。谢谢 – eat 2011-03-14 12:00:36