MATLAB Answers

Problem with fmincon fval

4 views (last 30 days)
Koen Franse
Koen Franse on 19 Feb 2021
Edited: Matt J on 21 Feb 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 Comment
Walter Roberson
Walter Roberson on 19 Feb 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.

Sign in to comment.

Answers (1)

Matt J
Matt J on 19 Feb 2021
Edited: Matt J on 19 Feb 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 Comments
Matt J
Matt J on 19 Feb 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.

Sign in to comment.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by