-
Notifications
You must be signed in to change notification settings - Fork 388
Energy class for inventorying multiple energy models #944
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
Merged
Merged
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
8843b3b
New energy class to inventory multiple energy models
liljonnystyle 9bda1eb
revert some inadvertent changes
liljonnystyle 32527f8
revert some inadvertent changes
liljonnystyle 9475e15
Merge branch 'i210_dev' into jc-energy-class
liljonnystyle 1aeb97d
energy.py changed to base_energy.py
joyncarpio eae12b7
update traci.py
joyncarpio 4106217
Energy models for power_demand and toyota
joyncarpio 3e84963
fix typo
liljonnystyle 5398d21
rename get method
liljonnystyle fd4a9cc
Merge branch 'i210_dev' into jc-energy-class
liljonnystyle 5558af0
Update base_energy.py
joyncarpio f82dfb0
Update base_energy.py
joyncarpio 3ad43b4
Update power_demand.py
joyncarpio be2673b
Update toyota_energy.py
joyncarpio 2104764
add get_fuel_consumption() back
liljonnystyle 372335b
remove extra whitespace
liljonnystyle f747be3
Update base_energy.py
joyncarpio 9ae2578
Update power_demand.py
joyncarpio 4461995
Update toyota_energy.py
joyncarpio 23688b2
Update base_energy.py
joyncarpio 0a0de58
Update power_demand.py
joyncarpio c133fb0
Update toyota_energy.py
joyncarpio 81cfba9
Update base_energy.py
joyncarpio b8d2d12
Update rewards.py
joyncarpio d718a33
Update params.py
joyncarpio 4643ed8
Update rewards.py
joyncarpio 26afe67
Update base_energy.py
joyncarpio 994c089
Update power_demand.py
joyncarpio 31ca68f
Update toyota_energy.py
joyncarpio e2d95cd
Create base_energy.py
joyncarpio ddedb95
Create toyota_energy.py
joyncarpio 74382e4
Create power_demand.py
joyncarpio 70e9a4b
Update params.py
joyncarpio f338c4b
Update traci.py
joyncarpio 3d48f15
Update traci.py
joyncarpio 8a0bdee
Update rewards.py
joyncarpio 0e0a6f7
Update traci.py
joyncarpio ef1209b
Delete base_energy.py
liljonnystyle 45d7e4f
Delete power_demand.py
liljonnystyle 6a08833
Delete toyota_energy.py
liljonnystyle 979aa95
Update power_demand.py
joyncarpio 7134153
Update toyota_energy.py
joyncarpio 1089108
Update power_demand.py
joyncarpio ae48511
Update toyota_energy.py
joyncarpio 21e6805
Updated energy model codes
joyncarpio cc5edbd
Update params.py
joyncarpio 695d7c9
Update rewards.py
joyncarpio 6a0208b
Update power_demand.py
joyncarpio 2c9bcaa
Create git push
joyncarpio 8e14083
address pydocstyle and flake8 issues
liljonnystyle 745c2bd
Delete git push
liljonnystyle e3c2a24
rename pkl files
liljonnystyle b495a0c
Merge branch 'jc-energy-class' of https://github.com/flow-project/flo…
liljonnystyle 24b036e
update docstring
liljonnystyle 8416fee
Merge branch 'i210_dev' into jc-energy-class
liljonnystyle 2976f52
Merge branch 'i210_dev' of https://github.com/flow-project/flow into …
liljonnystyle a6ca83a
tweak energy_model default instantiation
liljonnystyle e015769
Merge branch 'i210_dev' of https://github.com/flow-project/flow into …
liljonnystyle 2ce4523
rm empty line
liljonnystyle b7ad0e6
push error handling downstream, fail silently
liljonnystyle c4e7b95
energy model not found error in traci
liljonnystyle b79a696
fix typo
liljonnystyle 627803d
set default energy in global scope
liljonnystyle 2a0ae22
add temporary ray test fix
liljonnystyle b90e43c
implement true mpg correction and mpg reward
liljonnystyle 6bb8fce
add print statement for defaulted energy model
liljonnystyle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Script containing the base vehicle energy class.""" | ||
from abc import ABCMeta, abstractmethod | ||
|
||
|
||
class BaseEnergyModel(metaclass=ABCMeta): | ||
joyncarpio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""Base energy model class. | ||
|
||
Calculate the instantaneous power consumption of a vehicle in | ||
the network. It returns the power in Watts regardless of the | ||
vehicle type: whether EV or Combustion Engine, Toyota Prius or Tacoma | ||
or non-Toyota vehicles. Non-Toyota vehicles are set by default | ||
to be an averaged-size vehicle. | ||
""" | ||
|
||
def __init__(self, kernel): | ||
self.k = kernel | ||
|
||
# 15 kilowatts = 1 gallon/hour conversion factor | ||
self.conversion = 15e3 | ||
|
||
@abstractmethod | ||
def get_instantaneous_power(self, accel, speed, grade): | ||
"""Calculate the instantaneous power consumption of a vehicle. | ||
|
||
Must be implemented by child classes. | ||
|
||
Parameters | ||
---------- | ||
accel : float | ||
Instantaneous acceleration of the vehicle | ||
speed : float | ||
Instantaneous speed of the vehicle | ||
grade : float | ||
Instantaneous road grade of the vehicle | ||
Returns | ||
------- | ||
float | ||
""" | ||
pass | ||
|
||
def get_instantaneous_fuel_consumption(self, accel, speed, grade): | ||
"""Calculate the instantaneous fuel consumption of a vehicle. | ||
|
||
Fuel consumption is reported in gallons per hour, with the conversion | ||
rate of 15kW = 1 gallon/hour. | ||
|
||
Parameters | ||
---------- | ||
accel : float | ||
Instantaneous acceleration of the vehicle | ||
speed : float | ||
Instantaneous speed of the vehicle | ||
grade : float | ||
Instantaneous road grade of the vehicle | ||
Returns | ||
------- | ||
float | ||
""" | ||
return self.get_instantaneous_power(accel, speed, grade) * self.conversion |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.