limit the number of function evaluation per iteration in FSOLVE
5 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
John D'Errico
2017-7-3
编辑:John D'Errico
2017-7-3
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!