risb.optimize.solver_newton module¶
Abstract base class for quasi-Newton methods.
- class risb.optimize.solver_newton.NewtonSolver(history_size=6, n_restart=inf)[source]¶
Bases:
ABC
Base class for quasi-Newton methods to find the root of a function.
- Parameters:
Notes
update_x()
must be defined in the inherited class.- error¶
History of error vector of
x
.- Type:
- g_x¶
History of fixed point function with
x
as the input.- Type:
- solve(fun, x0, args=(), tol=1e-12, maxiter=1000, options=None)[source]¶
Find the root of a function. It is called similarly to :func:scipy.optimize.root.
- Parameters:
fun (callable) – The function to find the root of. It must be callable as
fun(x, *args)
.x0 (numpy.ndarray) – Initial guess of the parameters. This does not neccessarily have to be flattened, but it usually is.
args (tuple, optional) – Additional arguments to pass to
fun
.tol (float, optional) – The tolerance. When the 2-norm difference of the return of
fun
is less than this, the solver stops.maxiter (int, optional) – Maximum number of iterations.
options (dict, optional) – keyword arguments to pass to
update_x()
.
- Returns:
Root of
fun
.- Return type:
- abstract update_x(**kwargs)[source]¶
Return a single iteration for the new guess for
x
.- Parameters:
**kwargs (dict) – Keyword arguments specific to the solver implementation.
- Returns:
New guess for x to add to history.
- Return type:
- x¶
History of guesses to the root problem.
- Type: