[][src]Function cobyla::fmin_cobyla

pub fn fmin_cobyla<'a, F: ObjFn<U>, G: CstrFn, U>(
    func: F,
    x0: &'a mut [f64],
    cons: &[G],
    args: U,
    rhobeg: f64,
    rhoend: f64,
    maxfun: i32,
    iprint: i32
) -> (i32, &'a [f64])

Minimizes a function using the Constrained Optimization By Linear Approximation (COBYLA) method.

This interface is modeled after scypi.optimize.fmin_cobyla

Example

use cobyla::{fmin_cobyla, CstrFn};

fn paraboloid(x: &[f64], _data: &mut ()) -> f64 {
    10. * (x[0] + 1.).powf(2.) + x[1].powf(2.)
}

let mut x = vec![1., 1.];

// Constraints definition to be positive eventually
let mut cons: Vec<&CstrFn> = vec![];
cons.push(&|x: &[f64]| x[1] - x[0] * x[0]);
cons.push(&|x: &[f64]| 1. - x[0] * x[0] - x[1] * x[1]);

let (status, x_opt) = fmin_cobyla(paraboloid, &mut x, &cons, (), 0.5, 1e-4, 200, 0);
println!("status = {}", status);
println!("x = {:?}", x_opt);