-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
40 lines (32 loc) · 1.13 KB
/
main.py
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
import random
from config import Config
from state import State
from treeFactory import TreeFactory
from evolution import Evolution
from fitness import Fitness
from heuristic import Heuristic
import timeit
class TinyGPGenerator:
def __init__(self):
self.config = Config()
self.state = State(self.config)
self.heuristic = Heuristic()
self.fitness = Fitness(self.heuristic, self.config)
self.tree_factory = TreeFactory(self.state, self.fitness, self.config)
self.evolution = Evolution(self.state, self.fitness, self.config)
def run(self):
self.config.assert_probabilities()
# timeit
start_time = timeit.default_timer()
self.tree_factory.generate_population()
end_time = timeit.default_timer()
print(f"Time to generate population: {end_time - start_time}")
v = self.evolution.evolve()
self.end(v)
def end(self, v):
print('PROBLEM NOT SOLVED') if v != 1 else print('PROBLEM SOLVED')
print('END')
pass
if __name__ == "__main__":
generator = TinyGPGenerator()
generator.run()