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