Пример #1
0
 def __init__(self, roadmap, length_attr='length' ) :
     super(PairUniformRoadmap,self).__init__(roadmap, length_attr)
     
     uniform = roadprob.UniformDist( self.roadmap, self.length_attr )
     self.distr = uniform
     
     # compute carry and fetch --- using roadmap movers complexity
     lendict = { road : data.get( self.length_attr, 1 )
                for _,__, road, data in self.roadmap.edges_iter( keys=True, data=True )
                }
     total = sum( lendict.values() )
     W = { road : roadlen / total
                for road, roadlen in lendict.iteritems() }
     
     if False :
         W2 = { (r1,r2) : w1*w2
               for r1,w1 in W.iteritems()
               for r2,w2 in W.iteritems() }
         
         self._meancarry = roadEd.roadEd( self.roadmap, W2, length_attr=self.length_attr )
         
     else :
         rategraph = nx.DiGraph()
         for r1,w1 in W.iteritems() :
             for r2,w2 in W.iteritems() :
                 rategraph.add_edge( r1, r2, rate=w1*w2 )
                 
         self._meancarry = roadcplx.carryMileageRate( self.roadmap, rategraph )
         
     self._meanfetch = 0.
Пример #2
0
 def __init__(self) :
     roadmap = ACC2014Square()
     
     super(ACC2014Distr,self).__init__(roadmap, 'length' )
     
     rategraph = nx.DiGraph()
     rategraph.add_edge( 'N', 'E', rate=1./5 )
     rategraph.add_edge( 'W', 'E', rate=1./5 )
     rategraph.add_edge( 'W', 'S', rate=3./5 )
     
     self._meancarry = roadcplx.carryMileageRate( roadmap, rategraph )
     self._meanfetch = roadcplx.fetchMileageRate( roadmap, rategraph )
     
     # for sampler
     weights = { (r1,r2) : data.get( 'rate' )
                for r1,r2, data in rategraph.edges_iter( data=True )
                }
     #weights[ ('N','E') ] = 1./5
     #weights[ ('W','E') ] = 1./5
     #weights[ ('W','S') ] = 3./5
     self.wset = roadprob.WeightedSet(weights)
Пример #3
0
 probe = RoadmapEMD()
 probe.horizon = 10000.
 
 complexity_computed = []
 complexity_estimated = []
 
 def showresults() :
     plt.scatter( complexity_computed, complexity_estimated )
     
 for t in range(1) :
     roadnet, rategraph = get_sim_setting( mu=2. )
     
     R = totalrate( rategraph )
     n_rategraph = scale_rates( rategraph, 1. / R )
     
     enroute_velocity = carryMileageRate( roadnet, n_rategraph )
     balance_velocity = fetchMileageRate( roadnet, n_rategraph )
     complexity = enroute_velocity + balance_velocity
     #complexity = moverscomplexity( roadnet, n_rategraph )
     
     
     for k in range(1) :
         numveh = np.random.randint(1,5+1)
         
         rate_predicted = convert_complexity_and_servicerate( complexity, numveh )
         simrates = scale_rates( n_rategraph, .99 * rate_predicted )
         
         probe.scenario( roadnet, simrates, numveh, 1. )
         
         probe.sim_init()
         probe.run_sim()