Expand description

A collection of nature-inspired meta-heuristic algorithms.

Terminology

For unifying the terms, in this documentation,

  • “Iteration” is called “generation”.
  • “Function” that evaluates value is called “objective function”.
  • “Return value” of the objective function is called “fitness”.

Algorithm

There are two traits Algorithm and Setting. The previous is used to design the optimization method, and the latter is the setting interface.

Solver is a simple interface for obtaining the solution, or analyzing the result. This type allows you to use the pre-defined methods without importing any traits.

All provided methods are listed in the module methods.

For making your owned method, please see utility::prelude.

Objective Function

For a quick demo with callable object, please see Fx.

You can define your question as an objective function through implementing ObjFunc, and then the upper bound, lower bound, and an objective function ObjFunc::fitness() returns Fitness should be defined.

Random Function

This crate uses a 64bit ChaCha algorithm (random::Rng) to generate uniform random values. Before that, a random seed is required. The seed is generated by getrandom crate, please see its support platform.

In parallelization, the random number is unstable because of the dynamic planning of the rayon library. Fix the seed and change the thread to one via to obtain a determined result. Please see crate::rayon::single_thread when enabled rayon feature.

Features

  • std: Default feature. Enable standard library function, such as timing and threading. If std is disabled, crate “libm” will be enabled for the math functions.
  • rayon: Enable parallel computation via rayon, let objective function running without ordered. Disable it for the platform that doesn’t supported threading, or if your objective function is not complicate enough. This feature require std feature.
  • clap: Add CLI argument support for the provided algorithms and their options.

Compatibility

If you are using this crate for providing objective function, other downstream crates of yours may have some problems with compatibility.

The most important thing is using a stable version, specifying the major version number. Then re-export (pub use) this crate for the downstream crates.

This crate does the same things on ndarray and rayon.

Re-exports

Modules

  • Pre-implemented optimization methods.
  • The re-export of the crate ndarray.
  • The re-export of the crate rand and its related crates.
  • Random number generator module.
  • rayonrayon
    The re-export of the crate rayon.
  • The utility API for advanced usage.

Macros

  • A tool macro used to generate multiple builder functions (methods).

Structs

  • A quick interface help to create objective function from a callable object.
  • A Fitness type carrying final results.
  • A public API for using optimization methods.

Traits

  • The methods of the meta-heuristic algorithms.
  • A problem is well bounded.
  • The return value of the objective function (ObjFunc).
  • A trait for the objective function.
  • A trait that provides a conversion to original setting.