问题
Why does Modelica's nonlinear solver oneSolveNonlinearEquation
take more time to solve a nonlinear equation than traditional fixed point iterative (FPI) scheme?
The equation
y= arctan(1-x/1+x)-x
solved by the oneSolveNonlinearEquation
solver (which basically uses Brent's Method) solves the above equation in 6 iterations whereas traditional iterative approach takes 111 iterations. However, the CPU time taken by the iterative scheme is lesser than that taken by the oneSolveNonlinearEquation
solver (see image).
Why is this? Could be due to computational efficiency of the iterative scheme i.e., to say lesser event generation in the iterative scheme?
回答1:
The different root finding methods have different properties. Convergence speed is just one, and it can be counted in number of iterations, or in CPU time. Both will greatly depend on start values, curvature and monotonicity of the function, bounds, cost to evaluate the function, availability of analytic derivatives etc.. Other interesting properties could be guarantee of convergence, or whether derivatives are required.
The Wikipedia article on root finding algorithms gives a good overview of the advantages and disadvantages of the different methods:
- https://en.wikipedia.org/wiki/Root-finding_algorithm
If one method works much better than others for your special case, you should just implement and use it! Be careful when benchmarking, it is very easy to find examples where each method can shine. For this reason, you should test each algorithm on a variety of functions, maybe 10 different ones, and each one with different intervals. Bisection will perform worse for the same function but larger start interval. Brent is a good and proven method, that is why it is used in the MSL. You could even think about sending a Pull Request to the MSL and add alternatives.
来源:https://stackoverflow.com/questions/60260770/simulation-speed-of-nonlinear-solver-in-modelica