Crate optimal

Source
Expand description

Mathematical optimization and machine learning framework and algorithms.

Optimal provides a composable framework for mathematical optimization and machine learning from the optimization perspective, in addition to algorithm implementations.

The framework consists of runners, optimizers, and problems, with a chain of dependency as follows: runner -> optimizer -> problem. Most optimizers can support many problems and most runners can support many optimizers.

A problem defines a mathematical optimization problem. An optimizer defines the steps for solving a problem, usually as an infinite series of state transitions incrementally improving a solution. A runner defines the stopping criteria for an optimizer and may affect the optimization sequence in other ways.

§Examples

Minimize the “count” problem using a derivative-free optimizer:

use optimal::{prelude::*, BinaryDerivativeFreeConfig};

println!(
    "{:?}",
    BinaryDerivativeFreeConfig::start_default_for(16, |point| {
        point.iter().filter(|x| **x).count() as f64
    })
    .argmin()
);

Minimize the “sphere” problem using a derivative optimizer:

use optimal::{prelude::*, RealDerivativeConfig};

println!(
    "{:?}",
    RealDerivativeConfig::start_default_for(
        2,
        std::iter::repeat(-10.0..=10.0).take(2),
        |point| point.iter().map(|x| x.powi(2)).sum(),
        |point| point.iter().map(|x| 2.0 * x).collect(),
    )
    .nth(100)
    .unwrap()
    .best_point()
);

For more control over configuration parameters, introspection of the optimization process, serialization, and specialization that may improve performance, see individual optimizer packages.

Modules§

prelude
Useful traits, types, and functions unlikely to conflict with existing definitions.

Structs§

BinaryDerivativeFree
A generic binary derivative-free optimizer.
BinaryDerivativeFreeConfig
Binary derivative-free optimizer configuration parameters.
RealDerivative
A generic binary derivative-free optimizer.
RealDerivativeConfig
Binary derivative-free optimizer configuration parameters.

Traits§

Optimizer
Running optimizer methods independent of configuration and state.
OptimizerExt
An extension trait adding methods to StreamingIterator for optimization.
StreamingIterator
An interface for dealing with streaming iterators.
StreamingIteratorExt
An extension trait adding methods to StreamingIterator.