This file is indexed.

/usr/share/sumo/tools/assign/statisticsElements.py is in sumo-tools 0.15.0~dfsg-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
"""
@file    statisticsElements.py
@author  Yun-Pang Wang
@author  Daniel Krajzewicz
@author  Michael Behrisch
@date    2008-07-10
@version $Id: statisticsElements.py 11671 2012-01-07 20:14:30Z behrisch $

This script is to define classes, functions, parse-reader and output files/format for
- calculating network performances
- conducting significance tests (either t-Test or Kruskal-Wallis-Test) and
- writing results into files.

SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
Copyright (C) 2008-2012 DLR (http://www.dlr.de/) and contributors
All rights reserved
"""

import string
from xml.sax import saxutils, make_parser, handler


# This class is for storing vehicle information, such as departure time, route and travel time.
class Vehicle:
    def __init__(self, label):
        self.label = label
        self.method = None
        self.depart = 0.
        self.arrival = 0.       
        self.speed = 0.
        self.route = []
        self.traveltime = 0.
        self.travellength = 0.
        self.departdelay = 0.
        self.waittime = 0.
        self.rank = 0.

    def __repr__(self):
        return "%s_%s_%s_%s_%s_%s<%s>" % (self.label, self.depart, self.arrival, self.speed, self.traveltime, self.travellength, self.route)

# This class is used in the significance test.
class Assign:
    def __init__(self, method, totalVeh, totalTravelTime, totalTravelLength, totalDepartDelay, totalWaitTime, avgTravelTime, avgTravelLength, avgTravelSpeed, avgDepartDelay, avgWaitTime, SDTravelTime, SDLength, SDSpeed, SDWaitTime):
        self.label = method
        self.totalVeh = totalVeh
        self.totalTravelTime = totalTravelTime
        self.totalTravelLength = totalTravelLength
        self.totalDepartDelay = totalDepartDelay
        self.totalWaitTime = totalWaitTime
        self.avgTravelTime = avgTravelTime
        self.avgTravelLength = avgTravelLength
        self.avgTravelSpeed = avgTravelSpeed
        self.avgDepartDelay = avgDepartDelay
        self.avgWaitTime = avgWaitTime
        self.SDTravelTime = SDTravelTime
        self.SDLength = SDLength      
        self.SDSpeed = SDSpeed
        self.SDWaitTime = SDWaitTime
        self.sumrank = 0.
        
    def __repr__(self):
        return "%s_<%s|%s|%s|%s|%s|%s|%s|%s|%s>" % (self.label, self.totalVeh, self.avgTravelTime, self.avgTravelLength, self.avgTravelSpeed,
                                                     self.avgWaitTime, self.SDTravelTime, self.SDLength, self.SDSpeed, self.SDWaitTime)

# This cloass is used for the t test in the significance test.
class T_Value:
    def __init__(self, avgtraveltime, avgtravelspeed, avgtravellength, avgwaittime, lowvalue, highvalue):
        self.avgtraveltime = avgtraveltime
        self.avgtravelspeed = avgtravelspeed
        self.avgtravellength = avgtravellength
        self.avgwaittime = avgwaittime
        self.lowtvalue = lowvalue
        self.hightvalue = highvalue
        
    def __repr__(self):
        return "%<%s|%s|%s|%s>" % (self.avgtraveltime, self.avgtravelspeed, self.avgtravellength, self.avgwaittime)

# This class is used for the Kruskal-Wallis test in the significance test.
class H_Value:
    def __init__(self, label, lowvalue, highvalue):
        self.label = label
        self.traveltime = 0.
        self.travelspeed = 0.
        self.travellength = 0.
        self.waittime = 0.
        # 95% confidence interval
        self.lowchivalue = lowvalue 
        # 99% confidence interval
        self.highchivalue = highvalue
        
    def __repr__(self):
        return "%<%s|%s|%s|%s|%s|%s>" % (self.traveltime, self.travelspeed, self.travellength, self.waittime, self.lowchivalue, self.highchivalue)
        
# The class is for parsing the XML input file (vehicle information). This class is used in the networkStatistics.py for
# calculating the gloabal network performances, e.g. avg. travel time and avg. travel speed.
class VehInformationReader(handler.ContentHandler):
    def __init__(self, vehList):
        self._vehList = vehList
        self._Vehicle = None
        self._routeString = ''
            
    def startElement(self, name, attrs):
        if name == 'tripinfo':
            self._Vehicle = Vehicle(attrs['id'])
            self._Vehicle.traveltime = float(attrs['duration'])
            self._Vehicle.travellength = float(attrs['routeLength'])
            self._Vehicle.departdelay = float(attrs['departDelay'])
            self._Vehicle.waittime = float(attrs['departDelay']) + float(attrs['waitSteps']) 
            self._vehList.append(self._Vehicle)
           
# output the network statistics based on the sumo-simulation results
def getStatisticsOutput(assignments, outputfile):
    foutveh = file(outputfile, 'w')
    foutveh.write('average vehicular travel time(s) = the sum of all vehicular travel times / the number of vehicles\n')
    foutveh.write('average vehicular travel length(m) = the sum of all vehicular travel lengths / the number of vehicles\n')
    foutveh.write('average vehicular travel speed(m/s) = the sum of all vehicular travel speeds / the number of vehicles\n')
    for method in assignments.itervalues():
        foutveh.write('\nAssignment Method:%s\n' %method.label)
        foutveh.write('- total number of vehicles:%s\n' %method.totalVeh)
        foutveh.write('- total departure delay(s):%s, ' %method.totalDepartDelay)    
        foutveh.write('- average departure delay(s):%s\n' %method.avgDepartDelay)
        foutveh.write('- total waiting time(s):%s, ' %method.totalWaitTime)    
        foutveh.write('- average vehicular waiting time(s):%s\n' %method.avgWaitTime)
        foutveh.write('- total travel time(s):%s, ' % method.totalTravelTime)    
        foutveh.write('- average vehicular travel time(s):%s\n' %method.avgTravelTime)
        foutveh.write('- total travel length(m):%s, ' %method.totalTravelLength)
        foutveh.write('- average vehicular travel length(m):%s\n' %method.avgTravelLength)
        foutveh.write('- average vehicular travel speed(m/s):%s\n' %method.avgTravelSpeed)
    foutveh.close()
       
# output the results of the significance tests according to the sumo-simulation results
def getSignificanceTestOutput(assignments, tTest, tValueAvg, hValues, outputfile):
    foutSGtest = file(outputfile, 'w')
    if tTest:
        foutSGtest.write('The significances of the performance averages among the used assignment models are examined with the t test.\n')
        assignlist = list(assignments.itervalues())
        for num, A in enumerate(assignlist):
            for B in assignlist[num+1: ]:
                foutSGtest.write('\nmethod:%s' %A.label)
                foutSGtest.write('\nmethod:%s' %B.label)
                foutSGtest.write('\n   t-value for the avg. travel time:%s' %tValueAvg[A][B].avgtraveltime)
                foutSGtest.write('\n   t-value for the avg. travel length:%s'%tValueAvg[A][B].avgtravellength)
                foutSGtest.write('\n   t-value for the avg.travel speed:%s' %tValueAvg[A][B].avgtravelspeed)
                foutSGtest.write('\n   t-value for the avg. wait time:%s\n' %tValueAvg[A][B].avgwaittime)
                foutSGtest.write('\n95 t-value:%s' %tValueAvg[A][B].lowtvalue)
                foutSGtest.write('\n99 t-value:%s\n' %tValueAvg[A][B].hightvalue)
                
    foutSGtest.write('The significance test among the different assignment methods is also done with the Kruskal-Wallis test.\n')
    for h in hValues:
        foutSGtest.write('\n\nmethods:%s' %h.label)
        foutSGtest.write('\nH_traveltime:%s' %h.traveltime)
        foutSGtest.write('\nH_travelspeed:%s' %h.travelspeed)
        foutSGtest.write('\nH_travellength:%s' %h.travellength)
        foutSGtest.write('\nH_waittime:%s\n' %h.waittime)
        foutSGtest.write('\n95 chi-square value:%s' %h.lowchivalue)
        foutSGtest.write('\n99 chi-square value:%s\n' %h.highchivalue)
    foutSGtest.close()