Tue, 04 Aug 2026 19:41:34 -0500
Do not prune new insertions on first round
| 35 | 1 | /*! |
| 2 | Solver for the point source localisation problem using a sliding | |
| 3 | primal-dual proximal splitting method. | |
| 4 | */ | |
| 5 | ||
| 89 | 6 | use crate::domain::{AdmissibleDomain, FullSpace}; |
|
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
|
7 | 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
|
8 | 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
|
9 | use crate::measures::merging::SpikeMerging; |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
10 | 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
|
11 | 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
|
12 | 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
|
13 | 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
|
14 | 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
|
15 | 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
|
16 | 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
|
17 | 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
|
18 | 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
|
19 | 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
|
20 | 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
|
21 | 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
|
22 | 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
|
23 | 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
|
24 | }; |
|
4f468d35fa29
General forward operators, separation 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::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
|
26 | use alg_tools::nalgebra_support::ToNalgebraRealField; |
| 89 | 27 | 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
|
28 | use anyhow::ensure; |
| 89 | 29 | use measures::DeltaMeasure; |
| 35 | 30 | 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
|
31 | use serde::{Deserialize, Serialize}; |
| 35 | 32 | |
| 33 | /// Settings for [`pointsource_sliding_pdps_pair`]. | |
| 34 | #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)] | |
| 35 | #[serde(default)] | |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
36 | 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
|
37 | /// 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
|
38 | 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
|
39 | /// 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
|
40 | 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
|
41 | /// 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
|
42 | /// |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
49
diff
changeset
|
43 | /// 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
|
44 | pub σd0: F, |
| 35 | 45 | /// Transport parameters |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
46 | pub transport: TransportConfig<F>, |
| 35 | 47 | /// 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
|
48 | 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
|
49 | /// 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
|
50 | pub guess: BoundedCurvatureGuess, |
| 35 | 51 | } |
| 52 | ||
| 53 | #[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
|
54 | impl<F: Float> Default for SlidingPDPSConfig<F> { |
| 35 | 55 | fn default() -> Self { |
| 56 | SlidingPDPSConfig { | |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
57 | τ0: 0.99, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
58 | σd0: 0.05, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
59 | σ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
|
60 | 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
|
61 | 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
|
62 | guess: BoundedCurvatureGuess::BetterThanZero, |
| 35 | 63 | } |
| 64 | } | |
| 65 | } | |
| 66 | ||
|
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
|
67 | type MeasureZ<F, Z, const N: usize> = Pair<RNDM<N, F>, Z>; |
| 35 | 68 | |
| 69 | /// Iteratively solve the pointsource localisation with an additional variable | |
| 70 | /// using sliding primal-dual proximal splitting | |
| 71 | /// | |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
72 | /// The parametrisation is as for [`crate::forward_pdps::pointsource_forward_pdps_pair`], |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
73 | /// except an additional domain restriction may be given. |
| 35 | 74 | #[replace_float_literals(F::cast_from(literal))] |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
75 | pub fn pointsource_sliding_pdps_pair_dom< |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
76 | F, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
77 | I, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
78 | 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
|
79 | Dat, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
80 | Reg, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
81 | P, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
82 | Z, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
83 | R, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
84 | 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
|
85 | Plot, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
86 | /*KOpM, */ KOpZ, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
87 | H, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
88 | const N: usize, |
| 35 | 89 | >( |
|
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
|
90 | 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
|
91 | reg: &Reg, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
92 | prox_penalty: &P, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
93 | config: &SlidingPDPSConfig<F>, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
94 | 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
|
95 | 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
|
96 | (μ0, mut z, mut y): (Option<RNDM<N, F>>, Z, Y), |
| 35 | 97 | //opKμ : KOpM, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
98 | opKz: &KOpZ, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
99 | fnR: &R, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
100 | fnH: &H, |
| 89 | 101 | domain: &mut impl AdmissibleDomain<Loc<N, 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
|
102 | ) -> DynResult<MeasureZ<F, Z, N>> |
| 35 | 103 | where |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
104 | 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
|
105 | 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
|
106 | 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
|
107 | + 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
|
108 | 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
|
109 | 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
|
110 | //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
|
111 | 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
|
112 | 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
|
113 | 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
|
114 | // 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
|
115 | // + GEMV<F, RNDM<N, F>> |
| 35 | 116 | // + 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
|
117 | // RNDM<N, F>, Y, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
36
diff
changeset
|
118 | // PreadjointCodomain = S, |
| 35 | 119 | // > |
| 120 | // + 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
|
121 | // + AdjointProductBoundedBy<RNDM<N, F>, 𝒟, FloatType=F>, |
| 35 | 122 | // for<'b> KOpM::Preadjoint<'b> : GEMV<F, Y>, |
| 123 | // 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
|
124 | KOpZ: BoundedLinear<Z, L2, L2, F, Codomain = Y> |
| 35 | 125 | + 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
|
126 | + 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
|
127 | 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
|
128 | Y: ClosedEuclidean<F>, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
129 | 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
|
130 | 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
|
131 | 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
|
132 | 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
|
133 | 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
|
134 | 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
|
135 | Plot: Plotter<P::ReturnMapping, S, RNDM<N, F>>, |
| 35 | 136 | { |
| 137 | // 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
|
138 | /*ensure!( |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
139 | config.τ0 > 0.0 |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
140 | && config.τ0 < 1.0 |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
141 | && config.σp0 > 0.0 |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
142 | && config.σp0 < 1.0 |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
143 | && config.σd0 > 0.0 |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
144 | && 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
|
145 | "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
|
146 | );*/ |
|
4f468d35fa29
General forward operators, separation 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 | config.transport.check()?; |
| 35 | 148 | |
| 149 | // 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
|
150 | 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
|
151 | 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
|
152 | //let zero_z = z.similar_origin(); |
| 35 | 153 | |
| 154 | // Set up parameters | |
| 155 | // 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
|
156 | // let opAnorm = opA.opnorm_bound(PairNorm(Radon, L2, L2), L2); |
| 35 | 157 | let bigθ = 0.0; //opKμ.transport_lipschitz_factor(L2Squared); |
| 158 | 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
|
159 | 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
|
160 | 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
|
161 | 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
|
162 | 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
|
163 | 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
|
164 | |
| 35 | 165 | // We need to satisfy |
| 166 | // | |
| 167 | // τσ_dM(1-σ_p L_z)/(1 - τ L) + [σ_p L_z + σ_pσ_d‖K_z‖^2] < 1 | |
| 168 | // ^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 169 | // with 1 > σ_p L_z and 1 > τ L. | |
| 170 | // | |
| 171 | // To do so, we first solve σ_p and σ_d from standard PDPS step length condition | |
| 172 | // ^^^^^ < 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
|
173 | // 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
|
174 | let σ_d = if is_fb { 0.0 } else { config.σd0 / nKz }; |
| 35 | 175 | let σ_p = config.σp0 / (l_z + config.σd0 * nKz); |
| 176 | // Observe that = 1 - ^^^^^^^^^^^^^^^^^^^^^ = 1 - σ_{p,0} | |
| 177 | // We get the condition τσ_d M (1-σ_p L_z) < (1-σ_{p,0})*(1-τ L) | |
| 178 | // ⟺ τ [ σ_d M (1-σ_p L_z) + (1-σ_{p,0}) L ] < (1-σ_{p,0}) | |
| 179 | let φ = 1.0 - config.σp0; | |
| 180 | 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
|
181 | let τ = config.τ0 * φ / (σ_d * bigM * a + φ * l); |
| 35 | 182 | let ψ = 1.0 - τ * l; |
| 183 | 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
|
184 | ensure!(β < 1.0); |
| 44 | 185 | // Now we need κ‖K_μ(π_♯^1 - π_♯^0)γ‖^2 ≤ (1/θ - τ[ℓ_F + ℓ]) ∫ c_2 dγ for κ defined as: |
| 36 | 186 | let κ = τ * σ_d * ψ / ((1.0 - β) * ψ - τ * σ_d * bigM); |
| 35 | 187 | // The factor two in the manuscript disappears due to the definition of 𝚹 being |
| 188 | // 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
|
189 | |
|
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
|
190 | 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
|
191 | 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
|
192 | &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
|
193 | 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
|
194 | κ * 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
|
195 | ); |
|
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
|
196 | |
| 35 | 197 | // Acceleration is not currently supported |
| 198 | // let γ = dataterm.factor_of_strong_convexity(); | |
| 199 | let ω = 1.0; | |
| 200 | ||
| 201 | // We multiply tolerance by τ for FB since our subproblems depending on tolerances are scaled | |
| 202 | // by τ compared to the conditional gradient approach. | |
| 203 | let tolerance = config.insertion.tolerance * τ * reg.tolerance_scaling(); | |
| 204 | let mut ε = tolerance.initial(); | |
| 205 | ||
| 206 | let starH = fnH.conjugate(); | |
| 207 | ||
| 208 | // 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
|
209 | 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
|
210 | 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
|
211 | + fnR.apply(z) |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
212 | + reg.apply(μ) |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
213 | + 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
|
214 | n_spikes: μ.len(), |
| 35 | 215 | ε, |
| 216 | // 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
|
217 | ..stats |
| 35 | 218 | }; |
| 219 | let mut stats = IterInfo::new(); | |
| 220 | ||
| 221 | // 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
|
222 | 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
|
223 | 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
|
224 | |
| 35 | 225 | //opKμ.preadjoint().apply_add(&mut v, y); |
| 226 | // We want to proceed as in Example 4.12 but with v and v̆ as in §5. | |
| 227 | // With A(ν, z) = A_μ ν + A_z z, following Example 5.1, we have | |
| 228 | // P_ℳ[F'(ν, z) + Ξ(ν, z, y)]= A_ν^*[A_ν ν + A_z z] + K_μ ν = A_ν^*A(ν, z) + K_μ ν, | |
| 229 | // where A_ν^* becomes a multiplier. | |
| 230 | // This is much easier with K_μ = 0, which is the only reason why are enforcing it. | |
| 231 | // 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
|
232 | |
|
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 | //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
|
234 | |
|
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
|
235 | 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
|
236 | &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
|
237 | &μ, |
|
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 | ε, |
|
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 | τ, |
|
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
|
240 | &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
|
241 | &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
|
242 | &config.transport, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
243 | domain, |
|
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
|
244 | ); |
|
63
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 | 247 | |
| 248 | // Solve finite-dimensional subproblem several times until the dual variable for the | |
| 249 | // 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
|
250 | 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
|
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 | 255 | // 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
|
256 | 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
|
257 | let mut τv̆ = v̆ * τ; |
| 35 | 258 | // opKμ.preadjoint().gemv(&mut τv̆, τ, y, 1.0); |
| 259 | ||
| 260 | // 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
|
261 | 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
|
262 | &mut μ, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
263 | &mut τv̆, |
|
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 | ε, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
266 | &config.insertion, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
267 | ®, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
268 | &state, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
269 | &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
|
270 | )?; |
| 35 | 271 | |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
272 | // 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
|
273 | 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
|
274 | 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
|
275 | 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
|
276 | //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
|
277 | |
| 35 | 278 | // 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
|
279 | 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
|
280 | &mut γ, |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
281 | &μ, |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
282 | &μ̆, |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
283 | &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
|
284 | &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
|
285 | 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
|
286 | ε, |
|
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
|
287 | τ, |
|
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
|
288 | &τθ_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
|
289 | reg, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
290 | &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
|
291 | &config.insertion.refinement, |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
292 | &mut attempts, |
| 35 | 293 | ) { |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
294 | break 'adapt_transport (τv̆, z_new, μ̆); |
| 35 | 295 | } |
| 296 | }; | |
| 297 | ||
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
298 | γ.get_transport_stats(&mut stats, &μ); |
| 35 | 299 | |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
300 | // Do dual update |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
301 | // 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
|
302 | z.axpy(1.0 + ω, &z_new, -ω); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
303 | //z = (z - &z_new) * (-ω) + &z_new; |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
304 | opKz.gemv(&mut y, σ_d, z, 1.0); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
305 | y = starH.prox(σ_d, y); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
306 | z = z_new; |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
307 | |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
308 | // Merge spikes. |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
309 | // 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
|
310 | // and not to performing any pruning. That is be to done below simultaneously for γ. |
| 89 | 311 | let did_merge = config.insertion.if_merge_now(&state, |ins| { |
| 312 | stats.merged += 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
|
313 | &mut μ, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
314 | &mut τv̆, |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
315 | &μ̆, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
316 | τ, |
|
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
317 | ε, |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
318 | ins, |
|
49
6b0db7251ebe
Some documentation and factor changes related to ℓ_F and ℓ_r.
Tuomo Valkonen <tuomov@iki.fi>
parents:
45
diff
changeset
|
319 | ®, |
|
81
642141008293
Add regularisation term to merge fitness for scaling heuristic to be justified
Tuomo Valkonen <tuomov@iki.fi>
parents:
78
diff
changeset
|
320 | Some(|μ̃: &RNDM<N, F>| f.apply(Pair(μ̃, &z)) + reg.apply(μ̃)), |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
321 | ); |
| 89 | 322 | γ.prune_compat(&mut μ, &mut stats); |
| 323 | ||
| 324 | if config.insertion.random_insertions { | |
| 325 | if let Some(x) = domain.random_point() { | |
| 326 | μ += DeltaMeasure { x, α: 0.0 }; | |
| 327 | stats.inserted += 1; | |
| 328 | } | |
|
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
|
329 | } |
| 35 | 330 | |
| 89 | 331 | for _ in 0..config.insertion.extra_weight_optimisation_steps { |
| 332 | // Do extra weight optimisation step heuristic | |
| 333 | let Pair(v, mut _z_tmp) = f.differential(Pair(&μ, &z)); | |
| 334 | τv̆ = v * τ; | |
| 335 | prox_penalty.reweigh( | |
| 336 | &mut μ, | |
| 337 | &mut τv̆, | |
| 338 | τ, | |
| 339 | ε, | |
| 340 | &config.insertion, | |
| 341 | ®, | |
| 342 | &state, | |
| 343 | &mut stats, | |
| 344 | )?; | |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
345 | |
| 89 | 346 | // opKz_adj.apply_add(&mut z_tmp, &y); |
| 347 | // z_tmp.axpy(1.0, &z, -σ_p); | |
| 348 | // let z_new = fnR.prox(σ_p, z_tmp); | |
| 349 | // z.axpy(1.0 + ω, &z_new, -ω); | |
| 350 | // //z = (z - &z_new) * (-ω) + &z_new; | |
| 351 | // opKz.gemv(&mut y, σ_d, z, 1.0); | |
| 352 | // y = starH.prox(σ_d, y); | |
| 353 | // z = z_new; | |
| 354 | } | |
| 355 | Ok(()) | |
| 356 | })?; | |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
357 | |
| 89 | 358 | if did_merge.is_none() { |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
359 | γ.prune_compat(&mut μ, &mut stats); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
360 | } |
| 35 | 361 | |
| 362 | // Update step length parameters | |
| 363 | // let ω = pdpsconfig.acceleration.accelerate(&mut τ, &mut σ, γ); | |
| 364 | ||
| 365 | // Give statistics if requested | |
| 366 | let iter = state.iteration(); | |
| 367 | stats.this_iters += 1; | |
| 368 | ||
| 369 | state.if_verbose(|| { | |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
370 | 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
|
371 | full_stats(&μ, &z, ε, std::mem::replace(&mut stats, IterInfo::new())) |
| 35 | 372 | }); |
| 373 | ||
| 374 | // Update main tolerance for next iteration | |
| 375 | ε = tolerance.update(ε, iter); | |
| 376 | } | |
| 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 | 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
|
379 | f.apply(Pair(μ̃, &z)) /*+ fnR.apply(z) + reg.apply(μ)*/ |
| 35 | 380 | + fnH.apply(/* opKμ.apply(&μ̃) + */ opKz.apply(&z)) |
| 84 | 381 | + reg.apply(μ̃) |
| 35 | 382 | }; |
| 383 | ||
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
384 | μ.merge_spikes_fitness(config.insertion.final_merging_method(), fit, |&v| v); |
| 35 | 385 | μ.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
|
386 | Ok(Pair(μ, z)) |
| 35 | 387 | } |
|
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
|
388 | |
|
4f468d35fa29
General forward operators, separation 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 | /// 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
|
390 | /// 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
|
391 | /// |
|
4f468d35fa29
General forward operators, separation 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 | /// 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
|
393 | /// 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
|
394 | #[replace_float_literals(F::cast_from(literal))] |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
395 | pub fn pointsource_sliding_fb_pair_dom<F, I, S, Dat, Reg, P, Z, R, Plot, const N: usize>( |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
396 | f: &Dat, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
397 | reg: &Reg, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
398 | prox_penalty: &P, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
399 | config: &SlidingFBConfig<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
400 | iterator: I, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
401 | plotter: Plot, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
402 | (μ0, z): (Option<RNDM<N, F>>, Z), |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
403 | //opKμ : KOpM, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
404 | fnR: &R, |
| 89 | 405 | domain: &mut impl AdmissibleDomain<Loc<N, F>>, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
406 | ) -> DynResult<MeasureZ<F, Z, N>> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
407 | where |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
408 | F: Float + ToNalgebraRealField, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
409 | I: AlgIteratorFactory<IterInfo<F>>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
410 | Dat: DifferentiableMapping<MeasureZ<F, Z, N>, Codomain = F, DerivativeDomain = Pair<S, Z>> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
411 | + BoundedCurvature<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
412 | S: DifferentiableRealMapping<N, F> + ClosedMul<F> + MinMaxMapping<Loc<N, F>, F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
413 | RNDM<N, F>: SpikeMerging<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
414 | Reg: SlidingRegTerm<Loc<N, F>, F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
415 | P: TransportProxPenalty<Loc<N, F>, S, Reg, F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
416 | for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
417 | Z: ClosedEuclidean<F> + AXPY + Clone, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
418 | for<'b> &'b Z: Instance<Z>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
419 | R: Prox<Z, Codomain = F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
420 | Plot: Plotter<P::ReturnMapping, S, RNDM<N, F>>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
421 | // We should not need to explicitly require this: |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
422 | for<'b> &'b Loc<0, F>: Instance<Loc<0, F>>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
423 | // Loc<0, F>: StaticEuclidean<Field = F, PrincipalE = Loc<0, F>> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
424 | // + Instance<Loc<0, F>> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
425 | // + VectorSpace<Field = F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
426 | { |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
427 | let opKz: ZeroOp<Z, Loc<0, F>, _, _, F> = |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
428 | ZeroOp::new_dualisable(StaticEuclideanOriginGenerator, z.dual_origin()); |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
429 | let fnH = Zero::new(); |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
430 | // Convert config. We don't implement From (that could be done with the o2o crate), as σd0 |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
431 | // needs to be chosen in a general case; for the problem of this fucntion, anything is valid. |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
432 | let &SlidingFBConfig { τ0, σp0, insertion, transport, guess } = config; |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
433 | let pdps_config = SlidingPDPSConfig { τ0, σp0, insertion, transport, guess, σd0: 0.0 }; |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
434 | |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
435 | pointsource_sliding_pdps_pair_dom( |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
436 | f, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
437 | reg, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
438 | prox_penalty, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
439 | &pdps_config, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
440 | iterator, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
441 | plotter, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
442 | (μ0, z, Loc([])), |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
443 | &opKz, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
444 | fnR, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
445 | &fnH, |
| 89 | 446 | domain, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
447 | ) |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
448 | } |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
449 | |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
450 | #[deprecated] |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
451 | /// Version of [`pointsource_sliding_pdps_pair`] without domain specification. |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
452 | #[replace_float_literals(F::cast_from(literal))] |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
453 | pub fn pointsource_sliding_pdps_pair< |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
454 | F, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
455 | I, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
456 | S, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
457 | Dat, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
458 | Reg, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
459 | P, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
460 | Z, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
461 | R, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
462 | Y, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
463 | Plot, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
464 | /*KOpM, */ KOpZ, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
465 | H, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
466 | const N: usize, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
467 | >( |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
468 | f: &Dat, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
469 | reg: &Reg, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
470 | prox_penalty: &P, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
471 | config: &SlidingPDPSConfig<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
472 | iterator: I, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
473 | plotter: Plot, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
474 | init: (Option<RNDM<N, F>>, Z, Y), |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
475 | //opKμ : KOpM, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
476 | opKz: &KOpZ, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
477 | fnR: &R, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
478 | fnH: &H, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
479 | ) -> DynResult<MeasureZ<F, Z, N>> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
480 | where |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
481 | F: Float + ToNalgebraRealField, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
482 | I: AlgIteratorFactory<IterInfo<F>>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
483 | Dat: DifferentiableMapping<MeasureZ<F, Z, N>, Codomain = F, DerivativeDomain = Pair<S, Z>> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
484 | + BoundedCurvature<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
485 | S: DifferentiableRealMapping<N, F> + ClosedMul<F> + MinMaxMapping<Loc<N, F>, F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
486 | for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
487 | //Pair<S, Z>: ClosedMul<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
488 | RNDM<N, F>: SpikeMerging<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
489 | Reg: SlidingRegTerm<Loc<N, F>, F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
490 | P: TransportProxPenalty<Loc<N, F>, S, Reg, F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
491 | // KOpM : Linear<RNDM<N, F>, Codomain=Y> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
492 | // + GEMV<F, RNDM<N, F>> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
493 | // + Preadjointable< |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
494 | // RNDM<N, F>, Y, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
495 | // PreadjointCodomain = S, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
496 | // > |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
497 | // + TransportLipschitz<L2Squared, FloatType=F> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
498 | // + AdjointProductBoundedBy<RNDM<N, F>, 𝒟, FloatType=F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
499 | // for<'b> KOpM::Preadjoint<'b> : GEMV<F, Y>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
500 | // Since Z is Hilbert, we may just as well use adjoints for K_z. |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
501 | KOpZ: BoundedLinear<Z, L2, L2, F, Codomain = Y> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
502 | + GEMV<F, Z> |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
503 | + SimplyAdjointable<Z, Y, AdjointCodomain = Z>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
504 | KOpZ::SimpleAdjoint: GEMV<F, Y>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
505 | Y: ClosedEuclidean<F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
506 | for<'b> &'b Y: Instance<Y>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
507 | Z: ClosedEuclidean<F> + AXPY, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
508 | for<'b> &'b Z: Instance<Z>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
509 | R: Prox<Z, Codomain = F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
510 | H: Conjugable<Y, F, Codomain = F>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
511 | for<'b> H::Conjugate<'b>: Prox<Y>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
512 | Plot: Plotter<P::ReturnMapping, S, RNDM<N, F>>, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
513 | { |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
514 | pointsource_sliding_pdps_pair_dom( |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
515 | f, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
516 | reg, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
517 | prox_penalty, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
518 | config, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
519 | iterator, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
520 | plotter, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
521 | init, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
522 | opKz, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
523 | fnR, |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
524 | fnH, |
| 89 | 525 | &mut FullSpace, |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
526 | ) |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
527 | } |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
528 | |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
529 | #[deprecated] |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
530 | /// Version of [`pointsource_sliding_fb_pair_dom`] without domain specification |
|
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
531 | #[replace_float_literals(F::cast_from(literal))] |
|
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
|
532 | 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
|
533 | 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
|
534 | 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
|
535 | 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
|
536 | 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
|
537 | 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
|
538 | 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
|
539 | (μ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
|
540 | //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
|
541 | 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
|
542 | ) -> 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
|
543 | 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
|
544 | 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
|
545 | 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
|
546 | 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
|
547 | + 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
|
548 | 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
|
549 | 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
|
550 | 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
|
551 | 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
|
552 | 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
|
553 | 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
|
554 | 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
|
555 | 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
|
556 | 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
|
557 | // 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
|
558 | 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
|
559 | // 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
|
560 | // + 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
|
561 | // + 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
|
562 | { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
49
diff
changeset
|
563 | 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
|
564 | 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
|
565 | 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
|
566 | // 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
|
567 | // 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
|
568 | 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
|
569 | 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
|
570 | |
|
83
66b8ac0ebe00
Sliding methods now support domain restrictions
Tuomo Valkonen <tuomov@iki.fi>
parents:
81
diff
changeset
|
571 | pointsource_sliding_pdps_pair_dom( |
|
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
|
572 | 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
|
573 | 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
|
574 | 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
|
575 | &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
|
576 | 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
|
577 | 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
|
578 | (μ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
|
579 | &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
|
580 | 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
|
581 | &fnH, |
| 89 | 582 | &mut FullSpace, |
|
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
|
583 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
49
diff
changeset
|
584 | } |