diff -r eb3c7813b67a -r d4fd5f32d10e src/fb.rs --- a/src/fb.rs Thu Dec 01 23:07:35 2022 +0200 +++ b/src/fb.rs Wed Nov 30 23:45:04 2022 +0200 @@ -84,6 +84,7 @@ use serde::{Serialize, Deserialize}; use colored::Colorize; use nalgebra::DVector; +use clap::Parser; use alg_tools::iterate::{ AlgIteratorFactory, @@ -146,6 +147,11 @@ Zero, } +impl Default for InsertionStyle { + fn default() -> Self { + Self::Reuse + } +} /// Meta-algorithm type #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)] #[allow(dead_code)] @@ -166,10 +172,16 @@ AfterNth{ n : usize, factor : F }, } +impl Default for ErgodicTolerance { + fn default() -> Self { + Self::NonErgodic + } +} + /// Settings for [`pointsource_fb`]. #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)] #[serde(default)] -pub struct FBConfig { +pub struct FBConfig { /// Step length scaling pub τ0 : F, /// Meta-algorithm to apply @@ -180,24 +192,29 @@ /// Settings for the solution of the stepwise optimality condition in algorithms based on /// [`generic_pointsource_fb`]. -#[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)] +#[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug, Parser)] #[serde(default)] -pub struct FBGenericConfig { +pub struct FBGenericConfig { + #[clap(skip)] /// Method for constructing $μ$ on each iteration; see [`InsertionStyle`]. pub insertion_style : InsertionStyle, + #[clap(skip)] /// Tolerance for point insertion. pub tolerance : Tolerance, /// Stop looking for predual maximum (where to isert a new point) below /// `tolerance` multiplied by this factor. pub insertion_cutoff_factor : F, + #[clap(skip)] /// Apply tolerance ergodically pub ergodic_tolerance : ErgodicTolerance, + #[clap(skip)] /// Settings for branch and bound refinement when looking for predual maxima pub refinement : RefinementSettings, /// Maximum insertions within each outer iteration pub max_insertions : usize, /// Pair `(n, m)` for maximum insertions `m` on first `n` iterations. pub bootstrap_insertions : Option<(usize, usize)>, + #[clap(skip)] /// Inner method settings pub inner : InnerSettings, /// Spike merging method @@ -213,7 +230,7 @@ } #[replace_float_literals(F::cast_from(literal))] -impl Default for FBConfig { +impl Default for FBConfig { fn default() -> Self { FBConfig { τ0 : 0.99, @@ -224,7 +241,7 @@ } #[replace_float_literals(F::cast_from(literal))] -impl Default for FBGenericConfig { +impl Default for FBGenericConfig { fn default() -> Self { FBGenericConfig { insertion_style : InsertionStyle::Reuse, @@ -457,7 +474,7 @@ iterator : I, plotter : SeqPlotter ) -> DiscreteMeasure, F> -where F : Float + ToNalgebraRealField, +where F : ClapFloat + ToNalgebraRealField, I : AlgIteratorFactory>, for<'b> &'b A::Observable : std::ops::Neg, //+ std::ops::Mul, <-- FIXME: compiler overflow @@ -521,7 +538,7 @@ mut residual : A::Observable, mut specialisation : Spec, ) -> DiscreteMeasure, F> -where F : Float + ToNalgebraRealField, +where F : ClapFloat + ToNalgebraRealField, I : AlgIteratorFactory>, Spec : FBSpecialisation, A::Observable : std::ops::MulAssign,