summaryrefslogtreecommitdiff
path: root/generator.py
blob: 30fc039944119d3159e32cd601aa59c5e06861b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
The generator.py module contains classes describing genetic populations
and methods to generate default aircraft.
"""

import random
import concurrent.futures

import creator


def default_aircraft(evaluator):
    """Generate a default aircraft with a random name."""
    name = 'default_aircraft_' + str(random.randrange(1000, 9999))
    aircraft = creator.base.Aircraft(evaluator, name)
    airfoil = creator.wing.Airfoil(aircraft, 'default_airfoil')
    airfoil.add_naca(2412)
    soar1 = creator.wing.Spar(airfoil, 'default_spar_1', 0.30)
    soar2 = creator.wing.Spar(airfoil, 'default_spar_2', 0.60)
    stringer = creator.wing.Stringer(airfoil, 'default_stringer')
    return aircraft


def default_fuselage():
    pass


def default_propulsion():
    pass


class Population():
    """Collection of random airfoils."""
    def __init__(self, size):
        af = creator.Airfoil
        # print(af)
        self.size = size
        self.gen_number = 0  # incremented for every generation

    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)"""
Copyright 2019--2024 Marius PETER