1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
use crate::panoc::PANOCCache;
const DEFAULT_INITIAL_PENALTY: f64 = 10.0;
#[derive(Debug)]
pub struct AlmCache {
pub(crate) panoc_cache: PANOCCache,
pub(crate) y_plus: Option<Vec<f64>>,
pub(crate) xi: Option<Vec<f64>>,
pub(crate) delta_y_norm: f64,
pub(crate) delta_y_norm_plus: f64,
pub(crate) f2_norm: f64,
pub(crate) f2_norm_plus: f64,
pub(crate) w_alm_aux: Option<Vec<f64>>,
pub(crate) w_pm: Option<Vec<f64>>,
pub(crate) iteration: usize,
pub(crate) inner_iteration_count: usize,
pub(crate) last_inner_problem_norm_fpr: f64,
pub(crate) available_time: Option<std::time::Duration>,
}
impl AlmCache {
pub fn new(panoc_cache: PANOCCache, n1: usize, n2: usize) -> Self {
AlmCache {
panoc_cache,
y_plus: if n1 > 0 { Some(vec![0.0; n1]) } else { None },
xi: if n1 + n2 > 0 {
let mut xi_init = vec![DEFAULT_INITIAL_PENALTY; 1];
xi_init.append(&mut vec![0.0; n1]);
Some(xi_init)
} else {
None
},
w_alm_aux: if n1 > 0 { Some(vec![0.0; n1]) } else { None },
w_pm: if n2 > 0 { Some(vec![0.0; n2]) } else { None },
iteration: 0,
delta_y_norm: 0.0,
delta_y_norm_plus: std::f64::INFINITY,
f2_norm: 0.0,
f2_norm_plus: std::f64::INFINITY,
inner_iteration_count: 0,
last_inner_problem_norm_fpr: -1.0,
available_time: None,
}
}
pub fn reset(&mut self) {
self.panoc_cache.reset();
self.iteration = 0;
self.f2_norm = 0.0;
self.f2_norm_plus = 0.0;
self.delta_y_norm = 0.0;
self.delta_y_norm_plus = 0.0;
self.inner_iteration_count = 0;
}
}