my nonlinear constraints HAVE to be satisfied, what to do next?
Show older comments
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 Comments
Walter Roberson
on 9 May 2023
In the future, I may have 15th order polynomials with 20 variables.
Yikes! Unless the range of inputs is -1 to +1, 15th order polynomials are likely to involve a lot of numeric noise!
4th order polynomials are not so bad, but establishing bounds for them can be sensitive to numeric noise, especially at the place where the branches "cross".
Jon
on 9 May 2023
When you say "always honors nonlinear constraints", do you mean are the constraints always enforced as it iterates to a solution (that is the path to the solution is always feasible) or do you mean does the algorithm always converge to a feasible (non-linear constraints honored) solution?
I think either way there are options within MATLAB that will do this.
Torsten
on 9 May 2023
You wrote in another post about the consequences if the constraints are not satisfied:
The problem is not physical. For example, (1) energy becomes negative; (2) Snell's law is violated.
But does it really matter if during the iteration process, energy becomes negative and/or Snell's law is violated ? My guess is it would be adjusted a few iterations later.
Frank
on 9 May 2023
Walter Roberson
on 9 May 2023
fmincon does not check nonlinear constraints before running the objective function for every set of model parameters. (For one thing, it does not check them during the initial estimate of the jacobian, if I recall correctly.)
The poster is looking for a way to ensure that every trial model parameters passed to the objective function already satisfy all constraints.
Frank
on 9 May 2023
To Torsten: Thank you very much! It matters. If energy becomes negative or Snell's law is violated, that means I can't finish computing the objective function.
Then first project the infeasible points onto the feasible region defined by your constraints and evaluate your objective function with the result obtained after this projection:
Frank
on 9 May 2023
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).
Accepted Answer
More Answers (1)
Walter Roberson
on 9 May 2023
0 votes
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.
1 Comment
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!