Skip to content

Conversation

Yasharzf
Copy link
Collaborator

@Yasharzf Yasharzf commented May 9, 2020

Pull request information

  • Status: ready to merge
  • Kind of changes: bug fix
  • Related PR or issue:

Description

In vehicle/traci, we are storing all departed and arrived vehicle IDs for each simulation step. Every simulation step we are appending new vehicle list to _departed_ids and _arrived_ids. In large networks or high horizon times, this can be expensive and results in significant slow down. I changed _departed_ids and _arrived_ids to just store the current ids. I didn't totally delete them since we may need them (e.g., as in MultiEnv)

"""See parent class."""
if len(self._arrived_ids) > 0:
return self._arrived_ids[-1]
return self._arrived_ids
Copy link
Member

Choose a reason for hiding this comment

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

why this change? this affects a lot of the codebase. Otherwise LGTM

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

self._arrived_ids was a list storing ids for each step. in this function we just want the ids in the last step ([-1]). Since I don't have a list anymore, I deleted [-1].

Copy link
Member

Choose a reason for hiding this comment

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

So if it's not a list anymore why does it have a len method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good catch!

"""See parent class."""
if len(self._departed_ids) > 0:
return self._departed_ids[-1]
return self._departed_ids
Copy link
Member

Choose a reason for hiding this comment

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

same here

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5866

  • 9 of 10 (90.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 89.554%

Changes Missing Coverage Covered Lines Changed/Added Lines %
flow/core/kernel/vehicle/traci.py 9 10 90.0%
Totals Coverage Status
Change from base Build 5855: 0.02%
Covered Lines: 9439
Relevant Lines: 10540

💛 - Coveralls

Comment on lines +214 to +215
self._num_departed.append(sim_obs[tc.VAR_LOADED_VEHICLES_NUMBER])
self._num_arrived.append(sim_obs[tc.VAR_ARRIVED_VEHICLES_NUMBER])
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

Copy link
Member

@eugenevinitsky eugenevinitsky left a comment

Choose a reason for hiding this comment

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

LGTM

@eugenevinitsky eugenevinitsky merged commit 7398f50 into master May 9, 2020
brentgryffindor pushed a commit that referenced this pull request May 18, 2020
* changed _departed_ids, and _arrived_ids in the update function

* fixed bug in get_departed_ids and get_arrived_ids
liljonnystyle pushed a commit that referenced this pull request May 26, 2020
* changed _departed_ids, and _arrived_ids in the update function

* fixed bug in get_departed_ids and get_arrived_ids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants