- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
Latest commit
57 lines (44 loc) · 1.77 KB
/
Copy pathMain.py
File metadata and controls
57 lines (44 loc) · 1.77 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 25 09:18:22 2016
@author: Russ.Clay
"""
fromSimulationimportSimulation
fromExportimportExport
importos
importcsv
# declare the number of simulations to run and the number to assign to the first
# simulation log file (files will increment sequentially from the first number)
numSims=1
startNumber=0
simLog= []
# define the format of the output file for summary information from each simulation run
defwriteSimLog(simLog, startNumber):
popStatVals= ["SimNumber", "StartPopSize", "InitialConnections", "PosVal", "AvoidVal", "SickVal", "SickTime",
"DisTransRate", "ImmuneProb", "NumDied", "NumImmune"]
os.chdir('C:/Users/russ.clay/Desktop/Simulations/Agent/Exports')
withopen('simulationLogData.csv', 'wb') ascsvfile:
datawriter=csv.writer(csvfile, delimiter=',',
quotechar='|', quoting=csv.QUOTE_MINIMAL)
datawriter.writerow(popStatVals)
foriinsimLog:
runVals=i.getRunVals()
newRow=[]
newRow.append(startNumber)
forjinrunVals:
newRow.append(j)
datawriter.writerow(newRow)
startNumber+=1
# --------------------------------------------------------
# main code body
# create a new simulation, run it, and create all necessary output files for each simulation run
foriinrange(startNumber, numSims+startNumber):
newSim=Simulation(i)
newSim.preSimSetup()
simLog.append(newSim.runSim())
newExport=Export(newSim)
newExport.writeTimeLog(i)
newExport.writeFinalPopulation(i)
print('Finished Simulation '+str(i))
#write the summary file for all simulation runs
writeSimLog(simLog, startNumber)