为什么IPOPT会在违反约束的情况下评估目标功能? [英] Why does IPOPT evaluate objective function despite breaching constraints?

查看:259
本文介绍了为什么IPOPT会在违反约束的情况下评估目标功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Julia内使用IPOPT.我的目标函数将对某些参数值抛出错误(具体来说,尽管我认为这无关紧要,但它涉及协方差矩阵的Cholesky分解,因此要求协方差矩阵为正定).因此,我会非线性地约束参数,以使它们不会产生错误.尽管有此限制,但IPOPT仍然坚持在参数上评估目标函数,这会导致我的目标函数抛出错误.这导致我的脚本崩溃,导致痛苦和痛苦.

I'm using IPOPT within Julia. My objective function will throw an error for certain parameter values (specifically, though I assume this doesn't matter, it involves a Cholesky decomposition of a covariance matrix and so requires that the covariance matrix be positive-definite). As such, I non-linearly constrain the parameters so that they cannot produce an error. Despite this constraint, IPOPT still insists on evaluating the objective function at paramaters which cause my objective function to throw an error. This causes my script to crash, resulting in misery and pain.

我很感兴趣,为什么IPOPT通常会在违反约束的参数下评估函数. (我已经确保在评估函数之前确实检查了约束.)如果可能的话,我想知道如何才能停止执行此操作.

I'm interested why, in general, IPOPT would evaluate a function at parameters that breach the constraints. (I've ensured that it is indeed checking the constraints before evaluating the function.) If possible, I would like to know how I can stop it doing this.

我已将IPOPT的'bound_relax_factor'参数设置为零;这没有帮助.我知道我可以要求目标函数返回NaN而不是抛出错误,但是当我这样做时,IPOPT似乎变得更加混乱,并且最终没有收敛.可怜的东西.

I have set IPOPT's 'bound_relax_factor' parameter to zero; this doesn't help. I understand I could ask the objective function to return NaN instead of throwing an error, but when I do IPOPT seems to get even more confused and does not end up converging. Poor thing.

如果有帮助,我很高兴提供一些示例代码.

I'm happy to provide some example code if it would help.

在此先感谢:):)

一个评论者建议我在违反约束时要求我的目标函数返回错误的目标值.不幸的是,当我这样做时会发生以下情况:

A commenter suggested I ask my objective function to return a bad objective value when the constraints are violated. Unfortunately this is what happens when I do:

我不确定Ipopt为什么会从评估值为2.0016x10 ^ 2的点变为评估值为10 ^ 10的点-我担心IPOPT有一些根本性的知识,我不了解.

I'm not sure why Ipopt would go from a point evaluating at 2.0016x10^2 to a point evaluating at 10^10 — I worry there's something quite fundamental about IPOPT I'm not understanding.

将"constr_viol_tol"和"acceptable_constr_viol_tol"设置为最小值不会明显影响优化,也不会过度约束"我的参数(即确保它们不能在不可接受的值附近).

Setting 'constr_viol_tol' and 'acceptable_constr_viol_tol' to their minimal values doesn't noticably affect optimisation, nor does 'over-constraining' my parameters (i.e. ensuring they cannot be anywhere near an unacceptable value).

推荐答案

在所有中间迭代中,保证Ipopt满足的唯一约束是变量的简单上限和下限.在求解器在最终迭代中完成收敛之前(如果它可以达到满足终止条件的点),则不一定要满足任何其他线性或非线性等式或不等式约束.在存在任意非凸等式和不等式约束的情况下,保证中间迭代始终是可行的,这是很难解决的.牛顿阶跃方向基于局部一阶和二阶导数信息,因此将是一个近似值,如果问题的曲率不平凡,则可能会留下可行点的空间.考虑以x * y == constant为例的点的空间.

The only constraints that Ipopt is guaranteed to satisfy at all intermediate iterations are simple upper and lower bounds on variables. Any other linear or nonlinear equality or inequality constraint will not necessarily be satisfied until the solver has finished converging at the final iteration (if it can get to a point that satisfies termination conditions). Guaranteeing that intermediate iterates are always feasible in the presence of arbitrary non-convex equality and inequality constraints is not tractable. The Newton step direction is based on local first and second order derivative information, so will be an approximation and may leave the space of feasible points if the problem has nontrivial curvature. Think about the space of points where x * y == constant as an example.

您应该重新编写问题,以避免需要在无效点评估目标或约束函数.例如,不是采用从数据构造的协方差矩阵的Cholesky分解,而是引入单位下三角矩阵L和对角矩阵D.对所有i in 1:size(D,1)施加下界约束D[i, i] >= 0,对非线性等式约束L * D * L' == A施加约束,其中A是您的协方差矩阵.然后在需要进行Cholesky因子分解的任何地方使用L * sqrtm(D)(这可能是半定因子分解,因此比经典的严格正定L * L'因子分解更多地是修正的Cholesky表示形式.)

You should reformulate your problem to avoid needing to evaluate objective or constraint functions at invalid points. For example, instead of taking the Cholesky factorization of a covariance matrix constructed from your data, introduce a unit lower triangular matrix L and a diagonal matrix D. Impose lower bound constraints D[i, i] >= 0 for all i in 1:size(D,1), and nonlinear equality constraints L * D * L' == A where A is your covariance matrix. Then use L * sqrtm(D) anywhere you need to operate on the Cholesky factorization (this is a possibly semidefinite factorization, so more of a modified Cholesky representation than the classical strictly positive definite L * L' factorization).

请注意,如果您的问题是凸的,那么可能会有专门的公式表示圆锥求解器比Ipopt这样的通用非线性求解器更有效.

Note that if your problem is convex, then there is likely a specialized formulation that a conic solver will be more efficient at solving than a general-purpose nonlinear solver like Ipopt.

这篇关于为什么IPOPT会在违反约束的情况下评估目标功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆