#optimizer #optimization #constrained #derivative-free

bin+lib cobyla

Rust wrapping of a C implementation of the COBYLA optimizer

3 releases

0.1.2 Jan 21, 2021
0.1.1 Jan 20, 2021
0.1.0 Jan 18, 2021

#10 in #optimizer

21 downloads per month

Custom license

68KB
2K SLoC

C 1.5K SLoC // 0.1% comments Rust 225 SLoC // 0.1% comments

cobyla

This a Rust wrapper for COBYLA optimizer (COBYLA stands for Constrained Optimization BY Linear Approximations).

COBYLA an algorithm for minimizing a function of many variables. The method is derivatives free (only the function values are needed) and take into account constraints on the variables. The algorithm is described in:

M.J.D. Powell, "A direct search optimization method that models the objective and constraint functions by linear interpolation," in Advances in Optimization and Numerical Analysis Mathematics and Its Applications, vol. 275 (eds. Susana Gomez and Jean-Pierre Hennart), Kluwer Academic Publishers, pp. 51-67 (1994).


lib.rs:

cobyla

This a Rust wrapper for COBYLA optimizer (COBYLA stands for Constrained Optimization BY Linear Approximations).

COBYLA is an algorithm for minimizing a function of many variables. The method is derivatives free (only the function values are needed) and take into account constraints on the variables. The algorithm is described in:

M.J.D. Powell, "A direct search optimization method that models the objective and constraint functions by linear interpolation," in Advances in Optimization and Numerical Analysis Mathematics and Its Applications, vol. 275 (eds. Susana Gomez and Jean-Pierre Hennart), Kluwer Academic Publishers, pp. 51-67 (1994).

The objective function to be minimized has to implement the [ObjFn] trait, while constraints, also defined as functions of the input variables have to implement the [CstrFn] trait.

The algorithm is run using the [fmin_cobyla] function.

Implementation Note: the binding is generated with bindgen is visible as the raw_cobyla function using the callback type cobyla_calcfc which is used to compute the objective function and the constraints.

A trait representing an objective function.

An objective function takes the form of a closure f(x: &[f64], user_data: &mut U) -> f64

  • x - n-dimensional array
  • user_data - user defined data A trait representing aa constraint function.

An constraint function takes the form of a closure f(x: &[f64]) -> f64 The algorithm make the constraint positive eventually.

For instance if you want an upper bound MAX for x, you have to define the constraint as |x| MAX - x. Conversly for a lower bound you would define |x| x - MIN

  • x - n-dimensional array

No runtime deps

~0–1.6MB
~33K SLoC