t0 x 1+x2-2 = 0
解決方案:轉換成標準形式:
sub to x 1+x2 = 2
在Matlab中實現如下:
& gt& gth =;
& gt& gtf =[0;0];
& gt& gtaeq =[1 1];
& gt& gtb = 2;
& gt& gt[x,fval,exitflag,output,lambda] = quadprog(H,f,[ ],[ ],Aeq,b)
結果如下:
x =
1.0000
1.0000
fval =
-1.0000
exitflag =
1
輸出=
firstorderopt: 0
叠代次數:1
cgiterations: 1
算法:[1x58 char]
λ=
eqlin: 1.0000
ineqlin: [ ]
下限:[ ]
上:[ ]