Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
test_GASelection.RouletteWheelSelectionTest Class Reference

List of all members.

Public Member Functions

def setUp
def test_select_best
def test_selection

Public Attributes

 selector

Detailed Description

Test selection using a roulette wheel selection scheme.

Definition at line 162 of file test_GASelection.py.


Member Function Documentation

Definition at line 165 of file test_GASelection.py.

Ensure selection of a best organism in a population of 2.

Definition at line 169 of file test_GASelection.py.

00169 
00170     def test_select_best(self):
00171         """Ensure selection of a best organism in a population of 2.
00172         """
00173         worst_genome = MutableSeq("0", TestAlphabet())
00174         worst_org = Organism(worst_genome, test_fitness)
00175 
00176         better_genome = MutableSeq("1", TestAlphabet())
00177         better_org = Organism(better_genome, test_fitness)
00178 
00179         new_pop = self.selector.select([worst_org, better_org])
00180         for org in new_pop:
00181             self.assertEqual(org, better_org,
00182                              "Worse organism unexpectly selected.")

Test basic selection on a small population.

Definition at line 183 of file test_GASelection.py.

00183 
00184     def test_selection(self):
00185         """Test basic selection on a small population.
00186         """
00187         pop = [random_organism() for org_num in range(50)]
00188         new_pop = self.selector.select(pop)
00189 
00190         self.assertEqual(len(new_pop), len(pop),
00191                          "Did not maintain population size.")
00192 
        

Here is the call graph for this function:


Member Data Documentation

Definition at line 166 of file test_GASelection.py.


The documentation for this class was generated from the following file: