my nonlinear constraints HAVE to be satisfied, what to do next?
24 次查看(过去 30 天)
显示 更早的评论
I am working on a sophisticated anisotropic tomographic modeling project. I recently learned that the fmincon function in MATLAB does not always honor nonlinear constraints. I am aware that there are codes on GitHub that claim to always honor nonlinear constraints, but I do not have much confidence in GitHub code. My nonlinear constraints are quite complicated: they are 4th order polynomials with 4 variables for my current work. In the future, I may have 15th order polynomials with 20 variables.
I have two questions:
- Is there any MATLAB program that always honors nonlinear constraints?
- If there is no MATLAB program that always honors nonlinear constraints, I may have to write my own code that will always honor nonlinear constraints. I am thinking of boxing or bounding the mth order polynomials with n variables first (of course, this is a complicated task), so that I turn the nonlinear constraints into bound constraints next. Then, I could apply fmincon. Do you have any suggestions?
Thank you very much for your help!
10 个评论
Torsten
2023-5-9
编辑:Torsten
2023-5-9
Project means:
Solve the subproblem of finding the nearest feasible point to the one suggested by fmincon:
min: sum((x-x_suggested_by_fmincon).^2)
s.t.
your constraints on x.
in each call of your objective function.
But maybe evaluating your constraints gives similar problems as evaluating your objective for infeasible points - I don't know.
I think Matt J has more experience than I with optimization (see his answer below and the link I included to a similar discussion).
采纳的回答
Matt J
2023-5-9
编辑:Matt J
2023-5-9
(1) It is not possible to enforce equality constraints (e.g. Snell's Law) exactly , whether linear or non-linear. This is true both during the iterative process or at convergence. This is true for any optimization software app you might pursue. It is a fundamental limitation of finite precision digital computing.
(2) Inequality constraints, whether linear or nonlinear can be enforced at convergence by introducing slack, e.g., instead of c(x)<=0 impose c(x)<=-Delta<0. Set the ConstraintTolerance parameter to be less than Delta. Note: This will not work if your inequality constrained region has no interior, e.g., the constraint x^2<=0, but in this case, it means your inequality constraint should really be written as an equality constraint anyway.
(3) If for some reason, the computation of the objective or nonlinear constraint function cannot be completed for a certain input x, the recommended approach is to just return NaN or Inf. Certain fmincon algorithms like sqp or interior-point can recover from NaN or Inf values encountered during the iterative search.
3 个评论
更多回答(1 个)
Walter Roberson
2023-5-9
If you use surrogateopt then there is no explicit non-linear equality of inequality function parameter. However, you can have the function return a struct in which the field Fval is to be minimized, and the function will try to ensure that the field Ineq <= 0 .
The idea is that the function will be passed a set of model parameters that satisfy the bounds and linear equalities and inequalities, and the function will be responsible for testing nonlinear inequalities itself. If they pass, then compute a valid Fval; if they do not pass then return a high value such as Inf. So you would never compute with the locations that do not pass, because you tested for yourself.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!