Expand description
Pure-Rust COBYLA local optimizer.
Hand-translated from NLopt 2.7.1’s cobyla.c (Powell 1994) — see
[cobyla_native] for the implementation. The public API lives in
cobyla.
Pure-Rust COBYLA local optimizer.
Wraps the cobyla crate (a faithful
pure-Rust port of NLopt’s cobyla.c, itself a port of M.J.D. Powell’s
1994 FORTRAN implementation) behind an API consistent with this crate’s
differential_evolution and
levenberg_marquardt entry points.
§Constraint convention
Inequality constraints are passed in the autoeq/NLopt convention:
g_i(x) <= 0 is feasible. Internally this module flips the sign before
handing them to the cobyla crate, which uses the opposite convention
(fc(x) >= 0 is feasible).
§Example
use math_audio_optimisation::cobyla::{cobyla, CobylaConfig, CobylaConstraint, CobylaRhoBegin};
use ndarray::Array1;
use std::sync::Arc;
// Minimize 10*(x0+1)^2 + x1^2 subject to x0 >= 0
// (i.e. constraint -x0 <= 0 in our convention)
let f = |x: &Array1<f64>| 10.0 * (x[0] + 1.0).powi(2) + x[1].powi(2);
let constraints = vec![CobylaConstraint {
fun: Arc::new(|x: &Array1<f64>| -x[0]),
}];
let cfg = CobylaConfig {
x0: Array1::from(vec![1.0, 1.0]),
bounds: vec![(-10.0, 10.0), (-10.0, 10.0)],
maxeval: 200,
rho_begin: CobylaRhoBegin::All(0.5),
..Default::default()
};
let report = cobyla(&f, &constraints, cfg).expect("cobyla should run");
assert!(report.x[0] >= -1e-3, "x0 must be roughly >= 0");
assert!(report.fun < 10.1, "constrained minimum is at (0, 0) with value 10");Structs§
- Cobyla
Config - Configuration for
cobyla. - Cobyla
Constraint - A single inequality constraint
fun(x) <= 0. - Cobyla
Report - Result of a
cobylarun. - Cobyla
Stop Tols - Termination tolerances passed through to NLopt’s
nlopt_stopping.
Enums§
- Cobyla
RhoBegin - Initial trust-region radius spec.
Functions§
- cobyla
- Minimize
fsubject to bounds and inequality constraintsg_i(x) <= 0.
Type Aliases§
- Cobyla
Constraint Fn - Erased inequality-constraint closure. Returns
<= 0when feasible (NLopt convention; the wrapper flips the sign for thecobylacrate).