违反非线性约束fmincon内点Matlab

违反非线性约束fmincon内点Matlab,matlab,optimization,Matlab,Optimization,我试图在Matlab中使用fmincon(内点)施加两个非线性约束: sqrt(w*S*w') <= sigmaTgt/sqrt(260) sqrt(w*S*w') >= sigmaTgt/sqrt(260)-0.02/sqrt(260) 但是在优化之后,我一直得到sqrt(w*S*w')满足c(1),但不满足c(2),尽管exitflag为1且解算器已收敛 我写的对吗,还是我的解算器有点问题 来自输出的消息。消息: 找到满足约束条件的局部极小值 优化已完成,因为目标函数为 在可

我试图在Matlab中使用
fmincon(内点)
施加两个非线性约束:

sqrt(w*S*w') <= sigmaTgt/sqrt(260)
sqrt(w*S*w') >= sigmaTgt/sqrt(260)-0.02/sqrt(260)
但是在优化之后,我一直得到
sqrt(w*S*w')
满足
c(1)
,但不满足
c(2)
,尽管
exitflag
为1且解算器已收敛

我写的对吗,还是我的解算器有点问题


来自
输出的消息。消息

找到满足约束条件的局部极小值

优化已完成,因为目标函数为 在可行方向上不递减,在默认值范围内 最优性公差和约束在 约束公差的默认值

停止准则详情:

优化完成:相对一阶优化度量, 9.821943e-07小于options。OptimilityTolerance=1.000000e-06,相对最大约束冲突0.000000e+00小于options 比options.ConstraintTolerance=1.000000e-06

优化度量选项 相对一阶最优性=9.82e-07最优性公差 =1e-06(默认)相对最大值(约束冲突)=0.00e+00约束公差=1e-06(默认)

试一试:

options = optimset('OptimalityTolerance', 1e-20, 'ConstraintTolerance', 1e-20); 
% this may need to be instead started with the function name, depends on your MATLAB version
options = optimset('fmincon','OptimalityTolerance', 1e-20, 'ConstraintTolerance', 1e-20);
fmincon(....., options) % i.e. what you already are passing to fmincon but adding additional tolerances 
如果这能解决你的问题,请告诉我。如果不是,我的变量名可能是错误的,我需要您运行
options=optimset('fmincon')
并将变量名张贴在
options
中以设置公差。另一个选择是更改算法-MATHWORKS说
sqp
通常比您使用的方法更好:

options = optimset('fmincon','Algorithm','sqp','TolConSQP',1e-20) % other choices are 'active-set' or 'trust-region-reflective' and don't have the `TolConSQP` tolerance parameter, which you may not need at all anyhow
当然,如果适用于您的应用程序,您可以使用较低的公差-似乎1e-20对于任何算法都是最大的。
有关文档,请参见此处:

是,因为我将*-1从>=转换为:

你能帮我运行这个吗?options=optimset('fmincon')并在选项中发布变量?然后我可以很快给你一个解决方案,即使我没有优化工具箱。
options = optimset('fmincon','Algorithm','sqp','TolConSQP',1e-20) % other choices are 'active-set' or 'trust-region-reflective' and don't have the `TolConSQP` tolerance parameter, which you may not need at all anyhow