Fri, 14 Aug 2026 10:38:27 -0500
Small optimisation
| 35 | 1 | /*! |
| 2 | Solver for the point source localisation problem using a | |
| 3 | primal-dual proximal splitting with a forward step. | |
| 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:
39
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:
39
diff
changeset
|
8 | use crate::measures::merging::SpikeMerging; |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
9 | 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:
39
diff
changeset
|
10 | use crate::plot::Plotter; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
11 | use crate::prox_penalty::{ProxPenalty, StepLengthBoundPair}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
12 | use crate::regularisation::RegTerm; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
13 | use crate::types::*; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
14 | 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:
39
diff
changeset
|
15 | 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:
39
diff
changeset
|
16 | 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:
39
diff
changeset
|
17 | use alg_tools::euclidean::ClosedEuclidean; |
| 35 | 18 | use alg_tools::iterate::AlgIteratorFactory; |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
19 | use alg_tools::linops::{ |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
20 | BoundedLinear, IdOp, SimplyAdjointable, Space, StaticEuclideanOriginGenerator, ZeroOp, AXPY, |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
21 | GEMV, |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
22 | }; |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
23 | use alg_tools::mapping::{DifferentiableMapping, Instance}; |
| 35 | 24 | use alg_tools::nalgebra_support::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:
39
diff
changeset
|
25 | use alg_tools::norms::L2; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
26 | use anyhow::ensure; |
| 89 | 27 | use measures::DeltaMeasure; |
|
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:
39
diff
changeset
|
28 | use numeric_literals::replace_float_literals; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
29 | use serde::{Deserialize, Serialize}; |
| 35 | 30 | |
| 31 | /// Settings for [`pointsource_forward_pdps_pair`]. | |
| 32 | #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)] | |
| 33 | #[serde(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:
39
diff
changeset
|
34 | pub struct ForwardPDPSConfig<F: Float> { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
35 | /// Overall primal step length scaling. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
36 | pub τ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:
39
diff
changeset
|
37 | /// Primal 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:
39
diff
changeset
|
38 | pub σp0: 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:
39
diff
changeset
|
39 | /// Dual step length scaling for additional variable. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
40 | /// |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
41 | /// Taken zero for [`pointsource_fb_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:
39
diff
changeset
|
42 | pub σd0: F, |
| 35 | 43 | /// 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:
39
diff
changeset
|
44 | pub insertion: InsertionConfig<F>, |
| 35 | 45 | } |
| 46 | ||
| 47 | #[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:
39
diff
changeset
|
48 | impl<F: Float> Default for ForwardPDPSConfig<F> { |
| 35 | 49 | fn default() -> Self { |
|
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:
39
diff
changeset
|
50 | ForwardPDPSConfig { τ0: 0.99, σd0: 0.05, σp0: 0.99, insertion: Default::default() } |
| 35 | 51 | } |
| 52 | } | |
| 53 | ||
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
54 | type MeasureZ<F, Z, U> = Pair<DiscreteMeasure<U, F>, Z>; |
| 35 | 55 | |
| 56 | /// Iteratively solve the pointsource localisation with an additional variable | |
| 57 | /// using primal-dual proximal splitting with a forward step. | |
|
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:
39
diff
changeset
|
58 | /// |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
59 | /// The problem is |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
60 | /// $$ |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
61 | /// \min_{μ, z}~ F(μ, z) + R(z) + H(K_z z) + Q(μ), |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
62 | /// $$ |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
63 | /// 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:
39
diff
changeset
|
64 | /// * The data term $F$ is given in `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:
39
diff
changeset
|
65 | /// * the measure (Radon or positivity-constrained Radon) regulariser in $Q$ is given in `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:
39
diff
changeset
|
66 | /// * the functions $R$ and $H$ are given in `fnR` and `fnH`, and |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
67 | /// * the operator $K_z$ in `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:
39
diff
changeset
|
68 | /// |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
69 | /// This is dualised to |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
70 | /// $$ |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
71 | /// \min_{μ, z}\max_y~ F(μ, z) + R(z) + ⟨K_z z, y⟩ + Q(μ) - H^*(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:
39
diff
changeset
|
72 | /// $$ |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
73 | /// |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
74 | /// The algorithm is controlled by: |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
75 | /// * the proximal penalty in `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:
39
diff
changeset
|
76 | /// * the initial iterates in `z`, `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:
39
diff
changeset
|
77 | /// * The configuration in `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:
39
diff
changeset
|
78 | /// * The `iterator` that controls stopping and reporting. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
79 | /// Moreover, plotting is performed by `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:
39
diff
changeset
|
80 | /// |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
81 | /// The step lengths need to satisfy |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
82 | /// $$ |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
83 | /// τσ_dM(1-σ_p L_z)/(1 - τ L) + [σ_p L_z + σ_pσ_d‖K_z‖^2] < 1 |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
84 | /// $$ ^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
85 | /// with $1 > σ_p L_z$ and $1 > τ L$. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
86 | /// Since we are given “scalings” $τ_0$, $σ_{p,0}$, and $σ_{d,0}$ in `config`, we take |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
87 | /// $σ_d=σ_{d,0}/‖K_z‖$, and $σ_p = σ_{p,0} / (L_z σ_d‖K_z‖)$. This satisfies the |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
88 | /// part $[σ_p L_z + σ_pσ_d‖K_z‖^2] < 1$. Then with these cohices, we solve |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
89 | /// $$ |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
90 | /// τ = τ_0 \frac{1 - σ_{p,0}}{(σ_d M (1-σ_p L_z) + (1 - σ_{p,0} L)}. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
91 | /// $$ |
| 35 | 92 | #[replace_float_literals(F::cast_from(literal))] |
| 89 | 93 | pub fn pointsource_forward_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:
39
diff
changeset
|
94 | F, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
95 | 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:
39
diff
changeset
|
96 | 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:
39
diff
changeset
|
97 | S, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
98 | 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:
39
diff
changeset
|
99 | 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:
39
diff
changeset
|
100 | 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:
39
diff
changeset
|
101 | 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:
39
diff
changeset
|
102 | 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:
39
diff
changeset
|
103 | 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:
39
diff
changeset
|
104 | /*KOpM, */ KOpZ, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
105 | H, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
106 | Plot, |
| 35 | 107 | >( |
|
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:
39
diff
changeset
|
108 | 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:
39
diff
changeset
|
109 | 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:
39
diff
changeset
|
110 | 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:
39
diff
changeset
|
111 | config: &ForwardPDPSConfig<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:
39
diff
changeset
|
112 | 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:
39
diff
changeset
|
113 | mut plotter: Plot, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
114 | (μ0, mut z, mut y): (Option<DiscreteMeasure<U, F>>, Z, Y), |
| 35 | 115 | //opKμ : KOpM, |
|
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:
39
diff
changeset
|
116 | opKz: &KOpZ, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
117 | 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:
39
diff
changeset
|
118 | fnH: &H, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
119 | domain: &mut impl AdmissibleDomain<U>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
120 | ) -> DynResult<MeasureZ<F, Z, U>> |
| 35 | 121 | where |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
122 | F: Float + ToNalgebraRealField, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
123 | U: Space + Clone, |
|
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:
39
diff
changeset
|
124 | I: AlgIteratorFactory<IterInfo<F>>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
125 | Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
126 | S: ClosedMul<F>, |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
127 | for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
128 | DiscreteMeasure<U, F>: SpikeMerging<F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
129 | Reg: RegTerm<U, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
130 | P: ProxPenalty<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:
39
diff
changeset
|
131 | KOpZ: BoundedLinear<Z, L2, L2, F, Codomain = Y> |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
132 | + GEMV<F, Z> |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
133 | + SimplyAdjointable<Z, Y, AdjointCodomain = Z>, |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
134 | KOpZ::SimpleAdjoint: GEMV<F, 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:
39
diff
changeset
|
135 | Y: ClosedEuclidean<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:
39
diff
changeset
|
136 | 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:
66
diff
changeset
|
137 | Z: ClosedEuclidean<F> + AXPY, |
|
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:
39
diff
changeset
|
138 | 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:
39
diff
changeset
|
139 | 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:
39
diff
changeset
|
140 | H: Conjugable<Y, F, 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:
39
diff
changeset
|
141 | for<'b> H::Conjugate<'b>: Prox<Y>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
142 | Plot: Plotter<P::ReturnMapping, S, DiscreteMeasure<U, F>>, |
| 35 | 143 | { |
| 144 | // Check parameters | |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
145 | ensure!( |
| 95 | 146 | config.τ0 > 0.0 && config.σp0 > 0.0, |
| 147 | //&& config.τ0 < 1.0 && config.σp0 < 1.0 | |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
148 | "Invalid step length parameters" |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
149 | ); |
| 35 | 150 | |
| 151 | // 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:
39
diff
changeset
|
152 | let mut μ = μ0.unwrap_or_else(|| DiscreteMeasure::new()); |
| 35 | 153 | |
| 154 | // Set up parameters | |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
155 | let bigM = 0.0; //opKμ.adjoint_product_bound(prox_penalty).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:
39
diff
changeset
|
156 | 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:
65
diff
changeset
|
157 | 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:
39
diff
changeset
|
158 | 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:
39
diff
changeset
|
159 | 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:
39
diff
changeset
|
160 | let (l, l_z) = Pair(prox_penalty, &idOpZ).step_length_bound_pair(&f)?; |
| 95 | 161 | |
| 162 | let (τ, σ_p, σ_d) = if is_fb { | |
| 163 | (config.τ0 / l, config.σp0 / l_z, 0.0) | |
| 164 | } else { | |
| 165 | ensure!( | |
| 166 | //config.τ0 < 1.0 && | |
| 167 | config.σp0 < 1.0 && config.σd0 > 0.0 && config.σp0 * config.σd0 <= 1.0, | |
| 168 | "Invalid step length parameters" | |
| 169 | ); | |
| 170 | let σ_d = config.σd0 / nKz; | |
| 171 | let σ_p = config.σp0 / (l_z + config.σd0 * nKz); | |
| 172 | let φ = 1.0 - config.σp0; | |
| 173 | let a = 1.0 - σ_p * l_z; | |
| 174 | let τ = config.τ0 * φ / (σ_d * bigM * a + φ * l); | |
| 175 | (τ, σ_p, σ_d) | |
| 176 | }; | |
| 177 | ||
| 35 | 178 | // Acceleration is not currently supported |
| 179 | // let γ = dataterm.factor_of_strong_convexity(); | |
| 180 | let ω = 1.0; | |
| 181 | ||
| 182 | // We multiply tolerance by τ for FB since our subproblems depending on tolerances are scaled | |
| 183 | // by τ compared to the conditional gradient approach. | |
| 184 | let tolerance = config.insertion.tolerance * τ * reg.tolerance_scaling(); | |
| 185 | let mut ε = tolerance.initial(); | |
| 186 | ||
| 187 | let starH = fnH.conjugate(); | |
| 188 | ||
| 189 | // Statistics | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
190 | 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:
39
diff
changeset
|
191 | value: f.apply(Pair(μ, 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:
39
diff
changeset
|
192 | + fnR.apply(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:
39
diff
changeset
|
193 | + reg.apply(μ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
194 | + fnH.apply(/* opKμ.apply(μ) + */ opKz.apply(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:
39
diff
changeset
|
195 | n_spikes: μ.len(), |
| 35 | 196 | ε, |
| 197 | // postprocessing: config.insertion.postprocessing.then(|| μ.clone()), | |
|
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:
39
diff
changeset
|
198 | ..stats |
| 35 | 199 | }; |
| 200 | let mut stats = IterInfo::new(); | |
| 201 | ||
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
202 | let zy_step = |mut z, mut y, mut z_tmp| { |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
203 | // Do z variable primal update |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
204 | opKz_adj.apply_add(&mut z_tmp, &y); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
205 | z_tmp.axpy(1.0, &z, -σ_p); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
206 | let z_new = fnR.prox(σ_p, z_tmp); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
207 | //let z_new = fnR.prox(σ_p, z_tmp * (-σ_p) + &z); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
208 | // Do dual update |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
209 | z.axpy(1.0 + ω, &z_new, -ω); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
210 | //z = (z - &z_new) * (-ω) + &z_new; |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
211 | opKz.gemv(&mut y, σ_d, z, 1.0); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
212 | let y = starH.prox(σ_d, y); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
213 | (z_new, y) |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
214 | }; |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
215 | |
| 35 | 216 | // 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:
39
diff
changeset
|
217 | for state in iterator.iter_init(|| full_stats(&μ, &z, ε, stats.clone())) { |
| 35 | 218 | // Calculate initial transport |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
219 | let Pair(v, z_tmp) = f.differential(Pair(&μ, &z)); |
|
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:
66
diff
changeset
|
220 | let mut τv = v * τ; |
| 35 | 221 | let μ_base = μ.clone(); |
|
91
47d495348e38
Do not prune new insertions on first round
Tuomo Valkonen <tuomov@iki.fi>
parents:
89
diff
changeset
|
222 | let μ_base_len = μ_base.len(); |
| 35 | 223 | |
| 224 | // 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
|
225 | prox_penalty.insert_and_reweigh( |
|
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:
39
diff
changeset
|
226 | &mut μ, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
227 | &mut τv, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
228 | τ, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
229 | ε, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
230 | &config.insertion, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
231 | ®, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
232 | &state, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
233 | &mut stats, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
234 | )?; |
| 35 | 235 | |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
236 | (z, y) = zy_step(z, y, z_tmp); |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
237 | |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
238 | stats.inserted += μ.len() - μ_base.len(); |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
239 | |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
240 | // Merge spikes. |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
241 | // 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
|
242 | // and not to performing any pruning. That is be to done below simultaneously for γ. |
| 89 | 243 | let did_merge = config.insertion.if_merge_now(&state, |ins| { |
|
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:
65
diff
changeset
|
244 | stats.merged += prox_penalty.merge_spikes( |
|
fe47ad484deb
Allow fitness merge when forward_pdps and sliding_pdps are used as forward-backward with aux variable.
Tuomo Valkonen <tuomov@iki.fi>
parents:
65
diff
changeset
|
245 | &mut μ, |
|
fe47ad484deb
Allow fitness merge when forward_pdps and sliding_pdps are used as forward-backward with aux variable.
Tuomo Valkonen <tuomov@iki.fi>
parents:
65
diff
changeset
|
246 | &mut τv, |
|
fe47ad484deb
Allow fitness merge when forward_pdps and sliding_pdps are used as forward-backward with aux variable.
Tuomo Valkonen <tuomov@iki.fi>
parents:
65
diff
changeset
|
247 | &μ_base, |
|
fe47ad484deb
Allow fitness merge when forward_pdps and sliding_pdps are used as forward-backward with aux variable.
Tuomo Valkonen <tuomov@iki.fi>
parents:
65
diff
changeset
|
248 | τ, |
|
fe47ad484deb
Allow fitness merge when forward_pdps and sliding_pdps are used as forward-backward with aux variable.
Tuomo Valkonen <tuomov@iki.fi>
parents:
65
diff
changeset
|
249 | ε, |
|
fe47ad484deb
Allow fitness merge when forward_pdps and sliding_pdps are used as forward-backward with aux variable.
Tuomo Valkonen <tuomov@iki.fi>
parents:
65
diff
changeset
|
250 | ins, |
|
fe47ad484deb
Allow fitness merge when forward_pdps and sliding_pdps are used as forward-backward with aux variable.
Tuomo Valkonen <tuomov@iki.fi>
parents:
65
diff
changeset
|
251 | ®, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
252 | Some(|μ̃: &DiscreteMeasure<U, F>| f.apply(Pair(μ̃, &z)) + reg.apply(μ̃)), |
|
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:
65
diff
changeset
|
253 | ); |
|
91
47d495348e38
Do not prune new insertions on first round
Tuomo Valkonen <tuomov@iki.fi>
parents:
89
diff
changeset
|
254 | // Prune. Do not prune new insertions on first round. |
|
47d495348e38
Do not prune new insertions on first round
Tuomo Valkonen <tuomov@iki.fi>
parents:
89
diff
changeset
|
255 | stats.pruned += prune_with_stats(&mut μ, μ_base_len); |
| 35 | 256 | |
| 89 | 257 | if config.insertion.random_insertions { |
| 258 | if let Some(x) = domain.random_point() { | |
| 259 | μ += DeltaMeasure { x, α: 0.0 }; | |
| 260 | stats.inserted += 1; | |
| 261 | } | |
| 262 | } | |
| 35 | 263 | |
| 89 | 264 | for _ in 0..config.insertion.extra_weight_optimisation_steps { |
| 265 | // Do extra weight optimisation step heuristic | |
| 266 | let Pair(v, mut _z_tmp) = f.differential(Pair(&μ, &z)); | |
| 267 | τv = v * τ; | |
| 268 | prox_penalty.reweigh( | |
| 269 | &mut μ, | |
| 270 | &mut τv, | |
| 271 | τ, | |
| 272 | ε, | |
| 273 | &config.insertion, | |
| 274 | ®, | |
| 275 | &state, | |
| 276 | &mut stats, | |
| 277 | )?; | |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
278 | |
| 89 | 279 | // opKz_adj.apply_add(&mut z_tmp, &y); |
| 280 | // z_tmp.axpy(1.0, &z, -σ_p); | |
| 281 | // let z_new = fnR.prox(σ_p, z_tmp); | |
| 282 | // z.axpy(1.0 + ω, &z_new, -ω); | |
| 283 | // //z = (z - &z_new) * (-ω) + &z_new; | |
| 284 | // opKz.gemv(&mut y, σ_d, z, 1.0); | |
| 285 | // y = starH.prox(σ_d, y); | |
| 286 | // z = z_new; | |
| 287 | } | |
| 288 | Ok(()) | |
| 289 | })?; | |
| 290 | ||
| 291 | if did_merge.is_none() { | |
|
91
47d495348e38
Do not prune new insertions on first round
Tuomo Valkonen <tuomov@iki.fi>
parents:
89
diff
changeset
|
292 | // Prune. Do not prune new insertions on first round. |
|
47d495348e38
Do not prune new insertions on first round
Tuomo Valkonen <tuomov@iki.fi>
parents:
89
diff
changeset
|
293 | stats.pruned += prune_with_stats(&mut μ, μ_base_len); |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
294 | } |
| 35 | 295 | |
| 296 | // Update step length parameters | |
| 297 | // let ω = pdpsconfig.acceleration.accelerate(&mut τ, &mut σ, γ); | |
| 298 | ||
| 299 | // Give statistics if requested | |
| 300 | let iter = state.iteration(); | |
| 301 | stats.this_iters += 1; | |
| 302 | ||
| 303 | state.if_verbose(|| { | |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
72
diff
changeset
|
304 | 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:
39
diff
changeset
|
305 | full_stats(&μ, &z, ε, std::mem::replace(&mut stats, IterInfo::new())) |
| 35 | 306 | }); |
| 307 | ||
| 308 | // Update main tolerance for next iteration | |
| 309 | ε = tolerance.update(ε, iter); | |
| 310 | } | |
| 311 | ||
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
312 | 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:
39
diff
changeset
|
313 | f.apply(Pair(μ̃, &z)) /*+ fnR.apply(z) + reg.apply(μ)*/ |
| 35 | 314 | + fnH.apply(/* opKμ.apply(&μ̃) + */ opKz.apply(&z)) |
| 84 | 315 | + reg.apply(μ̃) |
| 35 | 316 | }; |
| 317 | ||
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
318 | μ.merge_spikes_fitness(config.insertion.final_merging_method(), fit, |&v| v); |
| 35 | 319 | μ.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:
39
diff
changeset
|
320 | Ok(Pair(μ, z)) |
| 35 | 321 | } |
|
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:
39
diff
changeset
|
322 | |
| 89 | 323 | #[deprecated] |
| 324 | pub fn pointsource_forward_pdps_pair< | |
| 325 | F, | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
326 | U, |
| 89 | 327 | I, |
| 328 | S, | |
| 329 | Dat, | |
| 330 | Reg, | |
| 331 | P, | |
| 332 | Z, | |
| 333 | R, | |
| 334 | Y, | |
| 335 | /*KOpM, */ KOpZ, | |
| 336 | H, | |
| 337 | Plot, | |
| 338 | >( | |
| 339 | f: &Dat, | |
| 340 | reg: &Reg, | |
| 341 | prox_penalty: &P, | |
| 342 | config: &ForwardPDPSConfig<F>, | |
| 343 | iterator: I, | |
| 344 | plotter: Plot, | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
345 | init: (Option<DiscreteMeasure<U, F>>, Z, Y), |
| 89 | 346 | //opKμ : KOpM, |
| 347 | opKz: &KOpZ, | |
| 348 | fnR: &R, | |
| 349 | fnH: &H, | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
350 | ) -> DynResult<MeasureZ<F, Z, U>> |
| 89 | 351 | where |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
352 | F: Float + ToNalgebraRealField, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
353 | U: Space + Clone, |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
354 | //for<'a> &'a U: Instance<U>, |
| 89 | 355 | I: AlgIteratorFactory<IterInfo<F>>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
356 | Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
357 | S: ClosedMul<F>, |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
358 | for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
359 | //Pair<S, Z>: ClosedMul<F>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
360 | DiscreteMeasure<U, F>: SpikeMerging<F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
361 | Reg: RegTerm<U, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
362 | P: ProxPenalty<U, S, Reg, F>, |
| 89 | 363 | KOpZ: BoundedLinear<Z, L2, L2, F, Codomain = Y> |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
364 | + GEMV<F, Z> |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
365 | + SimplyAdjointable<Z, Y, AdjointCodomain = Z>, |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
366 | KOpZ::SimpleAdjoint: GEMV<F, Y>, |
| 89 | 367 | Y: ClosedEuclidean<F>, |
| 368 | for<'b> &'b Y: Instance<Y>, | |
| 369 | Z: ClosedEuclidean<F> + AXPY, | |
| 370 | for<'b> &'b Z: Instance<Z>, | |
| 371 | R: Prox<Z, Codomain = F>, | |
| 372 | H: Conjugable<Y, F, Codomain = F>, | |
| 373 | for<'b> H::Conjugate<'b>: Prox<Y>, | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
374 | Plot: Plotter<P::ReturnMapping, S, DiscreteMeasure<U, F>>, |
| 89 | 375 | { |
| 376 | pointsource_forward_pdps_pair_dom( | |
| 377 | f, | |
| 378 | reg, | |
| 379 | prox_penalty, | |
| 380 | config, | |
| 381 | iterator, | |
| 382 | plotter, | |
| 383 | init, | |
| 384 | opKz, | |
| 385 | fnR, | |
| 386 | fnH, | |
| 387 | &mut FullSpace, | |
| 388 | ) | |
| 389 | } | |
| 390 | ||
|
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:
39
diff
changeset
|
391 | /// 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:
39
diff
changeset
|
392 | /// using 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:
39
diff
changeset
|
393 | /// |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
394 | /// The implementation uses [`pointsource_forward_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:
39
diff
changeset
|
395 | /// 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:
39
diff
changeset
|
396 | #[replace_float_literals(F::cast_from(literal))] |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
397 | pub fn pointsource_fb_pair_dom<F, U, I, S, Dat, Reg, P, Z, R, Plot>( |
|
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:
39
diff
changeset
|
398 | 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:
39
diff
changeset
|
399 | 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:
39
diff
changeset
|
400 | 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:
39
diff
changeset
|
401 | config: &FBConfig<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:
39
diff
changeset
|
402 | 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:
39
diff
changeset
|
403 | plotter: Plot, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
404 | (μ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:
39
diff
changeset
|
405 | //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:
39
diff
changeset
|
406 | fnR: &R, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
407 | domain: &mut impl AdmissibleDomain<U>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
408 | ) -> 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:
39
diff
changeset
|
409 | where |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
410 | F: Float + ToNalgebraRealField, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
411 | U: Space + Clone, |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
412 | 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:
39
diff
changeset
|
413 | I: AlgIteratorFactory<IterInfo<F>>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
414 | Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
415 | S: ClosedMul<F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
416 | DiscreteMeasure<U, F>: SpikeMerging<F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
417 | Reg: RegTerm<U, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
418 | P: ProxPenalty<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:
39
diff
changeset
|
419 | for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
420 | Z: ClosedEuclidean<F> + AXPY + Clone, |
|
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:
39
diff
changeset
|
421 | 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:
39
diff
changeset
|
422 | R: Prox<Z, Codomain = F>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
423 | 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:
39
diff
changeset
|
424 | { |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
425 | let opKz: ZeroOp<Z, Loc<0, F>, _, _, F> = |
|
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
426 | ZeroOp::new_dualisable(StaticEuclideanOriginGenerator, z.dual_origin()); |
|
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:
39
diff
changeset
|
427 | 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:
39
diff
changeset
|
428 | // 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:
39
diff
changeset
|
429 | // 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:
39
diff
changeset
|
430 | let &FBConfig { τ0, σp0, insertion } = 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:
39
diff
changeset
|
431 | let pdps_config = ForwardPDPSConfig { τ0, σp0, insertion, σ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:
39
diff
changeset
|
432 | |
| 89 | 433 | pointsource_forward_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:
39
diff
changeset
|
434 | 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:
39
diff
changeset
|
435 | 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:
39
diff
changeset
|
436 | 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:
39
diff
changeset
|
437 | &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:
39
diff
changeset
|
438 | 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:
39
diff
changeset
|
439 | 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:
39
diff
changeset
|
440 | (μ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:
39
diff
changeset
|
441 | &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:
39
diff
changeset
|
442 | 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:
39
diff
changeset
|
443 | &fnH, |
| 89 | 444 | domain, |
|
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:
39
diff
changeset
|
445 | ) |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
446 | } |
| 89 | 447 | |
| 448 | #[deprecated] | |
| 449 | #[replace_float_literals(F::cast_from(literal))] | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
450 | pub fn pointsource_fb_pair<F, U, I, S, Dat, Reg, P, Z, R, Plot>( |
| 89 | 451 | f: &Dat, |
| 452 | reg: &Reg, | |
| 453 | prox_penalty: &P, | |
| 454 | config: &FBConfig<F>, | |
| 455 | iterator: I, | |
| 456 | plotter: Plot, | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
457 | init: (Option<DiscreteMeasure<U, F>>, Z), |
| 89 | 458 | //opKμ : KOpM, |
| 459 | fnR: &R, | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
460 | ) -> DynResult<MeasureZ<F, Z, U>> |
| 89 | 461 | where |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
462 | F: Float + ToNalgebraRealField, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
463 | U: Space + Clone, |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
464 | for<'a> &'a U: Instance<U>, |
| 89 | 465 | I: AlgIteratorFactory<IterInfo<F>>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
466 | Dat: DifferentiableMapping<MeasureZ<F, Z, U>, Codomain = F, DerivativeDomain = Pair<S, Z>>, |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
467 | S: ClosedMul<F>, |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
468 | DiscreteMeasure<U, F>: SpikeMerging<F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
469 | Reg: RegTerm<U, F>, |
|
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
470 | P: ProxPenalty<U, S, Reg, F>, |
| 89 | 471 | for<'a> Pair<&'a P, &'a IdOp<Z>>: StepLengthBoundPair<F, Dat>, |
|
96
5ba25d740dfc
attempt to reduce trait bounds
Tuomo Valkonen <tuomov@iki.fi>
parents:
95
diff
changeset
|
472 | Z: ClosedEuclidean<F> + AXPY + Clone, |
| 89 | 473 | for<'b> &'b Z: Instance<Z>, |
| 474 | R: Prox<Z, Codomain = F>, | |
|
93
8f1e57821d76
Generalise algorithms to arbitrary domains
Tuomo Valkonen <tuomov@iki.fi>
parents:
91
diff
changeset
|
475 | Plot: Plotter<P::ReturnMapping, S, DiscreteMeasure<U, F>>, |
| 89 | 476 | { |
| 477 | pointsource_fb_pair_dom( | |
| 478 | f, | |
| 479 | reg, | |
| 480 | prox_penalty, | |
| 481 | config, | |
| 482 | iterator, | |
| 483 | plotter, | |
| 484 | init, | |
| 485 | fnR, | |
| 486 | &mut FullSpace, | |
| 487 | ) | |
| 488 | } |