DogLegConfig

Struct DogLegConfig 

Source
pub struct DogLegConfig {
Show 24 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,
}
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

Fields§

§linear_solver_type: LinearSolverType

Type of linear solver for the linear systems

§max_iterations: usize

Maximum number of iterations

§cost_tolerance: f64

Convergence tolerance for cost function

§parameter_tolerance: f64

Convergence tolerance for parameter updates

§gradient_tolerance: f64

Convergence tolerance for gradient norm

§timeout: Option<Duration>

Timeout duration

§trust_region_radius: f64

Initial trust region radius

§trust_region_min: f64

Minimum trust region radius

§trust_region_max: f64

Maximum trust region radius

§trust_region_increase_factor: f64

Trust region increase factor (for good steps, rho > 0.75)

§trust_region_decrease_factor: f64

Trust region decrease factor (for poor steps, rho < 0.25)

§min_step_quality: f64

Minimum step quality for acceptance (typically 0.0)

§good_step_quality: f64

Good step quality threshold (typically 0.75)

§poor_step_quality: f64

Poor step quality threshold (typically 0.25)

§use_jacobi_scaling: bool

Use Jacobi column scaling (preconditioning)

§initial_mu: f64

Initial mu regularization parameter for Gauss-Newton step

§min_mu: f64

Minimum mu regularization parameter

§max_mu: f64

Maximum mu regularization parameter

§mu_increase_factor: f64

Factor to increase mu when linear solver fails

§enable_step_reuse: bool

Enable 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: f64

Minimum 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: bool

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

Implementations§

Source§

impl DogLegConfig

Source

pub fn new() -> Self

Create a new Dog Leg configuration with default values.

Source

pub fn with_linear_solver_type( self, linear_solver_type: LinearSolverType, ) -> Self

Set the linear solver type

Source

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

Set the maximum number of iterations

Source

pub fn with_cost_tolerance(self, cost_tolerance: f64) -> Self

Set the cost tolerance

Source

pub fn with_parameter_tolerance(self, parameter_tolerance: f64) -> Self

Set the parameter tolerance

Source

pub fn with_gradient_tolerance(self, gradient_tolerance: f64) -> Self

Set the gradient tolerance

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Set the timeout duration

Source

pub fn with_trust_region_radius(self, radius: f64) -> Self

Set the initial trust region radius

Source

pub fn with_trust_region_bounds(self, min: f64, max: f64) -> Self

Set the trust region radius bounds

Source

pub fn with_trust_region_factors(self, increase: f64, decrease: f64) -> Self

Set the trust region adjustment factors

Source

pub fn with_step_quality_thresholds( self, min_quality: f64, poor_quality: f64, good_quality: f64, ) -> Self

Set the trust region quality thresholds

Source

pub fn with_jacobi_scaling(self, use_jacobi_scaling: bool) -> Self

Enable or disable Jacobi column scaling (preconditioning)

Source

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)

Source

pub fn with_step_reuse(self, enable_step_reuse: bool) -> Self

Enable or disable step reuse optimization (Ceres-style)

Source

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.

Source

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.

Source

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)

Source

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.

Source

pub fn print_configuration(&self)

Print configuration parameters (info level logging)

Trait Implementations§

Source§

impl Clone for DogLegConfig

Source§

fn clone(&self) -> DogLegConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for DogLegConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more