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
extern crate num;
pub mod constraints;
pub mod core;
pub mod lipschitz_estimator;
pub mod matrix_operations;
#[cfg(test)]
mod mocks;
#[cfg(test)]
mod tests {
#[allow(unused_imports)]
use super::*;
#[allow(unused_imports)]
use core::Optimizer;
use std::num::NonZeroUsize;
#[test]
fn t_access() {
let radius = 0.2;
let box_constraints = constraints::Ball2::new_at_origin_with_radius(radius);
let problem = core::Problem::new(
box_constraints,
super::mocks::my_gradient,
super::mocks::my_cost,
);
let gamma = 0.1;
let tolerance = 1e-6;
let mut fbs_cache =
core::fbs::FBSCache::new(NonZeroUsize::new(2).unwrap(), gamma, tolerance);
let mut fbs_engine = core::fbs::FBSEngine::new(problem, &mut fbs_cache);
let mut u = [0.0; 2];
let mut optimizer = core::fbs::FBSOptimizer::new(&mut fbs_engine);
let status = optimizer.solve(&mut u);
assert!(status.has_converged());
assert!(status.get_norm_fpr() < tolerance);
assert!((-0.14896 - u[0]).abs() < 1e-4);
assert!((0.13346 - u[1]).abs() < 1e-4);
}
}