Esempio n. 1
0
def _options_roads_neq( roadnet, road1, road2, length_attr ) :
    edge1, data1 = ROAD.obtain_edge( roadnet, road1, data_flag=True )
    u1,v1,_ = edge1 ; roadlen1 = data1.get( length_attr, np.inf )
    edge2, data2 = ROAD.obtain_edge( roadnet, road2, data_flag=True )
    u2,v2,_ = edge2 ; roadlen2 = data2.get( length_attr, np.inf )
    
    x = GLOBAL.x ; y = GLOBAL.y    
    cost_dict = {
                 '<-s' : x,
                 's->' : roadlen1 - x,
                 '->t' : y,
                 't<-' : roadlen2 - y
                 }
    
    options = []
    # paths through endpoints
    WAYP1 = [ ( 's->', v1 ) ]
    if not data1.get( 'oneway', False ) : WAYP1.append( ( '<-s', u1 ) )
    WAYP2 = [ ( '->t', u2 ) ]
    if not data2.get( 'oneway', False ) : WAYP2.append( ( 't<-', v2 ) )
    
    for s,u in WAYP1 :
        p = ROAD.roadify( roadnet, u, length_attr )
        for t,v in WAYP2 :
            q = ROAD.roadify( roadnet, v, length_attr )
            
            dst = ROAD.distance( roadnet, p, q, length_attr )
            cost = cost_dict[s] + dst + cost_dict[t]
            options.append( cost )
            
    return options
Esempio n. 2
0
def _options_roads_eq_yleqx( roadnet, road, length_attr ) :
    edge, data = ROAD.obtain_edge( roadnet, road, data_flag=True )
    u,v,_ = edge ; roadlen = data.get( length_attr, np.inf )
    p = ROAD.roadify( roadnet, u, length_attr )
    q = ROAD.roadify( roadnet, v, length_attr )
    
    x = GLOBAL.x ; y = GLOBAL.y
    sojourn_cost = roadlen - x + ROAD.distance( roadnet, q, p, length_attr ) + y    # a path using the rest of the network 
    options = [ sojourn_cost ]
    if not data.get( 'oneway', False ) :
        options.append( x - y )
    return options