Crates.io | optimize |
lib.rs | optimize |
version | 0.1.0 |
source | src |
created_at | 2018-07-07 10:09:03.449753 |
updated_at | 2018-07-07 10:09:03.449753 |
description | Crate for numerical optimization |
homepage | https://github.com/to266/optimize |
repository | https://github.com/to266/optimize.git |
max_upload_size | |
id | 73196 |
size | 25,870 |
This crate provides (non-linear) numerical optimization methods.
It is heavily based on scipy.optimize
.
The crate is actively developed and expanded to include more methods.
A simple example follows:
// Define a function that we aim to minimize
let function = |x: ArrayView1<f64>| (1.0 - x[0]).powi(2) + 100.0 * (x[1] - x[0].powi(2)).powi(2);
// Create a minimizer using the builder pattern. If some of the parameters are not given, default values are used.
let minimizer = NelderMeadBuilder::default()
.xtol(1e-6f64)
.ftol(1e-6f64)
.maxiter(50000)
.build()
.unwrap();
// Set the starting guess
let args = Array::from_vec(vec![3.0, -8.3]);
// Run the optimization
let ans = minimizer.minimize(&function, args.view());
// Print the optimized values
println!("Final optimized arguments: {}", ans);