pub struct Solver<F: ObjFunc, R> { /* private fields */ }
Expand description

A public API for using optimization methods.

Users can simply obtain their solution and see the result.

  • The method is a type that implemented Algorithm.
  • The objective function is a type that implement ObjFunc.
  • A basic algorithm data is hold by Context.

The builder of this type can infer the algorithm by Setting::Algorithm.

use metaheuristics_nature::{Rga, Solver};

// Build and run the solver
let s = Solver::build(Rga::default())
    .task(|ctx| ctx.gen == 20)
    .solve(MyFunc::new());
// Get the result from objective function
let ans = s.result();
// Get the optimized XY value of your function
let x = s.best_parameters();
let y = s.best_fitness();
// Get the history reports
let report = s.report();

Implementations

Get the reference of the objective function.

It’s useful when you need to get the preprocessed data from the initialization process, which is stored in the objective function.

Get the history report returned by record function.

Get the best parameters.

Get the best fitness.

Get the result of the objective function.

Seed of the random number generator.

Start to build a solver. Take a setting and setup the configurations.

Please check SolverBuilder type, it will help you choose your configuration.

If all things are well-setup, call SolverBuilder::solve.

The default value of each option can be found in their document.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.