-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_data.py
38 lines (32 loc) · 1.32 KB
/
read_data.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
import os
import statistics
def read_data(q_name, pop_f_name, dims):
dirname = os.path.dirname(__file__)
filename = f"data/{q_name}_{pop_f_name}_{dims}.txt"
path_to_file = os.path.join(dirname, filename)
values = []
cords = []
with open(path_to_file, "r") as f:
for line in f.readlines():
line = line.strip("\n")
line = line.split("\t")
values.append(float(line[0]))
cords.append(eval(line[1]))
min_value = round(min(values), 3)
mean = round(statistics.mean(values), 3)
std_dev = round(statistics.stdev(values), 3)
return min_value, mean, std_dev
q_name = "ackley"
dimensions = 2
# pop_f_name = "linear_increase"
# pop_f_name = "linear_decrease"
# pop_f_name = "exponential_increase"
# pop_f_name = "exponential_decrease"
# pop_f_name = "sin_wave_change"
# pop_f_name = "rect_wave_change"
pop_f_names = ["linear_increase", "linear_decrease", "exponential_increase", "exponential_decrease", "sin_wave_change", "rect_wave_change", "rect_wave_change_on_stagnation", "const"]
for pop_name in pop_f_names:
print(pop_name + " = \t" + str(read_data(q_name, pop_name, dimensions)))
# print(read_data(q_name, pop_f_name, dimensions))
# wartosc minimalna, wartosc srednia, odchylenie standardowe
# wstawic do tabeli