Display constraint gradient from fmincon

7 visualizzazioni (ultimi 30 giorni)
Pengfei
Pengfei il 17 Mag 2012
Hi all, I am doing nonlinear optimization using "fmincon". There are both nonlinear objective function and nonlinear constraints. As we know that fmincon calculates the gradient of both the objective and constraint functions through finite differences. Now I want it to display the gradient of the constraint functions in the iteration process. I know how to display the gradient of the objective, with the help of optimValues.gradient. But there is no such a field as gradient regarding the constraint functions.
Any idea? Thank!

Risposte (1)

Alan Weiss
Alan Weiss il 17 Mag 2012
I believe you will have to write your own routine to calculate the gradient you want, and include it in your output function. It should call your constraint function at x and at x + delta for a variety of vectors delta that point in the coordinate directions. Yes, this does seem like a waste of time when you know fmincon has already done the evaluation, but I know of no way of extracting the information from fmincon without editing fmincon itself (or editing a subroutine or two).
It is difficult, in general, to evaluate gradients for all possible nonlinear constraints, because there can be many of them, both equality and inequality constraints. But you know your problem, and can take exactly the gradients you want.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

Community Treasure Hunt

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

Start Hunting!

Translated by