From 9bf2a959302cb0c55d5285bb013cb9c116911d36 Mon Sep 17 00:00:00 2001 From: Stefan Kroboth Date: Wed, 14 Feb 2024 20:23:31 +0100 Subject: [PATCH] Stuff --- .gitattributes | 1 - python/argmin-testfunctions-py/Cargo.toml | 10 +- python/argmin-testfunctions-py/README.md | 187 ++++++++++++++++++ python/argmin-testfunctions-py/pyproject.toml | 6 + 4 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 python/argmin-testfunctions-py/README.md diff --git a/.gitattributes b/.gitattributes index a3bb38d40..50f7c60ad 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ -*.py linguist-detectable=false *.scss linguist-detectable=false *.js linguist-detectable=false *.html linguist-detectable=false diff --git a/python/argmin-testfunctions-py/Cargo.toml b/python/argmin-testfunctions-py/Cargo.toml index 2a440f985..ca9af0ae5 100644 --- a/python/argmin-testfunctions-py/Cargo.toml +++ b/python/argmin-testfunctions-py/Cargo.toml @@ -3,8 +3,16 @@ name = "argmin-testfunctions-py" version = "0.1.1" edition = "2021" license = "MIT OR Apache-2.0" +authors = ["Stefan Kroboth "] +description = "Test functions for optimization algorithms" +documentation = "https://docs.rs/argmin_testfunctions/" +homepage = "http://argmin-rs.org" +repository = "https://github.com/argmin-rs/argmin" +readme = "README.md" +keywords = ["test", "function", "optimization"] +categories = ["science"] +publish = false -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] name = "argmin_testfunctions_py" crate-type = ["cdylib"] diff --git a/python/argmin-testfunctions-py/README.md b/python/argmin-testfunctions-py/README.md new file mode 100644 index 000000000..7882c5b29 --- /dev/null +++ b/python/argmin-testfunctions-py/README.md @@ -0,0 +1,187 @@ +

+ +

+

argmin-testfunctions-py

+ +

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

+ +

+ GitHub Actions workflow status + License + argmin Discord +

+ +This makes the test functions of the `argmin_testfunctions` Rust crate available in Python. +For each test function the derivative and Hessian are available as well. +Most functions are 2D only, but some allow an arbitrary number of parameters. +For some functions additional optional parameters are accessible, which can be used to modify the shape of the test function. +For details on the individual test functions please consult the Rust docs, either for the +[latest release](https://docs.rs/argmin_testfunctions) or the +[current main branch](https://argmin-rs.github.io/argmin/argmin_testfunctions/index.html) + + +```python +from argmin_testfunctions_py import * + +# Ackley (arbitrary number of parameters) +c = ackley([0.1, 0.2, 0.3, 0.4]) +g = ackley_derivative([0.1, 0.2, 0.3, 0.4]) +h = ackley_hessian([0.1, 0.2, 0.3, 0.4]) + +# Ackley with custom (optional) parameters a, b, and c. +c = ackley([0.1, 0.2, 0.3, 0.4], a = 10.0, b = 0.3, c = 3.14) +g = ackley_derivative([0.1, 0.2, 0.3, 0.4], a = 10.0, b = 0.3, c = 3.14) +h = ackley_hessian([0.1, 0.2, 0.3, 0.4], a = 10.0, b = 0.3, c = 3.14) + +# Beale +c = beale([0.1, 0.2]) +g = beale_derivative([0.1, 0.2]) +h = beale_hessian([0.1, 0.2]) + +# Booth +c = booth([0.1, 0.2]) +g = booth_derivative([0.1, 0.2]) +h = booth_hessian([0.1, 0.2]) + +# Bukin No. 6 +c = bukin_n6([0.1, 0.2]) +g = bukin_n6_derivative([0.1, 0.2]) +h = bukin_n6_hessian([0.1, 0.2]) + +# Cross-in-tray +c = cross_in_tray([0.1, 0.2]) +g = cross_in_tray_derivative([0.1, 0.2]) +h = cross_in_tray_hessian([0.1, 0.2]) + +# Easom +c = easom([0.1, 0.2]) +g = easom_derivative([0.1, 0.2]) +h = easom_hessian([0.1, 0.2]) + +# Eggholder +c = eggholder([0.1, 0.2]) +g = eggholder_derivative([0.1, 0.2]) +h = eggholder_hessian([0.1, 0.2]) + +# Goldstein-Price +c = goldsteinprice([0.1, 0.2]) +g = goldsteinprice_derivative([0.1, 0.2]) +h = goldsteinprice_hessian([0.1, 0.2]) + +# Himmelblau +c = himmelblau([0.1, 0.2]) +g = himmelblau_derivative([0.1, 0.2]) +h = himmelblau_hessian([0.1, 0.2]) + +# Holder-Table +c = holder_table([0.1, 0.2]) +g = holder_table_derivative([0.1, 0.2]) +h = holder_table_hessian([0.1, 0.2]) + +# Levy (arbitray number of parameters) +c = levy([0.1, 0.2, 0.3, 0.4]) +g = levy_derivative([0.1, 0.2, 0.3, 0.4]) +h = levy_hessian([0.1, 0.2, 0.3, 0.4]) + +# Levy No. 13 +c = levy_n13([0.1, 0.2]) +g = levy_n13_derivative([0.1, 0.2]) +h = levy_n13_hessian([0.1, 0.2]) + +# Matyas +c = matyas([0.1, 0.2]) +g = matyas_derivative([0.1, 0.2]) +h = matyas_hessian([0.1, 0.2]) + +# McCorminck +c = mccorminck([0.1, 0.2]) +g = mccorminck_derivative([0.1, 0.2]) +h = mccorminck_hessian([0.1, 0.2]) + +# Picheny +c = picheny([0.1, 0.2]) +g = picheny_derivative([0.1, 0.2]) +h = picheny_hessian([0.1, 0.2]) + +# Rastrigin (with arbitrary number of parameters) +c = rastrigin([0.1, 0.2, 0.3, 0.4]) +g = rastrigin_derivative([0.1, 0.2, 0.3, 0.4]) +h = rastrigin_hessian([0.1, 0.2, 0.3, 0.4]) + +# Rastrigin with custom (optional) parameter a. +c = rastrigin([0.1, 0.2, 0.3, 0.4], a = 5.0) +g = rastrigin_derivative([0.1, 0.2, 0.3, 0.4], a = 5.0) +h = rastrigin_hessian([0.1, 0.2, 0.3, 0.4], a = 5.0) + +# Rosenbrock (with arbitrary number of parameters) +c = rosenbrock([0.1, 0.2, 0.3, 0.4]) +g = rosenbrock_derivative([0.1, 0.2, 0.3, 0.4]) +h = rosenbrock_hessian([0.1, 0.2, 0.3, 0.4]) + +# Rosenbrock with custom (optional) parameters a and b. +c = rosenbrock([0.1, 0.2, 0.3, 0.4], a = 5.0, b = 200.0) +g = rosenbrock_derivative([0.1, 0.2, 0.3, 0.4], a = 5.0, b = 200.0) +h = rosenbrock_hessian([0.1, 0.2, 0.3, 0.4], a = 5.0, b = 200.0) + +# Schaffer No. 2 +c = schaffer_n2([0.1, 0.2]) +g = schaffer_n2_derivative([0.1, 0.2]) +h = schaffer_n2_hessian([0.1, 0.2]) + +# Schaffer No. 4 +c = schaffer_n4([0.1, 0.2]) +g = schaffer_n4_derivative([0.1, 0.2]) +h = schaffer_n4_hessian([0.1, 0.2]) + +# Sphere (with arbitrary number of parameters) +c = sphere([0.1, 0.2, 0.3, 0.4]) +g = sphere_derivative([0.1, 0.2, 0.3, 0.4]) +h = sphere_hessian([0.1, 0.2, 0.3, 0.4]) + +# Styblinski-Tang +c = styblinski_tang([0.1, 0.2]) +g = styblinski_tang_derivative([0.1, 0.2]) +h = styblinski_tang_hessian([0.1, 0.2]) + +# Three-hump-camel +c = threehumpcamel([0.1, 0.2]) +g = threehumpcamel_derivative([0.1, 0.2]) +h = threehumpcamel_hessian([0.1, 0.2]) +``` + + +## License + +Licensed under either of + + - Apache License, Version 2.0, ([LICENSE-APACHE](https://github.com/argmin-rs/argmin/blob/main/LICENSE-APACHE) or ) + - MIT License ([LICENSE-MIT](https://github.com/argmin-rs/argmin/blob/main/LICENSE-MIT) or ) + +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. diff --git a/python/argmin-testfunctions-py/pyproject.toml b/python/argmin-testfunctions-py/pyproject.toml index e34ea90e4..9102f96e3 100644 --- a/python/argmin-testfunctions-py/pyproject.toml +++ b/python/argmin-testfunctions-py/pyproject.toml @@ -9,8 +9,14 @@ classifiers = [ "Programming Language :: Rust", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "License :: OSI Approved :: Apache Software License", ] dynamic = ["version"] +authors = [ + { name = "Stefan Kroboth", email = "stefan.kroboth@gmail.com" } +] [tool.maturin] features = ["pyo3/extension-module"]