【问题标题】:Violation nonlinear constraints fmincon interior-point Matlab违反非线性约束 fmincon 内点 Matlab
【发布时间】:2017-11-08 15:12:50
【问题描述】:

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

sqrt(w*S*w') <= sigmaTgt/sqrt(260)
sqrt(w*S*w') >= sigmaTgt/sqrt(260)-0.02/sqrt(260)

我尝试了以下方法:

function [c,ceq] = in_nonlconstr(w, S)

    c(1) = sqrt(w*S*w') - tgtVolAnn/sqrt(260);
    c(2) = - sqrt(w*S*w') + ( tgtVolAnn/sqrt(260) - 0.02/sqrt(260) );
    ceq = [];

end

但在优化之后,我不断得到 sqrt(w*S*w') 满足 c(1) 但不满足 c(2),尽管 exitflag 为 1 并且求解器已经收敛。

我写得对还是我的求解器有问题?


来自output.message的消息:

找到满足约束的局部最小值。

优化完成,因为目标函数是 在可行方向上不减少,在默认值范围内 最优性容差和约束满足在 约束容差的默认值。

停止条件详情:

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

优化指标选项 相对一阶最优性 = 9.82e-07 OptimalityTolerance = 1e-06(默认)相对最大值(违反约束)= 0.00e+00 ConstraintTolerance = 1e-06(默认)

【问题讨论】:

  • 是的,因为我将 *-1 用于从 >= 转换为
  • 你能为我运行这个吗? options = optimset('fmincon') 并在选项中发布变量?那么即使我没有优化工具箱,我也可以相当快地给你一个解决方案。

标签: matlab optimization


【解决方案1】:

试一试:

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 是所有算法中最大的。 有关文档,请参见此处:http://www.mathworks.com/help/optim/ug/fmincon.html#inputarg_options

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-29
    • 2016-03-31
    • 2021-06-17
    • 1970-01-01
    • 1970-01-01
    • 2022-07-05
    • 1970-01-01
    • 2012-11-01
    相关资源
    最近更新 更多