pub trait LineSearch<V: Vector>: Default {
// Required methods
fn take_optimal_step(
&mut self,
x: &mut V,
delta: &mut V,
error_y: &V,
fun: &impl Fn(&V, &mut V),
linear_solver: &impl Fn(&mut V) -> Result<(), DiffsolError>,
convergence: &mut Convergence<'_, V>,
) -> Result<ConvergenceStatus, DiffsolError>;
fn reset(&mut self);
}Expand description
Line search trait for nonlinear solvers The line search is used to find an optimal step size for the Newton iteration. The line search modifies the delta vector in place to scale it by the optimal step size The line search returns the norm of the modified delta vector The x vector is also modified in place to take the optimal step
Required Methods§
Sourcefn take_optimal_step(
&mut self,
x: &mut V,
delta: &mut V,
error_y: &V,
fun: &impl Fn(&V, &mut V),
linear_solver: &impl Fn(&mut V) -> Result<(), DiffsolError>,
convergence: &mut Convergence<'_, V>,
) -> Result<ConvergenceStatus, DiffsolError>
fn take_optimal_step( &mut self, x: &mut V, delta: &mut V, error_y: &V, fun: &impl Fn(&V, &mut V), linear_solver: &impl Fn(&mut V) -> Result<(), DiffsolError>, convergence: &mut Convergence<'_, V>, ) -> Result<ConvergenceStatus, DiffsolError>
Take the optimal step for the current iteration
§Arguments
x: current solution vector, modified in place to take the optimal stepdelta: current Newton step vector, modified in place to scale by the optimal step size (previous value is overwritten)error_y: current error estimate vector, used to compute the normfun: function to compute the residual F(x), takes x and modifies delta in placelinear_solver: function to solve the linear system J delta = -F(x), takes delta and modifies it in placeconvergence: convergence object to compute norms and check convergence
§Returns
ConvergenceStatus: status of the convergence after taking the optimal stepDiffsolError: error if the line search fails
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.