How do I use the patternsearch function for constraints that must be computed after the objective function?

2 views (last 30 days)
I have an objective function and a nonlinear unequality constraint whome both are computed by seperate simulation models. Some of the output of the objective function simulation model works as input to the constraint simulation model. How do I formulate the calls with the patternsearch function for such optimization problems?

Answers (1)

Matt J
Matt J on 13 Aug 2015
Edited: Matt J on 13 Aug 2015
You can't control whether objective function will be called first, so you must move the "objective function simulation" to its own a separate function doFirstSim() which both your objective and constraint functions can call when needed. If the constraint function is called first, it needs to be the one to trigger that simulation.
However, using the technique discussed here,
you can at least make sure that the simulation is not repeated unnecessarily and can be re-used by other functions that are considering the same point x.
In your case, the "ImportantQuantity" mentioned in the thread is the output of doFirstSim(). Using the technique in the thread, it will only get regenerated when a refresh of the simulation is needed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!