2
2
Customizing Behavior
3
3
====================
4
4
5
- NEAT-Python allows the user to provide drop-in replacements for some parts of the NEAT algorithm, and attempts
6
- to allow easily implementing common variations of the algorithm mentioned in the literature. If
5
+ NEAT-Python allows the user to provide drop-in replacements for some parts of the NEAT algorithm, which hopefully
6
+ makes it easier to implement common variations of the algorithm as mentioned in the literature. If
7
7
you find that you'd like to be able to customize something not shown here, please submit an issue on GitHub.
8
8
9
- Adding new activation functions
10
- -------------------------------
11
- To register a new activation function, you only need to call ` neat.activation_functions.add ` with your new
12
- function and the name by which you want to refer to it in the configuration file ::
9
+ New activation functions
10
+ ------------------------
11
+ New activation functions are registered with your ` Config ` instance, prior to creation of the ` Population ` instance,
12
+ as follows ::
13
13
14
14
def sinc(x):
15
15
return 1.0 if x == 0 else sin(x) / x
16
16
17
- neat.activation_functions.add ('my_sinc_function', sinc)
17
+ config.genome_config.add_activation ('my_sinc_function', sinc)
18
18
19
- Note that you must register the new function before you load the configuration file.
19
+ The first argument to `add_activation ` is the name by which this activation function will be referred to in the
20
+ configuration settings file.
20
21
21
- This is demonstrated in the `memory
22
- <https://github.com/CodeReclaimers/neat-python/tree/master/examples/memory> `_ example.
22
+ This is demonstrated in the `memory-fixed
23
+ <https://github.com/CodeReclaimers/neat-python/tree/master/examples/memory-fixed> `_ example.
24
+
25
+ NOTE: This method is only valid when using the `DefaultGenome ` implementation--different genome implementations
26
+ may require a different method of registration.
23
27
24
28
Reporting/logging
25
29
-----------------
@@ -34,54 +38,51 @@ behavior you can add using a reporter.
34
38
35
39
TODO: document reporter interface
36
40
37
- Species stagnation scheme
38
- -------------------------
41
+ New genome types
42
+ ----------------
39
43
40
- To use a different species stagnation scheme , you must create and register a custom class whose interface matches that
41
- of ` DefaultStagnation ` and set the `stagnation_type ` of your Config instance to this class .
44
+ To use a different genome type , you can create a custom class whose interface matches that of
45
+ ` DefaultGenome ` and pass this as the `genome_type ` argument to the ` Config ` constructor .
42
46
43
- This is demonstrated in the `interactive 2D image
44
- <https://github.com/CodeReclaimers/neat-python/blob/master/examples/picture2d/interactive .py> `_ example.
47
+ This is demonstrated in the `circuit evolution
48
+ <https://github.com/CodeReclaimers/neat-python/blob/master/examples/circuits/evolve .py> `_ example.
45
49
46
- TODO: document stagnation interface
50
+ TODO: document genome interface
47
51
48
- Reproduction scheme
49
- -------------------
52
+ Speciation scheme
53
+ -----------------
50
54
51
- The default reproduction scheme uses explicit fitness sharing and a fixed species stagnation limit. This behavior
52
- is encapsulated in the DefaultReproduction class .
55
+ To use a different speciation scheme, you can create a custom class whose interface matches that of
56
+ ` DefaultSpeciesSet ` and pass this as the ` species_set_type ` argument to the ` Config ` constructor .
53
57
54
- TODO: document reproduction interface
58
+ TODO: document species set interface
55
59
56
60
TODO: include example
57
61
58
- Speciation
59
- ----------
60
-
61
- If you need to change the speciation scheme, you may specify a subclass `Population ` and override the `_speciate ` method (or,
62
- if you must, `monkey patch/duck punch
63
- <https://en.wikipedia.org/wiki/Monkey_patch> `_ it).
62
+ Species stagnation scheme
63
+ -------------------------
64
64
65
- TODO: include example
65
+ The default species stagnation scheme is a simple fixed stagnation limit--when a species exhibits
66
+ no improvement for a fixed number of generations, all its members are removed from the simulation. This
67
+ behavior is encapsulated in the `DefaultStagnation ` class.
66
68
67
- Using different genome types
68
- ----------------------------
69
+ To use a different species stagnation scheme, you must create a custom class whose interface matches that
70
+ of ` DefaultStagnation `, and provide it as the ` stagnation_type ` argument to the ` Config ` constructor.
69
71
70
- To use a different genome type, you can create a custom class whose interface matches that of
71
- `DefaultGenome ` and pass this as the first argument to the `Config ` constructor (that is, the
72
- `genome_type ` parameter).
72
+ This is demonstrated in the `interactive 2D image
73
+ <https://github.com/CodeReclaimers/neat-python/blob/master/examples/picture2d/interactive.py> `_ example.
73
74
74
- TODO: document genome interface
75
+ TODO: document stagnation interface
75
76
76
- This is demonstrated in the ` circuit evolution
77
- <https://github.com/CodeReclaimers/neat-python/blob/master/examples/circuits/evolve.py> `_ example.
77
+ Reproduction scheme
78
+ -------------------
78
79
80
+ The default reproduction scheme uses explicit fitness sharing. This behavior is encapsulated in the
81
+ `DefaultReproduction ` class.
79
82
80
- Using a different gene type
81
- ---------------------------
83
+ To use a different reproduction scheme, you must create a custom class whose interface matches that
84
+ of ` DefaultReproduction `, and provide it as the ` reproduction_type ` argument to the ` Config ` constructor.
82
85
83
- To use a different gene type, you can create a custom class whose interface matches that of
84
- `NodeGene ` or `ConnectionGene `, and set the `node_gene_type ` or `conn_gene_type ` member,
85
- respectively, of your Config instance to this class.
86
+ TODO: document reproduction interface
86
87
87
88
TODO: include example
0 commit comments