Azzera filtri
Azzera filtri

limit the number of function evaluation per iteration in FSOLVE

6 visualizzazioni (ultimi 30 giorni)
Hello,
I'm hoping to set a bound to the number of function evaluation per stage in fsolve.
What I mean is this: with MaxFunctionEvaluations = 100, MaxIterations = 10, I want to enforce that each of the 10 iteration (until convergence) actually does MaxFunctionEvaluations/MaxIterations = 10 evaluation.
With MaxFunctionEvaluations set to the default value, MaxIterations = 10, I'm still getting Func-count = 3457 on the first iteration. My goal is to limit the number of evaluation per interation.
I'm not sure if this is possible. I appreciate all the help.
Thank you in advance.

Risposta accettata

John D'Errico
John D'Errico il 3 Lug 2017
Modificato: John D'Errico il 3 Lug 2017
Sorry, but you can't force fsolve to have this behavior, since that would require re-writing fsolve. It simply is not one of the available options.
If you are getting that many function evaluations, then it is almost certain that you have very many variables. Large problems require a lot of function evaluations. Just wanting something to take less time is not enough, unless your name is Harry Potter.
So while you don't say how many unknowns, this is surely a quite large problem. Since fsolve uses finite differences to compute the Jacobian at each iteration, this is certainly why it takes so many function evals per iteration. Most of them are spent on just computing the derivatives.
Some people may choose to suggest that you supply the Jacobian separately. Sorry, but that is almost never a real gain in speed, because computing those derivatives will take a large amount of time, even if you can do so analytically. So if you have n unknowns, and your function requires time T to compute one function evaluation, then computing the Jacobian matrix numerically will require roughly (n+1) function evaluations using finite differences. So the time is roughly O(n*T). As it turns out, computing the derivatives of a function is often more complicated than computing the function itself. But even if each of them also requires time T to compute, then the Jacobian will still require O(n+T) time to compute. So you gain essentially nothing at all.
Big problems require big time.
  1 Commento
Sidafa
Sidafa il 5 Lug 2017
Thank you so much for this. Walking through the fsolve code, I did find that bulk of the function evaluation was spent in the Jacobian evaluation.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by