pub struct DogLegConfig {Show 25 fields
pub linear_solver_type: LinearSolverType,
pub max_iterations: usize,
pub cost_tolerance: f64,
pub parameter_tolerance: f64,
pub gradient_tolerance: f64,
pub timeout: Option<Duration>,
pub trust_region_radius: f64,
pub trust_region_min: f64,
pub trust_region_max: f64,
pub trust_region_increase_factor: f64,
pub trust_region_decrease_factor: f64,
pub min_step_quality: f64,
pub good_step_quality: f64,
pub poor_step_quality: f64,
pub use_jacobi_scaling: bool,
pub initial_mu: f64,
pub min_mu: f64,
pub max_mu: f64,
pub mu_increase_factor: f64,
pub enable_step_reuse: bool,
pub min_cost_threshold: Option<f64>,
pub max_condition_number: Option<f64>,
pub min_relative_decrease: f64,
pub compute_covariances: bool,
pub enable_visualization: bool,
}Expand description
Configuration parameters for the Dog Leg trust region optimizer.
Controls trust region management, convergence criteria, adaptive regularization, and Ceres Solver enhancements for the Dog Leg algorithm.
§Builder Pattern
All configuration options can be set using the builder pattern:
use apex_solver::optimizer::dog_leg::DogLegConfig;
let config = DogLegConfig::new()
.with_max_iterations(100)
.with_trust_region_radius(1e4)
.with_mu_params(1e-4, 1e-8, 1.0, 10.0)
.with_jacobi_scaling(true)
.with_step_reuse(true);§Trust Region Behavior
The trust region radius Δ controls the maximum allowed step size:
- Initial radius (
trust_region_radius): Starting value (default: 1e4) - Bounds (
trust_region_min,trust_region_max): Valid range (default: 1e-3 to 1e6) - Adaptation: Increases for good steps, decreases for poor steps
§Adaptive μ Regularization (Ceres Enhancement)
Controls the regularization parameter in (J^T·J + μI)·h = -J^T·r:
initial_mu: Starting value (default: 1e-4 for numerical stability)min_mu,max_mu: Bounds (default: 1e-8 to 1.0)mu_increase_factor: Multiplier when solve fails (default: 10.0)
§Convergence Criteria
The optimizer terminates when ANY of the following conditions is met:
- Cost tolerance:
|cost_k - cost_{k-1}| < cost_tolerance - Parameter tolerance:
||step|| < parameter_tolerance - Gradient tolerance:
||J^T·r|| < gradient_tolerance - Maximum iterations:
iteration >= max_iterations - Timeout:
elapsed_time >= timeout
§See Also
DogLeg- The solver that uses this configurationLevenbergMarquardtConfig- Alternative damping approachGaussNewtonConfig- Undamped variant
Fields§
§linear_solver_type: LinearSolverTypeType of linear solver for the linear systems
max_iterations: usizeMaximum number of iterations
cost_tolerance: f64Convergence tolerance for cost function
parameter_tolerance: f64Convergence tolerance for parameter updates
gradient_tolerance: f64Convergence tolerance for gradient norm
timeout: Option<Duration>Timeout duration
trust_region_radius: f64Initial trust region radius
trust_region_min: f64Minimum trust region radius
trust_region_max: f64Maximum trust region radius
trust_region_increase_factor: f64Trust region increase factor (for good steps, rho > 0.75)
trust_region_decrease_factor: f64Trust region decrease factor (for poor steps, rho < 0.25)
min_step_quality: f64Minimum step quality for acceptance (typically 0.0)
good_step_quality: f64Good step quality threshold (typically 0.75)
poor_step_quality: f64Poor step quality threshold (typically 0.25)
use_jacobi_scaling: boolUse Jacobi column scaling (preconditioning)
initial_mu: f64Initial mu regularization parameter for Gauss-Newton step
min_mu: f64Minimum mu regularization parameter
max_mu: f64Maximum mu regularization parameter
mu_increase_factor: f64Factor to increase mu when linear solver fails
enable_step_reuse: boolEnable step reuse after rejection (Ceres-style efficiency optimization)
min_cost_threshold: Option<f64>Minimum objective function cutoff (optional early termination)
If set, optimization terminates when cost falls below this threshold. Useful for early stopping when a “good enough” solution is acceptable.
Default: None (disabled)
max_condition_number: Option<f64>Maximum condition number for Jacobian matrix (optional check)
If set, the optimizer checks if condition_number(J^T*J) exceeds this threshold and terminates with IllConditionedJacobian status. Note: Computing condition number is expensive, so this is disabled by default.
Default: None (disabled)
min_relative_decrease: f64Minimum relative cost decrease for step acceptance
Used in computing step quality (rho = actual_reduction / predicted_reduction). Steps with rho < min_relative_decrease are rejected. Matches Ceres Solver’s min_relative_decrease parameter.
Default: 1e-3 (Ceres-compatible)
compute_covariances: boolCompute per-variable covariance matrices (uncertainty estimation)
When enabled, computes covariance by inverting the Hessian matrix after convergence. The full covariance matrix is extracted into per-variable blocks stored in both Variable structs and optimizer::SolverResult.
Default: false (to avoid performance overhead)
enable_visualization: boolEnable real-time visualization (graphical debugging).
When enabled, optimization progress is logged to a Rerun viewer.
Note: Requires the visualization feature to be enabled in Cargo.toml.
Default: false
Implementations§
Source§impl DogLegConfig
impl DogLegConfig
Sourcepub fn with_linear_solver_type(
self,
linear_solver_type: LinearSolverType,
) -> Self
pub fn with_linear_solver_type( self, linear_solver_type: LinearSolverType, ) -> Self
Set the linear solver type
Sourcepub fn with_max_iterations(self, max_iterations: usize) -> Self
pub fn with_max_iterations(self, max_iterations: usize) -> Self
Set the maximum number of iterations
Sourcepub fn with_cost_tolerance(self, cost_tolerance: f64) -> Self
pub fn with_cost_tolerance(self, cost_tolerance: f64) -> Self
Set the cost tolerance
Sourcepub fn with_parameter_tolerance(self, parameter_tolerance: f64) -> Self
pub fn with_parameter_tolerance(self, parameter_tolerance: f64) -> Self
Set the parameter tolerance
Sourcepub fn with_gradient_tolerance(self, gradient_tolerance: f64) -> Self
pub fn with_gradient_tolerance(self, gradient_tolerance: f64) -> Self
Set the gradient tolerance
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set the timeout duration
Sourcepub fn with_trust_region_radius(self, radius: f64) -> Self
pub fn with_trust_region_radius(self, radius: f64) -> Self
Set the initial trust region radius
Sourcepub fn with_trust_region_bounds(self, min: f64, max: f64) -> Self
pub fn with_trust_region_bounds(self, min: f64, max: f64) -> Self
Set the trust region radius bounds
Sourcepub fn with_trust_region_factors(self, increase: f64, decrease: f64) -> Self
pub fn with_trust_region_factors(self, increase: f64, decrease: f64) -> Self
Set the trust region adjustment factors
Sourcepub fn with_step_quality_thresholds(
self,
min_quality: f64,
poor_quality: f64,
good_quality: f64,
) -> Self
pub fn with_step_quality_thresholds( self, min_quality: f64, poor_quality: f64, good_quality: f64, ) -> Self
Set the trust region quality thresholds
Sourcepub fn with_jacobi_scaling(self, use_jacobi_scaling: bool) -> Self
pub fn with_jacobi_scaling(self, use_jacobi_scaling: bool) -> Self
Enable or disable Jacobi column scaling (preconditioning)
Sourcepub fn with_mu_params(
self,
initial_mu: f64,
min_mu: f64,
max_mu: f64,
increase_factor: f64,
) -> Self
pub fn with_mu_params( self, initial_mu: f64, min_mu: f64, max_mu: f64, increase_factor: f64, ) -> Self
Set adaptive mu regularization parameters (Ceres-style)
Sourcepub fn with_step_reuse(self, enable_step_reuse: bool) -> Self
pub fn with_step_reuse(self, enable_step_reuse: bool) -> Self
Enable or disable step reuse optimization (Ceres-style)
Sourcepub fn with_min_cost_threshold(self, min_cost: f64) -> Self
pub fn with_min_cost_threshold(self, min_cost: f64) -> Self
Set minimum objective function cutoff for early termination.
When set, optimization terminates with MinCostThresholdReached status if the cost falls below this threshold. Useful for early stopping when a “good enough” solution is acceptable.
Sourcepub fn with_max_condition_number(self, max_cond: f64) -> Self
pub fn with_max_condition_number(self, max_cond: f64) -> Self
Set maximum condition number for Jacobian matrix.
If set, the optimizer checks if condition_number(J^T*J) exceeds this threshold and terminates with IllConditionedJacobian status. Note: Computing condition number is expensive, disabled by default.
Sourcepub fn with_min_relative_decrease(self, min_decrease: f64) -> Self
pub fn with_min_relative_decrease(self, min_decrease: f64) -> Self
Set minimum relative cost decrease for step acceptance.
Steps with rho = (actual_reduction / predicted_reduction) below this threshold are rejected. Default: 1e-3 (Ceres-compatible)
Sourcepub fn with_compute_covariances(self, compute_covariances: bool) -> Self
pub fn with_compute_covariances(self, compute_covariances: bool) -> Self
Enable or disable covariance computation (uncertainty estimation).
When enabled, computes the full covariance matrix by inverting the Hessian after convergence, then extracts per-variable covariance blocks.
Sourcepub fn with_visualization(self, enable: bool) -> Self
pub fn with_visualization(self, enable: bool) -> Self
Enable real-time visualization.
Note: Requires the visualization feature to be enabled in Cargo.toml.
§Arguments
enable- Whether to enable visualization
Sourcepub fn print_configuration(&self)
pub fn print_configuration(&self)
Print configuration parameters (info level logging)
Trait Implementations§
Source§impl Clone for DogLegConfig
impl Clone for DogLegConfig
Source§fn clone(&self) -> DogLegConfig
fn clone(&self) -> DogLegConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DogLegConfig
impl RefUnwindSafe for DogLegConfig
impl Send for DogLegConfig
impl Sync for DogLegConfig
impl Unpin for DogLegConfig
impl UnsafeUnpin for DogLegConfig
impl UnwindSafe for DogLegConfig
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.