| 63 /// Use fitness as merging criterion. Implies worse convergence guarantees. |
63 /// Use fitness as merging criterion. Implies worse convergence guarantees. |
| 64 pub fitness_merging: bool, |
64 pub fitness_merging: bool, |
| 65 |
65 |
| 66 /// Iterations between merging heuristic tries |
66 /// Iterations between merging heuristic tries |
| 67 pub merge_every: usize, |
67 pub merge_every: usize, |
| 68 // /// Save $μ$ for postprocessing optimisation |
68 |
| 69 // pub postprocessing : bool |
69 /// Additional weight optimisation steps |
| |
70 pub extra_weight_optimisation_steps: usize, |
| 70 } |
71 } |
| 71 |
72 |
| 72 #[replace_float_literals(F::cast_from(literal))] |
73 #[replace_float_literals(F::cast_from(literal))] |
| 73 impl<F: Float> Default for InsertionConfig<F> { |
74 impl<F: Float> Default for InsertionConfig<F> { |
| 74 fn default() -> Self { |
75 fn default() -> Self { |
| 83 merging: Default::default(), |
84 merging: Default::default(), |
| 84 final_merging: true, |
85 final_merging: true, |
| 85 fitness_merging: false, |
86 fitness_merging: false, |
| 86 merge_every: 10, |
87 merge_every: 10, |
| 87 merge_tolerance_mult: 2.0, |
88 merge_tolerance_mult: 2.0, |
| 88 // postprocessing : false, |
89 extra_weight_optimisation_steps: 0, |
| 89 } |
90 } |
| 90 } |
91 } |
| 91 } |
92 } |
| 92 |
93 |
| 93 impl<F: Float> InsertionConfig<F> { |
94 impl<F: Float> InsertionConfig<F> { |
| 116 where |
117 where |
| 117 F: Float + ToNalgebraRealField, |
118 F: Float + ToNalgebraRealField, |
| 118 Reg: RegTerm<Domain, F>, |
119 Reg: RegTerm<Domain, F>, |
| 119 Domain: Space + Clone, |
120 Domain: Space + Clone, |
| 120 { |
121 { |
| |
122 /// Unused, but required as a plotter parametrisation. |
| 121 type ReturnMapping: Mapping<Domain, Codomain = F>; |
123 type ReturnMapping: Mapping<Domain, Codomain = F>; |
| 122 |
124 |
| 123 /// Returns the type of this proximality penalty |
125 /// Returns the type of this proximality penalty |
| 124 fn prox_type() -> ProxTerm; |
126 fn prox_type() -> ProxTerm; |
| 125 |
127 |
| 126 /// Insert new spikes into `μ` to approximately satisfy optimality conditions |
128 /// Insert new spikes into `μ` to approximately satisfy optimality conditions |
| 127 /// with the forward step term fixed to `τv`. |
129 /// with the forward step term fixed to `τv`. |
| 128 /// |
130 /// |
| 129 /// May return `τv + w` for `w` a subdifferential of the regularisation term `reg`, |
131 /// Returns an indication of whether the tolerance bounds `ε` are satisfied. |
| 130 /// as well as an indication of whether the tolerance bounds `ε` are satisfied. |
|
| 131 /// |
132 /// |
| 132 /// `τv` is mutable to allow [`alg_tools::bounds::MinMaxMapping`] optimisation to |
133 /// `τv` is mutable to allow [`alg_tools::bounds::MinMaxMapping`] optimisation to |
| 133 /// refine data. Actual values of `τv` are not supposed to be mutated. |
134 /// refine data. Actual values of `τv` are not supposed to be mutated. |
| 134 /// |
135 /// |
| 135 /// `stats.inserted` should not be updated by implementations of this routine, |
136 /// `stats.inserted` should not be updated by implementations of this routine, |
| 142 ε: F, |
143 ε: F, |
| 143 config: &InsertionConfig<F>, |
144 config: &InsertionConfig<F>, |
| 144 reg: &Reg, |
145 reg: &Reg, |
| 145 state: &AlgIteratorIteration<I>, |
146 state: &AlgIteratorIteration<I>, |
| 146 stats: &mut IterInfo<F>, |
147 stats: &mut IterInfo<F>, |
| 147 ) -> DynResult<(Option<Self::ReturnMapping>, bool)> |
148 ) -> DynResult<bool> |
| |
149 where |
| |
150 I: AlgIterator; |
| |
151 |
| |
152 /// A variant of [`insert_and_reweigh`] that only does finite-dimensional weight optimisation, |
| |
153 /// without inserting spikes. |
| |
154 fn reweigh<I>( |
| |
155 &self, |
| |
156 μ: &mut DiscreteMeasure<Domain, F>, |
| |
157 τv: &mut PreadjointCodomain, |
| |
158 τ: F, |
| |
159 ε: F, |
| |
160 config: &InsertionConfig<F>, |
| |
161 reg: &Reg, |
| |
162 state: &AlgIteratorIteration<I>, |
| |
163 stats: &mut IterInfo<F>, |
| |
164 ) -> DynResult<()> |
| 148 where |
165 where |
| 149 I: AlgIterator; |
166 I: AlgIterator; |
| 150 |
167 |
| 151 /// Merge spikes, if possible. |
168 /// Merge spikes, if possible. |
| 152 /// |
169 /// |