Initial commit

This commit is contained in:
Yentl Van Tendeloo 2016-08-04 17:38:43 +02:00
commit 66a6860316
407 changed files with 1254365 additions and 0 deletions

53
models/seq_poly/model.py Normal file
View file

@ -0,0 +1,53 @@
import sys
sys.path.append("../../src/")
from DEVS import *
import random
class Generator(AtomicDEVS):
def __init__(self, num, ta):
AtomicDEVS.__init__(self, "Generator" + str(num))
self.state = None
self.ta = ta
def timeAdvance(self):
return self.ta
class StaticModel(CoupledDEVS):
def __init__(self, size, actives):
CoupledDEVS.__init__(self, "Root")
random.seed(1)
tas = [round(random.random(), 3) for _ in range(int(size/actives+1))]
ta_counter = 0
for i in range(size):
self.addSubModel(Generator(i, tas[0]))
if ta_counter >= actives:
ta_counter = 0
tas.pop(0)
else:
ta_counter += 1
class DynamicGenerator(AtomicDEVS):
def __init__(self, num, nexttype):
AtomicDEVS.__init__(self, "Generator" + str(num))
self.state = (nexttype, True, round(random.uniform(4.00, 6.00), 4))
self.nexttype = nexttype
def intTransition(self):
if self.state[0] - self.timeAdvance() <= 0:
return (self.nexttype, not self.state[1], self.state[2])
else:
return (self.state[0] - self.timeAdvance(), self.state[1], self.state[2])
def timeAdvance(self):
if self.state[1]:
return min(1.0, self.state[0])
else:
return min(self.state[2], self.state[0])
class DynamicModel(CoupledDEVS):
def __init__(self, size):
CoupledDEVS.__init__(self, "Root")
random.seed(1)
for i in range(size):
self.addSubModel(DynamicGenerator(i, 2000))

27
models/seq_poly/plot Normal file
View file

@ -0,0 +1,27 @@
reset
set terminal postscript enhanced colour portrait size 6, 6
set title "Performance of three schedulers"
set ylabel "Time (s)"
set xlabel "Number of collisions (models)"
set key top right
set out 'seq_poly.eps'
plot 'seq_poly/setSchedulerPolymorphic' title 'Polymorphic' w l, 'seq_poly/setSchedulerHeapSet' title 'HeapSet' w l, 'seq_poly/setSchedulerMinimalList' title 'Minimal List' w l
set title "Performance of three schedulers"
set key bottom right
set yrange [3:6]
set ylabel "Time (s)"
set xlabel "Number of collisions (models)"
set out 'seq_poly_zoom.eps'
plot 'seq_poly/setSchedulerPolymorphic' title 'Polymorphic' w l, 'seq_poly/setSchedulerHeapSet' title 'HeapSet' w l, 'seq_poly/setSchedulerMinimalList' title 'Minimal List' w l
unset yrange
set title "Wall clock time required for a fixed simulation time"
set ylabel "Time (s)"
set yrange [0:5]
set xlabel "Simulation time"
set out 'seq_poly_dynamic.eps'
#set key out center below
plot 'seq_poly/setSchedulerPolymorphic_dynamic' title 'Polymorphic' w l, 'seq_poly/setSchedulerHeapSet_dynamic' title 'HeapSet' w l, 'seq_poly/setSchedulerMinimalList_dynamic' title 'Minimal List' w l

11
models/seq_poly/plot_100 Normal file
View file

@ -0,0 +1,11 @@
set terminal postscript enhanced colour portrait size 6, 6
set title "Performance of three schedulers"
set key bottom right
set yrange [90:120]
set ylabel "Time taken (%)"
set xlabel "Number of collisions (%)"
set out 'seq_poly_zoom.eps'
plot 'setSchedulerHeapSet_100' using 1:($2/$4*100) title 'HeapSet' w l lw 5, 'setSchedulerMinimalList_100' using 1:($2/$4*100) title 'Minimal List' w l lw 5, 100 w l lw 5 title 'Polymorphic'
unset yrange

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,99 @@
1 34.9980213642
2 36.5979576111
3 40.0916717052
4 44.6968166828
5 47.0976509253
6 51.0031263828
7 53.0061130524
8 56.9856740634
9 57.8619080385
10 59.1422148546
11 62.8939167658
12 66.1740423838
13 69.5888765653
14 39.452300628
15 9.81980601947
16 10.1219320297
17 10.3594040076
18 10.6940494378
19 11.027678887
20 9.09549768766
21 7.16989930471
22 5.38450598717
23 4.94868270556
24 4.1995490392
25 4.24332968394
26 4.3077147007
27 4.3912970225
28 4.39898769061
29 4.48326698939
30 4.53549623489
31 4.58515723546
32 4.63497829437
33 4.63709060351
34 4.68165071805
35 4.71195737521
36 4.74547370275
37 4.7689936161
38 4.79102134705
39 4.76015297572
40 4.79159235954
41 4.81278928121
42 4.85297163328
43 4.88511665662
44 4.95236229897
45 4.96816492081
46 5.02565391858
47 5.0356713136
48 5.06979695956
49 5.05325333277
50 4.96282307307
51 4.9406979084
52 4.93491069476
53 4.92744088173
54 4.92540637652
55 4.90770594279
56 4.90413061778
57 4.88920696576
58 4.88625001907
59 4.85681668917
60 4.84712362289
61 4.85096335411
62 4.83810766538
63 4.7877582709
64 4.78851167361
65 4.76769439379
66 4.67819770177
67 4.69562228521
68 4.74345064163
69 4.7945283254
70 4.81087605158
71 4.84597031275
72 4.89070709546
73 4.9275077184
74 4.9977637132
75 5.01860642433
76 5.03865663211
77 5.07245262464
78 5.10150980949
79 5.12424659729
80 5.20184103648
81 5.22861059507
82 5.27152434985
83 5.33308092753
84 5.37662371
85 5.44022671382
86 5.48325435321
87 5.53079112371
88 5.58443633715
89 5.59080298742
90 5.61057734489
91 5.65496198336
92 5.69291869799
93 5.7355363369
94 5.74923825264
95 5.80846977234
96 5.86232304573
97 5.89609869321
98 5.94469364484
99 5.92336336772

View file

@ -0,0 +1,99 @@
1 34.9980213642 1 36.3385649522
2 36.5979576111 2 37.8044553598
3 40.0916717052 3 41.2813618978
4 44.6968166828 4 45.7729356289
5 47.0976509253 5 48.5511733691
6 51.0031263828 6 52.6058189074
7 53.0061130524 7 54.2927773794
8 56.9856740634 8 58.3867782752
9 57.8619080385 9 59.4434790611
10 59.1422148546 10 60.0769566695
11 62.8939167658 11 63.8088603814
12 66.1740423838 12 67.345568339
13 69.5888765653 13 71.0219780604
14 39.452300628 14 40.5175193946
15 9.81980601947 15 9.96999327342
16 10.1219320297 16 10.2611149947
17 10.3594040076 17 10.5464076996
18 10.6940494378 18 10.8370733261
19 11.027678887 19 11.2021596432
20 9.09549768766 20 9.27681962649
21 7.16989930471 21 7.27267829577
22 5.38450598717 22 5.4530266126
23 4.94868270556 23 5.01990803083
24 4.1995490392 24 4.23026601473
25 4.24332968394 25 4.28368544579
26 4.3077147007 26 4.36265563965
27 4.3912970225 27 4.42511693637
28 4.39898769061 28 4.80185834567
29 4.48326698939 29 4.8929421107
30 4.53549623489 30 4.95383310318
31 4.58515723546 31 4.98937972387
32 4.63497829437 32 5.04021755854
33 4.63709060351 33 4.90025003751
34 4.68165071805 34 4.88616108894
35 4.71195737521 35 4.93525997798
36 4.74547370275 36 4.966832002
37 4.7689936161 37 4.99971365929
38 4.79102134705 38 5.00621445974
39 4.76015297572 39 4.74968695641
40 4.79159235954 40 4.81041272481
41 4.81278928121 41 4.84219972293
42 4.85297163328 42 4.8793018659
43 4.88511665662 43 4.86641573906
44 4.95236229897 44 4.91535393397
45 4.96816492081 45 4.93961071968
46 5.02565391858 46 4.95840239525
47 5.0356713136 47 4.99161338806
48 5.06979695956 48 5.03271532059
49 5.05325333277 49 4.85305627187
50 4.96282307307 50 4.81664737066
51 4.9406979084 51 4.76444570223
52 4.93491069476 52 4.78323062261
53 4.92744088173 53 4.78754973412
54 4.92540637652 54 4.78639674187
55 4.90770594279 55 4.77682367961
56 4.90413061778 56 4.78402336438
57 4.88920696576 57 4.76896762848
58 4.88625001907 58 4.72460802396
59 4.85681668917 59 4.73069604238
60 4.84712362289 60 4.71695137024
61 4.85096335411 61 4.75092260043
62 4.83810766538 62 4.7099609375
63 4.7877582709 63 4.68792096774
64 4.78851167361 64 4.6817398866
65 4.76769439379 65 4.69553375244
66 4.67819770177 66 4.2492117087
67 4.69562228521 67 4.28769159317
68 4.74345064163 68 4.36001992226
69 4.7945283254 69 4.34454568227
70 4.81087605158 70 4.35539571444
71 4.84597031275 71 4.38970669111
72 4.89070709546 72 4.44276531537
73 4.9275077184 73 4.45531201363
74 4.9977637132 74 4.4770163695
75 5.01860642433 75 4.50476535161
76 5.03865663211 76 4.54101443291
77 5.07245262464 77 4.54225301743
78 5.10150980949 78 4.57738836606
79 5.12424659729 79 4.63785068194
80 5.20184103648 80 4.63350335757
81 5.22861059507 81 4.68449370066
82 5.27152434985 82 4.68822304408
83 5.33308092753 83 4.70865337054
84 5.37662371 84 4.75204626719
85 5.44022671382 85 4.81373238564
86 5.48325435321 86 4.84208393097
87 5.53079112371 87 4.85953720411
88 5.58443633715 88 4.89051731428
89 5.59080298742 89 4.92242773374
90 5.61057734489 90 4.94477367401
91 5.65496198336 91 4.98975841204
92 5.69291869799 92 4.98142902056
93 5.7355363369 93 5.03030665716
94 5.74923825264 94 5.08186435699
95 5.80846977234 95 5.07148226102
96 5.86232304573 96 5.1335097154
97 5.89609869321 97 5.14366292953
98 5.94469364484 98 5.15321946144
99 5.92336336772 99 5.08448425929

View file

@ -0,0 +1,10 @@
0 1.891
1000 1.820
2000 1.517
3000 1.522
4000 1.821
5000 1.821
6000 1.517
7000 1.521
8000 1.825
9000 1.824

View file

@ -0,0 +1,99 @@
1 78.3998696804
2 78.1593190034
3 79.7904365857
4 82.9703411261
5 83.0246070226
6 85.1757339636
7 85.7102687359
8 88.8778286775
9 87.5538387299
10 86.648711284
11 89.376248916
12 92.066579024
13 93.8859919707
14 72.5239726702
15 13.0012436708
16 13.1050723394
17 13.3213013013
18 13.261938254
19 13.527338028
20 12.1085050106
21 10.7659905752
22 6.53850062688
23 6.22004564603
24 4.77188936869
25 4.83000540733
26 4.85500065486
27 4.91544739405
28 4.80120197932
29 4.85180830956
30 4.90139396985
31 4.92982459068
32 4.97504933675
33 4.86668133736
34 4.87025594711
35 4.86367599169
36 4.91851504644
37 4.93514100711
38 4.94737799962
39 4.73099001249
40 4.77706162135
41 4.80015095075
42 4.79426805178
43 4.81554039319
44 4.87215868632
45 4.89183735847
46 4.91932233175
47 4.93843507767
48 4.97473899523
49 4.79398393631
50 4.74273403486
51 4.72348761559
52 4.69744261106
53 4.72418173154
54 4.7374159495
55 4.73507730166
56 4.74505734444
57 4.67874797185
58 4.69726165136
59 4.6545941035
60 4.67076166471
61 4.67741457621
62 4.61056375504
63 4.62143667539
64 4.63304726283
65 4.62573369344
66 4.22831392288
67 4.23447028796
68 4.26864329974
69 4.26532332102
70 4.30173476537
71 4.34359431267
72 4.36843665441
73 4.39659698804
74 4.43205030759
75 4.41587972641
76 4.4872036775
77 4.49582195282
78 4.52253230413
79 4.55950339635
80 4.6123770078
81 4.62363934517
82 4.67911163966
83 4.65031599998
84 4.70373821259
85 4.75865197182
86 4.7754556338
87 4.79091127714
88 4.84583131472
89 4.88521091143
90 4.85897596677
91 4.92259470622
92 4.91923300425
93 4.97885004679
94 5.00485102336
95 5.02323571841
96 5.06475893656
97 5.08311629295
98 5.07097363472
99 4.98035534223

View file

@ -0,0 +1,99 @@
1 78.3998696804 1 36.3385649522
2 78.1593190034 2 37.8044553598
3 79.7904365857 3 41.2813618978
4 82.9703411261 4 45.7729356289
5 83.0246070226 5 48.5511733691
6 85.1757339636 6 52.6058189074
7 85.7102687359 7 54.2927773794
8 88.8778286775 8 58.3867782752
9 87.5538387299 9 59.4434790611
10 86.648711284 10 60.0769566695
11 89.376248916 11 63.8088603814
12 92.066579024 12 67.345568339
13 93.8859919707 13 71.0219780604
14 72.5239726702 14 40.5175193946
15 13.0012436708 15 9.96999327342
16 13.1050723394 16 10.2611149947
17 13.3213013013 17 10.5464076996
18 13.261938254 18 10.8370733261
19 13.527338028 19 11.2021596432
20 12.1085050106 20 9.27681962649
21 10.7659905752 21 7.27267829577
22 6.53850062688 22 5.4530266126
23 6.22004564603 23 5.01990803083
24 4.77188936869 24 4.23026601473
25 4.83000540733 25 4.28368544579
26 4.85500065486 26 4.36265563965
27 4.91544739405 27 4.42511693637
28 4.80120197932 28 4.80185834567
29 4.85180830956 29 4.8929421107
30 4.90139396985 30 4.95383310318
31 4.92982459068 31 4.98937972387
32 4.97504933675 32 5.04021755854
33 4.86668133736 33 4.90025003751
34 4.87025594711 34 4.88616108894
35 4.86367599169 35 4.93525997798
36 4.91851504644 36 4.966832002
37 4.93514100711 37 4.99971365929
38 4.94737799962 38 5.00621445974
39 4.73099001249 39 4.74968695641
40 4.77706162135 40 4.81041272481
41 4.80015095075 41 4.84219972293
42 4.79426805178 42 4.8793018659
43 4.81554039319 43 4.86641573906
44 4.87215868632 44 4.91535393397
45 4.89183735847 45 4.93961071968
46 4.91932233175 46 4.95840239525
47 4.93843507767 47 4.99161338806
48 4.97473899523 48 5.03271532059
49 4.79398393631 49 4.85305627187
50 4.74273403486 50 4.81664737066
51 4.72348761559 51 4.76444570223
52 4.69744261106 52 4.78323062261
53 4.72418173154 53 4.78754973412
54 4.7374159495 54 4.78639674187
55 4.73507730166 55 4.77682367961
56 4.74505734444 56 4.78402336438
57 4.67874797185 57 4.76896762848
58 4.69726165136 58 4.72460802396
59 4.6545941035 59 4.73069604238
60 4.67076166471 60 4.71695137024
61 4.67741457621 61 4.75092260043
62 4.61056375504 62 4.7099609375
63 4.62143667539 63 4.68792096774
64 4.63304726283 64 4.6817398866
65 4.62573369344 65 4.69553375244
66 4.22831392288 66 4.2492117087
67 4.23447028796 67 4.28769159317
68 4.26864329974 68 4.36001992226
69 4.26532332102 69 4.34454568227
70 4.30173476537 70 4.35539571444
71 4.34359431267 71 4.38970669111
72 4.36843665441 72 4.44276531537
73 4.39659698804 73 4.45531201363
74 4.43205030759 74 4.4770163695
75 4.41587972641 75 4.50476535161
76 4.4872036775 76 4.54101443291
77 4.49582195282 77 4.54225301743
78 4.52253230413 78 4.57738836606
79 4.55950339635 79 4.63785068194
80 4.6123770078 80 4.63350335757
81 4.62363934517 81 4.68449370066
82 4.67911163966 82 4.68822304408
83 4.65031599998 83 4.70865337054
84 4.70373821259 84 4.75204626719
85 4.75865197182 85 4.81373238564
86 4.7754556338 86 4.84208393097
87 4.79091127714 87 4.85953720411
88 4.84583131472 88 4.89051731428
89 4.88521091143 89 4.92242773374
90 4.85897596677 90 4.94477367401
91 4.92259470622 91 4.98975841204
92 4.91923300425 92 4.98142902056
93 4.97885004679 93 5.03030665716
94 5.00485102336 94 5.08186435699
95 5.02323571841 95 5.07148226102
96 5.06475893656 96 5.1335097154
97 5.08311629295 97 5.14366292953
98 5.07097363472 98 5.15321946144
99 4.98035534223 99 5.08448425929

View file

@ -0,0 +1,10 @@
0 1.526
1000 1.457
2000 4.599
3000 4.604
4000 1.465
5000 1.464
6000 4.599
7000 4.604
8000 1.466
9000 1.464

View file

@ -0,0 +1,99 @@
1 36.3385649522
2 37.8044553598
3 41.2813618978
4 45.7729356289
5 48.5511733691
6 52.6058189074
7 54.2927773794
8 58.3867782752
9 59.4434790611
10 60.0769566695
11 63.8088603814
12 67.345568339
13 71.0219780604
14 40.5175193946
15 9.96999327342
16 10.2611149947
17 10.5464076996
18 10.8370733261
19 11.2021596432
20 9.27681962649
21 7.27267829577
22 5.4530266126
23 5.01990803083
24 4.23026601473
25 4.28368544579
26 4.36265563965
27 4.42511693637
28 4.80185834567
29 4.8929421107
30 4.95383310318
31 4.98937972387
32 5.04021755854
33 4.90025003751
34 4.88616108894
35 4.93525997798
36 4.966832002
37 4.99971365929
38 5.00621445974
39 4.74968695641
40 4.81041272481
41 4.84219972293
42 4.8793018659
43 4.86641573906
44 4.91535393397
45 4.93961071968
46 4.95840239525
47 4.99161338806
48 5.03271532059
49 4.85305627187
50 4.81664737066
51 4.76444570223
52 4.78323062261
53 4.78754973412
54 4.78639674187
55 4.77682367961
56 4.78402336438
57 4.76896762848
58 4.72460802396
59 4.73069604238
60 4.71695137024
61 4.75092260043
62 4.7099609375
63 4.68792096774
64 4.6817398866
65 4.69553375244
66 4.2492117087
67 4.28769159317
68 4.36001992226
69 4.34454568227
70 4.35539571444
71 4.38970669111
72 4.44276531537
73 4.45531201363
74 4.4770163695
75 4.50476535161
76 4.54101443291
77 4.54225301743
78 4.57738836606
79 4.63785068194
80 4.63350335757
81 4.68449370066
82 4.68822304408
83 4.70865337054
84 4.75204626719
85 4.81373238564
86 4.84208393097
87 4.85953720411
88 4.89051731428
89 4.92242773374
90 4.94477367401
91 4.98975841204
92 4.98142902056
93 5.03030665716
94 5.08186435699
95 5.07148226102
96 5.1335097154
97 5.14366292953
98 5.15321946144
99 5.08448425929

View file

@ -0,0 +1,10 @@
0 1.635
1000 1.502
2000 1.618
3000 1.613
4000 1.524
5000 1.506
6000 1.626
7000 1.612
8000 1.516
9000 1.505

59
models/seq_poly/timer.py Normal file
View file

@ -0,0 +1,59 @@
import sys
import random
schedulers = ["setSchedulerHeapSet", "setSchedulerMinimalList", "setSchedulerPolymorphic"]
maxsize = 200
factors = range(1, 50)
sys.path.append("../../src/")
from simulator import Simulator
import time
iters = int(sys.argv[1])
def runFunc(scheduler):
f = open("seq_poly/" + str(scheduler), 'w')
for factor in factors:
from model import StaticModel
total = 0.0
for _ in range(iters):
random.seed(1)
model = StaticModel(maxsize, factor)
sim = Simulator(model)
sim.setMessageCopy('none')
getattr(sim, scheduler)()
sim.setTerminationTime(1000)
start = time.time()
sim.simulate()
del sim
total += (time.time() - start)
f.write("%s %s\n" % (factor, total/iters))
print("%s %s" % (factor, total/iters))
f.close()
def runFunc_DYN(scheduler):
iters = 1
f = open("seq_poly/%s_dynamic" % scheduler, 'w')
from model import DynamicModel
random.seed(1)
model = DynamicModel(maxsize)
sim = Simulator(model)
sim.setMessageCopy('none')
getattr(sim, scheduler)()
termtime = 0
while termtime < 10000:
termtime += 1000
sim.setTerminationTime(termtime)
start = time.time()
sim.simulate()
f.write("%s %s\n" % (termtime - 1000, time.time() - start))
print("%s %s" % (termtime - 1000, time.time() - start))
del sim
f.close()
map(runFunc, schedulers)
#map(runFunc_DYN, schedulers)
"""
from multiprocessing import Pool
p = Pool(3)
p.map(runFunc, schedulers)
p = Pool(3)
p.map(runFunc_DYN, schedulers)
"""