Crate rosomaxa

Source
Expand description

This crate exposes a generalized hyper heuristics and some helper functionality which can be used to build a solver for optimization problems.

§Examples

This example demonstrates the usage of example models and heuristics to minimize Rosenbrock function. For the sake of minimalism, there is a pre-built solver and heuristic operator models. Check example module to see how to use functionality of the crate for an arbitrary domain.

use rosomaxa::prelude::*;
use rosomaxa::example::*;

let random = Arc::new(DefaultRandom::default());
// examples of heuristic operator, they are domain specific. Essentially, heuristic operator
// is responsible to produce a new, potentially better solution from the given one.
let noise_op = VectorHeuristicOperatorMode::JustNoise(Noise::new_with_ratio(1., (-0.1, 0.1), random));
let delta_op = VectorHeuristicOperatorMode::JustDelta(-0.1..0.1);
let delta_power_op = VectorHeuristicOperatorMode::JustDelta(-0.5..0.5);

// add some configuration and run the solver
let (solutions, _) = Solver::default()
    .with_fitness_fn(create_rosenbrock_function())
    .with_init_solutions(vec![vec![2., 2.]])
    .with_search_operator(noise_op, "noise", 1.)
    .with_search_operator(delta_op, "delta", 0.2)
    .with_diversify_operator(delta_power_op)
    .with_termination(Some(5), Some(1000), None, None)
    .solve()
    .expect("cannot build and use solver");

// expecting at least one solution with fitness close to 0
assert_eq!(solutions.len(), 1);
let (_, fitness) = solutions.first().unwrap();
assert!(*fitness < 0.001);

Modules§

algorithms
A collection of reusable algorithms without dependencies on any other module in the project.
evolution
Contains functionality to run evolution simulation.
example
This module contains example models and logic to demonstrate practical usage of rosomaxa crate.
hyper
This module contains a hyper-heuristic logic.
population
Specifies population types.
prelude
This module reimports a commonly used types.
termination
The termination module contains logic which defines termination criteria for metaheuristic, e.g. when to stop evolution in evolutionary algorithms.
utils
This module contains helper functionality.

Structs§

HeuristicStatistics
A refinement statistics to track evolution progress.
TelemetryHeuristicContext
A default heuristic context implementation which uses telemetry to track search progression parameters.

Enums§

HeuristicSpeed
Defines instant refinement speed type.

Traits§

HeuristicContext
Represents heuristic context.
HeuristicSolution
Represents solution in population defined as actual solution.
Stateful
A trait which specifies object with state behavior.

Functions§

get_default_population
Gets default population algorithm.
get_default_selection_size
Gets default population selection size.

Type Aliases§

DynHeuristicPopulation
Specifies a dynamically dispatched type for heuristic population.
HeuristicResult
Specifies a heuristic result type.