Skip to content

Commit 92a2dc6

Browse files
Reproducibility and documentation enhancements.
1 parent 8de6184 commit 92a2dc6

File tree

11 files changed

+1092
-11
lines changed

11 files changed

+1092
-11
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9+
## [Unreleased]
10+
11+
### Added
12+
- **Reproducibility Support**: Evolution can now be made deterministic by setting a random seed
13+
- Optional `seed` parameter in `[NEAT]` config section
14+
- Optional `seed` parameter in `Population.__init__()`
15+
- Optional `seed` parameter in `ParallelEvaluator.__init__()` for reproducible parallel evaluation
16+
- Per-genome deterministic seeding in parallel mode (seed + genome.key)
17+
- Comprehensive documentation in `docs/reproducibility.rst`
18+
- Complete test coverage in `tests/test_reproducibility.py` (9 tests)
19+
- **Fully backward compatible**: Existing code works without changes
20+
- Seed parameter controls Python's `random` module
21+
- Checkpoint system already preserved random state (unchanged)
22+
- All changes are fully backward compatible
23+
924
## [1.0.0] - 2025-01-09
1025

1126
### Added

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ For further information regarding general concepts and theory, please see the [p
1414
`neat-python` is licensed under the [3-clause BSD license](https://opensource.org/licenses/BSD-3-Clause). It is
1515
currently only supported on Python 3.8 through 3.14, and pypy3.
1616

17+
## Features ##
18+
19+
* Pure Python implementation with no dependencies beyond the standard library
20+
* Supports Python 3.8-3.14 and PyPy 3
21+
* **Reproducible evolution** - Set random seeds for deterministic, repeatable experiments
22+
* Parallel fitness evaluation using multiprocessing
23+
* Network export to JSON format for interoperability
24+
* Comprehensive documentation and examples
25+
1726
## Getting Started ##
1827

1928
If you want to try neat-python, please check out the repository, start playing with the examples (`examples/xor` is

docs/conf.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
'sphinx.ext.napoleon', # Google/NumPy docstring support
4141
# note: the below does not actually require (at least the Python) graphviz
4242
# package to be installed
43-
'sphinx.ext.inheritance_diagram',
43+
'sphinx.ext.inheritance_diagram',
44+
# Enhanced user experience
45+
'sphinx_copybutton', # Adds copy button to code blocks
46+
'sphinx_design', # Adds cards, tabs, badges for enhanced formatting
4447
]
4548

4649
extlinks = {'pytypes': ('https://docs.python.org/3/library/stdtypes.html#%s',
@@ -133,6 +136,12 @@
133136
# Provide links to python3 documentation
134137
intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}
135138

139+
# -- Options for sphinx_copybutton ----------------------------------------
140+
141+
# Remove prompts when copying code (e.g., >>>, $, In [1]:)
142+
copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: |Out\[\d*\]: "
143+
copybutton_prompt_is_regexp = True
144+
136145
# -- Options for HTML output ----------------------------------------------
137146

138147
# The theme to use for HTML and HTML Help pages. See the documentation for

docs/config_file.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,36 @@ itself. This section is always required, and is handled by the `Config` class i
7575
If this evaluates to ``True``, when all species simultaneously become extinct due to stagnation, a new random
7676
population will be created. If ``False``, a `CompleteExtinctionException` will be thrown.
7777

78+
.. _seed-label:
79+
80+
.. index:: ! seed
81+
.. index:: reproducibility
82+
.. index:: random
83+
84+
* *seed*
85+
Optional random seed for reproducible evolution. If specified, sets the seed for Python's ``random`` module,
86+
making evolution deterministic. If omitted or set to ``None``, behavior is non-deterministic (different results
87+
each run). **This parameter is optional and defaults to None.**
88+
89+
Example usage:
90+
91+
.. code-block:: ini
92+
93+
[NEAT]
94+
pop_size = 150
95+
seed = 42 # Enable reproducibility
96+
97+
The seed can also be set or overridden programmatically:
98+
99+
.. code-block:: python
100+
101+
pop = neat.Population(config, seed=42)
102+
103+
For detailed information about reproducibility, including parallel evaluation and best practices,
104+
see :ref:`reproducibility-label`.
105+
106+
.. versionadded:: 1.1
107+
78108
.. index:: stagnation
79109
.. index:: DefaultStagnation
80110

docs/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ Contents:
5757
:caption: User Guides
5858

5959
config_file
60+
reproducibility
6061
customization
61-
cookbook
6262
activation
6363
ctrnn
6464
network_export
65+
network_export
6566

6667
.. toctree::
6768
:maxdepth: 2

0 commit comments

Comments
 (0)