*ARCHIVED* development moved to aircraft-studio.
1
# This file is part of Marius Peter's airfoil analysis package (this program).
2
#
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program. If not, see <https://www.gnu.org/licenses/>.
15
"""
16
The generator. module contains a single Population class,
17
which represents a collection of randomized airfoils.
18
"""
19
20
from tools import creator
21
22
23
defdefault_airfoil():
24
"""Generate the default airfoil."""
25
airfoil = creator..(100,200)
26
airfoil.(2412)
27
airfoil.(10)
28
29
airfoil. = creator.()
30
airfoil..(,0.23)
31
airfoil..(,0.57)
32
airfoil..(0.3)
33
airfoil..(10)
34
airfoil..(0.4)
35
36
airfoil. = creator.()
37
airfoil..(,3,6,5,4)
38
airfoil..(0.1)
39
airfoil..(5)
40
airfoil..(0.1)
41
42
return airfoil
43
44
45
classPopulation(creator.Airfoil):
46
"""Collection of random airfoils."""
47
48
def__init__(self,size):
49
af = creator.
50
# print(af)
51
self. = size
52
self. = 0 # incremented for every generation
53
54
defmutate(self,prob_mt):
55
"""Randomly mutate the genes of prob_mt % of the population."""
56
57
defcrossover(self,prob_cx):
58
"""Combine the genes of prob_cx % of the population."""
59
60
defreproduce(self,prob_rp):
61
"""Pass on the genes of the fittest prob_rp % of the population."""
62
63
deffitness():
64
"""Rate the fitness of an individual on a relative (0-100)"""
65