#optimization #problem #solver #heuristics #vrp #routing #vehicle

rosomaxa

A rosomaxa algorithm and other building blocks for creating a solver for optimization problems

18 releases

0.9.0 Nov 10, 2024
0.8.0 Jul 13, 2024
0.7.2 Dec 22, 2023
0.7.1 Aug 26, 2023
0.1.1 Mar 10, 2022

#1373 in Algorithms

Download history 20/week @ 2024-08-17 26/week @ 2024-08-24 24/week @ 2024-08-31 21/week @ 2024-09-07 37/week @ 2024-09-14 26/week @ 2024-09-21 36/week @ 2024-09-28 27/week @ 2024-10-05 24/week @ 2024-10-12 27/week @ 2024-10-19 11/week @ 2024-10-26 16/week @ 2024-11-02 121/week @ 2024-11-09 36/week @ 2024-11-16 15/week @ 2024-11-23 19/week @ 2024-11-30

193 downloads per month
Used in 5 crates (via vrp-core)

Apache-2.0

215KB
4.5K SLoC

Description

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

More details are coming.


lib.rs:

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);

Dependencies

~2.1–2.8MB
~53K SLoC