1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
use super::activation::Activation;
use crate::engine::environment::Envionment;
#[derive(Debug, Clone)]
pub struct NeatEnvironment {
pub weight_mutate_rate: Option<f32>,
pub weight_perturb: Option<f32>,
pub new_node_rate: Option<f32>,
pub new_edge_rate: Option<f32>,
pub edit_weights: Option<f32>,
pub reactivate: Option<f32>,
pub input_size: Option<u32>,
pub output_size: Option<u32>,
pub activation_functions: Vec<Activation>,
}
impl NeatEnvironment {
pub fn new() -> Self {
NeatEnvironment {
weight_mutate_rate: None,
weight_perturb: None,
new_node_rate: None,
new_edge_rate: None,
edit_weights: None,
reactivate: None,
input_size: None,
output_size: None,
activation_functions: vec![Activation::Sigmoid],
}
}
pub fn set_weight_mutate_rate(mut self, num: f32) -> Self {
self.weight_mutate_rate = Some(num);
self
}
pub fn set_weight_perturb(mut self, num: f32) -> Self {
self.weight_perturb = Some(num);
self
}
pub fn set_new_node_rate(mut self, num: f32) -> Self {
self.new_node_rate = Some(num);
self
}
pub fn set_new_edge_rate(mut self, num: f32) -> Self {
self.new_edge_rate = Some(num);
self
}
pub fn set_edit_weights(mut self, num: f32) -> Self {
self.edit_weights = Some(num);
self
}
pub fn set_reactivate(mut self, num: f32) -> Self {
self.reactivate = Some(num);
self
}
pub fn set_input_size(mut self, num: u32) -> Self {
self.input_size = Some(num);
self
}
pub fn set_output_size(mut self, num: u32) -> Self {
self.output_size = Some(num);
self
}
pub fn set_activation_functions(mut self, funcs: Vec<Activation>) -> Self {
self.activation_functions = funcs;
self
}
}
unsafe impl Send for NeatEnvironment {}
unsafe impl Sync for NeatEnvironment {}
impl Default for NeatEnvironment {
fn default() -> Self {
Self::new()
}
}
impl Envionment for NeatEnvironment {}