
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) 展开
s.t x(1)^2+(x(2)-2)^2>=4
x<=2(2) 展开
展开全部
先在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
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

2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询