davidusb-geek / emhass

emhass: Energy Management for Home Assistant, is a Python module designed to optimize your home energy interfacing with Home Assistant.
MIT License
284 stars 54 forks source link

Update optimization.py #135

Closed michaelpiron closed 9 months ago

michaelpiron commented 9 months ago

Implemented changes:

To resolve following issue:

While looking at the code in order to understand the functioning of EMHASS, I noticed an inconsistency in the objective formulas. The profit cost function shows this: https://github.com/davidusb-geek/emhass/blob/bec6f76f1d7795a1ab8730fb0a61f883e75caf0c/src/emhass/optimization.py#L196-L204 which looks correct, and is consistent with the EMHASS documentation:

However, the "grid cost" cost function seems to have the formulas inverted, which is unexpected: https://github.com/davidusb-geek/emhass/blob/bec6f76f1d7795a1ab8730fb0a61f883e75caf0c/src/emhass/optimization.py#L205-L211

Therefore, I wonder if the objective formulas in "Grid cost" cost function shouldn't be inverted.

michaelpiron commented 9 months ago

For the sake of clarity: I didn't test these changes, as I don't have my dev space/container set up yet. I hope someone else can test this. On the other hand, the proposed changes are limited.

codecov[bot] commented 9 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (bec6f76) 88.16% compared to head (d77c4f6) 88.11%.

Files Patch % Lines
src/emhass/optimization.py 60.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #135 +/- ## ========================================== - Coverage 88.16% 88.11% -0.06% ========================================== Files 6 6 Lines 1420 1422 +2 ========================================== + Hits 1252 1253 +1 - Misses 168 169 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.