| 1 /*! |
1 /*! |
| 2 Iterative algorithms for solving the finite-dimensional subproblem. |
2 Iterative algorithms for solving the finite-dimensional subproblem. |
| 3 */ |
3 */ |
| 4 |
4 |
| 5 use serde::{Serialize, Deserialize}; |
5 use alg_tools::iterate::{AlgIteratorOptions, Verbose}; |
| |
6 use clap::ValueEnum; |
| 6 use numeric_literals::replace_float_literals; |
7 use numeric_literals::replace_float_literals; |
| 7 use alg_tools::iterate::{ |
8 use serde::{Deserialize, Serialize}; |
| 8 AlgIteratorOptions, |
|
| 9 Verbose, |
|
| 10 |
|
| 11 }; |
|
| 12 |
9 |
| 13 use crate::types::*; |
10 use crate::types::*; |
| 14 |
11 |
| |
12 pub mod l1squared_nonneg; |
| |
13 pub mod l1squared_unconstrained; |
| 15 pub mod nonneg; |
14 pub mod nonneg; |
| 16 pub mod unconstrained; |
15 pub mod unconstrained; |
| 17 pub mod l1squared_unconstrained; |
|
| 18 pub mod l1squared_nonneg; |
|
| 19 |
|
| 20 |
16 |
| 21 /// Method for solving finite-dimensional subproblems. |
17 /// Method for solving finite-dimensional subproblems. |
| 22 /// Not all outer methods necessarily support all options. |
18 /// Not all outer methods necessarily support all options. |
| 23 #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)] |
19 #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug, ValueEnum)] |
| 24 #[allow(dead_code)] |
20 #[allow(dead_code)] |
| 25 pub enum InnerMethod { |
21 pub enum InnerMethod { |
| 26 /// Forward-backward |
22 /// Forward-backward |
| 27 FB, |
23 FB, |
| 28 /// Semismooth Newton |
24 /// Semismooth Newton |
| 29 SSN, |
25 SSN, |
| 30 /// PDPS |
26 /// PDPS |
| 31 PDPS, |
27 PDPS, |
| |
28 /// Proximal point method |
| |
29 PP, |
| 32 } |
30 } |
| 33 |
31 |
| 34 /// Settings for the solution of finite-dimensional subproblems |
32 /// Settings for the solution of finite-dimensional subproblems |
| 35 #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)] |
33 #[derive(Clone, Copy, Eq, PartialEq, Serialize, Deserialize, Debug)] |
| 36 pub struct InnerSettings<F : Float> { |
34 pub struct InnerSettings<F: Float> { |
| 37 /// Method |
35 /// Method |
| 38 pub method : InnerMethod, |
36 pub method: InnerMethod, |
| 39 /// Proportional step length ∈ [0, 1) for `InnerMethod::FB`. |
37 /// Proportional step length ∈ [0, 1) for `InnerMethod::FB`. |
| 40 pub fb_τ0 : F, |
38 pub fb_τ0: F, |
| 41 /// Proportional primal and dual step lengths for `InnerMethod::PDPS`. |
39 /// Proportional primal and dual step lengths for `InnerMethod::PDPS`. |
| 42 pub pdps_τσ0 : (F, F), |
40 pub pdps_τσ0: (F, F), |
| |
41 /// Proximal point step length parameter and its growth |
| |
42 pub pp_τ: (F, F), |
| 43 /// Fraction of `tolerance` given to inner algorithm |
43 /// Fraction of `tolerance` given to inner algorithm |
| 44 pub tolerance_mult : F, |
44 pub tolerance_mult: F, |
| 45 /// Iterator options |
45 /// Iterator options |
| 46 #[serde(flatten)] |
46 #[serde(flatten)] |
| 47 pub iterator_options : AlgIteratorOptions, |
47 pub iterator_options: AlgIteratorOptions, |
| 48 } |
48 } |
| 49 |
49 |
| 50 #[replace_float_literals(F::cast_from(literal))] |
50 #[replace_float_literals(F::cast_from(literal))] |
| 51 impl<F : Float> Default for InnerSettings<F> { |
51 impl<F: Float> Default for InnerSettings<F> { |
| 52 fn default() -> Self { |
52 fn default() -> Self { |
| 53 InnerSettings { |
53 InnerSettings { |
| 54 fb_τ0 : 0.99, |
54 fb_τ0: 0.99, |
| 55 pdps_τσ0 : (1.98, 0.5), |
55 pdps_τσ0: (1.98, 0.5), |
| 56 iterator_options : AlgIteratorOptions { |
56 pp_τ: (100.0, 100.0), |
| |
57 iterator_options: AlgIteratorOptions { |
| 57 // max_iter cannot be very small, as initially FB needs many iterations, although |
58 // max_iter cannot be very small, as initially FB needs many iterations, although |
| 58 // on later invocations even one or two tends to be enough |
59 // on later invocations even one or two tends to be enough |
| 59 max_iter : 2000, |
60 max_iter: 2000, |
| 60 // verbose_iter affects testing of sufficient convergence, so we set it to |
61 // verbose_iter affects testing of sufficient convergence, so we set it to |
| 61 // a small value… |
62 // a small value… |
| 62 verbose_iter : Verbose::Every(1), |
63 verbose_iter: Verbose::Every(1), |
| 63 // … but don't print out anything |
64 // … but don't print out anything |
| 64 quiet : true, |
65 quiet: true, |
| 65 .. Default::default() |
66 ..Default::default() |
| 66 }, |
67 }, |
| 67 method : InnerMethod::SSN, |
68 method: InnerMethod::SSN, |
| 68 tolerance_mult : 0.01, |
69 tolerance_mult: 0.01, |
| 69 } |
70 } |
| 70 } |
71 } |
| 71 } |
72 } |