Problem with fmincon fval

2 visualizaciones (últimos 30 días)
Koen Franse
Koen Franse el 19 de Feb. de 2021
Editada: Matt J el 21 de Feb. de 2021
Hi,
I have a problem with my fmincon algorithm (settings probably). I have a separate costfunction that launches an external Finite Element model. However the fval of the first two iterations does not change. Therefore I decided to look into the fval values that result from the cost function. This is the output of my script:
Start fmincon
fval=1.211629e-06
fval=1.211628e-06
fval=1.211630e-06
fval=1.211593e-06
fval=1.211664e-06
fval=1.211465e-06
fval=1.211792e-06
First-order Norm of
Iter F-count f(x) Feasibility optimality step
0 7 1.211629e-06 0.000e+00 2.436e-12
fval=1.211629e-06
fval=1.211628e-06
fval=1.211630e-06
fval=1.211465e-06
fval=1.211792e-06
fval=1.211593e-06
fval=1.211664e-06
1 14 1.211629e-06 0.000e+00 2.436e-12 6.821e-09
fval=1.211629e-06
fval=1.211628e-06
fval=1.211630e-06
fval=1.211593e-06
fval=1.211664e-06
fval=1.211465e-06
fval=1.211792e-06
2 21 1.211629e-06 0.000e+00 2.436e-12 6.821e-09
I think it's strange that fmincon appears to start with the same input every iteration, since the first fval printed is the same every iteration. I would expect that f(x) would be equal to the lowest fval of that iteration, and that the algorithm would start from that input in the next iteration?
Anyone any idea what is going wrong? Or do I misunderstand something?
Thanks in advance!
  1 comentario
Walter Roberson
Walter Roberson el 19 de Feb. de 2021
I wonder if it is estimating the jacobian at that point?
Do you have any constraints? Some kind of constraints are defined to be done before any evaluation; some kinds of constraints are defined to be disabled during the initial estimation of the jacobian; during the main run, the order of applying linear constraints and nonlinear constraints is not defined.

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 19 de Feb. de 2021
Editada: Matt J el 19 de Feb. de 2021
As Walter suggests, the multiple fvals per iteration are part of finite difference computations needed to evaluate the cost function gradient. They are not used by fmincon to track cost function descent.
Note that the points where these function evaluations take place do not necessarily respect constraints (except perhaps lb, ub bounds), and therefore do not necessarily represent opportunities for progress by the optimization. If you have general linear (A, Aeq, b,beq) or non-linear constraints, some of those fvals can be for nearby non-feasible points, even if the current iterate itself is feasible.
  2 comentarios
Koen Franse
Koen Franse el 19 de Feb. de 2021
Hi Matt and Walter,
I've only applied an lb and ub constraint; I've also checked the input values of the cost function for these runs, and they are within the applied constraints.
The fact that the fval evaluations are performed to evaluate the cost function gradient and not for the cost function descent, makes it a little more clear for me. However I then would expect that if different fvals are found in iteration 0, a gradient can be computed and fmincon would start at a different (and better) point in the next iteration.
Matt J
Matt J el 19 de Feb. de 2021
Editada: Matt J el 21 de Feb. de 2021
However I then would expect that if different fvals are found in iteration 0,a gradient can be computed and fmincon would start at a different (and better) point in the next iteration.
Well, we have no reason to believe that that isn't the case. Just because progress is not evident when displaying fval to 6 decimal places doesn't mean that no progress is occurring.
Note that it is not generally guaranteed that fmincon will be monotonically decreasing in fval, though it might be true here since you only have bound constraints.

Iniciar sesión para comentar.

Categorías

Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by