~ubuntu-branches/ubuntu/utopic/deap/utopic-proposed

« back to all changes in this revision

Viewing changes to doc/examples/gp_parity.rst

  • Committer: Package Import Robot
  • Author(s): Daniel Stender, Miriam Ruiz, Daniel Stender, Jakub Wilk
  • Date: 2014-07-06 00:03:41 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20140706000341-s7gij1ki3d8xz6t9
Tags: 1.0.1-1
[ Miriam Ruiz ]
* New Upstream Release. Closes: #675200
* Upgraded Standards-Version from 3.9.2 to 3.9.5
* Switched to dh_python2
* Upgraded debian/compat to 9
* Added build-arch and build-indep targets to debian/rules
* Using awk to remove connection from the documentation to google analytics
* Using jquery.js and underscore.js from libjs-jquery and libjs-underscore
* Added patches/doc.patch

[ Daniel Stender ]
* deb/control:
  + Added myself to Uploaders.
  + Added version to b-p on python-all.
  + Updated Homepage.
  + Wrapped and sorted.
* deb/copyright:
  + Changed copyright file towards DEP-5.
  + Updated Source URI (project source moved to Github).
  + Added email addresses for copyright holders.
  + Dropped license for eap/toolbox.py (not included anymore).
  + Extended copyrights to 2014.
  + Added myself to copyrights for deb/*.
  + Specified license location.
* Added watch file [initial version by Jackson Doak].

[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.. _parity:
 
2
    
 
3
===================
 
4
Even-Parity Problem
 
5
===================
 
6
 
 
7
Parity is one of the classical GP problems. The goal is to find a program
 
8
that produces the value of the Boolean even parity given n independent
 
9
Boolean inputs. Usually, 6 Boolean inputs are used (Parity-6), and the goal
 
10
is to match the good parity bit value for each of the :math:`2^6 = 64`
 
11
possible entries. The problem can be made harder by increasing the number of
 
12
inputs (in the DEAP implementation, this number can easily be tuned, as it is
 
13
fixed by a constant named PARITY_FANIN_M).
 
14
 
 
15
For more information about this problem, see :ref:`refPapersParity`.
 
16
 
 
17
Primitives set used
 
18
===================
 
19
 
 
20
Parity uses standard Boolean operators as primitives, available in the Python
 
21
operator module :
 
22
   
 
23
.. literalinclude:: /../examples/gp/parity.py
 
24
   :lines: 49-55
 
25
    
 
26
In addition to the *n* inputs, we add two constant terminals, one at 0, one
 
27
at 1.
 
28
 
 
29
.. note::
 
30
    As Python is a dynamic typed language, you can mix Boolean operators and
 
31
    integers without any issue.
 
32
 
 
33
    
 
34
Evaluation function
 
35
===================
 
36
 
 
37
In this implementation, the fitness of a Parity individual is simply the
 
38
number of successful cases. Thus, the fitness is maximized, and the maximum
 
39
value is 64 in the case of a 6 inputs problems.
 
40
   
 
41
.. literalinclude:: /../examples/gp/parity.py
 
42
   :pyobject: evalParity
 
43
 
 
44
`inputs` and `outputs` are two pre-generated lists, to speedup the
 
45
evaluation, mapping a given input vector to the good output bit. The Python
 
46
:func:`sum` function works on booleans (false is interpreted as 0 and true as
 
47
1), so the evaluation function boils down to sum the number of successful
 
48
tests : the higher this sum, the better the individual.
 
49
 
 
50
Conclusion
 
51
==========
 
52
 
 
53
The other parts of the program are mostly the same as the :ref:`Symbolic
 
54
Regression algorithm <symbreg>`.
 
55
 
 
56
The complete :example:`gp/parity`.
 
57
 
 
58
.. _refPapersParity:
 
59
 
 
60
Reference
 
61
=========
 
62
 
 
63
*John R. Koza, "Genetic Programming II: Automatic Discovery of Reusable
 
64
Programs", MIT Press, 1994, pages 157-199.*