Skip to content

Commit c4d146a

Browse files
Updated documentation.
1 parent ae1d342 commit c4d146a

File tree

1 file changed

+43
-42
lines changed

1 file changed

+43
-42
lines changed

docs/customization.rst

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,28 @@
22
Customizing Behavior
33
====================
44

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
77
you find that you'd like to be able to customize something not shown here, please submit an issue on GitHub.
88

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::
1313

1414
def sinc(x):
1515
return 1.0 if x == 0 else sin(x) / x
1616

17-
neat.activation_functions.add('my_sinc_function', sinc)
17+
config.genome_config.add_activation('my_sinc_function', sinc)
1818

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.
2021

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.
2327

2428
Reporting/logging
2529
-----------------
@@ -34,54 +38,51 @@ behavior you can add using a reporter.
3438

3539
TODO: document reporter interface
3640

37-
Species stagnation scheme
38-
-------------------------
41+
New genome types
42+
----------------
3943

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.
4246

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.
4549

46-
TODO: document stagnation interface
50+
TODO: document genome interface
4751

48-
Reproduction scheme
49-
-------------------
52+
Speciation scheme
53+
-----------------
5054

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.
5357

54-
TODO: document reproduction interface
58+
TODO: document species set interface
5559

5660
TODO: include example
5761

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+
-------------------------
6464

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.
6668

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.
6971

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.
7374

74-
TODO: document genome interface
75+
TODO: document stagnation interface
7576

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+
-------------------
7879

80+
The default reproduction scheme uses explicit fitness sharing. This behavior is encapsulated in the
81+
`DefaultReproduction` class.
7982

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.
8285

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
8687

8788
TODO: include example

0 commit comments

Comments
 (0)