KmolYuan / metaheuristics-nature-rs

A collection of nature-inspired metaheuristic algorithms.
https://crates.io/crates/metaheuristics-nature
MIT License
14 stars 1 forks source link

Change to context-input API #3

Closed KmolYuan closed 3 years ago

KmolYuan commented 3 years ago

The shared state Context type replace the old AlgorithmBase structure.

The Algorithm trait API can be changed to:

fn init(&mut self, ctx: &mut Context) {}
fn generation(&mut self, ctx: &mut Context);

And the Solver trait can be changed to a structure Solver<M, F>:

struct Solver<M, F>
where
    M: Algorithm,
    F: ObjFunc,
{
    method: M,
    func: F,
}
KmolYuan commented 3 years ago

ea1057c2bb4ed765609c0374f0de7a7503b377df 84b51ed62784a43fe7c8dfdfcc73fa81dd09064b