why do we need the analytic gradient in fmincon?
4 views (last 30 days)
Show older comments
Commented: Chantrea Lean on 8 May 2015
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
Michael Haderlein on 8 May 2015
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.
More Answers (0)
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!