Struct metaheuristics_nature::Solver[][src]

pub struct Solver<F: ObjFunc>(_);
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.

This type can infer the algorithm by Setting::Algorithm.

use metaheuristics_nature::{Rga, Setting, Solver, Task};

let s = Solver::solve(
    MyFunc::new(),
    Rga::default().task(Task::MinFit(1e-20)),
    |_| true, // Run without callback
);
// 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 reports = s.reports();

Implementations

Create the task and run the algorithm, which may takes a lot of time.

Argument callback is a progress feedback function, returns true to keep algorithm running, same as the behavior of the while-loop.

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 for plotting.

Get the best parameters.

Get the best fitness.

Get the result of the objective function.

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.