应用 MATLAB优化工具箱编程,求解如下不等式约束优化问题。

如题所述

x0=[0;0];
VLB=[0 0];VUB=[];
[x,fval,exitflag,output]=fmincon('myfun1',x0,[],[],[],[],VLB,VUB,'mycon1')

% 几何法
figure;
plot(x(1),x(2),'ro'); hold on;
ezplot('x^2+y^2-4*x+4-3.7989');
ezplot('-x+y-2');
ezplot('x^2-y+1');
grid on;

两个函数文件

function f=myfun1(x)
    f=x(1)^2+x(2)^2-4*x(1)+4;
end

function [g,ceq]=mycon1(x)
g=[-x(1)+x(2)-2; x(1)^2-x(2)+1];
ceq=0;


最优化问题从几何上看是在第一象限(x1,x2>0), 直线即抛物线之下(两个约束条件), 最大的椭圆

温馨提示:答案为网友推荐,仅供参考
相似回答