-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulation.py
28 lines (17 loc) · 866 Bytes
/
simulation.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
from evolutionary import evolutionary, evolutionary_for_plots, evolutionary_plot_all
from time_evolutionary import measure_time
from utils.functions import bird, rosenbrock, shubert
from utils.utilities import generate_population, split_coordinates, result_message
from utils.plotter import Plot2D, Plot3D
def main():
fitness_function = bird
my_plot = Plot3D()
my_plot.create(fitness_function, 10)
population = generate_population(2, 10, 10)
iteration_best, best_individual, best_fitness = evolutionary_for_plots(fitness_function, population, 10, 0.3, 0.25, 100)
print(f'Found best individual: {best_individual}\nwith fitness: {best_fitness}')
x_coords, y_coords, z_coords = split_coordinates(iteration_best)
my_plot.add_points(x_coords, y_coords, z_coords, 'red', 2)
my_plot.show()
if __name__=="__main__":
main()