24小时热门版块排行榜    

CyRhmU.jpeg
南方科技大学公共卫生及应急管理学院2026级博士研究生招生报考通知(长期有效)
查看: 2041  |  回复: 2

椋木迪

新虫 (小有名气)

[求助] fmincon函数求解非线性约束优化问题出错已有1人参与

我用fmincon函数求解一个非线性约束优化问题总是算不出结果,不知道哪里出问题了,求大佬帮忙看看,一下是代码:
x0=[3.6;0.8;19;7.8;7.6;3.5;5.2];
A=[];b=[];
Aeq=[];beq=[];
lb=[2.6;0.7;17;7.3;7.3;2.9;5.0];ub=[3.6;0.8;28;8.3;8.3;3.9;5.5];
[x,fval,exitflag,output,lambda,grad,hessian]=fmincon(@myfun,x0,A,b,Aeq,beq,lb,ub,@mycon);

function [c,ceq] = mycon(x)
c(1)=27/(x(1)*x(2)^2*x(3))-1;
c(2)=397.5/(x(1)*x(2)^2*x(3)^2)-1;
c(3)=1.93*x(4)^3/(x(2)*x(3)*x(6)^4)-1;
c(4)=1.93*x(5)^3/(x(2)*x(3)*x(7)^4)-1;
c(5)= 10*x(6)^(-3)*sqrt((745*x(2)^(-1)*x(3)^(-1)*x(4))^2+1.69*10^7)-1100;
c(6)=10*x(7)^(-3)*sqrt((745*x(2)^(-1)*x(3)^(-1)*x(5))^2+1.575*10^8)-850;
c(7)=(1.5*x(6)+1.9)/x(4)-1;
c(8)=(1.1*x(7)+1.9)/x(5)-1;
c(9)=x(2)*x(3)-40;
c(10)=5-x(1)/x(2);
c(11)=x(1)/x(2)-12;
ceq = [];

function y = myfun(x)
y = 0.7854*x(1)*x(2)^2*(3.333*x(3)^2+14.9334*x(3)-43.0934)-1.5079*x(1)*(x(6)^2+x(7)^2)+7.477*(x(6)^3+x(7)^3)+0.7854*(x(4)*x(6)^2+x(5)*x(7)^2);

以下是MATLAB里的提示:
Local minimum found that satisfies the constraints.

Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the optimality tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.

<stopping criteria details>


Optimization completed: The relative first-order optimality measure, 7.082717e-09,
is less than options.OptimalityTolerance = 1.000000e-06, and the relative maximum constraint
violation, 0.000000e+00, is less than options.ConstraintTolerance = 1.000000e-06.

Optimization Metric                                            Options
relative first-order optimality =   7.08e-09       OptimalityTolerance =   1e-06 (default)
relative max(constraint violation) =   0.00e+00    ConstraintTolerance =   1e-06 (default)
由于是第一次用MATLAB来求解优化问题,所很多地方不懂,请多多指教,谢谢各位大神了。
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

somomo91

专家顾问 (职业作家)

【答案】应助回帖

感谢参与,应助指数 +1
这个问题很常见,找不到全局最优,只有局部最优
可以试着
1. 改变初始值
2. 修改 fmincon 的参数,比如算法等等
2楼2018-05-23 02:25:44
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

椋木迪

新虫 (小有名气)

引用回帖:
2楼: Originally posted by somomo91 at 2018-05-23 02:25:44
这个问题很常见,找不到全局最优,只有局部最优
可以试着
1. 改变初始值
2. 修改 fmincon 的参数,比如算法等等

fmincon函数不返回局部最优解么?最后没有结果出来。另外初始值修改过了,还是不行,sqp和set-active算法也同样不行。还有其他办法吗
3楼2018-05-23 14:25:12
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 椋木迪 的主题更新
信息提示
请填处理意见