src/sliding_pdps.rs

Mon, 23 Feb 2026 18:18:02 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Mon, 23 Feb 2026 18:18:02 -0500
branch
dev
changeset 64
d3be4f7ffd60
parent 63
7a8a55fd41c0
child 66
fe47ad484deb
permissions
-rw-r--r--

ATTEMPT, HAS BUGS: Make shifted_nonneg_soft_thresholding more readable

35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
1 /*!
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
2 Solver for the point source localisation problem using a sliding
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
3 primal-dual proximal splitting method.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
4 */
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
5
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
6 use crate::fb::*;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
7 use crate::forward_model::{BoundedCurvature, BoundedCurvatureGuess};
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
8 use crate::measures::merging::SpikeMerging;
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
9 use crate::measures::{DiscreteMeasure, RNDM};
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
10 use crate::plot::Plotter;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
11 use crate::prox_penalty::{ProxPenalty, StepLengthBoundPair};
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
12 use crate::regularisation::SlidingRegTerm;
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
13 use crate::sliding_fb::{SlidingFBConfig, Transport, TransportConfig, TransportStepLength};
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
14 use crate::types::*;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
15 use alg_tools::convex::{Conjugable, Prox, Zero};
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
16 use alg_tools::direct_product::Pair;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
17 use alg_tools::error::DynResult;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
18 use alg_tools::euclidean::ClosedEuclidean;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
19 use alg_tools::iterate::AlgIteratorFactory;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
20 use alg_tools::linops::{
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
21 BoundedLinear, IdOp, SimplyAdjointable, StaticEuclideanOriginGenerator, ZeroOp, AXPY, GEMV,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
22 };
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
23 use alg_tools::mapping::{DifferentiableMapping, DifferentiableRealMapping, Instance};
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
24 use alg_tools::nalgebra_support::ToNalgebraRealField;
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
25 use alg_tools::norms::L2;
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
26 use anyhow::ensure;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
27 use numeric_literals::replace_float_literals;
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
28 use serde::{Deserialize, Serialize};
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
29
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
30 /// Settings for [`pointsource_sliding_pdps_pair`].
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
31 #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)]
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
32 #[serde(default)]
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
33 pub struct SlidingPDPSConfig<F: Float> {
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
34 /// Overall primal step length scaling.
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
35 pub τ0: F,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
36 /// Primal step length scaling for additional variable.
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
37 pub σp0: F,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
38 /// Dual step length scaling for additional variable.
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
39 ///
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
40 /// Taken zero for [`pointsource_sliding_fb_pair`].
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
41 pub σd0: F,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
42 /// Transport parameters
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
43 pub transport: TransportConfig<F>,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
44 /// Generic parameters
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
45 pub insertion: InsertionConfig<F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
46 /// Guess for curvature bound calculations.
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
47 pub guess: BoundedCurvatureGuess,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
48 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
49
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
50 #[replace_float_literals(F::cast_from(literal))]
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
51 impl<F: Float> Default for SlidingPDPSConfig<F> {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
52 fn default() -> Self {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
53 SlidingPDPSConfig {
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
54 τ0: 0.99,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
55 σd0: 0.05,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
56 σp0: 0.99,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
57 transport: TransportConfig { θ0: 0.9, ..Default::default() },
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
58 insertion: Default::default(),
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
59 guess: BoundedCurvatureGuess::BetterThanZero,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
60 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
61 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
62 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
63
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
64 type MeasureZ<F, Z, const N: usize> = Pair<RNDM<N, F>, Z>;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
65
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
66 /// Iteratively solve the pointsource localisation with an additional variable
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
67 /// using sliding primal-dual proximal splitting
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
68 ///
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
69 /// The parametrisation is as for [`crate::forward_pdps::pointsource_forward_pdps_pair`].
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
70 #[replace_float_literals(F::cast_from(literal))]
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
71 pub fn pointsource_sliding_pdps_pair<
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
72 F,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
73 I,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
74 S,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
75 Dat,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
76 Reg,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
77 P,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
78 Z,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
79 R,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
80 Y,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
81 Plot,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
82 /*KOpM, */ KOpZ,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
83 H,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
84 const N: usize,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
85 >(
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
86 f: &Dat,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
87 reg: &Reg,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
88 prox_penalty: &P,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
89 config: &SlidingPDPSConfig<F>,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
90 iterator: I,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
91 mut plotter: Plot,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
92 (μ0, mut z, mut y): (Option<RNDM<N, F>>, Z, Y),
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
93 //opKμ : KOpM,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
94 opKz: &KOpZ,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
95 fnR: &R,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
96 fnH: &H,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
97 ) -> DynResult<MeasureZ<F, Z, N>>
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
98 where
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
99 F: Float + ToNalgebraRealField,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
100 I: AlgIteratorFactory<IterInfo<F>>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
101 Dat: DifferentiableMapping<MeasureZ<F, Z, N>, Codomain = F, DerivativeDomain = Pair<S, Z>>
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
102 + BoundedCurvature<F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
103 S: DifferentiableRealMapping<N, F> + ClosedMul<F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
104 for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
105 //Pair<S, Z>: ClosedMul<F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
106 RNDM<N, F>: SpikeMerging<F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
107 Reg: SlidingRegTerm<Loc<N, F>, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
108 P: ProxPenalty<Loc<N, F>, S, Reg, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
109 // KOpM : Linear<RNDM<N, F>, Codomain=Y>
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
110 // + GEMV<F, RNDM<N, F>>
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
111 // + Preadjointable<
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
112 // RNDM<N, F>, Y,
37
c5d8bd1a7728 Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents: 36
diff changeset
113 // PreadjointCodomain = S,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
114 // >
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
115 // + TransportLipschitz<L2Squared, FloatType=F>
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
116 // + AdjointProductBoundedBy<RNDM<N, F>, 𝒟, FloatType=F>,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
117 // for<'b> KOpM::Preadjoint<'b> : GEMV<F, Y>,
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
118 // Since Z is Hilbert, we may just as well use adjoints for K_z.
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
119 KOpZ: BoundedLinear<Z, L2, L2, F, Codomain = Y>
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
120 + GEMV<F, Z>
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
121 + SimplyAdjointable<Z, Y, AdjointCodomain = Z>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
122 KOpZ::SimpleAdjoint: GEMV<F, Y>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
123 Y: ClosedEuclidean<F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
124 for<'b> &'b Y: Instance<Y>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
125 Z: ClosedEuclidean<F>,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
126 for<'b> &'b Z: Instance<Z>,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
127 R: Prox<Z, Codomain = F>,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
128 H: Conjugable<Y, F, Codomain = F>,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
129 for<'b> H::Conjugate<'b>: Prox<Y>,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
130 Plot: Plotter<P::ReturnMapping, S, RNDM<N, F>>,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
131 {
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
132 // Check parameters
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
133 /*ensure!(
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
134 config.τ0 > 0.0
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
135 && config.τ0 < 1.0
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
136 && config.σp0 > 0.0
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
137 && config.σp0 < 1.0
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
138 && config.σd0 > 0.0
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
139 && config.σp0 * config.σd0 <= 1.0,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
140 "Invalid step length parameters"
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
141 );*/
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
142 config.transport.check()?;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
143
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
144 // Initialise iterates
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
145 let mut μ = μ0.unwrap_or_else(|| DiscreteMeasure::new());
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
146 let mut γ = Transport::new();
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
147 //let zero_z = z.similar_origin();
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
148
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
149 // Set up parameters
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
150 // TODO: maybe this PairNorm doesn't make sense here?
41
b6bdb6cb4d44 Remove initial transport adaptation—it is not needed, after all
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
151 // let opAnorm = opA.opnorm_bound(PairNorm(Radon, L2, L2), L2);
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
152 let bigθ = 0.0; //opKμ.transport_lipschitz_factor(L2Squared);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
153 let bigM = 0.0; //opKμ.adjoint_product_bound(&op𝒟).unwrap().sqrt();
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
154 let nKz = opKz.opnorm_bound(L2, L2)?;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
155 let ℓ = 0.0;
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
156 let idOpZ = IdOp::new();
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
157 let opKz_adj = opKz.adjoint();
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
158 let (l, l_z) = Pair(prox_penalty, &idOpZ).step_length_bound_pair(&f)?;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
159
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
160 // We need to satisfy
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
161 //
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
162 // τσ_dM(1-σ_p L_z)/(1 - τ L) + [σ_p L_z + σ_pσ_d‖K_z‖^2] < 1
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
163 // ^^^^^^^^^^^^^^^^^^^^^^^^^
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
164 // with 1 > σ_p L_z and 1 > τ L.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
165 //
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
166 // To do so, we first solve σ_p and σ_d from standard PDPS step length condition
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
167 // ^^^^^ < 1. then we solve τ from the rest.
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
168 // If opKZ is the zero operator, then we set σ_d = 0 for τ to be calculated correctly below.
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
169 let σ_d = if nKz == 0.0 { 0.0 } else { config.σd0 / nKz };
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
170 let σ_p = config.σp0 / (l_z + config.σd0 * nKz);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
171 // Observe that = 1 - ^^^^^^^^^^^^^^^^^^^^^ = 1 - σ_{p,0}
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
172 // We get the condition τσ_d M (1-σ_p L_z) < (1-σ_{p,0})*(1-τ L)
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
173 // ⟺ τ [ σ_d M (1-σ_p L_z) + (1-σ_{p,0}) L ] < (1-σ_{p,0})
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
174 let φ = 1.0 - config.σp0;
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
175 let a = 1.0 - σ_p * l_z;
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
176 let τ = config.τ0 * φ / (σ_d * bigM * a + φ * l);
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
177 let ψ = 1.0 - τ * l;
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
178 let β = σ_p * config.σd0 * nKz / a; // σ_p * σ_d * (nKz * nK_z) / a;
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
179 ensure!(β < 1.0);
44
03251c546744 curvature controls
Tuomo Valkonen <tuomov@iki.fi>
parents: 41
diff changeset
180 // Now we need κ‖K_μ(π_♯^1 - π_♯^0)γ‖^2 ≤ (1/θ - τ[ℓ_F + ℓ]) ∫ c_2 dγ for κ defined as:
36
fb911f72e698 Factor fix
Tuomo Valkonen <tuomov@iki.fi>
parents: 35
diff changeset
181 let κ = τ * σ_d * ψ / ((1.0 - β) * ψ - τ * σ_d * bigM);
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
182 // The factor two in the manuscript disappears due to the definition of 𝚹 being
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
183 // for ‖x-y‖₂² instead of c_2(x, y)=‖x-y‖₂²/2.
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
184
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
185 let mut θ_or_adaptive = match f.curvature_bound_components(config.guess) {
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
186 (_, Err(_)) => TransportStepLength::Fixed(config.transport.θ0),
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
187 (maybe_ℓ_F, Ok(transport_lip)) => {
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
188 let calculate_θτ = move |ℓ_F, max_transport| {
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
189 let ℓ_r = transport_lip * max_transport;
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
190 config.transport.θ0 / ((ℓ + ℓ_F + ℓ_r) + κ * bigθ * max_transport / τ)
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
191 };
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
192 match maybe_ℓ_F {
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
193 Ok(ℓ_F) => TransportStepLength::AdaptiveMax {
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
194 l: ℓ_F, // TODO: could estimate computing the real reesidual
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
195 max_transport: 0.0,
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
196 g: calculate_θτ,
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
197 },
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
198 Err(_) => TransportStepLength::FullyAdaptive {
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
199 l: F::EPSILON, // Start with something very small to estimate differentials
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
200 max_transport: 0.0,
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
201 g: calculate_θτ,
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
202 },
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
203 }
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
204 }
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
205 };
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
206 // Acceleration is not currently supported
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
207 // let γ = dataterm.factor_of_strong_convexity();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
208 let ω = 1.0;
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
209
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
210 // We multiply tolerance by τ for FB since our subproblems depending on tolerances are scaled
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
211 // by τ compared to the conditional gradient approach.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
212 let tolerance = config.insertion.tolerance * τ * reg.tolerance_scaling();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
213 let mut ε = tolerance.initial();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
214
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
215 let starH = fnH.conjugate();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
216
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
217 // Statistics
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
218 let full_stats = |μ: &RNDM<N, F>, z: &Z, ε, stats| IterInfo {
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
219 value: f.apply(Pair(μ, z))
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
220 + fnR.apply(z)
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
221 + reg.apply(μ)
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
222 + fnH.apply(/* opKμ.apply(μ) + */ opKz.apply(z)),
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
223 n_spikes: μ.len(),
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
224 ε,
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
225 // postprocessing: config.insertion.postprocessing.then(|| μ.clone()),
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
226 ..stats
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
227 };
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
228 let mut stats = IterInfo::new();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
229
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
230 // Run the algorithm
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
231 for state in iterator.iter_init(|| full_stats(&μ, &z, ε, stats.clone())) {
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
232 // Calculate initial transport
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
233 let Pair(v, _) = f.differential(Pair(&μ, &z));
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
234 //opKμ.preadjoint().apply_add(&mut v, y);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
235 // We want to proceed as in Example 4.12 but with v and v̆ as in §5.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
236 // With A(ν, z) = A_μ ν + A_z z, following Example 5.1, we have
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
237 // P_ℳ[F'(ν, z) + Ξ(ν, z, y)]= A_ν^*[A_ν ν + A_z z] + K_μ ν = A_ν^*A(ν, z) + K_μ ν,
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
238 // where A_ν^* becomes a multiplier.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
239 // This is much easier with K_μ = 0, which is the only reason why are enforcing it.
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
240 // TODO: Write a version of initial_transport that can deal with K_μ ≠ 0.
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
241
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
242 //dbg!(&μ);
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
243
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
244 γ.initial_transport(&μ, τ, &mut θ_or_adaptive, v);
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
245
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
246 let mut attempts = 0;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
247
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
248 // Solve finite-dimensional subproblem several times until the dual variable for the
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
249 // regularisation term conforms to the assumptions made for the transport above.
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
250 let (maybe_d, _within_tolerances, mut τv̆, z_new, μ̆) = 'adapt_transport: loop {
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
251 // Set initial guess for μ=μ^{k+1}.
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
252 γ.μ̆_into(&mut μ);
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
253 let μ̆ = μ.clone();
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
254
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
255 // Calculate τv̆ = τA_*(A[μ_transported + μ_transported_base]-b)
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
256 let Pair(mut τv̆, τz̆) = f.differential(Pair(&μ̆, &z)) * τ;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
257 // opKμ.preadjoint().gemv(&mut τv̆, τ, y, 1.0);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
258
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
259 // Construct μ^{k+1} by solving finite-dimensional subproblems and insert new spikes.
37
c5d8bd1a7728 Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents: 36
diff changeset
260 let (maybe_d, within_tolerances) = prox_penalty.insert_and_reweigh(
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
261 &mut μ,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
262 &mut τv̆,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
263 τ,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
264 ε,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
265 &config.insertion,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
266 &reg,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
267 &state,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
268 &mut stats,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
269 )?;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
270
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
271 // Do z variable primal update here to able to estimate B_{v̆^k-v^{k+1}}
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
272 let mut z_new = τz̆;
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
273 opKz_adj.gemv(&mut z_new, -σ_p, &y, -σ_p / τ);
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
274 z_new = fnR.prox(σ_p, z_new + &z);
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
275
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
276 // A posteriori transport adaptation.
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
277 if γ.aposteriori_transport(
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
278 &μ,
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
279 &μ̆,
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
280 &mut τv̆,
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
281 Some(z_new.dist2(&z)),
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
282 ε,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
283 &config.transport,
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
284 &mut attempts,
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
285 ) {
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
286 break 'adapt_transport (maybe_d, within_tolerances, τv̆, z_new, μ̆);
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
287 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
288 };
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
289
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
290 γ.get_transport_stats(&mut stats, &μ);
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
291
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
292 // Merge spikes.
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
293 // This crucially expects the merge routine to be stable with respect to spike locations,
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
294 // and not to performing any pruning. That is be to done below simultaneously for γ.
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
295 if config.insertion.merge_now(&state) {
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
296 stats.merged += prox_penalty.merge_spikes_no_fitness(
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
297 &mut μ,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
298 &mut τv̆,
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
299 &μ̆,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
300 τ,
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
301 ε,
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
302 &config.insertion,
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
303 &reg,
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
304 );
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
305 }
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
306
63
7a8a55fd41c0 Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 61
diff changeset
307 γ.prune_compat(&mut μ, &mut stats);
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
308
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
309 // Do dual update
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
310 // opKμ.gemv(&mut y, σ_d*(1.0 + ω), &μ, 1.0); // y = y + σ_d K[(1+ω)(μ,z)^{k+1}]
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
311 opKz.gemv(&mut y, σ_d * (1.0 + ω), &z_new, 1.0);
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
312 // opKμ.gemv(&mut y, -σ_d*ω, μ_base, 1.0);// y = y + σ_d K[(1+ω)(μ,z)^{k+1} - ω (μ,z)^k]-b
49
6b0db7251ebe Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
313 opKz.gemv(&mut y, -σ_d * ω, z, 1.0); // y = y + σ_d K[(1+ω)(μ,z)^{k+1} - ω (μ,z)^k]-b
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
314 y = starH.prox(σ_d, y);
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
315 z = z_new;
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
316
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
317 // Update step length parameters
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
318 // let ω = pdpsconfig.acceleration.accelerate(&mut τ, &mut σ, γ);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
319
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
320 // Give statistics if requested
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
321 let iter = state.iteration();
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
322 stats.this_iters += 1;
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
323
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
324 state.if_verbose(|| {
37
c5d8bd1a7728 Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents: 36
diff changeset
325 plotter.plot_spikes(iter, maybe_d.as_ref(), Some(&τv̆), &μ);
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
326 full_stats(&μ, &z, ε, std::mem::replace(&mut stats, IterInfo::new()))
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
327 });
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
328
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
329 // Update main tolerance for next iteration
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
330 ε = tolerance.update(ε, iter);
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
331 }
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
332
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
333 let fit = |μ̃: &RNDM<N, F>| {
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
334 f.apply(Pair(μ̃, &z)) /*+ fnR.apply(z) + reg.apply(μ)*/
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
335 + fnH.apply(/* opKμ.apply(&μ̃) + */ opKz.apply(&z))
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
336 };
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
337
39
6316d68b58af Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 37
diff changeset
338 μ.merge_spikes_fitness(config.insertion.final_merging_method(), fit, |&v| v);
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
339 μ.prune();
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
340 Ok(Pair(μ, z))
35
b087e3eab191 New version of sliding.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
341 }
61
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
342
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
343 /// Iteratively solve the pointsource localisation with an additional variable
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
344 /// using sliding forward-backward splitting.
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
345 ///
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
346 /// The implementation uses [`pointsource_sliding_pdps_pair`] with appropriate dummy
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
347 /// variables, operators, and functions.
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
348 #[replace_float_literals(F::cast_from(literal))]
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
349 pub fn pointsource_sliding_fb_pair<F, I, S, Dat, Reg, P, Z, R, Plot, const N: usize>(
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
350 f: &Dat,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
351 reg: &Reg,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
352 prox_penalty: &P,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
353 config: &SlidingFBConfig<F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
354 iterator: I,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
355 plotter: Plot,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
356 (μ0, z): (Option<RNDM<N, F>>, Z),
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
357 //opKμ : KOpM,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
358 fnR: &R,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
359 ) -> DynResult<MeasureZ<F, Z, N>>
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
360 where
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
361 F: Float + ToNalgebraRealField,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
362 I: AlgIteratorFactory<IterInfo<F>>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
363 Dat: DifferentiableMapping<MeasureZ<F, Z, N>, Codomain = F, DerivativeDomain = Pair<S, Z>>
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
364 + BoundedCurvature<F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
365 S: DifferentiableRealMapping<N, F> + ClosedMul<F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
366 RNDM<N, F>: SpikeMerging<F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
367 Reg: SlidingRegTerm<Loc<N, F>, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
368 P: ProxPenalty<Loc<N, F>, S, Reg, F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
369 for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
370 Z: ClosedEuclidean<F> + AXPY + Clone,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
371 for<'b> &'b Z: Instance<Z>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
372 R: Prox<Z, Codomain = F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
373 Plot: Plotter<P::ReturnMapping, S, RNDM<N, F>>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
374 // We should not need to explicitly require this:
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
375 for<'b> &'b Loc<0, F>: Instance<Loc<0, F>>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
376 // Loc<0, F>: StaticEuclidean<Field = F, PrincipalE = Loc<0, F>>
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
377 // + Instance<Loc<0, F>>
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
378 // + VectorSpace<Field = F>,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
379 {
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
380 let opKz: ZeroOp<Z, Loc<0, F>, _, _, F> =
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
381 ZeroOp::new_dualisable(StaticEuclideanOriginGenerator, z.dual_origin());
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
382 let fnH = Zero::new();
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
383 // Convert config. We don't implement From (that could be done with the o2o crate), as σd0
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
384 // needs to be chosen in a general case; for the problem of this fucntion, anything is valid.
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
385 let &SlidingFBConfig { τ0, σp0, insertion, transport, guess } = config;
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
386 let pdps_config = SlidingPDPSConfig { τ0, σp0, insertion, transport, guess, σd0: 0.0 };
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
387
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
388 pointsource_sliding_pdps_pair(
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
389 f,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
390 reg,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
391 prox_penalty,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
392 &pdps_config,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
393 iterator,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
394 plotter,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
395 (μ0, z, Loc([])),
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
396 &opKz,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
397 fnR,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
398 &fnH,
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
399 )
4f468d35fa29 General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
400 }

mercurial