MATLAB求解非线性规划问题 10

minf(x)=(x(1)-2)^2+(x(2)-3)^2s.tx(1)^2+(x(2)-2)^2>=4x<=2(2)... min f(x)=(x(1)-2)^2+(x(2)-3)^2
s.t x(1)^2+(x(2)-2)^2>=4
x<=2(2)
展开
 我来答
chendequan610
2009-12-29 · TA获得超过1904个赞
知道小有建树答主
回答量:201
采纳率:100%
帮助的人:159万
展开全部
先在MATLAB编辑器中建立非线性约束函数文件:
function [c,ceq]=my(x)
c=4-x(1)^2-(x(2)-2)^2;
ceq=[];
另存为my.m
在命令窗口键入如下命令:
>> fun='(x(1)-2)^2+(x(2)-3)^2';
>> [x,fval,exitflag,output,lambda]=fmincon(fun,rand(2,1),[],[],[],[],[],[inf;2],@my)
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 260
Optimization terminated: first-order optimality measure less than options.TolFun
and maximum constraint violation is less than options.TolCon.
Active inequalities (to within options.TolCon = 1e-006):
lower upper ineqlin ineqnonlin
2

x =

2.0000
2.0000

fval =

1.0000

exitflag =

1

output =

iterations: 5
funcCount: 23
stepsize: 1
algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'
firstorderopt: 3.8545e-013
cgiterations: []
message: [1x143 char]

lambda =

lower: [2x1 double]
upper: [2x1 double]
eqlin: [0x1 double]
eqnonlin: [0x1 double]
ineqlin: [0x1 double]
ineqnonlin: 2.2352e-007>> fun='(x(1)-2)^2+(x(2)-3)^2';
>> [x,fval,exitflag,output,lambda]=fmincon(fun,rand(2,1),[],[],[],[],[],[inf;2],@my)
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 260
Optimization terminated: first-order optimality measure less than options.TolFun
and maximum constraint violation is less than options.TolCon.
Active inequalities (to within options.TolCon = 1e-006):
lower upper ineqlin ineqnonlin
2

x =

2.0000
2.0000

fval =

1.0000

exitflag =

1

output =

iterations: 5
funcCount: 23
stepsize: 1
algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'
firstorderopt: 3.8545e-013
cgiterations: []
message: [1x143 char]

lambda =

lower: [2x1 double]
upper: [2x1 double]
eqlin: [0x1 double]
eqnonlin: [0x1 double]
ineqlin: [0x1 double]
ineqnonlin: 2.2352e-007
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式