pub struct NewtonRaphsonSolver { /* private fields */ }Expand description
Newton-Raphson solver for systems of nonlinear equations
This solver can handle:
- Square systems (equations == variables)
- Under-constrained systems (equations < variables) - uses least squares
- Over-constrained systems (equations > variables) - uses least squares
The solver uses adaptive damping and regularization for numerical stability.
Implementations§
Source§impl NewtonRaphsonSolver
impl NewtonRaphsonSolver
Sourcepub fn new(compiled: CompiledSystem) -> Self
pub fn new(compiled: CompiledSystem) -> Self
Create a new Newton-Raphson solver with adaptive parameters
Parameters are automatically adjusted based on system type:
- Over-constrained systems get more iterations, relaxed tolerance, conservative damping
- Normal systems use standard parameters for fast convergence
§Arguments
compiled- Compiled system of equations (each should evaluate to 0 at solution)
Sourcepub fn new_with_mode(
compiled: CompiledSystem,
mode: Mode,
) -> Result<Self, SolverError>
pub fn new_with_mode( compiled: CompiledSystem, mode: Mode, ) -> Result<Self, SolverError>
Create a new solver with an explicit execution mode.
Sourcepub fn new_with_variables(
compiled: CompiledSystem,
variables: &[&str],
) -> Result<Self, SolverError>
pub fn new_with_variables( compiled: CompiledSystem, variables: &[&str], ) -> Result<Self, SolverError>
Create a solver while specifying which variables to solve for.
Variables not listed here are treated as fixed parameters and must be provided in the initial guess.
Sourcepub fn new_with_variables_and_mode(
compiled: CompiledSystem,
variables: &[&str],
mode: Mode,
) -> Result<Self, SolverError>
pub fn new_with_variables_and_mode( compiled: CompiledSystem, variables: &[&str], mode: Mode, ) -> Result<Self, SolverError>
Create a solver with explicit variables and execution mode.
Sourcepub fn with_mode(self, mode: Mode) -> Result<Self, SolverError>
pub fn with_mode(self, mode: Mode) -> Result<Self, SolverError>
Update the execution mode for this solver.
Sourcepub fn try_with_equation_traces(
self,
traces: Vec<Option<EquationTrace>>,
) -> Result<Self, SolverError>
pub fn try_with_equation_traces( self, traces: Vec<Option<EquationTrace>>, ) -> Result<Self, SolverError>
Attach metadata describing the origin of each equation in the system
Sourcepub fn with_equation_traces(self, traces: Vec<Option<EquationTrace>>) -> Self
pub fn with_equation_traces(self, traces: Vec<Option<EquationTrace>>) -> Self
Attach metadata describing the origin of each equation in the system
Sourcepub fn trace_for_equation(
&self,
equation_index: usize,
) -> Option<&EquationTrace>
pub fn trace_for_equation( &self, equation_index: usize, ) -> Option<&EquationTrace>
Fetch trace metadata for a specific equation, if available
Sourcepub fn with_max_iterations(self, max_iterations: usize) -> Self
pub fn with_max_iterations(self, max_iterations: usize) -> Self
Override the maximum number of iterations
Sourcepub fn with_tolerance(self, tolerance: f64) -> Self
pub fn with_tolerance(self, tolerance: f64) -> Self
Override the convergence tolerance
Sourcepub fn with_damping(self, damping_factor: f64) -> Self
pub fn with_damping(self, damping_factor: f64) -> Self
Override the damping factor (clamped to [0.1, 1.0] for stability)
Sourcepub fn with_regularization(self, regularization: f64) -> Self
pub fn with_regularization(self, regularization: f64) -> Self
Override the base regularization parameter used when the system is ill-conditioned
Sourcepub fn solve(
&self,
initial_guess: HashMap<String, f64>,
) -> Result<Solution, SolverError>
pub fn solve( &self, initial_guess: HashMap<String, f64>, ) -> Result<Solution, SolverError>
Solve the system using standard Newton-Raphson method
Sourcepub fn solve_with_line_search(
&self,
initial_guess: HashMap<String, f64>,
) -> Result<Solution, SolverError>
pub fn solve_with_line_search( &self, initial_guess: HashMap<String, f64>, ) -> Result<Solution, SolverError>
Solve the system using Newton-Raphson with line search
Line search helps improve convergence robustness by automatically finding good step sizes, especially useful for difficult systems.
Auto Trait Implementations§
impl Freeze for NewtonRaphsonSolver
impl !RefUnwindSafe for NewtonRaphsonSolver
impl Send for NewtonRaphsonSolver
impl Sync for NewtonRaphsonSolver
impl Unpin for NewtonRaphsonSolver
impl !UnwindSafe for NewtonRaphsonSolver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more