MATLAB Answers

0

why do we need the analytic gradient in fmincon?

Asked by Chantrea Lean on 8 May 2015
Latest activity Commented on by Chantrea Lean on 8 May 2015
Dear sir,
I wondered that using command "fmincon" in matlab without analytic gradient and with analytic gradient we got the same result,so why do we need to use fmincon with analytic gradient ? I think it's very complex in case that we have multi-variables for the input.I noted that number of iteration for fmincon with analytic gradient is less than fmincon without gradient,but for the computation time it's not very different.Some problem I noted that sometime using fmincon without analytic gradient is faster than fmincon with analytic gradient, so why ?
thank you very much
Chantrea

  0 Comments

Sign in to comment.

1 Answer

Answer by Michael Haderlein on 8 May 2015
 Accepted Answer

The algorithm applied (by default interior-point-algorithm, find details here. This algorithm needs the Jacobian, so either you have an analytic solution or the Jacobian will be approximated by finite differences (I guess).
Now, the number of iterations usually is lower if the analytical Jacobian is available, but to what extend strongly depends on the function itself. If the function evaluation is fast, the number of iterations doesn't matter too much. However, there are cases when each function evaluation takes a long time, say, minutes. You'll agree that fast convergence and low number of evaluations will be a huge benefit then.
If you only have to do it a few times only and you get convergence anyway, I wouldn't spent too much time in deriving the Jacobian by hand. If you have to repeat it very often, if the function has trouble to converge, or if computational time is really high, I would try to find an analytical solution. But that's just my personal experience, there might as well be other opinions.

  1 Comment

thank you very much sir,

Sign in to comment.