diff --git a/src/lib.rs b/src/lib.rs index eb6baaab..db04adf0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,9 +11,6 @@ //! Note that this is the **API documentation** of **Optimization Engine**; to get started, //! you would rather check out the [documentation](). //! -//! -//! -//! extern crate num; @@ -29,39 +26,4 @@ pub mod matrix_operations; 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); - } -} +mod tests; diff --git a/src/tests.rs b/src/tests.rs new file mode 100644 index 00000000..cf6558c7 --- /dev/null +++ b/src/tests.rs @@ -0,0 +1,28 @@ +use super::*; +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); +}