Table of Contents

Class: TournamentSelection Bio/GA/Selection/Tournament.py

Implement tournament style selection.

Base Classes   
AbstractSelection
Methods   
__init__
_fitness_cmp
select
  __init__ 
__init__ (
        self,
        mutator,
        crossover,
        repairer,
        num_competitors=2,
        )

Initialize the tournament selector.

Arguments:

  • num_competitors-- The number of individiuals that should be involved in a selection round. By default we just have two individuals (head to head!).

See AbstractSelection for a description of the arguments to the initializer.

Exceptions   
ValueError( "Must have at least 2 competitors!" )
  _fitness_cmp 
_fitness_cmp (
        self,
        org_1,
        org_2,
        )

Comparison function for comparing two organisms.

This just allows us to easily sort organisms by fitness.

  select 
select ( self,  population )

Perform selection on the population using the Tournament model.

Arguments:

  • population -- A population of organisms on which we will perform selection. The individuals are assumed to have fitness values which are due to their current genome (ie. the fitness is up to date).


Table of Contents

This document was automatically generated on Mon Jul 1 12:03:10 2002 by HappyDoc version 2.0.1