Closed mrlogick closed 8 months ago
I have a small example at https://docs.rs/metaheuristics-nature/latest/metaheuristics_nature/struct.Fx.html.
The algorithm will try to minimize the function's return value, and bound
is the range of the variables.
use metaheuristics_nature::{Fx, Rga, Solver};
let bound = [[-50., 50.]; 4];
let f = Fx::new(&bound, |&[a, b, c, d]| a * a + 8. * b * b + c * c + d * d);
let s = Solver::build(Rga::default(), f)
.seed(0)
.task(|ctx| ctx.gen == 20)
.solve();
Currently, this crate does not support integer problems. The a, b, c, and d are real numbers (f64
).
Ok, it's clearer now, thanks!
As I just started learning genetic algorithms, it's not very clear to me how to use this crate. It would be good to have a simple example, like the Knapsack Problem, or something.