-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Write documentation structure and initial docs. Have also included a doctest runner. Once we're happy with this I'll flick the switch on read the docs. * Return to the original scaling for GA. Also include brief background.
- Loading branch information
1 parent
49ef509
commit 85bc17d
Showing
16 changed files
with
635 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line. | ||
SPHINXOPTS = | ||
SPHINXBUILD = python -msphinx | ||
SPHINXPROJ = Axelrod-dojo | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Genetic Algorithm | ||
================= | ||
|
||
A genetic algorithm aims to mimic evolutionary processes so as to optimise a | ||
particular function on some space of candidate solutions. | ||
|
||
The process can be described by assuming that there is a function | ||
:math:`f:V\to \mathbb{R}`, where :math:`V` is some vector space. | ||
In the case of the Prisoner's dilemma, | ||
the vector space :math:`V` corresponds to some representation of a | ||
particular archetype (which might not actually be a numeric vector space) and | ||
the function :math:`f` corresponds to some measure of performance/fitness of the | ||
strategy in question. | ||
|
||
In this setting a candidate solution :math:`x\in\mathbb{R}^m` corresponds to a | ||
chromosome with each :math:`x_i` corresponding to a gene. | ||
|
||
The genetic algorithm has three essential parameters: | ||
|
||
- The population size: the algorithm makes use of a number of candidate | ||
solutions at each stage. | ||
- The bottle neck parameter: at every stage the candidates in the population are | ||
ranked according to their fitness, only a certain number are kept (the best | ||
performing ones) from one generation to the next. This number is referred to | ||
as the bottle neck. | ||
- The mutation probability: from one stage to the next when new individuals are | ||
added to the population (more about this process shortly) there is a | ||
probability with which each gene randomly mutates. | ||
|
||
New individuals are added to the population (so as to ensure that the population | ||
size stays constant from one stage to the next) using a process of "crossover". | ||
Two high performing individuals are paired and according to some predefined | ||
procedure, genes from both these individuals are combined to create a new | ||
individual. | ||
|
||
For each strategy archetype, this library thus defines a process for mutation as | ||
well as for crossover. | ||
|
||
Finite state machines | ||
--------------------- | ||
|
||
A finite state machine is made up of the following: | ||
|
||
- a mapping from a state/action pair to another target state/action pair | ||
- an initial state/action pair. | ||
|
||
(See [Harper2017]_ for more details.) | ||
|
||
The crossover and mutation are implemented in the following way: | ||
|
||
- Crossover: this is done by taking a randomly selected number of target | ||
state/actions | ||
pairs from one individual and the rest from the other. | ||
- Mutation: given a mutation probability :math:`delta` each target state/action | ||
has a probability :math:`\delta` of being randomly changed to one of the other | ||
states or actions. Furthermore the **initial** action has a probability of | ||
being swapped of :math:`\delta\times 10^{-1}` and the **initial** state has a | ||
probability of being changed to another random state of :math:`\delta \times | ||
10^{-1} \times N` (where :math:`N` is the number of states). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Background | ||
========== | ||
|
||
Note that there are currently two algorithms implemented: | ||
|
||
- Genetic algorithm | ||
- Particle swam optimisation | ||
|
||
Note that these two algorithms are not equally suited to each archetype. For | ||
example the Genetic algorithm is believed to be better suited to discrete space | ||
strategies such as the finite state machines whilst the Particle swarm algorithm | ||
would be better suited to a continuous space strategy such as the Gambler. | ||
|
||
For more information on these algorithms and their implementations see: | ||
|
||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
genetic_algorithm.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Axelrod-dojo documentation build configuration file, created by | ||
# sphinx-quickstart on Wed Oct 11 09:40:19 2017. | ||
# | ||
# This file is execfile()d with the current directory set to its | ||
# containing dir. | ||
# | ||
# Note that not all possible configuration values are present in this | ||
# autogenerated file. | ||
# | ||
# All configuration values have a default; values that are commented out | ||
# serve to show the default. | ||
|
||
# If extensions (or modules to document with autodoc) are in another directory, | ||
# add these directories to sys.path here. If the directory is relative to the | ||
# documentation root, use os.path.abspath to make it absolute, like shown here. | ||
# | ||
# import os | ||
# import sys | ||
# sys.path.insert(0, os.path.abspath('.')) | ||
|
||
|
||
# -- General configuration ------------------------------------------------ | ||
|
||
# If your documentation needs a minimal Sphinx version, state it here. | ||
# | ||
# needs_sphinx = '1.0' | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
# ones. | ||
extensions = ['sphinx.ext.mathjax'] | ||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ['_templates'] | ||
|
||
# The suffix(es) of source filenames. | ||
# You can specify multiple suffix as a list of string: | ||
# | ||
# source_suffix = ['.rst', '.md'] | ||
source_suffix = '.rst' | ||
|
||
# The master toctree document. | ||
master_doc = 'index' | ||
|
||
# General information about the project. | ||
project = 'Axelrod-dojo' | ||
copyright = '2017, The Axelrod project developers' | ||
author = 'The Axelrod project developers' | ||
|
||
# The version info for the project you're documenting, acts as replacement for | ||
# |version| and |release|, also used in various other places throughout the | ||
# built documents. | ||
# | ||
# The short X.Y version. | ||
version = '' | ||
# The full version, including alpha/beta/rc tags. | ||
release = '' | ||
|
||
# The language for content autogenerated by Sphinx. Refer to documentation | ||
# for a list of supported languages. | ||
# | ||
# This is also used if you do content translation via gettext catalogs. | ||
# Usually you set "language" from the command line for these cases. | ||
language = None | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
# This patterns also effect to html_static_path and html_extra_path | ||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] | ||
|
||
# The name of the Pygments (syntax highlighting) style to use. | ||
pygments_style = 'sphinx' | ||
|
||
# If true, `todo` and `todoList` produce output, else they produce nothing. | ||
todo_include_todos = False | ||
|
||
|
||
# -- Options for HTML output ---------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. See the documentation for | ||
# a list of builtin themes. | ||
# | ||
html_theme = 'alabaster' | ||
|
||
# Theme options are theme-specific and customize the look and feel of a theme | ||
# further. For a list of options available for each theme, see the | ||
# documentation. | ||
# | ||
# html_theme_options = {} | ||
|
||
# Add any paths that contain custom static files (such as style sheets) here, | ||
# relative to this directory. They are copied after the builtin static files, | ||
# so a file named "default.css" will overwrite the builtin "default.css". | ||
html_static_path = ['_static'] | ||
|
||
# Custom sidebar templates, must be a dictionary that maps document names | ||
# to template names. | ||
# | ||
# This is required for the alabaster theme | ||
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars | ||
html_sidebars = { | ||
'**': [ | ||
'about.html', | ||
'navigation.html', | ||
'relations.html', # needs 'show_related': True theme option to display | ||
'searchbox.html', | ||
'donate.html', | ||
] | ||
} | ||
|
||
|
||
# -- Options for HTMLHelp output ------------------------------------------ | ||
|
||
# Output file base name for HTML help builder. | ||
htmlhelp_basename = 'Axelrod-dojodoc' | ||
|
||
|
||
# -- Options for LaTeX output --------------------------------------------- | ||
|
||
latex_elements = { | ||
# The paper size ('letterpaper' or 'a4paper'). | ||
# | ||
# 'papersize': 'letterpaper', | ||
|
||
# The font size ('10pt', '11pt' or '12pt'). | ||
# | ||
# 'pointsize': '10pt', | ||
|
||
# Additional stuff for the LaTeX preamble. | ||
# | ||
# 'preamble': '', | ||
|
||
# Latex figure (float) alignment | ||
# | ||
# 'figure_align': 'htbp', | ||
} | ||
|
||
# Grouping the document tree into LaTeX files. List of tuples | ||
# (source start file, target name, title, | ||
# author, documentclass [howto, manual, or own class]). | ||
latex_documents = [ | ||
(master_doc, 'Axelrod-dojo.tex', 'Axelrod-dojo Documentation', | ||
'The Axelrod project developers', 'manual'), | ||
] | ||
|
||
|
||
# -- Options for manual page output --------------------------------------- | ||
|
||
# One entry per manual page. List of tuples | ||
# (source start file, name, description, authors, manual section). | ||
man_pages = [ | ||
(master_doc, 'axelrod-dojo', 'Axelrod-dojo Documentation', | ||
[author], 1) | ||
] | ||
|
||
|
||
# -- Options for Texinfo output ------------------------------------------- | ||
|
||
# Grouping the document tree into Texinfo files. List of tuples | ||
# (source start file, target name, title, author, | ||
# dir menu entry, description, category) | ||
texinfo_documents = [ | ||
(master_doc, 'Axelrod-dojo', 'Axelrod-dojo Documentation', | ||
author, 'Axelrod-dojo', 'One line description of project.', | ||
'Miscellaneous'), | ||
] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
How to | ||
====== | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
use-different-ojective-functions.rst | ||
train-using-genetic-algorithm.rst | ||
train-using-particle-swarm-algorithm.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Train using the genetic algorithm | ||
================================= | ||
|
||
WIP: include all details for training with genetic algorithm. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Train using the particle swarm algorithm | ||
======================================== | ||
|
||
WIP: include all details for training with PSO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Use different objective functions | ||
================================= | ||
|
||
It is currently possible to optimise players for 3 different objectives: | ||
|
||
- Score; | ||
- Score difference; | ||
- Probability of fixation in a Moran process. | ||
|
||
This is done by passing a different objective :code:`name` to the | ||
:code:`prepare_objective` function:: | ||
|
||
>>> import axelrod_dojo as dojo | ||
>>> score_objective = dojo.prepare_objective(name="score", turns=10, repetitions=1) | ||
>>> diff_objective = dojo.prepare_objective(name="score_diff", turns=10, repetitions=1) | ||
>>> moran_objective = dojo.prepare_objective(name="moran", turns=10, repetitions=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.. Axelrod-dojo documentation master file, created by | ||
sphinx-quickstart on Wed Oct 11 09:40:19 2017. | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
Welcome to Axelrod-dojo's documentation! | ||
======================================== | ||
|
||
This library is a companion library to the `Axelrod | ||
<http://axelrod.readthedocs.io/en/stable/>`_ library: a research tool for the | ||
study of the iterated prisoners dilemma. The **Axelrod-dojo** is used to train | ||
strategies. | ||
|
||
This is done using implementations of: | ||
|
||
- Strategy archetypes :code:`Parameters` | ||
- Algorithms | ||
|
||
Table of Contents | ||
----------------- | ||
|
||
.. toctree:: | ||
:maxdepth: 3 | ||
|
||
tutorial/index.rst | ||
howtos/index.rst | ||
background/index.rst | ||
reference/index.rst | ||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. _bibliography: | ||
|
||
Bibliography | ||
============ | ||
|
||
This is a collection of various bibliographic items referenced in the | ||
documentation. | ||
|
||
.. [Harper2017] Marc Harper, Vincent Knight, Martin Jones, Georgios Koutsovoulo, Nikoleta E. Glynatsi and Owen Campbell (2017) Reinforcement Learning Produces Dominant Strategies for the Iterated Prisoner's Dilemma. Arxiv. http://arxiv.org/abs/1707.06307 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Reference | ||
========= | ||
|
||
This section is the reference guide for the various components of the library. | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
bibliography.rst |
Oops, something went wrong.