argmin_testfunctions/
lib.rs

1// Copyright 2018-2024 argmin developers
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5// http://opensource.org/licenses/MIT>, at your option. This file may not be
6// copied, modified, or distributed except according to those terms.
7
8//! A collection of two- and multidimensional test functions (and their derivatives and Hessians)
9//! for optimization algorithms. For two-dimensional test functions, the derivate and Hessian
10//! calculation does not allocate. For multi-dimensional test functions, the derivative and Hessian
11//! calculation comes in two variants. One variant returns `Vec`s and hence does allocate. This is
12//! needed for cases, where the number of parameters is only known at run time. In case the number
13//! of parameters are known at compile-time, the `_const` variants can be used, which return fixed
14//! size arrays and hence do not allocate.
15//!
16//! The derivative and Hessian calculation is always named `<test function name>_derivative` and
17//! `<test function name>_hessian`, respectively. The const generics variants are defined as
18//! `<test function name>_derivative_const` and `<test function name>_hessian_const`.
19//!
20//! Some functions, such as [`ackley()`], [`rosenbrock()`] and [`rastrigin()`] come with additional
21//! optional parameters which change the shape of the functions. These additional parameters
22//! are exposed in [`ackley_abc()`], [`rosenbrock_ab()`] and [`rastrigin_a()`].
23//!
24//! All functions are generic over their inputs and work with [`f64`] and [`f32`].
25//!
26//! ## Python wrapper
27//!
28//! Thanks to the python module
29//! [`argmin-testfunctions-py`](https://pypi.org/project/argmin-testfunctions-py/), it is possible
30//! to use the functions in Python as well. Note that the derivative and Hessian calculation used
31//! in the wrapper will always allocate.
32//!
33//! ## Running the tests and benchmarks
34//!
35//! The tests can be run with
36//!
37//! ```bash
38//! cargo test
39//! ```
40//!
41//! The test functions derivatives and Hessians are tested against
42//! [finitediff](https://crates.io/crates/finitediff) using
43//! [proptest](https://crates.io/crates/proptest) to sample the functions at various points.
44//!
45//! All functions are benchmarked using [criterion.rs](https://crates.io/crates/criterion).
46//! Run the benchmarks with
47//!
48//! ```bash
49//! cargo bench
50//! ```
51//!
52//! The report is available in `target/criterion/report/index.html`.
53//!
54//! ## Contributing
55//!
56//! This library is the most useful the more test functions it contains, therefore any contributions
57//! are highly welcome. For inspiration on what to implement and how to proceed, feel free to have
58//! a look at this [issue](https://github.com/argmin-rs/argmin/issues/450).
59//!
60//! While most of the implemented functions are probably already quite efficient, there are probably
61//! a few which may profit from performance improvements.
62//!
63//! ## License
64//!
65//! Licensed under either of
66//!
67//!   * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
68//!   * MIT License ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
69//!
70//! at your option.
71//!
72//! ### Contribution
73//!
74//! Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you,
75//! as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
76
77mod ackley;
78mod beale;
79mod booth;
80mod bukin;
81mod crossintray;
82mod easom;
83mod eggholder;
84mod goldsteinprice;
85mod himmelblau;
86mod holdertable;
87mod levy;
88mod matyas;
89mod mccorminck;
90mod picheny;
91mod rastrigin;
92mod rosenbrock;
93mod schaffer;
94mod sphere;
95mod styblinskitang;
96mod threehumpcamel;
97mod zero;
98
99pub use ackley::*;
100pub use beale::*;
101pub use booth::*;
102pub use bukin::*;
103pub use crossintray::*;
104pub use easom::*;
105pub use eggholder::*;
106pub use goldsteinprice::*;
107pub use himmelblau::*;
108pub use holdertable::*;
109pub use levy::*;
110pub use matyas::*;
111pub use mccorminck::*;
112pub use picheny::*;
113pub use rastrigin::*;
114pub use rosenbrock::*;
115pub use schaffer::*;
116pub use sphere::*;
117pub use styblinskitang::*;
118pub use threehumpcamel::*;
119pub use zero::*;