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!