my-bfgs

Crates.iomy-bfgs
lib.rsmy-bfgs
version0.1.2
sourcesrc
created_at2022-04-26 18:06:48.191323
updated_at2023-02-01 12:08:31.599376
descriptionA pure Rust implementation of the BFGS optimization algorithm
homepage
repositoryhttps://github.com/paulkernfeld/bfgs
max_upload_size
id575614
size9,103
Heartsh (heartsh)

documentation

https://docs.rs/bfgs

README

bfgs

This package contains an implementation of BFGS, an algorithm for minimizing convex twice-differentiable functions.

BFGS is explained at a high level in the blog post introducing this package.

In this example, we minimize a 2d function:

extern crate bfgs;
extern crate ndarray;

use ndarray::{Array, Array1};

fn main() {
    let x0 = Array::from_vec(vec![8.888, 1.234]);  // Chosen arbitrarily
    let f = |x: &Array1<f64>| x.dot(x);
    let g = |x: &Array1<f64>| 2.0 * x;
    let x_min = bfgs::bfgs(x0, f, g);
    assert_eq!(x_min, Ok(Array::from_vec(vec![0.0, 0.0])));
}

This project uses cargo-make for builds; to build, run cargo make all.

License: MIT/Apache-2.0

Commit count: 17

cargo fmt