ndev/lib.rs
1mod network;
2
3#[cfg(test)]
4mod tests {
5 use crate::network::{GeneticAlgorithm, Selection, SelectionType};
6
7 #[test]
8 fn xor() {
9 let mut ga = GeneticAlgorithm::new(
10 100,
11 &[2, 4, 1],
12 Selection::new(0.25f32, 0.04f32, SelectionType::Truncation),
13 0.2f32,
14 );
15 ga.run(&[
16 &[0f32, 0f32],
17 &[0f32, 1f32],
18 &[1f32, 0f32],
19 &[1f32, 1f32],
20 ], &[
21 &[0f32],
22 &[1f32],
23 &[1f32],
24 &[0f32],
25 ]);
26
27 assert_eq!(2 + 2, 4);
28 }
29}