Struct metaheuristics_nature::Solver
source · [−]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.
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.