#optimization #function #test

argmin_testfunctions

Test functions for optimization algorithms

3 unstable releases

0.2.0 Feb 16, 2024
0.1.1 Nov 30, 2018
0.1.0 Oct 3, 2018

#164 in Science

Download history 101/week @ 2024-06-06 120/week @ 2024-06-13 224/week @ 2024-06-20 103/week @ 2024-06-27 308/week @ 2024-07-04 71/week @ 2024-07-11 56/week @ 2024-07-18 154/week @ 2024-07-25 110/week @ 2024-08-01 89/week @ 2024-08-08 132/week @ 2024-08-15 86/week @ 2024-08-22 298/week @ 2024-08-29 176/week @ 2024-09-05 108/week @ 2024-09-12 146/week @ 2024-09-19

731 downloads per month
Used in 6 crates (5 directly)

MIT/Apache

225KB
5K SLoC

argmin_testfunctions

Website | Book | Docs (latest release) | Docs (main branch)

Crates.io version Crates.io downloads GitHub Actions workflow status License argmin Discord

A collection of two- and multidimensional test functions (and their derivatives and Hessians) for optimization algorithms. For two-dimensional test functions, the derivate and Hessian calculation does not allocate. For multi-dimensional tes functions, the derivative and Hessian calculation comes in two variants. One variant returns Vecs and hence does allocate. This is needed for cases, where the number of parameters is only known at run time. In case the number of parameters are known at compile-time, the _const variants can be used, which return fixed size arrays and hence do not allocate.

The derivative and Hessian calculation is always named <test function name>_derivative and <test function name>_hessian, respectively. The const generics variants are defined as <test function name>_derivative_const and <test function name>_hessian_const.

Some functions, such as ackley, rosenbrock and rastrigin come with additional optional parameters which change the shape of the functions. These additional parameters are exposed in ackley_abc, rosenbrock_ab and rastrigin_a.

All functions are generic over their inputs and work with [f64] and [f32].

For a list of all implemented functions see the documentation linked above.

Python wrapper

Thanks to the python module argmin-testfunctions-py, it is possible to use the functions in Python as well. Note that the derivative and Hessian calculation used in the wrapper will always allocate.

Running the tests and benchmarks

The tests can be run with

cargo test

The test functions derivatives and Hessians are tested against finitediff using proptest to sample the functions at various points.

All functions are benchmarked using criterion.rs. Run the benchmarks with

cargo bench

The report is available in target/criterion/report/index.html.

Contributing

This library is the most useful the more test functions it contains, therefore any contributions are highly welcome. For inspiration on what to implement and how to proceed, feel free to have a look at this issue.

While most of the implemented functions are probably already quite efficient, there are probably a few which may profit from performance improvements.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~465KB