| 201 into_none(Some(|_: &DiscreteMeasure<Domain, F>| F::ZERO)), |
201 into_none(Some(|_: &DiscreteMeasure<Domain, F>| F::ZERO)), |
| 202 ) |
202 ) |
| 203 } |
203 } |
| 204 } |
204 } |
| 205 |
205 |
| |
206 /// Value for [`StepLengthBound`]. |
| |
207 #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)] |
| |
208 pub enum StepLengthBoundValue<F: Float> { |
| |
209 /// Lipschitz factor |
| |
210 LipschitzFactor(F), |
| |
211 /// Lipschitz factor, but should not be trusted, use adaptation instead |
| |
212 UnreliableLipschitzFactor(F), |
| |
213 /// None, failure |
| |
214 Failure, |
| |
215 } |
| |
216 |
| 206 /// Trait to calculate step length bound by `Dat` when the proximal penalty is `Self`, |
217 /// Trait to calculate step length bound by `Dat` when the proximal penalty is `Self`, |
| 207 /// which is typically also a [`ProxPenalty`]. If it is given by a (squared) norm $\|.\|_*$, and |
218 /// which is typically also a [`ProxPenalty`]. If it is given by a (squared) norm $\|.\|_*$, and |
| 208 /// and `Dat` respresents the function $f$, then this trait should calculate `L` such that |
219 /// and `Dat` respresents the function $f$, then this trait should calculate `L` such that |
| 209 /// $\|f'(x)-f'(y)\| ≤ L\|x-y\|_*, where the step length is supposed to satisfy $τ L ≤ 1$. |
220 /// $\|f'(x)-f'(y)\| ≤ L\|x-y\|_*, where the step length is supposed to satisfy $τ L ≤ 1$. |
| 210 pub trait StepLengthBound<F: Float, Dat> { |
221 pub trait StepLengthBound<F: Float, Dat> { |
| 211 /// Returns $L$. |
222 /// Returns $L$. |
| 212 fn step_length_bound(&self, f: &Dat) -> DynResult<F>; |
223 fn step_length_bound(&self, f: &Dat) -> StepLengthBoundValue<F>; |
| 213 } |
224 } |
| 214 |
225 |
| 215 /// A variant of [`StepLengthBound`] for step length parameters for [`Pair`]s of variables. |
226 /// A variant of [`StepLengthBound`] for step length parameters for [`Pair`]s of variables. |
| 216 pub trait StepLengthBoundPair<F: Float, Dat> { |
227 pub trait StepLengthBoundPair<F: Float, Dat> { |
| 217 fn step_length_bound_pair(&self, f: &Dat) -> DynResult<(F, F)>; |
228 fn step_length_bound_pair(&self, f: &Dat) -> DynResult<(F, F)>; |