fmincon computes all the outputs even with a failed step.

1 visualización (últimos 30 días)
Ravi Kumar Pallantla
Ravi Kumar Pallantla el 12 de Oct. de 2016
Editada: Ravi Kumar Pallantla el 13 de Oct. de 2016
I have an objective function which I am trying to minimize. And I supply the gradient and Hessian along with my objective function. My function looks like
[f,g,h] = myfunc(x);
f = ...;
if nargout>1, g = ...; end
if nargout>2, h = ...; end
fprintf('%d\n',nargout); % I Want to see what outputs fmincon is asking for.
Initially, all the three (f,g,h) are computed as nargout = 3. After the step is calculated,i.e., during 2nd iteration, nargout is still 3 even though I see that the step is a failed step. That is f doesn't decrease using the correction but fmincon still asks to compute gradient and Hessian at this new value of x. Isn't this waste of time(as this value of x is rejected)? (Or) Is it possible to put a condition that gradient and Hessian should be computed only after the correction/step is valid?
Options I use are: Trust-region-reflective algorithm, with 'x' being constrained between some fixed bounds, on matlab2013b. And
options.GradObj = 'on'; options.Hessian = 'on';

Respuestas (1)

Pritesh Shah
Pritesh Shah el 12 de Oct. de 2016
Hi,
First thing, there should be only one output value from your objective function for single objective function. https://in.mathworks.com/products/optimization/features.html#defining-and-solving-optimization-problems
  3 comentarios
Ravi Kumar Pallantla
Ravi Kumar Pallantla el 12 de Oct. de 2016
True, Jacobian or Hessian can also be outputs of objective function. I updated my question saying that I include them in my options.
Walter Roberson
Walter Roberson el 12 de Oct. de 2016
Note: for trust-region-reflective, using option 'Hessian', 'on' requires that the third output of the objective function is the estimated hessian. trust-region-reflective always requires that the second output of the objective function is the gradient (that is, if you do not turn on the GradObj option then it will refuse to use trust-region-reflective)

Iniciar sesión para comentar.

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by