diff options
Diffstat (limited to 'aircraftstudio/generator')
-rw-r--r-- | aircraftstudio/generator/__init__.py | 1 | ||||
-rw-r--r-- | aircraftstudio/generator/generator.py | 43 |
2 files changed, 44 insertions, 0 deletions
diff --git a/aircraftstudio/generator/__init__.py b/aircraftstudio/generator/__init__.py new file mode 100644 index 0000000..4f233cb --- /dev/null +++ b/aircraftstudio/generator/__init__.py @@ -0,0 +1 @@ +from .generator import * diff --git a/aircraftstudio/generator/generator.py b/aircraftstudio/generator/generator.py new file mode 100644 index 0000000..898683a --- /dev/null +++ b/aircraftstudio/generator/generator.py @@ -0,0 +1,43 @@ +""" +The generator.py module contains classes describing genetic populations +and methods to generate default aircraft. +""" + +from aircraftstudio import creator + + +def default_fuselage(): + pass + + +def default_propulsion(): + pass + + +class Population(): + """Represents a collection of aircraft.""" + def __init__(self, size): + self.aircrafts = [] + for _ in range(size): + self.aircrafts.append(creator.base.Aircraft.from_random()) + self.size = size + self.results = None + self.gen_number = 0 # incremented for every generation + + #TODO class methods for default and random population + # def from_default(self, size): + # for i in range(size): + # self.aircrafts.append(creator.base.Aircraft.from_default()) + + # def from_random(self, size): + # for i in range(size): + # self.aircrafts.append(creator.base.Aircraft.from_random()) + + def mutate(self, prob_mt): + """Randomly mutate the genes of prob_mt % of the population.""" + def crossover(self, prob_cx): + """Combine the genes of prob_cx % of the population.""" + def reproduce(self, prob_rp): + """Pass on the genes of the fittest prob_rp % of the population.""" + def fitness(): + """Rate the fitness of an individual on a relative scale (0-100)""" |