Skip to main content

IncrementalSolver

Trait IncrementalSolver 

Source
pub trait IncrementalSolver: SolverAlgorithm {
    // Provided methods
    fn solve_on_change(
        &self,
        matrix: &dyn Matrix,
        prev_solution: &[Precision],
        delta: &SparseDelta,
        options: &SolverOptions,
    ) -> Result<SolverResult> { ... }
    fn solve_on_change_with(
        &self,
        matrix: &dyn Matrix,
        prev_solution: &[Precision],
        delta: &SparseDelta,
        options: &SolverOptions,
        _inc_config: &IncrementalConfig,
    ) -> Result<SolverResult> { ... }
}
Expand description

Extension trait that adds an event-gated entry point to any SolverAlgorithm. Blanket-implemented below, so every solver in the crate gets solve_on_change for free.

Provided Methods§

Source

fn solve_on_change( &self, matrix: &dyn Matrix, prev_solution: &[Precision], delta: &SparseDelta, options: &SolverOptions, ) -> Result<SolverResult>

Solve A·x = b_prev + delta given prev_solution ≈ A⁻¹ · b_prev.

The default impl reconstructs b_new = A·prev_solution + delta and runs a warm-started solve. Implementations may override for algorithm-specific shortcuts (e.g. push-style solvers can localise work to the support of delta).

Source

fn solve_on_change_with( &self, matrix: &dyn Matrix, prev_solution: &[Precision], delta: &SparseDelta, options: &SolverOptions, _inc_config: &IncrementalConfig, ) -> Result<SolverResult>

As solve_on_change, but with explicit IncrementalConfig for tuning the warm-start / full-fallback boundary.

Uses the residual-correction pattern:

r   = b_new − A·prev_solution        ( ≈ delta when prev is converged )
dx  = A⁻¹ · r                         ( inner solve on a small RHS )
x_new = prev_solution + dx

This is the right framing because most iterative solvers in this crate do not honour SolverOptions::initial_guess correctly — e.g. Neumann’s compute_next_term adds the k=0 series term on top of solution, which means feeding it a non-zero initial guess double-counts. Solving for the correction dx from zero avoids that entire failure mode and asymptotically requires fewer iters because ||r|| ≪ ||b_new|| for small deltas — Neumann’s geometric convergence rate makes the iteration count drop proportionally to log(||r||/||b_new||).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§