Mon, 13 Apr 2026 22:29:26 -0500
Automatic transport disabling after sufficient failures, for efficiency
| 0 | 1 | /*! |
| 2 | Solver for the point source localisation problem with primal-dual proximal splitting. | |
| 3 | ||
| 4 | This corresponds to the manuscript | |
| 5 | ||
|
13
bdc57366d4f5
arXiv links, README beautification
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
6 | * Valkonen T. - _Proximal methods for point source localisation_, |
|
bdc57366d4f5
arXiv links, README beautification
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
7 | [arXiv:2212.02991](https://arxiv.org/abs/2212.02991). |
| 0 | 8 | |
| 35 | 9 | The main routine is [`pointsource_pdps_reg`]. |
| 0 | 10 | Both norm-2-squared and norm-1 data terms are supported. That is, implemented are solvers for |
| 11 | <div> | |
| 12 | $$ | |
| 13 | \min_{μ ∈ ℳ(Ω)}~ F_0(Aμ - b) + α \|μ\|_{ℳ(Ω)} + δ_{≥ 0}(μ), | |
| 14 | $$ | |
| 15 | for both $F_0(y)=\frac{1}{2}\|y\|_2^2$ and $F_0(y)=\|y\|_1$ with the forward operator | |
| 16 | $A \in 𝕃(ℳ(Ω); ℝ^n)$. | |
| 17 | </div> | |
| 18 | ||
| 19 | ## Approach | |
| 20 | ||
| 21 | <p> | |
| 22 | The problem above can be written as | |
| 23 | $$ | |
| 24 | \min_μ \max_y G(μ) + ⟨y, Aμ-b⟩ - F_0^*(μ), | |
| 25 | $$ | |
| 26 | where $G(μ) = α \|μ\|_{ℳ(Ω)} + δ_{≥ 0}(μ)$. | |
| 27 | The Fenchel–Rockafellar optimality conditions, employing the predual in $ℳ(Ω)$, are | |
| 28 | $$ | |
| 29 | 0 ∈ A_*y + ∂G(μ) | |
| 30 | \quad\text{and}\quad | |
| 31 | Aμ - b ∈ ∂ F_0^*(y). | |
| 32 | $$ | |
| 33 | The solution of the first part is as for forward-backward, treated in the manuscript. | |
| 34 | This is the task of <code>generic_pointsource_fb</code>, where we use <code>FBSpecialisation</code> | |
| 35 | to replace the specific residual $Aμ-b$ by $y$. | |
| 36 | For $F_0(y)=\frac{1}{2}\|y\|_2^2$ the second part reads $y = Aμ -b$. | |
| 37 | For $F_0(y)=\|y\|_1$ the second part reads $y ∈ ∂\|·\|_1(Aμ - b)$. | |
| 38 | </p> | |
| 39 | */ | |
| 40 | ||
|
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
|
41 | use crate::fb::{postprocess, prune_with_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
|
42 | use crate::forward_model::ForwardModel; |
| 32 | 43 | use crate::measures::merging::SpikeMerging; |
|
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 | use crate::measures::merging::SpikeMergingMethod; |
|
4f468d35fa29
General 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
|
45 | use crate::measures::{DiscreteMeasure, RNDM}; |
|
4f468d35fa29
General 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
|
46 | 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
|
47 | pub use crate::prox_penalty::{InsertionConfig, ProxPenalty, StepLengthBoundPD}; |
| 32 | 48 | use crate::regularisation::RegTerm; |
|
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
|
49 | 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
|
50 | use alg_tools::convex::{Conjugable, ConvexMapping, Prox}; |
|
4f468d35fa29
General 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
|
51 | 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
|
52 | 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:
39
diff
changeset
|
53 | use alg_tools::linops::{Mapping, AXPY}; |
|
4f468d35fa29
General 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
|
54 | use alg_tools::mapping::{DataTerm, Instance}; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
55 | use alg_tools::nalgebra_support::ToNalgebraRealField; |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
56 | use anyhow::ensure; |
|
4f468d35fa29
General 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
|
57 | use clap::ValueEnum; |
|
4f468d35fa29
General 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 | 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
|
59 | use serde::{Deserialize, Serialize}; |
| 0 | 60 | |
| 61 | /// Acceleration | |
| 62 | #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, ValueEnum, Debug)] | |
| 63 | pub enum Acceleration { | |
| 64 | /// No acceleration | |
| 65 | #[clap(name = "none")] | |
| 66 | None, | |
| 67 | /// Partial acceleration, $ω = 1/\sqrt{1+σ}$ | |
| 68 | #[clap(name = "partial", help = "Partial acceleration, ω = 1/√(1+σ)")] | |
| 69 | Partial, | |
| 70 | /// Full acceleration, $ω = 1/\sqrt{1+2σ}$; no gap convergence guaranteed | |
|
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
|
71 | #[clap( |
|
4f468d35fa29
General 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 | name = "full", |
|
4f468d35fa29
General 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 | help = "Full acceleration, ω = 1/√(1+2σ); no gap convergence guaranteed" |
|
4f468d35fa29
General 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 | )] |
|
4f468d35fa29
General 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 | Full, |
| 0 | 76 | } |
| 77 | ||
| 35 | 78 | #[replace_float_literals(F::cast_from(literal))] |
| 79 | impl Acceleration { | |
| 80 | /// PDPS parameter acceleration. Updates τ and σ and returns ω. | |
| 81 | /// This uses dual strong convexity, not primal. | |
|
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
|
82 | fn accelerate<F: Float>(self, τ: &mut F, σ: &mut F, γ: F) -> F { |
| 35 | 83 | match self { |
| 84 | Acceleration::None => 1.0, | |
| 85 | Acceleration::Partial => { | |
| 86 | let ω = 1.0 / (1.0 + γ * (*σ)).sqrt(); | |
| 87 | *σ *= ω; | |
| 88 | *τ /= ω; | |
| 89 | ω | |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
90 | } |
| 35 | 91 | Acceleration::Full => { |
| 92 | let ω = 1.0 / (1.0 + 2.0 * γ * (*σ)).sqrt(); | |
| 93 | *σ *= ω; | |
| 94 | *τ /= ω; | |
| 95 | ω | |
|
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 | } |
| 35 | 97 | } |
| 98 | } | |
| 99 | } | |
| 100 | ||
| 101 | /// Settings for [`pointsource_pdps_reg`]. | |
| 0 | 102 | #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)] |
| 103 | #[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
|
104 | pub struct PDPSConfig<F: Float> { |
| 0 | 105 | /// Primal step length scaling. We must have `τ0 * σ0 < 1`. |
|
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
|
106 | pub τ0: F, |
| 0 | 107 | /// Dual step length scaling. We must have `τ0 * σ0 < 1`. |
|
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 | pub σ0: F, |
| 0 | 109 | /// Accelerate if available |
|
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
|
110 | pub acceleration: Acceleration, |
| 0 | 111 | /// 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
|
112 | pub generic: InsertionConfig<F>, |
| 0 | 113 | } |
| 114 | ||
| 115 | #[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
|
116 | impl<F: Float> Default for PDPSConfig<F> { |
| 0 | 117 | fn default() -> Self { |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
118 | let τ0 = 5.0; |
| 0 | 119 | PDPSConfig { |
| 120 | τ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
|
121 | σ0: 0.99 / τ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
|
122 | acceleration: Acceleration::Partial, |
|
4f468d35fa29
General 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
|
123 | generic: InsertionConfig { |
|
4f468d35fa29
General 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 | merging: SpikeMergingMethod { enabled: true, ..Default::default() }, |
|
4f468d35fa29
General 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
|
125 | ..Default::default() |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
126 | }, |
| 0 | 127 | } |
| 128 | } | |
| 129 | } | |
| 130 | ||
| 131 | /// Iteratively solve the pointsource localisation problem using primal-dual proximal splitting. | |
| 132 | /// | |
| 133 | /// The settings in `config` have their [respective documentation](PDPSConfig). `opA` is the | |
| 134 | /// forward operator $A$, $b$ the observable, and $\lambda$ the regularisation weight. | |
| 135 | /// The operator `op𝒟` is used for forming the proximal term. Typically it is a convolution | |
| 136 | /// operator. Finally, the `iterator` is an outer loop verbosity and iteration count control | |
| 137 | /// as documented in [`alg_tools::iterate`]. | |
| 138 | /// | |
| 139 | /// For the mathematical formulation, see the [module level](self) documentation and the manuscript. | |
| 140 | /// | |
| 141 | /// Returns the final iterate. | |
| 142 | #[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
|
143 | pub fn pointsource_pdps_reg<'a, F, I, A, Phi, Reg, Plot, P, const N: usize>( |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
144 | f: &'a DataTerm<F, RNDM<N, F>, A, Phi>, |
|
4f468d35fa29
General 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
|
145 | 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
|
146 | 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
|
147 | pdpsconfig: &PDPSConfig<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
|
148 | 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
|
149 | mut plotter: Plot, |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
150 | μ0: Option<RNDM<N, F>>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
151 | ) -> DynResult<RNDM<N, F>> |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
152 | where |
|
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
|
153 | F: Float + ToNalgebraRealField, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
154 | I: AlgIteratorFactory<IterInfo<F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
155 | A: ForwardModel<RNDM<N, F>, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
156 | for<'b> &'b A::Observable: Instance<A::Observable>, |
|
4f468d35fa29
General 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
|
157 | A::Observable: AXPY<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:
39
diff
changeset
|
158 | RNDM<N, F>: SpikeMerging<F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
159 | Reg: RegTerm<Loc<N, F>, F>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
160 | Phi: Conjugable<A::Observable, 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
|
161 | for<'b> Phi::Conjugate<'b>: Prox<A::Observable>, |
|
4f468d35fa29
General 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
|
162 | P: ProxPenalty<Loc<N, F>, A::PreadjointCodomain, Reg, F> + StepLengthBoundPD<F, A, RNDM<N, F>>, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
163 | Plot: Plotter<P::ReturnMapping, A::PreadjointCodomain, RNDM<N, F>>, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
164 | { |
|
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
|
165 | // Check parameters |
|
4f468d35fa29
General 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
|
166 | ensure!( |
|
4f468d35fa29
General 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
|
167 | pdpsconfig.τ0 > 0.0 && pdpsconfig.σ0 > 0.0 && pdpsconfig.τ0 * pdpsconfig.σ0 <= 1.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
|
168 | "Invalid step length parameters" |
|
4f468d35fa29
General 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
|
169 | ); |
| 0 | 170 | |
|
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
|
171 | let opA = f.operator(); |
|
4f468d35fa29
General 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
|
172 | let b = f.data(); |
|
4f468d35fa29
General 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
|
173 | let phistar = f.fidelity().conjugate(); |
| 35 | 174 | |
| 32 | 175 | // Set up parameters |
|
34
efa60bc4f743
Radon FB + sliding improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
32
diff
changeset
|
176 | let config = &pdpsconfig.generic; |
|
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
|
177 | let l = prox_penalty.step_length_bound_pd(opA)?; |
| 32 | 178 | let mut τ = pdpsconfig.τ0 / l; |
| 179 | let mut σ = pdpsconfig.σ0 / l; | |
|
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
|
180 | let γ = phistar.factor_of_strong_convexity(); |
| 32 | 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.tolerance * τ * reg.tolerance_scaling(); | |
| 185 | let mut ε = tolerance.initial(); | |
| 186 | ||
| 187 | // 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
|
188 | let mut μ = μ0.unwrap_or_else(|| DiscreteMeasure::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
|
189 | let mut y = f.residual(&μ); |
|
4f468d35fa29
General 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
|
190 | let full_stats = |μ: &RNDM<N, F>, ε, stats| IterInfo { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
191 | value: f.apply(μ) + 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
|
192 | n_spikes: μ.len(), |
| 35 | 193 | ε, |
| 194 | // postprocessing: config.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
|
195 | ..stats |
| 35 | 196 | }; |
| 32 | 197 | let mut stats = IterInfo::new(); |
| 198 | ||
| 199 | // Run the algorithm | |
| 35 | 200 | for state in iterator.iter_init(|| full_stats(&μ, ε, stats.clone())) { |
| 32 | 201 | // Calculate smooth part of surrogate model. |
|
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
|
202 | // FIXME: the clone is required to avoid compiler overflows with reference-Mul requirement above. |
|
4f468d35fa29
General 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
|
203 | let mut τv = opA.preadjoint().apply(y.clone() * τ); |
| 32 | 204 | |
| 205 | // Save current base point | |
| 206 | let μ_base = μ.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
|
207 | |
| 32 | 208 | // Insert and reweigh |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
209 | let (maybe_d, _within_tolerances) = prox_penalty |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
210 | .insert_and_reweigh(&mut μ, &mut τv, τ, ε, config, ®, &state, &mut stats)?; |
| 32 | 211 | |
| 212 | // Prune and possibly merge spikes | |
| 35 | 213 | if config.merge_now(&state) { |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
214 | stats.merged += |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
215 | prox_penalty.merge_spikes_no_fitness(&mut μ, &mut τv, &μ_base, τ, ε, config, ®); |
| 35 | 216 | } |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
217 | stats.inserted += μ.len() - μ_base.len(); |
| 35 | 218 | stats.pruned += prune_with_stats(&mut μ); |
| 0 | 219 | |
| 32 | 220 | // Update step length parameters |
| 35 | 221 | let ω = pdpsconfig.acceleration.accelerate(&mut τ, &mut σ, γ); |
| 32 | 222 | |
| 223 | // Do dual update | |
|
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
|
224 | // y = y_prev + τb |
|
4f468d35fa29
General 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
|
225 | y.axpy(τ, b, 1.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
|
226 | // y = y_prev - τ(A[(1+ω)μ^{k+1}]-b) |
|
4f468d35fa29
General 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 | opA.gemv(&mut y, -τ * (1.0 + ω), &μ, 1.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
|
228 | // y = y_prev - τ(A[(1+ω)μ^{k+1} - ω μ^k]-b) |
|
4f468d35fa29
General 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 | opA.gemv(&mut y, τ * ω, &μ_base, 1.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
|
230 | y = phistar.prox(τ, y); |
| 0 | 231 | |
| 35 | 232 | // Give statistics if requested |
| 233 | let iter = state.iteration(); | |
| 32 | 234 | stats.this_iters += 1; |
| 235 | ||
| 236 | state.if_verbose(|| { | |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
35
diff
changeset
|
237 | plotter.plot_spikes(iter, maybe_d.as_ref(), Some(&τv), &μ); |
| 35 | 238 | full_stats(&μ, ε, std::mem::replace(&mut stats, IterInfo::new())) |
| 239 | }); | |
| 240 | ||
| 241 | ε = tolerance.update(ε, iter); | |
| 242 | } | |
| 32 | 243 | |
|
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
|
244 | postprocess(μ, config, |μ| f.apply(μ)) |
|
24
d29d1fcf5423
Support arbitrary regularisation terms; implement non-positivity-constrained regularisation.
Tuomo Valkonen <tuomov@iki.fi>
parents:
13
diff
changeset
|
245 | } |