use nalgebra::DMatrix;
use crate::solving::ContractionOptions;
#[derive(Clone, Debug)]
pub enum WeightingMatrix {
InverseZTZ,
Provided(DMatrix<f64>),
}
#[derive(Clone, Debug)]
pub struct GmmOptions {
pub max_iterations: usize,
pub tolerance: f64,
pub update_weighting: bool,
pub weighting: WeightingMatrix,
}
impl Default for GmmOptions {
fn default() -> Self {
Self {
max_iterations: 1,
tolerance: 1e-10,
update_weighting: false,
weighting: WeightingMatrix::InverseZTZ,
}
}
}
#[derive(Clone, Debug)]
pub struct ProblemOptions {
pub contraction: ContractionOptions,
pub gmm: GmmOptions,
}
impl Default for ProblemOptions {
fn default() -> Self {
Self {
contraction: ContractionOptions::default(),
gmm: GmmOptions::default(),
}
}
}
impl ProblemOptions {
pub fn with_contraction(mut self, contraction: ContractionOptions) -> Self {
self.contraction = contraction;
self
}
pub fn with_weighting(mut self, weighting: WeightingMatrix) -> Self {
self.gmm.weighting = weighting;
self
}
pub fn with_max_gmm_iterations(mut self, max_iterations: usize) -> Self {
self.gmm.max_iterations = max_iterations.max(1);
self
}
pub fn with_gmm_tolerance(mut self, tolerance: f64) -> Self {
self.gmm.tolerance = tolerance;
self
}
pub fn with_weighting_updates(mut self, update: bool) -> Self {
self.gmm.update_weighting = update;
self
}
}
pub type EstimationOptions = ProblemOptions;