diff --git a/examples/ex01/ex01.py b/examples/ex01/ex01.py index db4cb50..bda4f37 100644 --- a/examples/ex01/ex01.py +++ b/examples/ex01/ex01.py @@ -9,7 +9,7 @@ from gaft import GAEngine from gaft.components import BinaryIndividual -from gaft.components import GAPopulation +from gaft.components import Population from gaft.operators import TournamentSelection from gaft.operators import UniformCrossover from gaft.operators import FlipBitMutation @@ -22,7 +22,7 @@ # Define population. indv_template = BinaryIndividual(ranges=[(0, 10)], eps=0.001) -population = GAPopulation(indv_template=indv_template, size=50).init() +population = Population(indv_template=indv_template, size=50).init() # Create genetic operators. selection = TournamentSelection() diff --git a/examples/ex02/ex02.py b/examples/ex02/ex02.py index b27038a..bd31b62 100644 --- a/examples/ex02/ex02.py +++ b/examples/ex02/ex02.py @@ -9,7 +9,7 @@ from gaft import GAEngine from gaft.components import BinaryIndividual -from gaft.components import GAPopulation +from gaft.components import Population from gaft.operators import TournamentSelection from gaft.operators import UniformCrossover from gaft.operators import FlipBitBigMutation @@ -20,7 +20,7 @@ # Define population. indv_template = BinaryIndividual(ranges=[(-2, 2), (-2, 2)], eps=0.001) -population = GAPopulation(indv_template=indv_template, size=50).init() +population = Population(indv_template=indv_template, size=50).init() # Create genetic operators. #selection = RouletteWheelSelection() diff --git a/gaft/components/__init__.py b/gaft/components/__init__.py index ab5d4bf..239af42 100644 --- a/gaft/components/__init__.py +++ b/gaft/components/__init__.py @@ -1,4 +1,4 @@ from .individual import IndividualBase from .binary_individual import BinaryIndividual -from .population import GAPopulation +from .population import Population diff --git a/gaft/components/population.py b/gaft/components/population.py index 3ebbabd..50d84a2 100644 --- a/gaft/components/population.py +++ b/gaft/components/population.py @@ -33,7 +33,7 @@ def __call__(self, fitness): return self.result -class GAIndividuals(object): +class Individuals(object): ''' Descriptor for all individuals in population. ''' @@ -49,10 +49,10 @@ def __set__(self, instance, value): instance.update_flag() -class GAPopulation(object): +class Population(object): # All individuals. - individuals = GAIndividuals('individuals') + individuals = Individuals('individuals') def __init__(self, indv_template, size=100): ''' diff --git a/gaft/engine.py b/gaft/engine.py index 89595bc..950520e 100644 --- a/gaft/engine.py +++ b/gaft/engine.py @@ -12,7 +12,7 @@ import pstats import os -from .components import IndividualBase, GAPopulation +from .components import IndividualBase, Population from .plugin_interfaces.operators import GASelection, GACrossover, GAMutation from .plugin_interfaces.analysis import OnTheFlyAnalysis from .mpiutil import mpi @@ -106,7 +106,7 @@ def __init__(self, population, selection, crossover, mutation, the engine object unites these informations and provide means for running a genetic algorthm optimization. - :param population: The GAPopulation to be reproduced in evolution iteration. + :param population: The Population to be reproduced in evolution iteration. :param selection: The GASelection to be used for individual seleciton. :param crossover: The GACrossover to be used for individual crossover. :param mutation: The GAMutation to be used for individual mutation. @@ -231,8 +231,8 @@ def _check_parameters(self): ''' Helper function to check parameters of engine. ''' - if not isinstance(self.population, GAPopulation): - raise TypeError('population must be a GAPopulation object') + if not isinstance(self.population, Population): + raise TypeError('population must be a Population object') if not isinstance(self.selection, GASelection): raise TypeError('selection operator must be a GASelection instance') if not isinstance(self.crossover, GACrossover): diff --git a/gaft/plugin_interfaces/analysis.py b/gaft/plugin_interfaces/analysis.py index a032cb9..65dd408 100644 --- a/gaft/plugin_interfaces/analysis.py +++ b/gaft/plugin_interfaces/analysis.py @@ -36,7 +36,7 @@ def register_step(self, g, population, engine): :type g: int :param population: The up to date population of the iteration. - :type population: GAPopulation + :type population: Population :param engine: The current GAEngine where the analysis is running. :type engine: GAEngine @@ -49,7 +49,7 @@ def finalize(self, population, engine): post-processing of the collected data. :param population: The up to date population of the iteration. - :type population: GAPopulation + :type population: Population :param engine: The current GAEngine where the analysis is running. :type engine: GAEngine diff --git a/gaft/plugin_interfaces/metaclasses.py b/gaft/plugin_interfaces/metaclasses.py index 645f878..612b0a5 100644 --- a/gaft/plugin_interfaces/metaclasses.py +++ b/gaft/plugin_interfaces/metaclasses.py @@ -6,7 +6,7 @@ from functools import wraps from ..components.individual import IndividualBase -from ..components.population import GAPopulation +from ..components.population import Population from ..mpiutil import master_only @@ -153,8 +153,8 @@ def _wrapped_select(self, population, fitness): ''' Wrapper to add parameters type checking. ''' # Check parameter types. - if not isinstance(population, GAPopulation): - raise TypeError('population must be GAPopulation object') + if not isinstance(population, Population): + raise TypeError('population must be Population object') if not callable(fitness): raise TypeError('fitness must be a callable object') diff --git a/tests/dynamic_linear_scaling_test.py b/tests/dynamic_linear_scaling_test.py index ed5281c..1787adc 100644 --- a/tests/dynamic_linear_scaling_test.py +++ b/tests/dynamic_linear_scaling_test.py @@ -9,7 +9,7 @@ from gaft import GAEngine from gaft.components import BinaryIndividual -from gaft.components import GAPopulation +from gaft.components import Population from gaft.operators import RouletteWheelSelection from gaft.operators import UniformCrossover from gaft.operators import FlipBitMutation @@ -25,7 +25,7 @@ def test_run(self): Make sure GA engine can run correctly. ''' indv_template = BinaryIndividual(ranges=[(0, 10)], eps=0.001, verbosity=0) - population = GAPopulation(indv_template=indv_template, size=50).init() + population = Population(indv_template=indv_template, size=50).init() # Create genetic operators. selection = RouletteWheelSelection() diff --git a/tests/engine_test.py b/tests/engine_test.py index 98c2274..aa888b5 100644 --- a/tests/engine_test.py +++ b/tests/engine_test.py @@ -9,7 +9,7 @@ from gaft import GAEngine from gaft.components import BinaryIndividual -from gaft.components import GAPopulation +from gaft.components import Population from gaft.operators import RouletteWheelSelection from gaft.operators import UniformCrossover from gaft.operators import FlipBitMutation @@ -25,7 +25,7 @@ def test_run(self): Make sure GA engine can run correctly. ''' indv_template = BinaryIndividual(ranges=[(0, 10)], eps=0.001, verbosity=0) - population = GAPopulation(indv_template=indv_template, size=50).init() + population = Population(indv_template=indv_template, size=50).init() # Create genetic operators. selection = RouletteWheelSelection() diff --git a/tests/exponential_ranking_selection_test.py b/tests/exponential_ranking_selection_test.py index e4e8a8b..4014ec0 100644 --- a/tests/exponential_ranking_selection_test.py +++ b/tests/exponential_ranking_selection_test.py @@ -6,7 +6,7 @@ import unittest -from gaft.components import GAPopulation, BinaryIndividual +from gaft.components import Population, BinaryIndividual from gaft.operators import ExponentialRankingSelection class ExponentialRankingSelectionTest(unittest.TestCase): @@ -20,7 +20,7 @@ def fitness(indv): def test_selection(self): indv = BinaryIndividual(ranges=[(0, 30)], verbosity=0) - p = GAPopulation(indv) + p = Population(indv) p.init() selection = ExponentialRankingSelection() diff --git a/tests/flip_bit_big_mutation_test.py b/tests/flip_bit_big_mutation_test.py index d034162..d961602 100644 --- a/tests/flip_bit_big_mutation_test.py +++ b/tests/flip_bit_big_mutation_test.py @@ -9,7 +9,7 @@ from gaft import GAEngine from gaft.components import BinaryIndividual -from gaft.components import GAPopulation +from gaft.components import Population from gaft.operators import RouletteWheelSelection from gaft.operators import UniformCrossover from gaft.operators.mutation.flip_bit_mutation import FlipBitBigMutation @@ -23,7 +23,7 @@ def test_mutate(self): ''' Make sure the individual can be mutated correctly. ''' indv_template = BinaryIndividual(ranges=[(0, 10)], eps=0.001, verbosity=0) - population = GAPopulation(indv_template=indv_template, size=50).init() + population = Population(indv_template=indv_template, size=50).init() # Create genetic operators. selection = RouletteWheelSelection() diff --git a/tests/linear_ranking_selection_test.py b/tests/linear_ranking_selection_test.py index b109045..d8fbbb2 100644 --- a/tests/linear_ranking_selection_test.py +++ b/tests/linear_ranking_selection_test.py @@ -6,7 +6,7 @@ import unittest -from gaft.components import GAPopulation, BinaryIndividual +from gaft.components import Population, BinaryIndividual from gaft.operators import LinearRankingSelection class LinearRankingSelectionTest(unittest.TestCase): @@ -20,7 +20,7 @@ def fitness(indv): def test_selection(self): indv = BinaryIndividual(ranges=[(0, 30)], verbosity=0) - p = GAPopulation(indv) + p = Population(indv) p.init() selection = LinearRankingSelection() diff --git a/tests/linear_scaling_test.py b/tests/linear_scaling_test.py index 85c2ed5..a6524be 100644 --- a/tests/linear_scaling_test.py +++ b/tests/linear_scaling_test.py @@ -9,7 +9,7 @@ from gaft import GAEngine from gaft.components import BinaryIndividual -from gaft.components import GAPopulation +from gaft.components import Population from gaft.operators import RouletteWheelSelection from gaft.operators import UniformCrossover from gaft.operators import FlipBitMutation @@ -25,7 +25,7 @@ def test_run(self): Make sure GA engine can run correctly. ''' indv_template = BinaryIndividual(ranges=[(0, 10)], eps=0.001, verbosity=0) - population = GAPopulation(indv_template=indv_template, size=50).init() + population = Population(indv_template=indv_template, size=50).init() # Create genetic operators. selection = RouletteWheelSelection() diff --git a/tests/population_test.py b/tests/population_test.py index 68126cc..895ae4d 100644 --- a/tests/population_test.py +++ b/tests/population_test.py @@ -1,12 +1,12 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -''' Test case for GAPopulation +''' Test case for Population ''' import unittest -from gaft.components import GAPopulation, BinaryIndividual +from gaft.components import Population, BinaryIndividual class PopulationTest(unittest.TestCase): @@ -20,7 +20,7 @@ def fitness(indv): def test_initialization(self): ''' Make sure a population can be initialized correctly. ''' - population = GAPopulation(indv_template=self.indv_template, size=10) + population = Population(indv_template=self.indv_template, size=10) self.assertListEqual(population.individuals, []) @@ -32,14 +32,14 @@ def test_initialization(self): def test_new_population(self): ''' Make sure population can clone a new population. ''' - population = GAPopulation(indv_template=self.indv_template, size=10) + population = Population(indv_template=self.indv_template, size=10) population.init() new_population = population.new() self.assertEqual(new_population.size, 10) self.assertListEqual(new_population.individuals, []) def test_all_fits(self): - population = GAPopulation(indv_template=self.indv_template, size=10) + population = Population(indv_template=self.indv_template, size=10) population.init() all_fits = population.all_fits(fitness=self.fitness) diff --git a/tests/roulette_wheel_selection_test.py b/tests/roulette_wheel_selection_test.py index abb05fb..a5b5ec8 100644 --- a/tests/roulette_wheel_selection_test.py +++ b/tests/roulette_wheel_selection_test.py @@ -6,7 +6,7 @@ import unittest -from gaft.components import GAPopulation, BinaryIndividual +from gaft.components import Population, BinaryIndividual from gaft.operators.selection.roulette_wheel_selection import RouletteWheelSelection class RouletteWheelSelectionTest(unittest.TestCase): @@ -20,7 +20,7 @@ def fitness(indv): def test_selection(self): indv = BinaryIndividual(ranges=[(0, 30)], verbosity=0) - p = GAPopulation(indv) + p = Population(indv) p.init() selection = RouletteWheelSelection() diff --git a/tests/tournament_selection_test.py b/tests/tournament_selection_test.py index 3d0ba7b..fb61a5f 100644 --- a/tests/tournament_selection_test.py +++ b/tests/tournament_selection_test.py @@ -6,7 +6,7 @@ import unittest -from gaft.components import GAPopulation, BinaryIndividual +from gaft.components import Population, BinaryIndividual from gaft.operators import TournamentSelection class TournamentSelectionTest(unittest.TestCase): @@ -20,7 +20,7 @@ def fitness(indv): def test_selection(self): indv = BinaryIndividual(ranges=[(0, 30)], verbosity=0) - p = GAPopulation(indv) + p = Population(indv) p.init() selection = TournamentSelection()