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

feature: add usage forecast #906

Merged
merged 34 commits into from Dec 19, 2023
Merged

Conversation

victorgarcia98
Copy link
Contributor

@victorgarcia98 victorgarcia98 commented Nov 22, 2023

Description

The usage forecast is passed as a new column of the device constraints and later incorporated as a Pyomo parameter. This parameter is used in the device_bounds constraint as an extra component. Multiple components can be defined in the flex-model using the QuantityOrSensor syntax:

  1. Sensor
{
    "usage-forecast" : [
        {"sensor" : 1},
        {"sensor" : 2}
    ]
}
  1. Constant value
{
    "usage-forecast" : [
        "10 kWh",
        "40 kWh",
    ]
}

Further Improvements

  • Revise/Test definition of capacity_in_mw. For example, using a capacity of 2MW, allowed me to charge 2MWh every 15min block while it should be 500kWh.

TODOs

  • Add field to API docstring
  • Add field to documentation
  • Use field consumption_is_positive. By default, the usage forecast sign interpretation is (+) increase stock level (-) decrease stock level.

Related Items


  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
flexmeasures/data/models/planning/linear_optimization.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/linear_optimization.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/storage.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/tests/conftest.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/storage.py Outdated Show resolved Hide resolved
Flix6x and others added 3 commits November 24, 2023 09:54
* refactor: fix spelling

Signed-off-by: F.N. Claessen <felix@seita.nl>

* style: missing type annotation

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: method and variable renaming

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: add test case explanations

Signed-off-by: F.N. Claessen <felix@seita.nl>

---------

Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
* refactor: fix spelling

Signed-off-by: F.N. Claessen <felix@seita.nl>

* style: missing type annotation

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: method and variable renaming

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: add test case explanations

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: separate logic for falling back on a default attribute and applying a maximum capacity limit

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: fill gaps in capacity sensor data using the max_value rather than with the fallback

Signed-off-by: F.N. Claessen <felix@seita.nl>

* fix: type annotation (see https://docs.python.org/3/library/typing.html#typing.Optional)

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: clearly separate steps of falling back and performing a nanmin

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: simplify and have get_quantity_from_attribute return a Quantity, as its name already suggested

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: switch argument order

Signed-off-by: F.N. Claessen <felix@seita.nl>

* refactor: update docstring

Signed-off-by: F.N. Claessen <felix@seita.nl>

* style: flake8

Signed-off-by: F.N. Claessen <felix@seita.nl>

---------

Signed-off-by: F.N. Claessen <felix@seita.nl>
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

Please remind me: do we still have an unresolved issue in terms of having a test pass that we expected to fail (because of an unsustainable usage forecast)?

flexmeasures/data/models/planning/linear_optimization.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/linear_optimization.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/storage.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/tests/test_solver.py Outdated Show resolved Hide resolved
@Flix6x
Copy link
Contributor

Flix6x commented Dec 4, 2023

Will you tackle the todos in this PR or as a follow-up?

@victorgarcia98
Copy link
Contributor Author

Please remind me: do we still have an unresolved issue in terms of having a test pass that we expected to fail (because of an unsustainable usage forecast)?

Yes, other than adding a resampling factor for the sensor, the current test should fail as we are providing the value power_capacity as the energy value to each 15min interval..

…ery-power-capacity-as-sensor

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

Awesome. Now it clicks. I only request documentation edits, including the changelog entry of course.

flexmeasures/data/models/planning/storage.py Outdated Show resolved Hide resolved
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

Still missing the changelog entry.

flexmeasures/data/models/planning/tests/conftest.py Outdated Show resolved Hide resolved
@Flix6x Flix6x added this to the 0.18.0 milestone Dec 18, 2023
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Base automatically changed from feature/planning/battery-power-capacity-as-sensor to main December 19, 2023 08:55
victorgarcia98 and others added 2 commits December 19, 2023 09:57
Signed-off-by: Victor <victor@seita.nl>
Fix typo (*los componentes*) and swap out some changelog entries between Features and Infrastructure.

Signed-off-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
@Flix6x
Copy link
Contributor

Flix6x commented Dec 19, 2023

Black is failing after your last merge. Feel free to merge after resolving.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
@victorgarcia98 victorgarcia98 merged commit 5576b56 into main Dec 19, 2023
8 of 9 checks passed
@victorgarcia98 victorgarcia98 deleted the feature/planning/usage-forecast branch December 19, 2023 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants