文档介绍
例5-6 求二次规划的最优解 max f (x1, x2)=x1x2+3 sub. to x1+x2-2=0 解:化成标准形式: x1+x2=2 在Matlab中实现如下: H=[0,-1;-1,0]; C=[0;0]; Aeq=[1 1]; b=2; [x,fval,exitflag,output,lambda] = quadprog(H,C,[ ],[ ],Aeq,b) 结果为: x = sub.to x1+x2=2 标准形式: fval exitflag =4 output = iterations: 1 algorithm: 'large-scale: projective preconditioned conjugate gradients' f irstorderopt: 0 cgiterations: 1 message: 'Optimization terminated: local minimum found; the solution is singular.' lambda = eqlin ineqlin: [ ] lower: [ ] upper: [ ] 结果 xopt=[2.571,1.143,0.000] fopt 求解约束优化问题 . 解:(1)将目标函数写成二次函数的形式 ,其中: [xopt, fopt]=quadprog( H, C, A, b, Aeq, beq, lb, ub, x0, options) (2)编写求解二次规划的M文件: H=[4,-2,0;-2,4,0;0,0,2]; C=[0,0,1]; A=[1,3,2]; b=[6]; Aeq=[2,-1,1]; beq=[4]; lb=zeros(3,1); [xopt,fopt]=quadprig(H,C,A,b,Aeq,beq,l