diff -r 9738b51d90d7 -r 4f468d35fa29 src/fb.rs
--- a/src/fb.rs Sun Apr 27 15:03:51 2025 -0500
+++ b/src/fb.rs Thu Feb 26 11:38:43 2026 -0500
@@ -74,37 +74,34 @@
We solve this with either SSN or FB as determined by
-[`crate::subproblem::InnerSettings`] in [`FBGenericConfig::inner`].
+[`crate::subproblem::InnerSettings`] in [`InsertionConfig::inner`].
*/
+use crate::measures::merging::SpikeMerging;
+use crate::measures::{DiscreteMeasure, RNDM};
+use crate::plot::Plotter;
+pub use crate::prox_penalty::{InsertionConfig, ProxPenalty, StepLengthBound};
+use crate::regularisation::RegTerm;
+use crate::types::*;
+use alg_tools::error::DynResult;
+use alg_tools::instance::Instance;
+use alg_tools::iterate::AlgIteratorFactory;
+use alg_tools::mapping::DifferentiableMapping;
+use alg_tools::nalgebra_support::ToNalgebraRealField;
use colored::Colorize;
use numeric_literals::replace_float_literals;
use serde::{Deserialize, Serialize};
-use alg_tools::euclidean::Euclidean;
-use alg_tools::instance::Instance;
-use alg_tools::iterate::AlgIteratorFactory;
-use alg_tools::linops::{Mapping, GEMV};
-use alg_tools::mapping::RealMapping;
-use alg_tools::nalgebra_support::ToNalgebraRealField;
-
-use crate::dataterm::{calculate_residual, DataTerm, L2Squared};
-use crate::forward_model::{AdjointProductBoundedBy, ForwardModel};
-use crate::measures::merging::SpikeMerging;
-use crate::measures::{DiscreteMeasure, RNDM};
-use crate::plot::{PlotLookup, Plotting, SeqPlotter};
-pub use crate::prox_penalty::{FBGenericConfig, ProxPenalty};
-use crate::regularisation::RegTerm;
-use crate::types::*;
-
/// Settings for [`pointsource_fb_reg`].
#[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)]
#[serde(default)]
pub struct FBConfig {
/// Step length scaling
pub τ0: F,
+ // Auxiliary variable step length scaling for [`crate::forward_pdps::pointsource_fb_pair`]
+ pub σp0: F,
/// Generic parameters
- pub generic: FBGenericConfig,
+ pub insertion: InsertionConfig,
}
#[replace_float_literals(F::cast_from(literal))]
@@ -112,12 +109,13 @@
fn default() -> Self {
FBConfig {
τ0: 0.99,
- generic: Default::default(),
+ σp0: 0.99,
+ insertion: Default::default(),
}
}
}
-pub(crate) fn prune_with_stats(μ: &mut RNDM) -> usize {
+pub(crate) fn prune_with_stats(μ: &mut RNDM) -> usize {
let n_before_prune = μ.len();
μ.prune();
debug_assert!(μ.len() <= n_before_prune);
@@ -125,30 +123,19 @@
}
#[replace_float_literals(F::cast_from(literal))]
-pub(crate) fn postprocess<
- F: Float,
- V: Euclidean + Clone,
- A: GEMV, Codomain = V>,
- D: DataTerm,
- const N: usize,
->(
- mut μ: RNDM,
- config: &FBGenericConfig,
- dataterm: D,
- opA: &A,
- b: &V,
-) -> RNDM
+pub(crate) fn postprocess) -> F, const N: usize>(
+ mut μ: RNDM,
+ config: &InsertionConfig,
+ f: Dat,
+) -> DynResult>
where
- RNDM: SpikeMerging,
- for<'a> &'a RNDM: Instance>,
+ RNDM: SpikeMerging,
+ for<'a> &'a RNDM: Instance>,
{
- μ.merge_spikes_fitness(
- config.final_merging_method(),
- |μ̃| dataterm.calculate_fit_op(μ̃, opA, b),
- |&v| v,
- );
+ //μ.merge_spikes_fitness(config.final_merging_method(), |μ̃| f.apply(μ̃), |&v| v);
+ μ.merge_spikes_fitness(config.final_merging_method(), f, |&v| v);
μ.prune();
- μ
+ Ok(μ)
}
/// Iteratively solve the pointsource localisation problem using forward-backward splitting.
@@ -161,50 +148,41 @@
///
/// For details on the mathematical formulation, see the [module level](self) documentation.
///
-/// The implementation relies on [`alg_tools::bisection_tree::BTFN`] presentations of
-/// sums of simple functions usign bisection trees, and the related
-/// [`alg_tools::bisection_tree::Aggregator`]s, to efficiently search for component functions
-/// active at a specific points, and to maximise their sums. Through the implementation of the
-/// [`alg_tools::bisection_tree::BT`] bisection trees, it also relies on the copy-on-write features
-/// of [`std::sync::Arc`] to only update relevant parts of the bisection tree when adding functions.
-///
/// Returns the final iterate.
#[replace_float_literals(F::cast_from(literal))]
-pub fn pointsource_fb_reg(
- opA: &A,
- b: &A::Observable,
- reg: Reg,
+pub fn pointsource_fb_reg(
+ f: &Dat,
+ reg: &Reg,
prox_penalty: &P,
fbconfig: &FBConfig,
iterator: I,
- mut plotter: SeqPlotter,
-) -> RNDM
+ mut plotter: Plot,
+ μ0 : Option>,
+) -> DynResult>
where
F: Float + ToNalgebraRealField,
- I: AlgIteratorFactory>,
- for<'b> &'b A::Observable: std::ops::Neg