-
Notifications
You must be signed in to change notification settings - Fork 1
/
SumUp-Temperature-VarNAgentsUp.py
40 lines (35 loc) · 1.55 KB
/
SumUp-Temperature-VarNAgentsUp.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
# coding: utf-8
# Imports
from __future__ import division
import numpy as np
# Control variables
# temperatures = np.linspace(0.23, 0.27, 41, endpoint=True) # List of temperatures to simulate
# temperatures = [0.5]
# temperatures = np.linspace(0.1, 0.22, 13, endpoint=True) # List of temperatures to simulate
temperatures = np.linspace(0.28, 0.9, 63, endpoint=True) # List of temperatures to simulate
# Reading model results from file
avNAgentsUp = []
varNAgentsUp = []
for temperature in temperatures:
sumNAgentsUp = 0.0
sumNAgentsUp2 = 0.0
n = 0
with open("./Results/nAgentsUp-T{:.4f}.csv".format(temperature), 'r') as f:
for line in f:
for element in line.split(","):
sumNAgentsUp += int(element)
sumNAgentsUp2 += int(element) ** 2
n += 1
if 0.23 <= temperature < 0.2350:
with open("./Results/nAgentsUpB-T{:.4f}.csv".format(temperature), 'r') as f:
for line in f:
for element in line.split(","):
sumNAgentsUp += int(element)
sumNAgentsUp2 += int(element) ** 2
n += 1
avNAgentsUp.append(sumNAgentsUp/n)
varNAgentsUp.append(sumNAgentsUp2/n - (sumNAgentsUp/n)**2)
# Write summary results to file
with open("./Results/Summary-Temperature-VarNAgentsUp-FINALEXTRAPOINTS.csv", "w") as f:
for temperature, avNAgentsUp_element, varNAgentsUp_element in zip(temperatures, avNAgentsUp, varNAgentsUp):
f.write("{}, {}, {}\n".format(temperature, avNAgentsUp_element, varNAgentsUp_element))