@@ -22,7 +22,7 @@ class Node:
2222 """
2323 Node in a network.
2424 """
25- def __init__ (s , W : "World" , name : str , x : float , y : float , signal : list [float ]= [0 ], signal_offset : float = 0 , signal_offset_old : float | None = None , flow_capacity : float | None = None , number_of_lanes : int = None , auto_rename = False , attribute = None , user_attribute = None , user_function = None ):
25+ def __init__ (s , W : "World" , name : str , x : float , y : float , signal : list [float ]= [0 ], signal_offset : float = 0 , signal_offset_old : float | None = None , flow_capacity : float | None = None , number_of_lanes : int | None = None , auto_rename = False , attribute = None , user_attribute = None , user_function = None ):
2626 """
2727 Create a node.
2828
@@ -83,14 +83,14 @@ def __init__(s, W: "World", name: str, x: float, y: float, signal: list[float]=[
8383 s .user_function = user_function
8484
8585 #incoming/outgoing links
86- s .inlinks : dict [Link ] = dict ()
87- s .outlinks : dict [Link ] = dict ()
86+ s .inlinks : dict [str , Link ] = dict ()
87+ s .outlinks : dict [str , Link ] = dict ()
8888
8989 #request for inter-link transfer (demand for node model)
9090 s .incoming_vehicles : list [Vehicle ] = []
9191
9292 #vertical queue for vehicle generation
93- s .generation_queue : list [Vehicle ] = deque ()
93+ s .generation_queue : deque [Vehicle ] = deque ()
9494
9595 #signal settings
9696 #If this node does not have a signal, set `signal=[0]`
@@ -199,7 +199,7 @@ def generate(s):
199199 if veh .specified_route [0 ] in outlinks :
200200 outlinks = [veh .specified_route [0 ]]
201201 else :
202- raise ValueError (f"Vehicle { veh .name } : specified route { s .specified_route } is inconsistent at the origin node { s .name } . Debug info: { outlinks = } " )
202+ raise ValueError (f"Vehicle { veh .name } : specified route { veh .specified_route } is inconsistent at the origin node { s .name } . Debug info: { outlinks = } " )
203203
204204 preference = np .array ([veh .route_pref [l .id ] for l in outlinks ], dtype = float )
205205 if s .W .hard_deterministic_mode == False :
@@ -807,7 +807,7 @@ class Vehicle:
807807 """
808808 Vehicle or platoon in a network.
809809 """
810- def __init__ (s , W : "World" , orig : Node | str , dest : Node | str , departure_time :float , name : str | None = None , route_pref : dict = None , route_choice_principle = None , mode : str = "single_trip" , links_prefer : list = [], links_avoid : list = [], trip_abort : int = 1 , departure_time_is_time_step : int = 0 , attribute = None , user_attribute = None , user_function = None , auto_rename = False ):
810+ def __init__ (s , W : "World" , orig : Node | str , dest : Node | str , departure_time :int | float , name : str | None = None , route_pref : dict = None , route_choice_principle = None , mode : str = "single_trip" , links_prefer : list = [], links_avoid : list = [], trip_abort : int = 1 , departure_time_is_time_step : int = 0 , attribute = None , user_attribute = None , user_function = None , auto_rename = False ):
811811 """
812812 Create a vehicle (more precisely, platoon).
813813
@@ -819,8 +819,8 @@ def __init__(s, W: "World", orig: Node|str, dest: Node|str, departure_time:float
819819 The origin node.
820820 dest : str | Node
821821 The destination node.
822- departure_time : int
823- The departure time of the vehicle.
822+ departure_time : int | float
823+ The departure time of the vehicle. This can be timestep or time in second.
824824 name : str, optional
825825 The name of the vehicle, default is the id of the vehicle.
826826 route_pref : dict, optional
@@ -862,13 +862,13 @@ def __init__(s, W: "World", orig: Node|str, dest: Node|str, departure_time:float
862862
863863 #出発・到着時刻
864864 if departure_time_is_time_step :#互換性のため,departure_timeは常にタイムステップ表記 -> TODO: 要訂正!
865- s .departure_time = departure_time
865+ s .departure_time : int = departure_time
866866 else :
867- s .departure_time = int (departure_time / s .W .DELTAT )
868- s .departure_time_in_second = departure_time * s .W .DELTAT #TODO: temporal workaround
869- s .arrival_time = - 1
870- s .link_arrival_time = - 1
871- s .travel_time = - 1
867+ s .departure_time : int = int (departure_time / s .W .DELTAT )
868+ s .departure_time_in_second : float = departure_time * s .W .DELTAT #TODO: temporal workaround
869+ s .arrival_time : int = - 1
870+ s .link_arrival_time : float = - 1
871+ s .travel_time : float = - 1
872872
873873 #状態:home, wait, run,end
874874 s .state : str = "home"
@@ -2291,7 +2291,7 @@ def check_simulation_ongoing(W) -> bool:
22912291 Returns 1 if the simulation is ongoing and has not reached its final time.
22922292 """
22932293 if W .finalized == 0 :
2294- return 1
2294+ return True
22952295 return W .T <= W .TSIZE - 1
22962296
22972297 def simulation_terminated (W ):
@@ -2357,7 +2357,7 @@ def get_link(W, link:str|Link) -> Link:
23572357 return W .LINKS_NAME_DICT [link ]
23582358 raise Exception (f"'{ link } ' is not Link in this World" )
23592359
2360- def get_nearest_node (W , x :float , y :float ) -> Node :
2360+ def get_nearest_node (W , x :float , y :float ) -> Node | None :
23612361 """
23622362 Get the nearest node to the given coordinates.
23632363
0 commit comments