Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MPG reward #931

Merged
merged 4 commits into from
May 18, 2020
Merged

Add MPG reward #931

merged 4 commits into from
May 18, 2020

Conversation

eugenevinitsky
Copy link
Member

Adds an MPG and MP-joule reward

Copy link
Collaborator

@Yasharzf Yasharzf left a comment

Choose a reason for hiding this comment

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

in addition to the comments, docstring style should be fixed. pydocstyle test fails

"""Calculate power consumption of a vehicle.
Assumes vehicle is an average sized vehicle.
The power calculated here is the lower bound of the actual power consumed
by a vehicle.
Copy link
Collaborator

Choose a reason for hiding this comment

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

add description of parameters and returns


accel = abs(speed - prev_speed) / env.sim_step

power += M * speed * accel + M * g * Cr * speed + 0.5 * rho * A * Ca * speed ** 3
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you have a reference especially for some of the coefficients (e.g., Cr)? if yes, you can add it to the docstring

Copy link
Member Author

Choose a reason for hiding this comment

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

No, they're from Joy and are custom values

"""Calculate miles per mega-joule of either a particular vehicle or the total average of all the vehilces.
Assumes vehicle is an average sized vehicle.
The power calculated here is the lower bound of the actual power consumed
by a vehicle.
Copy link
Collaborator

Choose a reason for hiding this comment

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

params, returns?

# meters / joule is (v * \delta t) / (power * \delta t)
mpj = speed / power
else:
for veh_id in env.k.vehicle.get_ids():
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't you iterate over vehicle.get_ids() if veh_id is None? here veh_id can be a list, shouldn't you iterate over veh_id list?

"""Calculate mpg of either a particular vehicle or the total average of all the vehilces.
Assumes vehicle is an average sized vehicle.
The power calculated here is the lower bound of the actual power consumed
by a vehicle.
Copy link
Collaborator

Choose a reason for hiding this comment

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

params and returns?

mpj = 0
counter = 0
if not isinstance(veh_id, list):
speed = env.k.vehicle.get_speed(veh_id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens if veh_id is None?

Copy link
Member Author

Choose a reason for hiding this comment

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

that'd be a higher up error. I can add an assert

mpg = 0
counter = 0
if not isinstance(veh_id, list):
speed = env.k.vehicle.get_speed(veh_id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

same, if veh_id is None?

# meters / gallon is (v * \delta t) / (gallons_s * \delta t)
mpg = speed / gallons_per_s
else:
for veh_id in env.k.vehicle.get_ids():
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

@coveralls
Copy link

coveralls commented May 14, 2020

Pull Request Test Coverage Report for Build 5929

  • 6 of 55 (10.91%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.4%) to 89.146%

Changes Missing Coverage Covered Lines Changed/Added Lines %
flow/core/kernel/vehicle/traci.py 2 6 33.33%
flow/core/rewards.py 3 48 6.25%
Totals Coverage Status
Change from base Build 5867: -0.4%
Covered Lines: 9445
Relevant Lines: 10595

💛 - Coveralls

Copy link
Collaborator

@Yasharzf Yasharzf 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 3154f26 into master May 18, 2020
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.

3 participants