pathsim.optim.anderson module¶
- class pathsim.optim.anderson.Anderson(m=5, restart=False)[source]¶
Bases:
objectClass for accelerated fixed-point iteration through anderson acceleration. Solves a nonlinear set of equations given in the fixed-point form:
x = g(x)
Anderson Accelerstion tracks the evolution of the solution from the previous iterations. The next step in the iteration is computed as a linear combination of the previous iterates. The coefficients are computed to minimize the least squares error of the fixed-point problem.
- class pathsim.optim.anderson.NewtonAnderson(m=5, restart=False)[source]¶
Bases:
AndersonModified class for hybrid anderson acceleration that can use a jacobian ‘jac’ of the function ‘g’ for a newton step before the fixed point step for the initial estimate before applying the anderson acceleration.
If a jacobian ‘jac’ is available, this significantly improves the convergence (speed and robustness) of the solution.
- solve(func, x0, jac=None, iterations_max=100, tolerance=1e-06)[source]¶
Solve the function ‘func’ with initial value ‘x0’ up to a certain tolerance.
- Parameters:
Note
This method is for testing purposes only and not used in the simulation loop.
- Returns:
x (numeric) – solution
res (float) – residual
i (int) – iteration count