### 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

# 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 [

] trait, while constraints,
also defined as functions of the input variables have to implement the [`ObjFn`

] trait.`CstrFn`

The algorithm is run using the [

] function.`fmin_cobyla`

Implementation Note: the binding is generated with bindgen is visible as the

function using the callback type
`raw_cobyla`

which is used to compute the objective function and the constraints.`cobyla_calcfc`

A trait representing an objective function.

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

- n-dimensional array`x`

- user defined data A trait representing aa constraint function.`user_data`

An constraint function takes the form of a closure

The algorithm make the constraint positive eventually.`f``(`x`:` `&``[``f64``]``)` `->` `f64`

For instance if you want an upper bound MAX for x,
you have to define the constraint as

.
Conversly for a lower bound you would define `|`x`|` `MAX` `-` x`|`x`|` x `-` `MIN`

- n-dimensional array`x`

#### No runtime deps

~0–1.6MB

~33K SLoC