Package pygene :: Module organism :: Class BaseOrganism
[show private | hide private]
[frames | no frames]

Type BaseOrganism

object --+    
         |    
PGXmlMixin --+
             |
            BaseOrganism

Known Subclasses:
MendelOrganism, Organism, ProgOrganism

Base class for genetic algo and genetic programming organisms

Best not use this directly, but rather use or subclass from one of:
Method Summary
  __add__(self, partner)
Allows '+' operator for sexual reproduction
  __cmp__(self, other)
Convenience method which invokes duel
  __repr__(self)
Delivers a minimal string representation of this organism.
  duel(self, opponent)
Duels this organism against an opponent
  dump(self)
Produce a detailed human-readable report on this organism and its structure
  fitness(self)
Return the fitness level of this organism, as a float
  mate(self, partner)
Mates this organism with another organism to produce an entirely new organism
  mutate(self)
Implement the mutation phase
  xmlDumpAttribs(self, elem)
Dump out the custom attributes of this organism
  xmlDumpSelf(self, doc, parent)
Dumps out this object's contents into an xml tree
    Inherited from PGXmlMixin
  xmlDump(self, fileobj)
Dumps out the population to an open file in XML format.
  xmlDumpClass(self, tag)
dumps out class information
  xmlDumps(self)
dumps out to xml, returning a string of the raw generated xml
    Inherited from object
  __init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Method Details

__add__(self, partner)
(Addition operator)

Allows '+' operator for sexual reproduction

Returns a whole new organism object, whose gene pair for each gene name are taken as one gene randomly selected from each parent

__cmp__(self, other)
(Comparison operator)

Convenience method which invokes duel

Allows lists of organisms to be sorted

__repr__(self)
(Representation operator)

Delivers a minimal string representation of this organism.

Override if needed
Overrides:
__builtin__.object.__repr__

duel(self, opponent)

Duels this organism against an opponent

Returns -1 if this organism loses, 0 if it's a tie, or 1 if this organism wins

dump(self)

Produce a detailed human-readable report on this organism and its structure

fitness(self)

Return the fitness level of this organism, as a float

Should return a number from 0.0 to infinity, where 0.0 means 'perfect'

Organisms should evolve such that 'fitness' converges to zero.

This method must be overridden

mate(self, partner)

Mates this organism with another organism to produce an entirely new organism

Override this in subclasses

mutate(self)

Implement the mutation phase

Must be overridden

xmlDumpAttribs(self, elem)

Dump out the custom attributes of this organism

elem is an xml.dom.minidom.element object
Overrides:
pygene.xmlio.PGXmlMixin.xmlDumpAttribs

xmlDumpSelf(self, doc, parent)

Dumps out this object's contents into an xml tree

Arguments:
  • doc - an xml.dom.minidom.Document object
  • parent - an xml.dom.minidom.Element parent, being the node into which this node should be placed
Overrides:
pygene.xmlio.PGXmlMixin.xmlDumpSelf

Generated by Epydoc 2.1 on Mon Dec 12 14:37:12 2005 http://epydoc.sf.net