-
Notifications
You must be signed in to change notification settings - Fork 23
Feature/greedy priority algorithm #196
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
Open
carlossg
wants to merge
7
commits into
jmcollin78:main
Choose a base branch
from
carlossg:feature/greedy-priority-algorithm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
70f7206
feat: add greedy priority algorithm with load shedding support
carlossg da70a87
fix: allowed_power_overage_percent, greedy excess formula, SA test co…
carlossg d4ed0e2
docs: add algorithm comparison findings
carlossg d2e5690
refactor: remove can_be_shed option
carlossg b4d3639
Merge branch 'jmcollin78:main' into feature/greedy-priority-algorithm
carlossg 2a65382
fix: read actual power from sensor for non-can_change_power devices
carlossg 006edea
refactor: rename algorithm entrypoint and apply overage tolerance in SA
carlossg 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| """Protocol definition for Solar Optimizer algorithms.""" | ||
|
|
||
| from typing import Protocol, runtime_checkable | ||
|
|
||
| from .managed_device import ManagedDevice | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class SolarOptimizerAlgorithm(Protocol): | ||
| """Protocol that all optimization algorithms must implement.""" | ||
|
|
||
| def optimize( | ||
| self, | ||
| devices: list[ManagedDevice], | ||
| power_consumption: float, | ||
| solar_power_production: float, | ||
| allowed_power_overage: float, | ||
| sell_cost: float, | ||
| buy_cost: float, | ||
| sell_tax_percent: float, | ||
| battery_soc: float, | ||
| priority_weight: int, | ||
| ) -> tuple[list[dict], float, float]: | ||
| """Run one optimization cycle. | ||
|
|
||
| Args: | ||
| devices: list of managed devices to optimize | ||
| power_consumption: current net grid consumption in W (including battery charge) | ||
| solar_power_production: current solar production in W | ||
| allowed_power_overage: max W of grid import allowed to turn on a device (Greedy only) | ||
| sell_cost: grid sell price in €/kWh | ||
| buy_cost: grid buy price in €/kWh | ||
| sell_tax_percent: tax applied to sold energy (%) | ||
| battery_soc: battery state of charge 0-100 | ||
| priority_weight: how much device priority influences decisions (0-100) | ||
|
|
||
| Returns: | ||
| (solution, objective, total_power): | ||
| solution: list of device dicts with at minimum 'name', 'state', 'requested_power' | ||
| objective: scalar cost metric (lower = better) | ||
| total_power: total W consumed by active devices in solution | ||
| """ | ||
| ... |
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
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.