Tue, 04 Aug 2026 23:47:29 -0500
Extra weight optim was probably disabled
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
1 | /*! |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
2 | Proximal penalty abstraction |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
3 | */ |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
4 | |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
5 | use alg_tools::types::*; |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
6 | use numeric_literals::replace_float_literals; |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
7 | use serde::{Deserialize, Serialize}; |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
8 | |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
9 | use crate::measures::merging::SpikeMergingMethod; |
|
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:
51
diff
changeset
|
10 | use crate::measures::DiscreteMeasure; |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
11 | use crate::regularisation::RegTerm; |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
12 | use crate::subproblem::InnerSettings; |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
13 | use crate::tolerance::Tolerance; |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
14 | use crate::types::{IterInfo, RefinementSettings}; |
|
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:
51
diff
changeset
|
15 | 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:
51
diff
changeset
|
16 | use alg_tools::instance::Space; |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
17 | use alg_tools::iterate::{AlgIterator, AlgIteratorIteration}; |
|
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:
51
diff
changeset
|
18 | use alg_tools::mapping::Mapping; |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
19 | use alg_tools::nalgebra_support::ToNalgebraRealField; |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
20 | |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
21 | pub mod radon_squared; |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
22 | pub mod wave; |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
23 | pub use radon_squared::RadonSquared; |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
24 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
25 | /// Settings for the solution of the stepwise optimality condition. |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
26 | #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)] |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
27 | #[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:
51
diff
changeset
|
28 | pub struct InsertionConfig<F: Float> { |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
29 | /// Tolerance for point insertion. |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
30 | pub tolerance: Tolerance<F>, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
31 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
32 | /// Stop looking for predual maximum (where to isert a new point) below |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
33 | /// `tolerance` multiplied by this factor. |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
34 | /// |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
35 | /// Not used by [`crate::prox_penalty::radon_squared`]. |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
36 | pub insertion_cutoff_factor: F, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
37 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
38 | /// Settings for branch and bound refinement when looking for predual maxima |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
39 | pub refinement: RefinementSettings<F>, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
40 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
41 | /// Maximum insertions within each outer iteration |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
42 | /// |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
43 | /// Not used by [`crate::prox_penalty::radon_squared`]. |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
44 | pub max_insertions: usize, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
45 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
46 | /// Pair `(n, m)` for maximum insertions `m` on first `n` iterations. |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
47 | /// |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
48 | /// Not used by [`crate::prox_penalty::radon_squared`]. |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
49 | pub bootstrap_insertions: Option<(usize, usize)>, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
50 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
51 | /// Inner method settings |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
52 | pub inner: InnerSettings<F>, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
53 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
54 | /// Spike merging method |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
55 | pub merging: SpikeMergingMethod<F>, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
56 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
57 | /// Tolerance multiplier for merges |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
58 | pub merge_tolerance_mult: F, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
59 | |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
60 | /// Merge spikes after last step (even if merging not generally enabled) |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
61 | pub final_merging: bool, |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
62 | |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
63 | /// Use fitness as merging criterion. Implies worse convergence guarantees. |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
64 | pub fitness_merging: bool, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
65 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
66 | /// Iterations between merging heuristic tries |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
67 | pub merge_every: usize, |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
68 | |
| 89 | 69 | /// Additional weight optimisation steps after merge and random insertion |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
70 | pub extra_weight_optimisation_steps: usize, |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
71 | |
|
90
b471a13e3136
Added greedy insertion option, but does and actually really should not too much
Tuomo Valkonen <tuomov@iki.fi>
parents:
89
diff
changeset
|
72 | /// Maximum iteration for scaling hack, zero if no maximum. |
|
b471a13e3136
Added greedy insertion option, but does and actually really should not too much
Tuomo Valkonen <tuomov@iki.fi>
parents:
89
diff
changeset
|
73 | pub max_scaling_iter: usize, |
|
b471a13e3136
Added greedy insertion option, but does and actually really should not too much
Tuomo Valkonen <tuomov@iki.fi>
parents:
89
diff
changeset
|
74 | |
| 89 | 75 | /// Random insertion after merge |
| 76 | pub random_insertions: bool, | |
| 77 | ||
|
90
b471a13e3136
Added greedy insertion option, but does and actually really should not too much
Tuomo Valkonen <tuomov@iki.fi>
parents:
89
diff
changeset
|
78 | /// Greedily insert points, even if no tolerance violation. |
|
b471a13e3136
Added greedy insertion option, but does and actually really should not too much
Tuomo Valkonen <tuomov@iki.fi>
parents:
89
diff
changeset
|
79 | pub greedy: bool, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
80 | } |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
81 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
82 | #[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:
51
diff
changeset
|
83 | impl<F: Float> Default for InsertionConfig<F> { |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
84 | 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:
51
diff
changeset
|
85 | InsertionConfig { |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
86 | tolerance: Default::default(), |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
87 | insertion_cutoff_factor: 1.0, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
88 | refinement: Default::default(), |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
89 | max_insertions: 100, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
90 | //bootstrap_insertions : None, |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
91 | bootstrap_insertions: Some((10, 1)), |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
92 | inner: Default::default(), |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
93 | merging: Default::default(), |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
94 | final_merging: true, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
95 | fitness_merging: false, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
96 | merge_every: 10, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
97 | merge_tolerance_mult: 2.0, |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
98 | extra_weight_optimisation_steps: 0, |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
99 | max_scaling_iter: 0, |
| 89 | 100 | random_insertions: false, |
|
90
b471a13e3136
Added greedy insertion option, but does and actually really should not too much
Tuomo Valkonen <tuomov@iki.fi>
parents:
89
diff
changeset
|
101 | greedy: false, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
102 | } |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
103 | } |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
104 | } |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
105 | |
|
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:
51
diff
changeset
|
106 | impl<F: Float> InsertionConfig<F> { |
| 89 | 107 | /// Check if merging should be attempted this iteration. |
| 108 | /// Wrapped in a possible error, returns [`Some`] of the return value of `f`, if merging should | |
| 109 | /// be performed. | |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
110 | pub fn if_merge_now<I: AlgIterator, A>( |
|
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
111 | &self, |
|
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
112 | state: &AlgIteratorIteration<I>, |
| 89 | 113 | mut f: impl FnMut(&Self) -> DynResult<A>, |
| 114 | ) -> DynResult<Option<A>> { | |
|
94
88d994f2d63d
Extra weight optim was probably disabled
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
115 | if (self.merging.enabled |
|
88d994f2d63d
Extra weight optim was probably disabled
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
116 | || self.merging.scaling.is_some() |
|
88d994f2d63d
Extra weight optim was probably disabled
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
117 | || self.extra_weight_optimisation_steps > 0) |
| 89 | 118 | && state.iteration() % self.merge_every == 0 |
| 119 | { | |
| 120 | if self.max_scaling_iter != 0 && state.iteration() > self.max_scaling_iter { | |
| 121 | if !self.merging.enabled { | |
| 122 | Ok(None) | |
| 123 | } else { | |
| 124 | Ok(Some(f(&InsertionConfig { | |
| 125 | merging: SpikeMergingMethod { scaling: None, ..self.merging }, | |
| 126 | ..*self | |
| 127 | })?)) | |
| 128 | } | |
| 129 | } else { | |
| 130 | Ok(Some(f(self)?)) | |
| 131 | } | |
| 132 | } else { | |
| 133 | Ok(None) | |
| 134 | } | |
| 135 | } | |
| 136 | ||
| 137 | // Lightweight version of [`Self::if_merge_now`]. | |
| 138 | pub fn if_merge_now_check<I: AlgIterator, A>( | |
| 139 | &self, | |
| 140 | state: &AlgIteratorIteration<I>, | |
| 141 | mut f: impl FnMut() -> A, | |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
142 | ) -> Option<A> { |
|
94
88d994f2d63d
Extra weight optim was probably disabled
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
143 | if (self.merging.enabled |
|
88d994f2d63d
Extra weight optim was probably disabled
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
144 | || self.merging.scaling.is_some() |
|
88d994f2d63d
Extra weight optim was probably disabled
Tuomo Valkonen <tuomov@iki.fi>
parents:
90
diff
changeset
|
145 | || self.extra_weight_optimisation_steps > 0) |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
146 | && state.iteration() % self.merge_every == 0 |
|
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
147 | { |
|
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
148 | if self.max_scaling_iter != 0 && state.iteration() > self.max_scaling_iter { |
|
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
149 | if !self.merging.enabled { |
|
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
150 | None |
|
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
151 | } else { |
| 89 | 152 | Some(f()) |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
153 | } |
|
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
154 | } else { |
| 89 | 155 | Some(f()) |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
156 | } |
|
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
157 | } else { |
|
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
158 | None |
|
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
159 | } |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
160 | } |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
161 | |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
162 | /// Returns the final merging method |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
163 | pub fn final_merging_method(&self) -> SpikeMergingMethod<F> { |
|
78
2a122736e91c
Add maximum iteration setting for scaling heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
75
diff
changeset
|
164 | SpikeMergingMethod { enabled: self.final_merging, scaling: None, ..self.merging } |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
165 | } |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
166 | } |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
167 | |
|
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:
51
diff
changeset
|
168 | /// Available proximal terms |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
169 | #[derive(Copy, Clone, Debug, Serialize, Deserialize, Eq, PartialEq)] |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
170 | pub enum ProxTerm { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
171 | /// Partial-to-wave 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:
51
diff
changeset
|
172 | Wave, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
173 | /// Radon-norm squared |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
174 | RadonSquared, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
175 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
176 | |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
177 | /// Trait for proximal penalties |
|
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:
51
diff
changeset
|
178 | pub trait ProxPenalty<Domain, PreadjointCodomain, Reg, F = f64> |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
179 | where |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
180 | F: Float + ToNalgebraRealField, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
181 | Reg: RegTerm<Domain, 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:
51
diff
changeset
|
182 | Domain: Space + Clone, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
183 | { |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
184 | /// Unused, but required as a plotter parametrisation. |
|
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:
51
diff
changeset
|
185 | type ReturnMapping: Mapping<Domain, 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:
51
diff
changeset
|
186 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
187 | /// Returns the type of this proximality 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:
51
diff
changeset
|
188 | fn prox_type() -> ProxTerm; |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
189 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
190 | /// Insert new spikes into `μ` to approximately satisfy optimality conditions |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
191 | /// with the forward step term fixed to `τv`. |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
192 | /// |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
193 | /// Returns an indication of whether the tolerance bounds `ε` are satisfied. |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
194 | /// |
|
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:
51
diff
changeset
|
195 | /// `τv` is mutable to allow [`alg_tools::bounds::MinMaxMapping`] optimisation 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:
51
diff
changeset
|
196 | /// refine data. Actual values of `τv` are not supposed to be mutated. |
|
63
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
197 | /// |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
198 | /// `stats.inserted` should not be updated by implementations of this routine, |
|
7a8a55fd41c0
Subproblem solver and sliding adjustments/improvements
Tuomo Valkonen <tuomov@iki.fi>
parents:
61
diff
changeset
|
199 | /// only `stats.inner_iters`. |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
200 | fn insert_and_reweigh<I>( |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
201 | &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:
51
diff
changeset
|
202 | μ: &mut DiscreteMeasure<Domain, F>, |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
203 | τv: &mut PreadjointCodomain, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
204 | τ: F, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
205 | ε: 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:
51
diff
changeset
|
206 | config: &InsertionConfig<F>, |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
207 | reg: &Reg, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
208 | state: &AlgIteratorIteration<I>, |
|
61
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
209 | stats: &mut IterInfo<F>, |
|
75
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
210 | ) -> DynResult<bool> |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
211 | where |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
212 | I: AlgIterator; |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
213 | |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
214 | /// A variant of [`insert_and_reweigh`] that only does finite-dimensional weight optimisation, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
215 | /// without inserting spikes. |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
216 | fn reweigh<I>( |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
217 | &self, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
218 | μ: &mut DiscreteMeasure<Domain, F>, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
219 | τv: &mut PreadjointCodomain, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
220 | τ: F, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
221 | ε: F, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
222 | config: &InsertionConfig<F>, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
223 | reg: &Reg, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
224 | state: &AlgIteratorIteration<I>, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
225 | stats: &mut IterInfo<F>, |
|
677a5fd1b014
Added an extra step heuristic
Tuomo Valkonen <tuomov@iki.fi>
parents:
63
diff
changeset
|
226 | ) -> DynResult<()> |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
227 | where |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
228 | I: AlgIterator; |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
229 | |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
230 | /// Merge spikes, if possible. |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
231 | /// |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
232 | /// Either optimality condition merging or objective value (fitness) merging |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
233 | /// may be used, the latter only if `fitness` is provided and `config.fitness_merging` |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
234 | /// is set. |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
235 | fn merge_spikes( |
|
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
236 | &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:
51
diff
changeset
|
237 | μ: &mut DiscreteMeasure<Domain, F>, |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
238 | τv: &mut PreadjointCodomain, |
|
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:
51
diff
changeset
|
239 | μ_base: &DiscreteMeasure<Domain, F>, |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
240 | τ: F, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
241 | ε: 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:
51
diff
changeset
|
242 | config: &InsertionConfig<F>, |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
243 | reg: &Reg, |
|
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:
51
diff
changeset
|
244 | fitness: Option<impl Fn(&DiscreteMeasure<Domain, F>) -> F>, |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
245 | ) -> usize; |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
246 | |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
247 | /// Merge spikes, if possible. |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
248 | /// |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
249 | /// Unlike [`Self::merge_spikes`], this variant only supports optimality condition based merging |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
250 | #[inline] |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
251 | fn merge_spikes_no_fitness( |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
252 | &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:
51
diff
changeset
|
253 | μ: &mut DiscreteMeasure<Domain, F>, |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
254 | τv: &mut PreadjointCodomain, |
|
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:
51
diff
changeset
|
255 | μ_base: &DiscreteMeasure<Domain, F>, |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
256 | τ: F, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
257 | ε: 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:
51
diff
changeset
|
258 | config: &InsertionConfig<F>, |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
259 | reg: &Reg, |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
260 | ) -> usize { |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
261 | /// This is a hack to create a `None` of same type as a `Some` |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
262 | // for the `impl Fn` parameter of `merge_spikes`. |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
263 | #[inline] |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
264 | fn into_none<T>(_: Option<T>) -> Option<T> { |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
265 | None |
|
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
266 | } |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
267 | self.merge_spikes( |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
268 | μ, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
269 | τv, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
270 | μ_base, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
271 | τ, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
272 | ε, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
273 | config, |
|
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
274 | reg, |
|
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:
51
diff
changeset
|
275 | into_none(Some(|_: &DiscreteMeasure<Domain, F>| F::ZERO)), |
|
51
0693cc9ba9f0
Update documentation references
Tuomo Valkonen <tuomov@iki.fi>
parents:
39
diff
changeset
|
276 | ) |
|
39
6316d68b58af
Merging adjustments, parameter tuning, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents:
37
diff
changeset
|
277 | } |
|
37
c5d8bd1a7728
Generic proximal penalty support
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
278 | } |
|
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:
51
diff
changeset
|
279 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
280 | /// Trait to calculate step length bound by `Dat` when the proximal penalty is `Self`, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
281 | /// which is typically also a [`ProxPenalty`]. If it is given by a (squared) norm $\|.\|_*$, 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:
51
diff
changeset
|
282 | /// and `Dat` respresents the function $f$, then this trait should calculate `L` such that |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
283 | /// $\|f'(x)-f'(y)\| ≤ L\|x-y\|_*, where the step length is supposed to satisfy $τ L ≤ 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:
51
diff
changeset
|
284 | pub trait StepLengthBound<F: Float, 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:
51
diff
changeset
|
285 | /// Returns $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:
51
diff
changeset
|
286 | fn step_length_bound(&self, f: &Dat) -> DynResult<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:
51
diff
changeset
|
287 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
288 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
289 | /// A variant of [`StepLengthBound`] for step length parameters for [`Pair`]s of variables. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
290 | pub trait StepLengthBoundPair<F: Float, 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:
51
diff
changeset
|
291 | fn step_length_bound_pair(&self, f: &Dat) -> DynResult<(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:
51
diff
changeset
|
292 | } |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
293 | |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
294 | /// Trait to calculate step length bound by the operator `A` when the proximal penalty is `Self`, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
295 | /// which is typically also a [`ProxPenalty`]. If it is given by a (squared) norm $\|.\|_*$, |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
296 | /// then this trait should calculate `L` such that |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
297 | /// $\|Ax\| ≤ L\|x\|_*, where the primal-dual step lengths are supposed to satisfy $τσ L^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:
51
diff
changeset
|
298 | /// The domain needs to be specified here, because A can operate on various domains. |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
299 | pub trait StepLengthBoundPD<F: Float, A, Domain> { |
|
4f468d35fa29
General forward operators, separation of measures into own crate, and other architecture improvements to support the pointsource_pde crate.
Tuomo Valkonen <tuomov@iki.fi>
parents:
51
diff
changeset
|
300 | /// Returns $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:
51
diff
changeset
|
301 | fn step_length_bound_pd(&self, f: &A) -> DynResult<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:
51
diff
changeset
|
302 | } |