Package pyvision :: Package optimize :: Module genetic
[hide private]
[frames] | no frames]

Module genetic

source code

This module contains a basic framework for a genetic algorithm. This specific implentation specifically keeps high selective pressure on the population by always keeping the best individuals found. The algorithm checks to make sure that no individual is tested twice.

Chromozomes are constructed from "Variable" classes that govern rondom generation and recombination of each element in the chromozome. For example if your fitness function requires a number from one to ten you could uses a ChoiceVariable with choices = [1,2,3,4,5,6,7,8,9,10].

TODO: Add a tutorial.

This class also has some examples in the unit tests.

Classes [hide private]
  GAVariable
This is a superclass for a variable that is optimized by the GA.
  GAFloat
  GALogFloat
A float on a log scale.
  GAAngle
Maps to an angle in the range -pi to pi.
  GAUnitRect
  GAUnitRect2
  GAInteger
  GABoolean
  GAChoice
  GARanking
  GAUnitVector
A vector constrained to length 1.0.
  GAWeighting
A positive vector that sums to 1.0.
  GASequence
  GASet
  GeneticAlgorithm
Functions [hide private]
 
_clipRange(val, minval, maxval) source code
 
_circularRange(val, minval, maxval) source code
 
list_generate(args) source code
 
dict_generate(args) source code
 
_gaWork(data)
This is a work function that gets called on child processes to evaluate a fitness function.
source code
Variables [hide private]
  _GA_EVALUATE = 'GA_EVALUATE'
  _GA_STOP_WORKER = 'GA_STOP_WORKER'
  _GA_SCORE = 'GA_SCORE'
  __package__ = 'pyvision.optimize'