-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvis.py
34 lines (23 loc) · 802 Bytes
/
vis.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
import sys
import matplotlib.pyplot as plt
from optimisation.utils.utils import input_parse, get_function, get_algorithm
from optimisation.visualisation import Plotter
from optimisation.functions import Function
X_SHAPE = 2
X_MIN = -5
X_MAX = 5
function_name, algorithm_name = input_parse(sys.argv)
f = get_function(function_name)
f = Function(X_MIN, X_MAX, X_SHAPE, f)
f.make_data()
f.find_min()
algo = get_algorithm(algorithm_name)
algo = algo(f)
plotter = Plotter(f.x, f.y)
fig_surf = plotter.surface()
fig_surf.savefig(f'imgs/{function_name}_3d_plot.png')
fig_cont, sc, sc2 = plotter.countour()
anim = plotter.countour_animation(fig_cont, plotter.contour_update, algo)
plt.show()
# Save the animation
# anim.save(f'gif/{function_name}_{algorithm_name}.gif', writer='imagemagick', fps=1)