線性規划
線性規划的標准形式
\[\underset{x}{min}{\ c^Tx}\ s.t.\ Ax \leqslant b \]
例如,線性規划為:
\[\underset{x}{min}{\ c^Tx} \ s.t. \ Ax \geqslant b \]
其matlab標准形式為:
\[\underset{x}{min}{\ -c^Tx}\ s.t. -AX \leqslant -b \]
matlab指令為:
【例】求解線性規划問題:
\[min\ z = 2x_1+3x_2+x_3 \]
\[s.t.\begin{cases} x_1+4x_2+2_x3 \geqslant 8\\ 3x_1+2x_2 \geqslant 6\\ x_1,x_2,x_3 \geqslant 0 \end{cases} \]
編寫matlab程序如下:
c = [2;3;1];
a = [1,4,2;3,2,0];
b = [8;6]
[x,y] = linprog(c,-a,-b,[],[],zeros(3,1))
這里-a,-b即是為了將不等式化為標准形式$$(Ax \geqslant b化成 -Ax \leqslant -b)$$
參考書籍:Matlab在數學中的應用(第二版)卓金武