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