Skip to content

Commit 59c5ccd

Browse files
committed
fix #17664
1 parent 23a252c commit 59c5ccd

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tools/sumolib/miscutils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,28 @@ def getFlowNumber(flow):
316316
if flow.end is not None:
317317
duration = parseTime(flow.end) - parseTime(flow.begin)
318318
period = 0
319+
isFractional = False
319320
if flow.period is not None:
320321
if 'exp' in flow.period:
321322
# use expected value
322323
period = 1 / float(flow.period[4:-1])
324+
isFractional = True
323325
else:
324326
period = float(flow.period)
327+
elif flow.probability is not None:
328+
# use expected value
329+
period = 1 / float(flow.probability)
330+
isFractional = True
325331
for attr in ['perHour', 'vehsPerHour']:
326332
if flow.hasAttribute(attr):
327333
period = 3600 / float(flow.getAttribute(attr))
328334
if period > 0:
329-
return math.ceil(duration / period)
335+
count = duration / period
336+
if isFractional:
337+
return count
338+
else:
339+
# flows with a regular period always start at least one vehicle at the begin time
340+
return math.ceil(count)
330341
else:
331342
return 1
332343

0 commit comments

Comments
 (0)