Initial commit
This commit is contained in:
commit
66a6860316
407 changed files with 1254365 additions and 0 deletions
248
models/seq_activity_firespread/model.py
Normal file
248
models/seq_activity_firespread/model.py
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
import sys
|
||||
sys.path.append('../../src/')
|
||||
|
||||
from infinity import *
|
||||
from DEVS import AtomicDEVS, CoupledDEVS
|
||||
from math import exp
|
||||
|
||||
T_AMBIENT = 27.0
|
||||
T_IGNITE = 300.0
|
||||
T_GENERATE = 500.0
|
||||
T_BURNED = 60.0
|
||||
TIMESTEP = 0.01
|
||||
PH_INACTIVE = 'inactive'
|
||||
PH_UNBURNED = 'unburned'
|
||||
PH_BURNING = 'burning'
|
||||
PH_BURNED = 'burned'
|
||||
RADIUS = 3
|
||||
TMP_DIFF = 1.0
|
||||
|
||||
#########################################
|
||||
## Map layout
|
||||
#########################################
|
||||
## x_max = 6, y_max = 6
|
||||
#########################################
|
||||
## 0 1 2 3 4 5 6
|
||||
## 0
|
||||
## 1
|
||||
## 2
|
||||
## 3
|
||||
## 4
|
||||
## 5
|
||||
## 6
|
||||
#########################################
|
||||
#########################################
|
||||
|
||||
def getPhaseFor(temp, phase):
|
||||
if temp > T_IGNITE or (temp > T_BURNED and phase == PH_BURNING):
|
||||
return PH_BURNING
|
||||
elif temp < T_BURNED and phase == PH_BURNING:
|
||||
return PH_BURNED
|
||||
else:
|
||||
return PH_UNBURNED
|
||||
|
||||
class CellState(object):
|
||||
# Simply here for future necessity
|
||||
def __init__(self, temp):
|
||||
self.temperature = temp
|
||||
self.igniteTime = float('inf')
|
||||
self.currentTime = 0.0
|
||||
self.phase = PH_INACTIVE
|
||||
self.surroundingTemps = [T_AMBIENT] * 4
|
||||
self.oldTemperature = temp
|
||||
|
||||
def __str__(self):
|
||||
return "%s (T: %f)" % (self.phase, self.temperature)
|
||||
|
||||
def copy(self):
|
||||
a = CellState(self.temperature)
|
||||
a.igniteTime = self.igniteTime
|
||||
a.currentTime = self.currentTime
|
||||
a.phase = self.phase
|
||||
a.surroundingTemps = list(self.surroundingTemps)
|
||||
a.oldTemperature = self.oldTemperature
|
||||
return a
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.temperature == other.temperature and self.igniteTime == other.igniteTime and self.currentTime == other.currentTime and self.phase == other.phase and self.surroundingTemps == other.surroundingTemps and self.oldTemperature == other.oldTemperature
|
||||
|
||||
def toCellState(self):
|
||||
return self.temperature
|
||||
|
||||
class Cell(AtomicDEVS):
|
||||
def __init__(self, x, y, x_max, y_max):
|
||||
AtomicDEVS.__init__(self, "Cell(%d, %d)" % (x, y))
|
||||
|
||||
self.state = CellState(T_AMBIENT)
|
||||
|
||||
# For Cell DEVS tracing
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
self.inports = [self.addInPort("in_N"), self.addInPort("in_E"), self.addInPort("in_S"), self.addInPort("in_W"), self.addInPort("in_G")]
|
||||
self.outport = self.addOutPort("out_T")
|
||||
|
||||
self.taMap = {PH_INACTIVE: INFINITY, PH_UNBURNED: 1.0, PH_BURNING: 1.0, PH_BURNED: INFINITY}
|
||||
|
||||
def preActivityCalculation(self):
|
||||
return None
|
||||
|
||||
def postActivityCalculation(self, _):
|
||||
return self.state.temperature - T_AMBIENT
|
||||
|
||||
def intTransition(self):
|
||||
#for _ in range(4100):
|
||||
# pass
|
||||
# First check for the surrounding cells and whether we are on a border or not
|
||||
self.state.currentTime += self.timeAdvance()
|
||||
# OK, now we have a complete list
|
||||
if abs(self.state.temperature - self.state.oldTemperature) > TMP_DIFF:
|
||||
self.state.oldTemperature = self.state.temperature
|
||||
|
||||
if self.state.phase == PH_BURNED:
|
||||
# Don't do anything as we are already finished
|
||||
return self.state
|
||||
elif self.state.phase == PH_BURNING:
|
||||
newTemp = 0.98689 * self.state.temperature + 0.0031 * (sum(self.state.surroundingTemps)) + 2.74 * exp(-0.19 * (self.state.currentTime * TIMESTEP - self.state.igniteTime)) + 0.213
|
||||
elif self.state.phase == PH_UNBURNED:
|
||||
newTemp = 0.98689 * self.state.temperature + 0.0031 * (sum(self.state.surroundingTemps)) + 0.213
|
||||
|
||||
newPhase = getPhaseFor(newTemp, self.state.phase)
|
||||
if newPhase == PH_BURNED:
|
||||
newTemp = T_AMBIENT
|
||||
if self.state.phase == PH_UNBURNED and newPhase == PH_BURNING:
|
||||
self.state.igniteTime = self.state.currentTime * TIMESTEP
|
||||
|
||||
self.state.phase = newPhase
|
||||
self.state.temperature = newTemp
|
||||
return self.state
|
||||
|
||||
def extTransition(self, inputs):
|
||||
# NOTE we can make the assumption that ALL temperatures are received simultaneously, due to Parallel DEVS being used
|
||||
self.state.currentTime += self.elapsed
|
||||
if self.inports[-1] in inputs:
|
||||
# A temperature from the generator, so simply set our own temperature
|
||||
self.state.temperature = inputs[self.inports[-1]][0]
|
||||
self.state.phase = getPhaseFor(self.state.temperature, self.state.phase)
|
||||
if self.state.phase == PH_BURNING:
|
||||
self.state.igniteTime = self.state.currentTime * TIMESTEP
|
||||
else:
|
||||
for num, inport in enumerate(self.inports[:4]):
|
||||
self.state.surroundingTemps[num] = inputs.get(inport, [self.state.surroundingTemps[num]])[0]
|
||||
|
||||
if self.state.phase == PH_INACTIVE:
|
||||
self.state.phase = PH_UNBURNED
|
||||
return self.state
|
||||
|
||||
def outputFnc(self):
|
||||
if abs(self.state.temperature - self.state.oldTemperature) > TMP_DIFF:
|
||||
return {self.outport: [self.state.temperature]}
|
||||
else:
|
||||
return {}
|
||||
|
||||
def timeAdvance(self):
|
||||
return self.taMap[self.state.phase]
|
||||
|
||||
class Junk(object):
|
||||
def __init__(self):
|
||||
self.status = True
|
||||
|
||||
def __str__(self):
|
||||
return "Generator"
|
||||
|
||||
def copy(self):
|
||||
a = Junk()
|
||||
a.status = self.status
|
||||
return a
|
||||
|
||||
class Generator(AtomicDEVS):
|
||||
def __init__(self, levels):
|
||||
AtomicDEVS.__init__(self, "Generator")
|
||||
self.outports = []
|
||||
for i in range(levels):
|
||||
self.outports.append(self.addOutPort("out_" + str(i)))
|
||||
self.state = Junk()
|
||||
|
||||
def intTransition(self):
|
||||
self.state.status = False
|
||||
return self.state
|
||||
|
||||
def outputFnc(self):
|
||||
output = {}
|
||||
for i in range(len(self.outports)):
|
||||
output[self.outports[i]] = [T_AMBIENT + T_GENERATE/(2**i)]
|
||||
return output
|
||||
|
||||
def timeAdvance(self):
|
||||
if self.state.status:
|
||||
return 1.0
|
||||
else:
|
||||
return INFINITY
|
||||
|
||||
def preActivityCalculation(self):
|
||||
return None
|
||||
|
||||
def postActivityCalculation(self, _):
|
||||
return 0.0
|
||||
|
||||
class FireSpread(CoupledDEVS):
|
||||
def putGenerator(self, x, y):
|
||||
CENTER = (x, y)
|
||||
for level in range(RADIUS):
|
||||
# Left side
|
||||
y = level
|
||||
for x in range(-level, level + 1, 1):
|
||||
self.connectPorts(self.generator.outports[level], self.cells[CENTER[0] + x][CENTER[1] + y].inports[-1])
|
||||
self.connectPorts(self.generator.outports[level], self.cells[CENTER[0] + x][CENTER[1] - y].inports[-1])
|
||||
x = level
|
||||
for y in range(-level + 1, level, 1):
|
||||
self.connectPorts(self.generator.outports[level], self.cells[CENTER[0] + x][CENTER[1] + y].inports[-1])
|
||||
self.connectPorts(self.generator.outports[level], self.cells[CENTER[0] - x][CENTER[1] + y].inports[-1])
|
||||
|
||||
def __init__(self, x_max, y_max):
|
||||
CoupledDEVS.__init__(self, "FireSpread")
|
||||
|
||||
self.cells = []
|
||||
try:
|
||||
from mpi4py import MPI
|
||||
nodes = MPI.COMM_WORLD.Get_size()
|
||||
except ImportError:
|
||||
nodes = 1
|
||||
node = 0
|
||||
totalCount = x_max * y_max
|
||||
counter = 0
|
||||
for x in range(x_max):
|
||||
row = []
|
||||
for y in range(y_max):
|
||||
if nodes == 1:
|
||||
node = 0
|
||||
elif x <= x_max/2 and y < y_max/2:
|
||||
node = 0
|
||||
elif x <= x_max/2 and y > y_max/2:
|
||||
node = 1
|
||||
elif x > x_max/2 and y < y_max/2:
|
||||
node = 2
|
||||
elif x > x_max/2 and y > y_max/2:
|
||||
node = 3
|
||||
row.append(self.addSubModel(Cell(x, y, x_max, y_max), node))
|
||||
self.cells.append(row)
|
||||
counter += 1
|
||||
|
||||
# Everything is now constructed, so connect the ports now
|
||||
self.generator = self.addSubModel(Generator(RADIUS))
|
||||
#self.putGenerator(2, 2)
|
||||
#self.putGenerator(2, y_max-3)
|
||||
#self.putGenerator(x_max-3, 2)
|
||||
#self.putGenerator(x_max-3, y_max-3)
|
||||
self.putGenerator(5, 5)
|
||||
|
||||
for x in range(x_max):
|
||||
for y in range(y_max):
|
||||
if x != 0:
|
||||
self.connectPorts(self.cells[x][y].outport, self.cells[x-1][y].inports[2])
|
||||
if y != y_max - 1:
|
||||
self.connectPorts(self.cells[x][y].outport, self.cells[x][y+1].inports[1])
|
||||
if x != x_max - 1:
|
||||
self.connectPorts(self.cells[x][y].outport, self.cells[x+1][y].inports[3])
|
||||
if y != 0:
|
||||
self.connectPorts(self.cells[x][y].outport, self.cells[x][y-1].inports[0])
|
||||
13
models/seq_activity_firespread/plot
Normal file
13
models/seq_activity_firespread/plot
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
reset
|
||||
set terminal postscript enhanced colour portrait size 6,6
|
||||
set out 'seq_activity_firespread.eps'
|
||||
set title "Simulation time for firespread"
|
||||
set key top left
|
||||
set xlabel "Total number of models"
|
||||
set ylabel "Time (s)"
|
||||
#plot 'seq_activity_firespread/setSchedulerActivityHeap' title 'Activity Heap', 'seq_activity_firespread/setSchedulerHeapSet' title 'HeapSet', 'seq_activity_firespread/setSchedulerMinimalList' title 'Minimal List', 'seq_activity_firespread/setSchedulerSortedList' title 'Sorted List'
|
||||
plot 'seq_activity_firespread/setSchedulerActivityHeap' title 'Activity Heap' w l, 'seq_activity_firespread/setSchedulerHeapSet' title 'HeapSet' w l, 'seq_activity_firespread/setSchedulerMinimalList' title 'Minimal List' w l, 'seq_activity_firespread/setSchedulerSortedList' title 'Sorted List' w l
|
||||
|
||||
set xrange [0:3000]
|
||||
set out 'seq_activity_firespread_zoom.eps'
|
||||
plot 'seq_activity_firespread/setSchedulerActivityHeap' title 'Activity Heap' w l, 'seq_activity_firespread/setSchedulerHeapSet' title 'HeapSet' w l, 'seq_activity_firespread/setSchedulerMinimalList' title 'Minimal List' w l, 'seq_activity_firespread/setSchedulerSortedList' title 'Sorted List' w l
|
||||
8
models/seq_activity_firespread/plot_100
Normal file
8
models/seq_activity_firespread/plot_100
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
reset
|
||||
set terminal postscript enhanced colour portrait size 6,6
|
||||
set out 'seq_activity_firespread.eps'
|
||||
set title "Simulation time for firespread"
|
||||
set key top left
|
||||
set xlabel "Total number of models"
|
||||
set ylabel "Time (s)"
|
||||
plot 'seq_activity_firespread/setSchedulerActivityHeap' title 'Activity Heap' w l, 'seq_activity_firespread/setSchedulerHeapSet' title 'HeapSet' w l, 'seq_activity_firespread/setSchedulerMinimalList' title 'Minimal List' w l, 'seq_activity_firespread/setSchedulerSortedList' title 'Sorted List' w l
|
||||
91
models/seq_activity_firespread/setSchedulerActivityHeap
Normal file
91
models/seq_activity_firespread/setSchedulerActivityHeap
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
100 0.240222465992
|
||||
121 0.284727752209
|
||||
144 0.326584804058
|
||||
169 0.375241184235
|
||||
196 0.422246336937
|
||||
225 0.469304776192
|
||||
256 0.514549398422
|
||||
289 0.562045788765
|
||||
324 0.614278078079
|
||||
361 0.649203050137
|
||||
400 0.682233381271
|
||||
441 0.711326575279
|
||||
484 0.749686801434
|
||||
529 0.769834709167
|
||||
576 0.798548352718
|
||||
625 0.815191102028
|
||||
676 0.830131053925
|
||||
729 0.842848360538
|
||||
784 0.860375189781
|
||||
841 0.856474387646
|
||||
900 0.867112076283
|
||||
961 0.864574253559
|
||||
1024 0.877214789391
|
||||
1089 0.883920586109
|
||||
1156 0.881080901623
|
||||
1225 0.888922047615
|
||||
1296 0.898495578766
|
||||
1369 0.902493917942
|
||||
1444 0.909102451801
|
||||
1521 0.908285498619
|
||||
1600 0.901860272884
|
||||
1681 0.934172391891
|
||||
1764 0.933623802662
|
||||
1849 0.938035368919
|
||||
1936 0.927596867085
|
||||
2025 0.946350574493
|
||||
2116 0.951256036758
|
||||
2209 0.941100084782
|
||||
2304 0.971946918964
|
||||
2401 0.925834083557
|
||||
2500 0.978461039066
|
||||
2601 0.994739842415
|
||||
2704 0.995354878902
|
||||
2809 1.02566099167
|
||||
2916 1.01342103481
|
||||
3025 1.02201015949
|
||||
3136 1.05034493208
|
||||
3249 1.07496154308
|
||||
3364 1.05737783909
|
||||
3481 1.08237519264
|
||||
3600 1.08014725447
|
||||
3721 1.08937253952
|
||||
3844 1.11247887611
|
||||
3969 1.09317746162
|
||||
4096 1.11325138807
|
||||
4225 1.13788346052
|
||||
4356 1.14371216297
|
||||
4489 1.18271020651
|
||||
4624 1.11530535221
|
||||
4761 1.17880061865
|
||||
4900 1.27090764046
|
||||
5041 1.27123404741
|
||||
5184 1.23510987759
|
||||
5329 1.32282296419
|
||||
5476 1.26266155243
|
||||
5625 1.31297421455
|
||||
5776 1.28617317677
|
||||
5929 1.28255677223
|
||||
6084 1.29771604538
|
||||
6241 1.26418532133
|
||||
6400 1.25211964846
|
||||
6561 1.28612875938
|
||||
6724 1.35052484274
|
||||
6889 1.3348175168
|
||||
7056 1.24602227211
|
||||
7225 1.50032920837
|
||||
7396 1.3708496809
|
||||
7569 1.57386409044
|
||||
7744 1.43172559738
|
||||
7921 1.34539651871
|
||||
8100 1.19482668638
|
||||
8281 1.43756344318
|
||||
8464 1.26480004787
|
||||
8649 1.3722332716
|
||||
8836 1.34890033007
|
||||
9025 1.38903802633
|
||||
9216 1.48006383181
|
||||
9409 1.34714546204
|
||||
9604 1.55682841539
|
||||
9801 1.43338626623
|
||||
10000 1.59058433771
|
||||
91
models/seq_activity_firespread/setSchedulerHeapSet
Normal file
91
models/seq_activity_firespread/setSchedulerHeapSet
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
100 0.226246476173
|
||||
121 0.261581587791
|
||||
144 0.299371492863
|
||||
169 0.34144718647
|
||||
196 0.383192932606
|
||||
225 0.427901935577
|
||||
256 0.468216252327
|
||||
289 0.506950759888
|
||||
324 0.541691303253
|
||||
361 0.584604215622
|
||||
400 0.620400643349
|
||||
441 0.644228339195
|
||||
484 0.671416628361
|
||||
529 0.697513461113
|
||||
576 0.716212797165
|
||||
625 0.728418338299
|
||||
676 0.750058507919
|
||||
729 0.751612591743
|
||||
784 0.765629088879
|
||||
841 0.782111120224
|
||||
900 0.773976969719
|
||||
961 0.776369464397
|
||||
1024 0.782183206081
|
||||
1089 0.775770747662
|
||||
1156 0.794334948063
|
||||
1225 0.811960542202
|
||||
1296 0.805442273617
|
||||
1369 0.814023411274
|
||||
1444 0.814774858952
|
||||
1521 0.811607146263
|
||||
1600 0.847791218758
|
||||
1681 0.861179196835
|
||||
1764 0.831688988209
|
||||
1849 0.842000043392
|
||||
1936 0.851121747494
|
||||
2025 0.850674951077
|
||||
2116 0.859324288368
|
||||
2209 0.866709089279
|
||||
2304 0.876520586014
|
||||
2401 0.866443741322
|
||||
2500 0.883474814892
|
||||
2601 0.89487054348
|
||||
2704 0.89167444706
|
||||
2809 0.916162502766
|
||||
2916 0.911873698235
|
||||
3025 0.927051019669
|
||||
3136 0.954437327385
|
||||
3249 0.865363729
|
||||
3364 0.951761555672
|
||||
3481 0.98135420084
|
||||
3600 1.00115574598
|
||||
3721 0.945872163773
|
||||
3844 0.990826261044
|
||||
3969 0.998338198662
|
||||
4096 1.02144671679
|
||||
4225 1.04620203972
|
||||
4356 1.08107653856
|
||||
4489 1.07211278677
|
||||
4624 1.06561243534
|
||||
4761 1.14151208401
|
||||
4900 1.1346337676
|
||||
5041 1.20358138084
|
||||
5184 1.21537736654
|
||||
5329 1.18439155817
|
||||
5476 1.21267249584
|
||||
5625 1.1492706418
|
||||
5776 1.26243237257
|
||||
5929 1.19562410116
|
||||
6084 1.37217469215
|
||||
6241 1.29337176085
|
||||
6400 1.17512942553
|
||||
6561 1.26677691936
|
||||
6724 1.25305944681
|
||||
6889 1.1949403882
|
||||
7056 1.22964887619
|
||||
7225 1.23809258938
|
||||
7396 1.22572095394
|
||||
7569 1.26042776108
|
||||
7744 1.15103598833
|
||||
7921 1.44157497883
|
||||
8100 1.26417980194
|
||||
8281 1.46500861645
|
||||
8464 1.35032008886
|
||||
8649 1.22122730017
|
||||
8836 1.38142094612
|
||||
9025 1.42132151127
|
||||
9216 1.47396833897
|
||||
9409 1.37827976942
|
||||
9604 1.35060716867
|
||||
9801 1.37758309841
|
||||
10000 1.35175169706
|
||||
91
models/seq_activity_firespread/setSchedulerMinimalList
Normal file
91
models/seq_activity_firespread/setSchedulerMinimalList
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
100 0.20150642395
|
||||
121 0.232398426533
|
||||
144 0.268543791771
|
||||
169 0.309681200981
|
||||
196 0.345152592659
|
||||
225 0.386514472961
|
||||
256 0.42381118536
|
||||
289 0.457683265209
|
||||
324 0.499541199207
|
||||
361 0.529594087601
|
||||
400 0.565743041039
|
||||
441 0.593734741211
|
||||
484 0.612760353088
|
||||
529 0.64217042923
|
||||
576 0.660423707962
|
||||
625 0.682518494129
|
||||
676 0.70322624445
|
||||
729 0.71340174675
|
||||
784 0.724935078621
|
||||
841 0.743531131744
|
||||
900 0.744651913643
|
||||
961 0.755652606487
|
||||
1024 0.773002433777
|
||||
1089 0.779445755482
|
||||
1156 0.791037404537
|
||||
1225 0.787784671783
|
||||
1296 0.813582861423
|
||||
1369 0.841538369656
|
||||
1444 0.848928523064
|
||||
1521 0.850610458851
|
||||
1600 0.89677863121
|
||||
1681 0.909114277363
|
||||
1764 0.918510711193
|
||||
1849 0.916479098797
|
||||
1936 0.943597245216
|
||||
2025 0.95909807682
|
||||
2116 0.977495539188
|
||||
2209 0.992601490021
|
||||
2304 1.01982735395
|
||||
2401 1.04228304625
|
||||
2500 1.07186831236
|
||||
2601 1.09195421934
|
||||
2704 1.11123046875
|
||||
2809 1.14109973907
|
||||
2916 1.17551567554
|
||||
3025 1.20246677399
|
||||
3136 1.25347048044
|
||||
3249 1.23274769783
|
||||
3364 1.32211956978
|
||||
3481 1.32800074816
|
||||
3600 1.37067797184
|
||||
3721 1.37527707815
|
||||
3844 1.44688721895
|
||||
3969 1.47539746761
|
||||
4096 1.5466149807
|
||||
4225 1.57658609152
|
||||
4356 1.62593535185
|
||||
4489 1.64160341024
|
||||
4624 1.70612075329
|
||||
4761 1.77455605268
|
||||
4900 1.81851104498
|
||||
5041 1.94156910181
|
||||
5184 1.97664994001
|
||||
5329 2.00588467121
|
||||
5476 2.02205739021
|
||||
5625 2.02167693377
|
||||
5776 2.15209627151
|
||||
5929 2.2707236886
|
||||
6084 1.94723633528
|
||||
6241 2.1867726922
|
||||
6400 2.21558490992
|
||||
6561 2.40252326727
|
||||
6724 2.31568347216
|
||||
6889 2.37099903822
|
||||
7056 2.53042054176
|
||||
7225 2.48085706234
|
||||
7396 2.52184232473
|
||||
7569 2.55362695456
|
||||
7744 2.45592166185
|
||||
7921 2.84276198149
|
||||
8100 2.70634746552
|
||||
8281 2.93663452864
|
||||
8464 2.85909417868
|
||||
8649 2.89354460239
|
||||
8836 3.02056947947
|
||||
9025 2.9988509655
|
||||
9216 3.20122884512
|
||||
9409 3.11429377794
|
||||
9604 3.31007168293
|
||||
9801 3.23726166487
|
||||
10000 3.22211567163
|
||||
91
models/seq_activity_firespread/setSchedulerSortedList
Normal file
91
models/seq_activity_firespread/setSchedulerSortedList
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
100 0.202241420746
|
||||
121 0.237482869625
|
||||
144 0.274608457088
|
||||
169 0.314075434208
|
||||
196 0.356438422203
|
||||
225 0.394814312458
|
||||
256 0.430365347862
|
||||
289 0.469712626934
|
||||
324 0.508007884026
|
||||
361 0.541258406639
|
||||
400 0.568832027912
|
||||
441 0.600357341766
|
||||
484 0.626566171646
|
||||
529 0.65471521616
|
||||
576 0.667852258682
|
||||
625 0.688750839233
|
||||
676 0.702064549923
|
||||
729 0.713662981987
|
||||
784 0.729122459888
|
||||
841 0.746700716019
|
||||
900 0.751493287086
|
||||
961 0.759235227108
|
||||
1024 0.762286090851
|
||||
1089 0.763243913651
|
||||
1156 0.785572659969
|
||||
1225 0.782066726685
|
||||
1296 0.81456091404
|
||||
1369 0.821872055531
|
||||
1444 0.835059940815
|
||||
1521 0.855132675171
|
||||
1600 0.839707410336
|
||||
1681 0.888016951084
|
||||
1764 0.883149802685
|
||||
1849 0.906357729435
|
||||
1936 0.911254036427
|
||||
2025 0.925924360752
|
||||
2116 0.945433056355
|
||||
2209 0.963268089294
|
||||
2304 0.979500329494
|
||||
2401 0.997949540615
|
||||
2500 1.02767431736
|
||||
2601 1.03862577677
|
||||
2704 1.06490260363
|
||||
2809 1.08583031893
|
||||
2916 1.11426502466
|
||||
3025 1.1245005846
|
||||
3136 1.13743308783
|
||||
3249 1.13787366152
|
||||
3364 1.18787515163
|
||||
3481 1.23329766989
|
||||
3600 1.28969855309
|
||||
3721 1.27939500809
|
||||
3844 1.30438742638
|
||||
3969 1.33336162567
|
||||
4096 1.3977575779
|
||||
4225 1.41161931753
|
||||
4356 1.45252919197
|
||||
4489 1.46383014917
|
||||
4624 1.50754675865
|
||||
4761 1.56494822502
|
||||
4900 1.59297275543
|
||||
5041 1.69366886616
|
||||
5184 1.72341663837
|
||||
5329 1.74345017672
|
||||
5476 1.75275470018
|
||||
5625 1.73997089863
|
||||
5776 1.84348348379
|
||||
5929 1.94732481241
|
||||
6084 1.62044450045
|
||||
6241 1.83437690735
|
||||
6400 1.87838349342
|
||||
6561 2.03297270536
|
||||
6724 1.92828910351
|
||||
6889 1.96618150473
|
||||
7056 2.11858382225
|
||||
7225 2.05750243664
|
||||
7396 2.06992359161
|
||||
7569 2.12669249773
|
||||
7744 2.04242231846
|
||||
7921 2.35713373423
|
||||
8100 2.20817576647
|
||||
8281 2.43476822376
|
||||
8464 2.34521347284
|
||||
8649 2.27195681334
|
||||
8836 2.43023608923
|
||||
9025 2.46671522856
|
||||
9216 2.61486543417
|
||||
9409 2.59561314583
|
||||
9604 2.74612511396
|
||||
9801 2.66866044998
|
||||
10000 2.74972089529
|
||||
34
models/seq_activity_firespread/timer.py
Normal file
34
models/seq_activity_firespread/timer.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import sys
|
||||
import random
|
||||
schedulers = ["setSchedulerSortedList", "setSchedulerActivityHeap", "setSchedulerMinimalList", "setSchedulerHeapSet"]
|
||||
sys.path.append("../../src/")
|
||||
sizes = range(10, 71, 1)
|
||||
from simulator import Simulator
|
||||
iters = max(int(sys.argv[1]), 20)
|
||||
import time
|
||||
|
||||
def runFunc(scheduler):
|
||||
f = open("seq_activity_firespread/" + str(scheduler), 'w')
|
||||
for size in sizes:
|
||||
from model import FireSpread
|
||||
total = 0.0
|
||||
for _ in range(iters):
|
||||
model = FireSpread(size, size)
|
||||
sim = Simulator(model)
|
||||
sim.setMessageCopy('none')
|
||||
getattr(sim, scheduler)()
|
||||
sim.setTerminationTime(150)
|
||||
start = time.time()
|
||||
sim.simulate()
|
||||
total += (time.time() - start)
|
||||
# Take the square of size, as we have this many cells instead of only 'size' cells
|
||||
f.write("%s %s\n" % (size*size, total/iters))
|
||||
print("%s -- %s %s" % (scheduler, size*size, total/iters))
|
||||
f.close()
|
||||
|
||||
map(runFunc, schedulers)
|
||||
"""
|
||||
from multiprocessing import Pool
|
||||
p = Pool(4)
|
||||
p.map(runFunc, schedulers)
|
||||
"""
|
||||
Loading…
Add table
Add a link
Reference in a new issue