[Python] Design & build airplanes from your specifications.
1
"""
2
The generator. module contains classes describing genetic populations
3
and methods to generate default aircraft.
4
"""
5
6
from aircraftstudio import creator
7
8
9
defdefault_fuselage():
10
pass
11
12
13
defdefault_propulsion():
14
pass
15
16
17
classPopulation():
18
"""Represents a collection of aircraft."""
19
def__init__(self,size):
20
self. = []
21
for _ in range():
22
self..(...())
23
self. = size
24
self. = None
25
self. = 0 # incremented for every generation
26
27
#TODO class methods for default and random population
28
# def from_default(self, size):
29
# for i in range(size):
30
# self.aircrafts.append(creator.base.Aircraft.from_default())
31
32
# def from_random(self, size):
33
# for i in range(size):
34
# self.aircrafts.append(creator.base.Aircraft.from_random())
35
36
defmutate(self,prob_mt):
37
"""Randomly mutate the genes of prob_mt % of the population."""
38
defcrossover(self,prob_cx):
39
"""Combine the genes of prob_cx % of the population."""
40
defreproduce(self,prob_rp):
41
"""Pass on the genes of the fittest prob_rp % of the population."""
42
deffitness():
43
"""Rate the fitness of an individual on a relative (0-100)"""
44