Corrector Protocols

The protocols module provides protocol definitions for the correction framework.

Corrector Step Protocol

CorrectorStepProtocol()

Protocol for step transformation functions in Newton-type methods.

class hiten.algorithms.corrector.protocols.CorrectorStepProtocol(*args, **kwargs)[source]

Bases: Protocol

Protocol for a step-size control strategy used by backends.

Transforms a Newton step into an accepted update and returns the new point, new residual norm, and effective step scale.

__call__(x, delta, current_norm)[source]

Transform a Newton step into an accepted update.

Parameters:
  • x (np.ndarray) – Current iterate in the Newton method.

  • delta (np.ndarray) – Newton step direction (typically from solving J*delta = -F).

  • current_norm (float) – Norm of the residual at the current iterate x.

Returns:

  • x_new (np.ndarray) – Updated iterate after applying the step transformation.

  • r_norm_new (float) – Norm of the residual at the new iterate x_new.

  • alpha_used (float) – Step-size scaling factor actually employed.

Return type:

Tuple[ndarray, float, float]

__init__(*args, **kwargs)

Corrector Backend Protocol

CorrectorBackendProtocol()

Protocol for backend correctors.

class hiten.algorithms.corrector.protocols.CorrectorBackendProtocol(*args, **kwargs)[source]

Bases: Protocol

Protocol for backend correctors (e.g., Newton).

correct[source]

Correct method for the backend.

Type:

Callable

Parameters:
Return type:

tuple[ndarray, dict]

correct(x0, residual_fn, *, jacobian_fn=None, norm_fn=None, tol=1e-10, max_attempts=25, max_delta=0.01, fd_step=1e-08)[source]

Correct the initial guess for the residual function.

Parameters:
  • x0 (np.ndarray) – Initial guess for the parameter vector.

  • residual_fn (ResidualFn) – Residual function R(x).

  • jacobian_fn (JacobianFn | None) – Optional analytical Jacobian.

  • norm_fn (NormFn | None) – Optional norm function for convergence checks.

  • tol (float) – Convergence tolerance on residual norm.

  • max_attempts (int) – Maximum Newton iterations.

  • max_delta (float | None) – Optional cap on infinity-norm of Newton step.

  • fd_step (float) – Finite-difference step if Jacobian is not provided.

Returns:

  • x_corrected (np.ndarray) – Corrected parameter vector.

  • info (dict) – Convergence information with keys ‘iterations’ and ‘residual_norm’.

Return type:

tuple[ndarray, dict]

__init__(*args, **kwargs)