How can I call intermediate functions within fmincon?

2 次查看(过去 30 天)
I am trying to minimize a nonlinear problem using fmincon. The evaluation of my objective, f, and constraints, g, require not only a vector of design variables, x, but also a vector of state variables, y(x), i.e. f = f(x,y(x)) and g = g(x,y(x)). The evaluation of y for a certain x is performed through an expensive fixed-point iteration procedure.
I am having difficulties injecting this iteration procedure efficiently into fmincon. I want to run the procedure only once for every vector x that fmincon returns and then feed the resulting y into f and g. However, due to the input structure of fmincon, I am forced to run the procedure once for every call to f or g, instead of once for every x. I cannot combine the x and y vectors, as fmincon will mistake y for design variables. I also cannot run the procedure externally from fmincon, as y changes depending on x.
I am considering two solutions to this, one using global variables, and the other using the 'Outputfcn' field in optimoptions. I have not explored both solutions in detail yet. 'Outputfcn' does not look too promising though, as its documentation specifies that it can only used for displaying data from the algorithm, but can not be used for setting values.

采纳的回答

Alan Weiss
Alan Weiss 2018-8-31
It is possible that you could use the technique in Objective and Nonlinear Constraints in the Same Function.
Alan Weiss
MATLAB mathematical toolbox documentation

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by