用matlab解非线性规划问题
目标函数:functionf=fun3(x);f=3000/x(1)+180/x(2)+2160/x(3)+210/x(4)+2700*0.2/x(5)+82.25;约束...
目标函数:function f= fun3(x);
f=3000/x(1)+180/x(2)+2160/x(3)+210/x(4)+2700*0.2/x(5)+82.25;
约束条件:x1+x2+x4+x4+x5=23.5;
0<x1,x2,x3,x4,x5<23.5
代码:
x0=[4.7;4.7;4.7;4.7;4.7];
A=[];
b=[];
Aeq=[1 1 1 1 1];beq=[23.5];
VLB=[0;0;0;0;0];VUB=[23.5;23.5;23.5;23.5;23.5];
[x,fval]=fmincon('fun3',x0,A,b,Aeq,beq,VLB,VUB);
出错:Warning: Trust-region-reflective method does not currently solve this type of
problem,
using active-set (line search) instead.
求教 我是新手 展开
f=3000/x(1)+180/x(2)+2160/x(3)+210/x(4)+2700*0.2/x(5)+82.25;
约束条件:x1+x2+x4+x4+x5=23.5;
0<x1,x2,x3,x4,x5<23.5
代码:
x0=[4.7;4.7;4.7;4.7;4.7];
A=[];
b=[];
Aeq=[1 1 1 1 1];beq=[23.5];
VLB=[0;0;0;0;0];VUB=[23.5;23.5;23.5;23.5;23.5];
[x,fval]=fmincon('fun3',x0,A,b,Aeq,beq,VLB,VUB);
出错:Warning: Trust-region-reflective method does not currently solve this type of
problem,
using active-set (line search) instead.
求教 我是新手 展开
1个回答
展开全部
x0=[4.7;4.7;4.7;4.7;4.7];
A=[];
b=[];
Aeq=[1 1 1 1 1];beq=[23.5];
VLB=[1e-4;1e-4;1e-4;1e-4;1e-4];VUB=[23.5;23.5;23.5;23.5;23.5];
options=optimset('largescale','off','display','final','tolx',1e-16,'tolfun',1e-16,'MaxFunEvals',600000,'MaxIter',30000);
[x,fval,exitflag,output]=fmincon(@fun3,x0,A,b,Aeq,beq,VLB,VUB,[],options);
disp('fval=');
disp(fval);
disp('exitflag=');
disp(exitflag);
disp('output=');
disp(output);
disp('x=');
disp(x);
运行结果
Optimization terminated: Search direction less than 2*options.TolX
and maximum constraint violation is less than options.TolCon.
No active inequalities
fval=
1.0705e+003
exitflag=
4
output=
iterations: 147
funcCount: 1072
stepsize: 1
algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'
firstorderopt: 4.6830e-006
cgiterations: []
message: [1x129 char]
x=
8.4462
2.0689
7.1668
2.2347
3.5834
下界不要是0,那样会出现除数为0的错误,也不要太小,太小也可能搜索不到。
A=[];
b=[];
Aeq=[1 1 1 1 1];beq=[23.5];
VLB=[1e-4;1e-4;1e-4;1e-4;1e-4];VUB=[23.5;23.5;23.5;23.5;23.5];
options=optimset('largescale','off','display','final','tolx',1e-16,'tolfun',1e-16,'MaxFunEvals',600000,'MaxIter',30000);
[x,fval,exitflag,output]=fmincon(@fun3,x0,A,b,Aeq,beq,VLB,VUB,[],options);
disp('fval=');
disp(fval);
disp('exitflag=');
disp(exitflag);
disp('output=');
disp(output);
disp('x=');
disp(x);
运行结果
Optimization terminated: Search direction less than 2*options.TolX
and maximum constraint violation is less than options.TolCon.
No active inequalities
fval=
1.0705e+003
exitflag=
4
output=
iterations: 147
funcCount: 1072
stepsize: 1
algorithm: 'medium-scale: SQP, Quasi-Newton, line-search'
firstorderopt: 4.6830e-006
cgiterations: []
message: [1x129 char]
x=
8.4462
2.0689
7.1668
2.2347
3.5834
下界不要是0,那样会出现除数为0的错误,也不要太小,太小也可能搜索不到。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询