changeset 706:e395bffe1412 dev

cleaned unused code (up to date in Paul St-Aubin PVC code)
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 22 Jul 2015 14:15:33 -0400
parents 0ceee3b1a96d
children a37c565f4b68 29daabe094fe
files python/events.py
diffstat 1 files changed, 0 insertions(+), 124 deletions(-) [+]
line wrap: on
line diff
--- a/python/events.py	Wed Jul 22 13:46:28 2015 -0400
+++ b/python/events.py	Wed Jul 22 14:15:33 2015 -0400
@@ -338,130 +338,6 @@
     Non-prototype interactions will be assigned to an existing prototype if all indicators are similar enough'''
     pass
 
-# TODO:
-#http://stackoverflow.com/questions/3288595/multiprocessing-using-pool-map-on-a-function-defined-in-a-class
-#http://www.rueckstiess.net/research/snippets/show/ca1d7d90
-def calculateIndicatorPipe(pairs, predParam, timeHorizon=75,collisionDistanceThreshold=1.8):  
-    collisionPoints, crossingZones = prediction.computeCrossingsCollisions(pairs.roadUser1, pairs.roadUser2, predParam, collisionDistanceThreshold, timeHorizon)      
-    #print pairs.num    
-    # Ignore empty collision points
-    empty = 1
-    for i in collisionPoints:
-        if(collisionPoints[i] != []):
-            empty = 0
-    if(empty == 1):
-        pairs.hasCP = 0
-    else:
-        pairs.hasCP = 1
-    pairs.CP = collisionPoints
-    
-    # Ignore empty crossing zones
-    empty = 1
-    for i in crossingZones:
-        if(crossingZones[i] != []):
-            empty = 0
-    if(empty == 1):
-        pairs.hasCZ = 0
-    else:
-        pairs.hasCZ = 1
-    pairs.CZ = crossingZones
-    return pairs
-
-def calculateIndicatorPipe_star(a_b):
-    """Convert `f([1,2])` to `f(1,2)` call."""
-    return calculateIndicatorPipe(*a_b)
-
-class VehPairs():
-    '''Create a veh-pairs object from objects list'''
-    def __init__(self,objects):
-        self.pairs = createInteractions(objects)
-        self.interactionCount = 0
-        self.CPcount = 0
-        self.CZcount = 0
-    
-    # Process indicator calculation with support for multi-threading
-    def calculateIndicators(self,predParam,threads=1,timeHorizon=75,collisionDistanceThreshold=1.8):       
-        if(threads > 1):
-            pool = multiprocessing.Pool(threads)
-            self.pairs = pool.map(calculateIndicatorPipe_star, itertools.izip(self.pairs, itertools.repeat(predParam)))
-            pool.close()
-        else:
-            #prog = Tools.ProgressBar(0, len(self.pairs), 77) #Removed in traffic-intelligenc port
-            for j in xrange(len(self.pairs)):
-                #prog.updateAmount(j) #Removed in traffic-intelligenc port
-                collisionPoints, crossingZones = prediction.computeCrossingsCollisions(self.pairs[j].roadUser1, self.pairs[j].roadUser2, predParam, collisionDistanceThreshold, timeHorizon)      
-                
-                # Ignore empty collision points
-                empty = 1
-                for i in collisionPoints:
-                    if(collisionPoints[i] != []):
-                        empty = 0
-                if(empty == 1):
-                    self.pairs[j].hasCP = 0
-                else:
-                    self.pairs[j].hasCP = 1
-                self.pairs[j].CP = collisionPoints
-                
-                # Ignore empty crossing zones
-                empty = 1
-                for i in crossingZones:
-                    if(crossingZones[i] != []):
-                        empty = 0
-                if(empty == 1):
-                    self.pairs[j].hasCZ = 0
-                else:
-                    self.pairs[j].hasCZ = 1
-                self.pairs[j].CZ = crossingZones       
-                
-        for j in self.pairs:
-            self.interactionCount = self.interactionCount + len(j.CP)
-        self.CPcount = len(self.getCPlist())
-        self.Czcount = len(self.getCZlist())
-    
-    
-    def getPairsWCP(self):
-        lists = []
-        for j in self.pairs:
-            if(j.hasCP):
-                lists.append(j.num)
-        return lists
-        
-    def getPairsWCZ(self):
-        lists = []
-        for j in self.pairs:
-            if(j.hasCZ):
-                lists.append(j.num)
-        return lists
-    
-    def getCPlist(self,indicatorThreshold=float('Inf')):
-        lists = []
-        for j in self.pairs:
-            if(j.hasCP):
-                for k in j.CP:
-                    if(j.CP[k] != [] and j.CP[k][0].indicator < indicatorThreshold):
-                        lists.append([k,j.CP[k][0]])
-        return lists
-     
-    def getCZlist(self,indicatorThreshold=float('Inf')):
-        lists = []
-        for j in self.pairs:
-            if(j.hasCZ):
-                for k in j.CZ:
-                    if(j.CZ[k] != [] and j.CZ[k][0].indicator < indicatorThreshold):
-                        lists.append([k,j.CZ[k][0]])
-        return lists
-        
-    def genIndicatorHistogram(self, CPlist=False, bins=range(0,100,1)):
-        if(not CPlist):
-            CPlist = self.getCPlist()
-        if(not CPlist):
-            return False
-        TTC_list = []
-        for i in CPlist:
-            TTC_list.append(i[1].indicator)
-        histo = np.histogram(TTC_list,bins=bins)
-        histo += (histo[0].astype(float)/np.sum(histo[0]),)
-        return histo
 
 class Crossing(moving.STObject):
     '''Class for the event of a street crossing