src/types.rs

branch
dev
changeset 35
b087e3eab191
parent 34
efa60bc4f743
--- a/src/types.rs	Thu Aug 29 00:00:00 2024 -0500
+++ b/src/types.rs	Tue Dec 31 09:25:45 2024 -0500
@@ -4,7 +4,6 @@
 
 use colored::ColoredString;
 use serde::{Serialize, Deserialize};
-use clap::ValueEnum;
 use alg_tools::iterate::LogRepr;
 use alg_tools::euclidean::Euclidean;
 use alg_tools::norms::{Norm, L1};
@@ -13,7 +12,7 @@
 pub use alg_tools::loc::Loc;
 pub use alg_tools::sets::Cube;
 
-use crate::measures::DiscreteMeasure;
+// use crate::measures::DiscreteMeasure;
 
 /// [`Float`] with extra display and string conversion traits such that [`clap`] doesn't choke up.
 pub trait ClapFloat : Float
@@ -31,6 +30,8 @@
     pub n_spikes : usize,
     /// Number of iterations this statistic covers
     pub this_iters : usize,
+    /// Number of spikes inserted since last IterInfo statistic
+    pub inserted : usize,
     /// Number of spikes removed by merging since last IterInfo statistic
     pub merged : usize,
     /// Number of spikes removed by pruning since last IterInfo statistic
@@ -43,8 +44,8 @@
     pub transport_error : Option<(F, F)>,
     /// Current tolerance
     pub ε : F,
-    /// Solve fin.dim problem for this measure to get the optimal `value`.
-    pub postprocessing : Option<DiscreteMeasure<Loc<F, N>, F>>,
+    // /// Solve fin.dim problem for this measure to get the optimal `value`.
+    // pub postprocessing : Option<RNDM<F, N>>,
 }
 
 impl<F : Float, const N : usize>  IterInfo<F, N> {
@@ -55,10 +56,11 @@
             n_spikes : 0,
             this_iters : 0,
             merged : 0,
+            inserted : 0,
             pruned : 0,
             inner_iters : 0,
             ε : F::NAN,
-            postprocessing : None,
+            // postprocessing : None,
             untransported_fraction : None,
             transport_error : None,
         }
@@ -68,13 +70,14 @@
 #[replace_float_literals(F::cast_from(literal))]
 impl<F, const N : usize> LogRepr for IterInfo<F, N> where F : LogRepr + Float {
     fn logrepr(&self) -> ColoredString {
-        format!("{}\t| N = {}, ε = {:.8}, inner_iters_mean = {}, merged+pruned_mean = {}+{}{}{}",
+        format!("{}\t| N = {}, ε = {:.8}, 𝔼inner_it = {}, 𝔼ins/mer/pru = {}/{}/{}{}{}",
                 self.value.logrepr(),
                 self.n_spikes,
                 self.ε,
-                self.inner_iters as float / self.this_iters as float,
-                self.merged as float / self.this_iters as float,
-                self.pruned as float / self.this_iters as float,
+                self.inner_iters as float / self.this_iters.max(1) as float,
+                self.inserted as float / self.this_iters.max(1) as float,
+                self.merged as float / self.this_iters.max(1) as float,
+                self.pruned as float / self.this_iters.max(1) as float,
                 match self.untransported_fraction {
                     None => format!(""),
                     Some((a, b)) => if b > 0.0 {
@@ -117,7 +120,7 @@
 }
 
 /// Data term type
-#[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug, ValueEnum)]
+#[derive(Clone, Copy, PartialEq, Serialize, Deserialize, Debug)]
 pub enum DataTerm {
     /// $\\|z\\|\_2^2/2$
     L2Squared,
@@ -140,10 +143,18 @@
 pub struct L2Squared;
 
 /// Trait for indicating that `Self` is Lipschitz with respect to the (semi)norm `D`.
-pub trait Lipschitz<D> {
+pub trait Lipschitz<M> {
     /// The type of floats
     type FloatType : Float;
 
     /// Returns the Lipschitz factor of `self` with respect to the (semi)norm `D`.
-    fn lipschitz_factor(&self, seminorm : D) -> Option<Self::FloatType>;
+    fn lipschitz_factor(&self, seminorm : M) -> Option<Self::FloatType>;
 }
+
+/// Trait for norm-bounded functions.
+pub trait NormBounded<M> {
+    type FloatType : Float;
+
+    /// Returns a bound on the values of this function object in the `M`-norm.
+    fn norm_bound(&self, m : M) -> Self::FloatType;
+}

mercurial