-
Notifications
You must be signed in to change notification settings - Fork 21
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
Feature/gsye 766 #1798
Merged
Merged
Feature/gsye 766 #1798
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bc3b6e6
GSYE-766: Added non-p2p handling
hannesdiedrich 6104c6d
GSYE-766: Fix NonP2PHandler: - adapt _is_home_area to actual scenario…
hannesdiedrich d122934
Merge branch 'master' into feature/GSYE-766
hannesdiedrich 50006bb
GSYE-766: Remove unneeded print
hannesdiedrich f442047
Merge branch 'feature/GSYE-766' of github.com:gridsingularity/gsy-e i…
hannesdiedrich 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 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 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,54 @@ | ||
from gsy_framework.constants_limits import GlobalConfig | ||
from gsy_framework.exceptions import GSyException | ||
|
||
|
||
class NonP2PHandler: | ||
"""Handles non-p2p case""" | ||
|
||
def __init__(self, scenario: dict): | ||
self.non_p2p_scenario = scenario | ||
self._energy_sell_rate = 0.0 | ||
self._energy_buy_rate = 0.0 | ||
self._get_energy_rates_from_infinite_bus(scenario) | ||
self._handle_non_p2p_scenario(scenario) | ||
|
||
def _get_energy_rates_from_infinite_bus(self, scenario: dict): | ||
for child in scenario["children"]: | ||
if child.get("type") == "InfiniteBus": | ||
self._energy_buy_rate = child.get("energy_buy_rate", GlobalConfig.FEED_IN_TARIFF) | ||
self._energy_sell_rate = child.get( | ||
"energy_sell_rate", GlobalConfig.MARKET_MAKER_RATE | ||
) | ||
return | ||
|
||
raise GSyException( | ||
"For non-p2p simulation, an InfiniteBus has to be present in the first " | ||
"level of the configuration tree." | ||
) | ||
|
||
@staticmethod | ||
def _is_home_area(area: dict): | ||
return area.get("children") and all( | ||
child.get("type", None) for child in area.get("children") | ||
) | ||
|
||
def _add_market_maker_to_home(self, area: dict): | ||
if "children" not in area or not area["children"]: | ||
return | ||
if not self._is_home_area(area): | ||
return | ||
area["children"].append( | ||
{ | ||
"name": "MarketMaker", | ||
"type": "InfiniteBus", | ||
"energy_buy_rate": self._energy_buy_rate, | ||
"energy_sell_rate": self._energy_sell_rate, | ||
} | ||
) | ||
|
||
def _handle_non_p2p_scenario(self, area: dict): | ||
if "children" not in area or not area["children"]: | ||
return | ||
self._add_market_maker_to_home(area) | ||
for child in area["children"]: | ||
self._handle_non_p2p_scenario(child) |
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now this is good. However, keep in mind that in the future we might need to set different energy rates per home. We will deal with it when we need it though, nothing to do for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, having different rates per home will lead to more changes anyway. Let's deal with this then. Thanks for pointing out though.