Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion flow/core/kernel/simulation/traci.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def pass_api(self, kernel_api):
tc.VAR_TIME_STEP,
tc.VAR_DELTA_T,
tc.VAR_LOADED_VEHICLES_NUMBER,
tc.VAR_DEPARTED_VEHICLES_NUMBER
tc.VAR_DEPARTED_VEHICLES_NUMBER,
tc.VAR_ARRIVED_VEHICLES_NUMBER
])

def simulation_step(self):
Expand Down
27 changes: 10 additions & 17 deletions flow/core/kernel/vehicle/traci.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def __init__(self,

# number of vehicles that entered the network for every time-step
self._num_departed = []
self._departed_ids = []
self._departed_ids = 0

# number of vehicles to exit the network for every time-step
self._num_arrived = []
self._arrived_ids = []
self._arrived_ids = 0
self._arrived_rl_ids = []

# whether or not to automatically color vehicles
Expand Down Expand Up @@ -184,8 +184,8 @@ def update(self, reset):
self.prev_last_lc[veh_id] = -float("inf")
self._num_departed.clear()
self._num_arrived.clear()
self._departed_ids.clear()
self._arrived_ids.clear()
self._departed_ids = 0
self._arrived_ids = 0
self._arrived_rl_ids.clear()
self.num_not_departed = 0

Expand All @@ -211,11 +211,10 @@ def update(self, reset):
self.__vehicles[veh_id]["last_lc"] = self.time_counter

# updated the list of departed and arrived vehicles
self._num_departed.append(
len(sim_obs[tc.VAR_DEPARTED_VEHICLES_IDS]))
self._num_arrived.append(len(sim_obs[tc.VAR_ARRIVED_VEHICLES_IDS]))
self._departed_ids.append(sim_obs[tc.VAR_DEPARTED_VEHICLES_IDS])
self._arrived_ids.append(sim_obs[tc.VAR_ARRIVED_VEHICLES_IDS])
self._num_departed.append(sim_obs[tc.VAR_LOADED_VEHICLES_NUMBER])
self._num_arrived.append(sim_obs[tc.VAR_ARRIVED_VEHICLES_NUMBER])
Comment on lines +214 to +215
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as long as there is a getter for these, this LGTM

self._departed_ids = sim_obs[tc.VAR_DEPARTED_VEHICLES_IDS]
self._arrived_ids = sim_obs[tc.VAR_ARRIVED_VEHICLES_IDS]

# update the number of not departed vehicles
self.num_not_departed += sim_obs[tc.VAR_LOADED_VEHICLES_NUMBER] - \
Expand Down Expand Up @@ -517,10 +516,7 @@ def get_num_arrived(self):

def get_arrived_ids(self):
"""See parent class."""
if len(self._arrived_ids) > 0:
return self._arrived_ids[-1]
else:
return 0
return self._arrived_ids

def get_arrived_rl_ids(self):
"""See parent class."""
Expand All @@ -531,10 +527,7 @@ def get_arrived_rl_ids(self):

def get_departed_ids(self):
"""See parent class."""
if len(self._departed_ids) > 0:
return self._departed_ids[-1]
else:
return 0
return self._departed_ids

def get_num_not_departed(self):
"""See parent class."""
Expand Down