Sun, 26 Jul 2026 17:30:51 -0500
Add maximum iteration setting for scaling heuristic
| 35 | 1 | /*! |
| 2 | Solver for the point source localisation problem using a sliding | |
| 3 | primal-dual proximal splitting method. | |
| 4 | */ | |
| 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; |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
11 | use crate::prox_penalty::StepLengthBoundPair; |
|
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
|
12 | use crate::regularisation::SlidingRegTerm; |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
13 | use crate::sliding_fb::{SlidingFBConfig, Transport, TransportConfig, TransportProxPenalty}; |
|
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::*; |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
15 | use alg_tools::bounds::MinMaxMapping; |
|
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
|
16 | 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
|
17 | 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
|
18 | 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
|
19 | 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
|
20 | 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
|
21 | 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
|
22 | 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
|
23 | }; |
|
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::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
|
25 | use alg_tools::nalgebra_support::ToNalgebraRealField; |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
26 | 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
|
27 | use anyhow::ensure; |
| 35 | 28 | 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
|
29 | use serde::{Deserialize, Serialize}; |
| 35 | 30 | |
| 31 | /// Settings for [`pointsource_sliding_pdps_pair`]. | |
| 32 | #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)] | |
| 33 | #[serde(default)] | |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
34 | 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
|
35 | /// 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
|
36 | 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
|
37 | /// 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
|
38 | 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
|
39 | /// 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
|
40 | /// |
|
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
|
41 | /// 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
|
42 | pub σd0: F, |
| 35 | 43 | /// Transport parameters |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
44 | pub transport: TransportConfig<F>, |
| 35 | 45 | /// 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
|
46 | 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
|
47 | /// 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
|
48 | pub guess: BoundedCurvatureGuess, |
| 35 | 49 | } |
| 50 | ||
| 51 | #[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
|
52 | impl<F: Float> Default for SlidingPDPSConfig<F> { |
| 35 | 53 | fn default() -> Self { |
| 54 | SlidingPDPSConfig { | |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
55 | τ0: 0.99, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
56 | σd0: 0.05, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
57 | σ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
|
58 | 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
|
59 | 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
|
60 | guess: BoundedCurvatureGuess::BetterThanZero, |
| 35 | 61 | } |
| 62 | } | |
| 63 | } | |
| 64 | ||
|
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
|
65 | type MeasureZ<F, Z, const N: usize> = Pair<RNDM<N, F>, Z>; |
| 35 | 66 | |
| 67 | /// Iteratively solve the pointsource localisation with an additional variable | |
| 68 | /// using sliding primal-dual proximal splitting | |
| 69 | /// | |
| 70 | /// The parametrisation is as for [`crate::forward_pdps::pointsource_forward_pdps_pair`]. | |
| 71 | #[replace_float_literals(F::cast_from(literal))] | |
| 72 | 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
|
73 | F, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
74 | I, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
75 | 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
|
76 | Dat, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
77 | Reg, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
78 | P, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
79 | Z, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
80 | R, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
81 | 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
|
82 | Plot, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
83 | /*KOpM, */ KOpZ, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
84 | H, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
85 | const N: usize, |
| 35 | 86 | >( |
|
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
|
87 | 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
|
88 | reg: &Reg, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
89 | prox_penalty: &P, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
90 | config: &SlidingPDPSConfig<F>, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
91 | 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
|
92 | 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
|
93 | (μ0, mut z, mut y): (Option<RNDM<N, F>>, Z, Y), |
| 35 | 94 | //opKμ : KOpM, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
95 | opKz: &KOpZ, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
96 | fnR: &R, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
97 | 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
|
98 | ) -> DynResult<MeasureZ<F, Z, N>> |
| 35 | 99 | where |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
100 | 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
|
101 | 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
|
102 | 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
|
103 | + BoundedCurvature<F>, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
104 | S: DifferentiableRealMapping<N, F> + ClosedMul<F> + MinMaxMapping<Loc<N, F>, 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
|
105 | 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
|
106 | //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
|
107 | 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
|
108 | Reg: SlidingRegTerm<Loc<N, F>, F>, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
109 | P: TransportProxPenalty<Loc<N, F>, S, Reg, 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
|
110 | // 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
|
111 | // + GEMV<F, RNDM<N, F>> |
| 35 | 112 | // + 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
|
113 | // RNDM<N, F>, Y, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
36
diff
changeset
|
114 | // PreadjointCodomain = S, |
| 35 | 115 | // > |
| 116 | // + 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
|
117 | // + AdjointProductBoundedBy<RNDM<N, F>, 𝒟, FloatType=F>, |
| 35 | 118 | // for<'b> KOpM::Preadjoint<'b> : GEMV<F, Y>, |
| 119 | // 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
|
120 | KOpZ: BoundedLinear<Z, L2, L2, F, Codomain = Y> |
| 35 | 121 | + 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
|
122 | + 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
|
123 | 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
|
124 | Y: ClosedEuclidean<F>, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
125 | for<'b> &'b Y: Instance<Y>, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
126 | Z: ClosedEuclidean<F> + AXPY, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
127 | 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
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | Plot: Plotter<P::ReturnMapping, S, RNDM<N, F>>, |
| 35 | 132 | { |
| 133 | // 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
|
134 | /*ensure!( |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
135 | config.τ0 > 0.0 |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
136 | && config.τ0 < 1.0 |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
137 | && config.σp0 > 0.0 |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
138 | && config.σp0 < 1.0 |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
139 | && config.σd0 > 0.0 |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
140 | && 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
|
141 | "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
|
142 | );*/ |
|
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
|
143 | config.transport.check()?; |
| 35 | 144 | |
| 145 | // 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
|
146 | 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
|
147 | 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
|
148 | //let zero_z = z.similar_origin(); |
| 35 | 149 | |
| 150 | // Set up parameters | |
| 151 | // 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
|
152 | // let opAnorm = opA.opnorm_bound(PairNorm(Radon, L2, L2), L2); |
| 35 | 153 | let bigθ = 0.0; //opKμ.transport_lipschitz_factor(L2Squared); |
| 154 | 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
|
155 | let nKz = opKz.opnorm_bound(L2, L2)?; |
|
66
fe47ad484deb
Allow fitness merge when forward_pdps and sliding_pdps are used as forward-backward with aux variable.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
156 | let is_fb = nKz == 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
|
157 | 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
|
158 | 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
|
159 | 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
|
160 | |
| 35 | 161 | // We need to satisfy |
| 162 | // | |
| 163 | // τσ_dM(1-σ_p L_z)/(1 - τ L) + [σ_p L_z + σ_pσ_d‖K_z‖^2] < 1 | |
| 164 | // ^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 165 | // with 1 > σ_p L_z and 1 > τ L. | |
| 166 | // | |
| 167 | // To do so, we first solve σ_p and σ_d from standard PDPS step length condition | |
| 168 | // ^^^^^ < 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
|
169 | // If opKZ is the zero operator, then we set σ_d = 0 for τ to be calculated correctly below. |
|
66
fe47ad484deb
Allow fitness merge when forward_pdps and sliding_pdps are used as forward-backward with aux variable.
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
170 | let σ_d = if is_fb { 0.0 } else { config.σd0 / nKz }; |
| 35 | 171 | let σ_p = config.σp0 / (l_z + config.σd0 * nKz); |
| 172 | // Observe that = 1 - ^^^^^^^^^^^^^^^^^^^^^ = 1 - σ_{p,0} | |
| 173 | // We get the condition τσ_d M (1-σ_p L_z) < (1-σ_{p,0})*(1-τ L) | |
| 174 | // ⟺ τ [ σ_d M (1-σ_p L_z) + (1-σ_{p,0}) L ] < (1-σ_{p,0}) | |
| 175 | let φ = 1.0 - config.σp0; | |
| 176 | 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
|
177 | let τ = config.τ0 * φ / (σ_d * bigM * a + φ * l); |
| 35 | 178 | let ψ = 1.0 - τ * l; |
| 179 | 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
|
180 | ensure!(β < 1.0); |
| 44 | 181 | // Now we need κ‖K_μ(π_♯^1 - π_♯^0)γ‖^2 ≤ (1/θ - τ[ℓ_F + ℓ]) ∫ c_2 dγ for κ defined as: |
| 36 | 182 | let κ = τ * σ_d * ψ / ((1.0 - β) * ψ - τ * σ_d * bigM); |
| 35 | 183 | // The factor two in the manuscript disappears due to the definition of 𝚹 being |
| 184 | // 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
|
185 | |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
186 | let mut τθ_or_adaptive = prox_penalty.get_transport_steplength( |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
187 | f.curvature_bound_components(config.guess), |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
188 | &config.transport, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
189 | 0.0, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
190 | κ * bigθ / τ, // = 0 currently |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
191 | ); |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
192 | |
| 35 | 193 | // Acceleration is not currently supported |
| 194 | // let γ = dataterm.factor_of_strong_convexity(); | |
| 195 | let ω = 1.0; | |
| 196 | ||
| 197 | // We multiply tolerance by τ for FB since our subproblems depending on tolerances are scaled | |
| 198 | // by τ compared to the conditional gradient approach. | |
| 199 | let tolerance = config.insertion.tolerance * τ * reg.tolerance_scaling(); | |
| 200 | let mut ε = tolerance.initial(); | |
| 201 | ||
| 202 | let starH = fnH.conjugate(); | |
| 203 | ||
| 204 | // 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
|
205 | 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
|
206 | 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
|
207 | + fnR.apply(z) |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
208 | + reg.apply(μ) |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
209 | + 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
|
210 | n_spikes: μ.len(), |
| 35 | 211 | ε, |
| 212 | // 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
|
213 | ..stats |
| 35 | 214 | }; |
| 215 | let mut stats = IterInfo::new(); | |
| 216 | ||
| 217 | // 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
|
218 | for state in iterator.iter_init(|| full_stats(&μ, &z, ε, stats.clone())) { |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
219 | let Pair(mut v, _) = f.differential(Pair(&μ, &z)); |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
220 | |
| 35 | 221 | //opKμ.preadjoint().apply_add(&mut v, y); |
| 222 | // We want to proceed as in Example 4.12 but with v and v̆ as in §5. | |
| 223 | // With A(ν, z) = A_μ ν + A_z z, following Example 5.1, we have | |
| 224 | // P_ℳ[F'(ν, z) + Ξ(ν, z, y)]= A_ν^*[A_ν ν + A_z z] + K_μ ν = A_ν^*A(ν, z) + K_μ ν, | |
| 225 | // where A_ν^* becomes a multiplier. | |
| 226 | // This is much easier with K_μ = 0, which is the only reason why are enforcing it. | |
| 227 | // 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
|
228 | |
|
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
|
229 | //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
|
230 | |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
231 | prox_penalty.initial_transport( |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
232 | &mut γ, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
233 | &μ, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
234 | ε, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
235 | τ, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
236 | &mut τθ_or_adaptive, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
237 | &v, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
238 | &config.transport, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
239 | ); |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
240 | |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
241 | let mut attempts = 0; |
| 35 | 242 | |
| 243 | // Solve finite-dimensional subproblem several times until the dual variable for the | |
| 244 | // regularisation term conforms to the assumptions made for the transport above. | |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
245 | let (mut τv̆, z_new, μ̆) = 'adapt_transport: loop { |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
246 | // Set initial guess for μ=μ^{k+1}. |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
247 | γ.μ̆_into(&mut μ); |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
248 | let μ̆ = μ.clone(); |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
249 | |
| 35 | 250 | // Calculate τv̆ = τA_*(A[μ_transported + μ_transported_base]-b) |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
251 | let Pair(v̆, mut z̆) = f.differential(Pair(&μ̆, &z)); |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
252 | let mut τv̆ = v̆ * τ; |
| 35 | 253 | // opKμ.preadjoint().gemv(&mut τv̆, τ, y, 1.0); |
| 254 | ||
| 255 | // Construct μ^{k+1} by solving finite-dimensional subproblems and insert new spikes. | |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
256 | 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
|
257 | &mut μ, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
258 | &mut τv̆, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
259 | τ, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
260 | ε, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
261 | &config.insertion, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
262 | ®, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
263 | &state, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
264 | &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
|
265 | )?; |
| 35 | 266 | |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
267 | // Do z variable primal update here to able to estimate B_{v̆^k-v^{k+1}} |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
268 | opKz_adj.apply_add(&mut z̆, &y); |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
269 | z̆.axpy(1.0, &z, -σ_p); |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
270 | let z_new = fnR.prox(σ_p, z̆); |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
271 | //let z_new = fnR.prox(σ_p, z̆ * (-σ_p) + &z); |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
272 | |
| 35 | 273 | // A posteriori transport adaptation. |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
274 | if prox_penalty.aposteriori_transport( |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
275 | &mut γ, |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
276 | &μ, |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
277 | &μ̆, |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
278 | &mut τv̆, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
279 | &mut v, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
280 | None, //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
|
281 | ε, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
282 | τ, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
283 | &τθ_or_adaptive, |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
284 | reg, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
285 | &config.transport, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
286 | &config.insertion.refinement, |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
287 | &mut attempts, |
| 35 | 288 | ) { |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
289 | break 'adapt_transport (τv̆, z_new, μ̆); |
| 35 | 290 | } |
| 291 | }; | |
| 292 | ||
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
293 | γ.get_transport_stats(&mut stats, &μ); |
| 35 | 294 | |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
295 | // Do dual update |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
296 | // opKμ.gemv(&mut y, σ_d*(1.0 + ω), &μ, 1.0); // y = y + σ_d K[(1+ω)(μ,z)^{k+1}] |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
297 | z.axpy(1.0 + ω, &z_new, -ω); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
298 | //z = (z - &z_new) * (-ω) + &z_new; |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
299 | opKz.gemv(&mut y, σ_d, z, 1.0); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
300 | y = starH.prox(σ_d, y); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
301 | z = z_new; |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
302 | |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
303 | // Merge spikes. |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
304 | // 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
|
305 | // and not to performing any pruning. That is be to done below simultaneously for γ. |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
306 | config.insertion.if_merge_now(&state, |ins| { |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
307 | let m = prox_penalty.merge_spikes( |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
308 | &mut μ, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
309 | &mut τv̆, |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
310 | &μ̆, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
311 | τ, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
312 | ε, |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
313 | ins, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
314 | ®, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
315 | Some(|μ̃: &RNDM<N, F>| f.apply(Pair(μ̃, &z))), |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
316 | ); |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
317 | if m > 0 { |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
318 | stats.merged += m; |
|
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
319 | } |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
320 | }); |
| 35 | 321 | |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
322 | γ.prune_compat(&mut μ, &mut stats); |
| 35 | 323 | |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
324 | for _ in 0..config.insertion.extra_weight_optimisation_steps { |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
325 | // Do extra weight optimisation step heuristic |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
326 | let Pair(v, mut _z_tmp) = f.differential(Pair(&μ, &z)); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
327 | τv̆ = v * τ; |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
328 | prox_penalty.reweigh( |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
329 | &mut μ, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
330 | &mut τv̆, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
331 | τ, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
332 | ε, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
333 | &config.insertion, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
334 | ®, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
335 | &state, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
336 | &mut stats, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
337 | )?; |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
338 | |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
339 | // opKz_adj.apply_add(&mut z_tmp, &y); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
340 | // z_tmp.axpy(1.0, &z, -σ_p); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
341 | // let z_new = fnR.prox(σ_p, z_tmp); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
342 | // z.axpy(1.0 + ω, &z_new, -ω); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
343 | // //z = (z - &z_new) * (-ω) + &z_new; |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
344 | // opKz.gemv(&mut y, σ_d, z, 1.0); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
345 | // y = starH.prox(σ_d, y); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
346 | // z = z_new; |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
347 | } |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
348 | |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
349 | if config.insertion.extra_weight_optimisation_steps > 0 { |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
350 | γ.prune_compat(&mut μ, &mut stats); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
351 | } |
| 35 | 352 | |
| 353 | // Update step length parameters | |
| 354 | // let ω = pdpsconfig.acceleration.accelerate(&mut τ, &mut σ, γ); | |
| 355 | ||
| 356 | // Give statistics if requested | |
| 357 | let iter = state.iteration(); | |
| 358 | stats.this_iters += 1; | |
| 359 | ||
| 360 | state.if_verbose(|| { | |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
361 | plotter.plot_spikes(iter, None, 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
|
362 | full_stats(&μ, &z, ε, std::mem::replace(&mut stats, IterInfo::new())) |
| 35 | 363 | }); |
| 364 | ||
| 365 | // Update main tolerance for next iteration | |
| 366 | ε = tolerance.update(ε, iter); | |
| 367 | } | |
| 368 | ||
|
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
|
369 | 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
|
370 | f.apply(Pair(μ̃, &z)) /*+ fnR.apply(z) + reg.apply(μ)*/ |
| 35 | 371 | + fnH.apply(/* opKμ.apply(&μ̃) + */ opKz.apply(&z)) |
| 372 | }; | |
| 373 | ||
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
374 | μ.merge_spikes_fitness(config.insertion.final_merging_method(), fit, |&v| v); |
| 35 | 375 | μ.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
|
376 | Ok(Pair(μ, z)) |
| 35 | 377 | } |
|
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
|
378 | |
|
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 | /// 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
|
380 | /// 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
|
381 | /// |
|
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 | /// 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
|
383 | /// 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
|
384 | #[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
|
385 | 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
|
386 | 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
|
387 | 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
|
388 | 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
|
389 | 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
|
390 | 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
|
391 | 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
|
392 | (μ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
|
393 | //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
|
394 | 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
|
395 | ) -> 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
|
396 | 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
|
397 | 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
|
398 | 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
|
399 | 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
|
400 | + BoundedCurvature<F>, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
401 | S: DifferentiableRealMapping<N, F> + ClosedMul<F> + MinMaxMapping<Loc<N, F>, 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
|
402 | 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
|
403 | Reg: SlidingRegTerm<Loc<N, F>, F>, |
|
72
e9a460a0e638
New simplified sliding a posteriori rule. Enable scaling heuristic from fixed `measure` crate. “Fast” spread Lipschitz factor fixes, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
68
diff
changeset
|
404 | P: TransportProxPenalty<Loc<N, F>, S, Reg, 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
|
405 | 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
|
406 | 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
|
407 | 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
|
408 | 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
|
409 | 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
|
410 | // 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
|
411 | 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
|
412 | // 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
|
413 | // + 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
|
414 | // + 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
|
415 | { |
|
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
|
416 | 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
|
417 | 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
|
418 | 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
|
419 | // 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
|
420 | // 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
|
421 | 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
|
422 | 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
|
423 | |
|
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
|
424 | 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
|
425 | 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
|
426 | 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
|
427 | 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
|
428 | &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
|
429 | 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
|
430 | 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
|
431 | (μ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
|
432 | &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
|
433 | 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
|
434 | &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
|
435 | ) |
|
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
|
436 | } |