-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlog.nls
260 lines (231 loc) · 5.77 KB
/
log.nls
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
globals [
log-car-file openfile
sink13 sink16 sink18 sink31 sink33 sink35 sink36
maximal-cog sum-cog-times sum-cog-counts max-life-time sum-life-times deadcars
;avarages
sum-carsspawned
sum-cars-that-couldnot-spawn
sum-deadcars
sum-av-cog-times
sum-p
sum-avarage-car-count
sum-avarage-cars-in-cognestion
sum-av-life-times
]
to init-car-log
if gnerate-file [
let car-log-name (word "carlog-" "dt" ".csv")
set log-car-file (word log-path car-log-name)
file-open log-car-file
file-print "deathtime ; birthtime ; lastTarget ; cognestion-count ; cognestion-time ; longest-cognestion"
]
end
to-report log-path
let path "log/"
; if System = "windows" [
; set path "log\\"
; ]
report path
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; final tests
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; indian
;to test-indian
; let sp 1
; let sz "indian"
;
; let times 10000
; let runs 10
;
; let t-av-file (word log-path (daytime "dt") "_" sz "average" times "ticksVariableSpawnProp.csv")
; print-all-log-test-headline t-av-file
;
; let tfile1 (word log-path (daytime "dt") "_" sz runs "runsFor" times "ticksVariableSpawnProp.csv")
; ;print-log-test-headline tfile1
;
; while [sp <= 100][
; runtest t-av-file tfile1 runs times sz sp
; set sp (sp + 1)
; ]
;end
to-report my-dev [a b]
if b = 0 [
report 0
]
report a / b
end
to runtest [t-av-file tfile runs times sz sp]
let r 1
print-log-test-headline tfile
clear-all
while [r <= runs][
test-init
set scenario sz
set spawn-propabilty sp
let get-readytime 250
while [ticks < get-readytime ] [
go
]
while [ticks < (times + get-readytime) ] [
go
]
let p (precision (100 * avarage-cars-in-cognestion / avarage-car-count) (1))
let av-cog-times (my-dev sum-cog-times sum-cog-counts)
let av-life-times (my-dev sum-life-times deadcars)
; print in files
print-log-test-line tfile sz r sp av-cog-times p av-life-times
; all average
set sum-carsspawned (sum-carsspawned + carsspawned)
set sum-deadcars (sum-deadcars + deadcars)
set sum-av-cog-times (sum-av-cog-times + av-cog-times)
set sum-p (sum-p + p)
set sum-avarage-car-count (sum-avarage-car-count + avarage-car-count)
set sum-avarage-cars-in-cognestion (sum-avarage-cars-in-cognestion + avarage-cars-in-cognestion)
set sum-av-life-times (sum-av-life-times + av-life-times)
set r r + 1
]
(print-all-log-test-line
t-av-file
sp
(sum-carsspawned / runs)
(sum-cars-that-couldnot-spawn / runs)
(sum-deadcars / runs)
(sum-av-cog-times / runs)
(sum-p / runs)
(sum-avarage-car-count / runs)
(sum-avarage-cars-in-cognestion / runs)
(sum-av-life-times / runs)
)
;;
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; stuff for printing testfiles
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; for the average of the testvalues divided by the count of testruns
to print-all-log-test-headline [
;input-parameter
tfile
]
;function
file-open tfile
file-print (word
"spawn-propability"
";" "carsspawned"
";" "carsnotspawned"
";" "deadcars"
";" "av-cog-time"
";" "%av-cars-in-cog"
";" "av-cars"
";" "av-cars-in-cog"
";" "av-life-time"
";" "jtt1"
";" "jtt2"
";" "jtt3"
)
file-close
end
to print-all-log-test-line [
;input-parameter
tfile
sp
av-carsspawned
av-cars-that-couldnot-spawn
av-deadcars
av-cog-times
av-p
av-avarage-car-count
av-avarage-cars-in-cognestion
av-life-times
]
;function
file-open tfile
file-print (word
sp
";" av-carsspawned
";" av-cars-that-couldnot-spawn
";" av-deadcars
";" av-cog-times
";" av-p
";" av-avarage-car-count
";" av-avarage-cars-in-cognestion
";" av-life-times
)
file-close
end
;; for big testfile of all testruns in one file
to print-log-test-headline [
;input-parameter
tfile
]
;function
file-open tfile
file-print (word "szenario"
";" "test-nummer"
";" "spawn-propability"
";" "carsspawned"
";" "carsnotspawned"
";" "deadcars"
";" "av-cog-time"
";" "%av-cars-in-cog"
";" "av-cars"
";" "av-cars-in-cog"
";" "av-life-time"
";" "jtt1"
";" "jtt2"
";" "jtt3"
)
file-close
end
to print-log-test-line [
;input-parameter
tfile
sz
r
sp
av-cog-times
p
av-life-times
]
;function
file-open tfile
file-print (word sz
";" r
";" sp
";" carsspawned
";" deadcars
";" av-cog-times
";" p
";" avarage-car-count
";" avarage-cars-in-cognestion
";" av-life-times
)
file-close
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; inizialisation for tests
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to test-init
safely-init-roadnetwork
reset-ticks
init-car-log
;initcars
end
to safely-init-roadnetwork
let s1 sum-carsspawned
let s2 sum-cars-that-couldnot-spawn
let s3 sum-deadcars
let s4 sum-av-cog-times
let s5 sum-p
let s6 sum-avarage-car-count
let s7 sum-avarage-cars-in-cognestion
let s8 sum-av-life-times
set sum-carsspawned s1
set sum-cars-that-couldnot-spawn s2
set sum-deadcars s3
set sum-av-cog-times s4
set sum-p s5
set sum-avarage-car-count s6
set sum-avarage-cars-in-cognestion s7
set sum-av-life-times s8
end