diff --git a/.gitignore b/.gitignore index 0e71e344..a07e9013 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /target .direnv/ + +*.log diff --git a/gbp-rs/src/factorgraph/factorgraph.rs b/gbp-rs/src/factorgraph/factorgraph.rs index 65a75cca..acda9d8d 100644 --- a/gbp-rs/src/factorgraph/factorgraph.rs +++ b/gbp-rs/src/factorgraph/factorgraph.rs @@ -1,8 +1,18 @@ use crate::factorgraph::factor::Factor; use crate::factorgraph::variable::Variable; +use super::factor::MeasurementModel; +use super::UnitInterval; + +#[derive(Debug)] pub struct GbpSettings { + /// Absolute distance threshold between linearisation point and adjacent belief means for relinearisation pub beta: f64, + /// Damping for the eta component of the message + pub damping: f64, + pub dropout: UnitInterval, + /// Number of undamped iterations after relinearisation before + pub num_undamped_iterations: usize, } /// A factor graph is a bipartite graph representing the factorization of a function. /// It is composed of two types of nodes: factors and variables. @@ -18,14 +28,6 @@ pub struct FactorGraph { // std::unique_ptr impl FactorGraph { - pub fn new(gbp_settings: GbpSettings) -> Self { - Self { - factors: Vec::new(), - variables: Vec::new(), - gbp_settings, - } - } - pub fn add_factor(&mut self, factor: F) { self.factors.push(factor); } @@ -34,16 +36,6 @@ impl FactorGraph { self.variables.push(variable); } - pub fn update_all_beliefs(&mut self) { - // for variable in self.variables.iter_mut() { - // variable.update_belief(); - // } - todo!() - // for factor in self.factors.iter_mut() { - // factor.update_belief(); - // } - } - // linearize_all_factors fn compute_factors(&mut self) { for factor in self.factors.iter() { @@ -51,12 +43,6 @@ impl FactorGraph { } } - fn robustify_all_factors(&mut self) { - for factor in self.factors.iter() { - factor.robustify_loss(); - } - } - fn jit_linearisation(&mut self) { for factor in self.factors.iter() { match factor.measurement_model() { @@ -67,7 +53,32 @@ impl FactorGraph { factor.compute(); } } + MeasurementModel::Linear => {} } } } + + pub fn new(gbp_settings: GbpSettings) -> Self { + Self { + factors: Vec::new(), + variables: Vec::new(), + gbp_settings, + } + } + + fn robustify_all_factors(&mut self) { + for factor in self.factors.iter() { + factor.robustify_loss(); + } + } + + pub fn update_all_beliefs(&mut self) { + // for variable in self.variables.iter_mut() { + // variable.update_belief(); + // } + todo!() + // for factor in self.factors.iter_mut() { + // factor.update_belief(); + // } + } } diff --git a/gbp-rs/src/factorgraph/mod.rs b/gbp-rs/src/factorgraph/mod.rs index 6c09eb85..bce844e8 100644 --- a/gbp-rs/src/factorgraph/mod.rs +++ b/gbp-rs/src/factorgraph/mod.rs @@ -4,3 +4,12 @@ pub mod message; pub mod variable; type NodeId = usize; + +use nutype::nutype; + +/// Represents a closed interval [0,1] +#[nutype( + validate(greater_or_equal = 0.0, less_or_equal = 1.0), + derive(Debug, Clone, Copy) +)] +pub struct UnitInterval(f64); diff --git a/hx.log b/hx.log deleted file mode 100644 index 8feed474..00000000 --- a/hx.log +++ /dev/null @@ -1,3 +0,0 @@ -2024-02-01T13:21:37.825 helix_lsp::transport [ERROR] rust-analyzer err <- "error: 'rust-analyzer' is not installed for the toolchain 'stable-x86_64-unknown-linux-gnu'\n" -2024-02-01T13:21:37.826 helix_lsp [ERROR] failed to initialize language server: server closed the stream -2024-02-01T13:21:37.826 helix_lsp::transport [ERROR] rust-analyzer err: <- StreamClosed