Skip to main content

NewtonRaphsonSolver

Struct NewtonRaphsonSolver 

Source
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

Source

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)
Source

pub fn new_with_mode( compiled: CompiledSystem, mode: Mode, ) -> Result<Self, SolverError>

Create a new solver with an explicit execution mode.

Source

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.

Source

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.

Source

pub fn with_mode(self, mode: Mode) -> Result<Self, SolverError>

Update the execution mode for this solver.

Source

pub fn mode(&self) -> &Mode

Returns the current execution mode.

Source

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

Source

pub fn with_equation_traces(self, traces: Vec<Option<EquationTrace>>) -> Self

Attach metadata describing the origin of each equation in the system

Source

pub fn trace_for_equation( &self, equation_index: usize, ) -> Option<&EquationTrace>

Fetch trace metadata for a specific equation, if available

Source

pub fn with_max_iterations(self, max_iterations: usize) -> Self

Override the maximum number of iterations

Source

pub fn with_tolerance(self, tolerance: f64) -> Self

Override the convergence tolerance

Source

pub fn with_damping(self, damping_factor: f64) -> Self

Override the damping factor (clamped to [0.1, 1.0] for stability)

Source

pub fn with_regularization(self, regularization: f64) -> Self

Override the base regularization parameter used when the system is ill-conditioned

Source

pub fn solve( &self, initial_guess: HashMap<String, f64>, ) -> Result<Solution, SolverError>

Solve the system using standard Newton-Raphson method

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.