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

WIP: Flexibile Loads #628

Closed
wants to merge 40 commits into from
Closed

Conversation

DEUCE1957
Copy link
Contributor

@DEUCE1957 DEUCE1957 commented Jul 23, 2024

Attempt to extend Redispatching by enabling Environment's to have flexible loads. See "getting_started" / "12_Flexibility.ipynb" for example use. Related to issue #623 (will move onto load / generator shedding once this works).

Currently working:

  1. Able to define "flexibility" actions (env.action_space({"flexibility":[("load_0_0", 0.1]}) with correct print string for BaseAction
  2. Able to load flexible load attributes from "flex_loads_charac.csv"
  3. "InvalidFlexibility" error if flexibility exceeds size of load
  4. Observable change in load after executing flexibility action in environment
  5. Integration with redispatch routine (flexibility and redispatch are solved together in one optim. problem)
  6. Observable change in actual/target flexibility after executing flexibility action in environment
  7. Automated tests

Conventions:
Positive flexibility: Reduce consumption (less demand in the grid)
Negative flexibility: Increase consumption (more demand in the grid)
target_flex: Sum of all flexibility at a load
actual_flex: Sum of all physically feasible flexibility at a load (determined by Environment)

@DEUCE1957 DEUCE1957 marked this pull request as draft July 23, 2024 15:37
@DEUCE1957 DEUCE1957 marked this pull request as ready for review September 23, 2024 08:42
@DEUCE1957
Copy link
Contributor Author

DEUCE1957 commented Sep 23, 2024

Most tests passing now, remaining error (in ci/circleci:test) appears to be from CI itself:

ERROR: test_alert_gym_compat (unittest.loader._FailedTest)
----------------------------------------------------------------------
AttributeError: type object '_FailedTest' has no attribute 'test_alert_gym_compat'

----------------------------------------------------------------------

Appreciate any review / feedback to solve this @BDonnot

@BDonnot
Copy link
Collaborator

BDonnot commented Oct 2, 2024

Hello,

Sorry for the delay.

This is so weird. I'll check the CI ASAP

@BDonnot
Copy link
Collaborator

BDonnot commented Oct 3, 2024

Hello,

I think the CI is working on the dev_1.10.4 now, can you synch and see if it solves your issue ?

@DEUCE1957
Copy link
Contributor Author

DEUCE1957 commented Oct 4, 2024

Afraid I am still getting the same error as above for the CI. @BDonnot

"1. **End of Chronics**: The agent reaches the end of the chronics (timeseries) for an Episode (no more data => scenario ends)\n",
"2. **Disconnected Generator / Load**: A load, generator is disconnected from the grid. This also applies to Energy Storage Systems (ESSs) if they are being controlled (agent told it to charge / discharge some energy)\n",
"3. **Islanding**: The grid splits into multiple parts / islands. For example, a load of generator is alone on a busbar. \n",
"4. **Powerflow Divergence**: The redispatching routine \"diverges\": this means that Grid2OP is not able to find a setpoint for the generators for which both \"pmin, pmax and the ramps constrained\" as well as the \"load / generator balancing the solver \"diverges\" and is not able to compute the next state (often meaning there are no feasible solutions to the Kirchoff's laws)\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll try to update the doc but actually point 4 above is two different things:

  • either the backend diverge (cannot compute the flows, no feasible solution found)
  • or the "grid2op routine" to compute the "redispatching" fails

It is two distinct things.


import sys
from pathlib import Path
sys.path.append(str(Path(__file__).parent))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would avoid doing that if possible


import sys
from pathlib import Path
sys.path.append(str(Path(__file__).parent))
Copy link
Collaborator

Choose a reason for hiding this comment

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

It was not necessary before, and tests used to pass on the CI, maybe this is what caused the issue. Can you remove all these changes in the test suite and run it again ?

Copy link
Contributor Author

@DEUCE1957 DEUCE1957 Oct 8, 2024

Choose a reason for hiding this comment

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

Trying that now, was a hotfix to get the tests running locally but seems I forgot to remove it later

@BDonnot
Copy link
Collaborator

BDonnot commented Oct 7, 2024

Hi,

I see you added

import sys
from pathlib import Path
sys.path.append(str(Path(__file__).parent))

In a lot of files. That should not be necessary (did not used to be there when tests passed). Have you tried to remove it and see if tests pass ? Maybe you are missing the gym / gymnasium import when you do that (it's in general not a good idea to "mess with" python sys.path, it often leads to weird behaviour). Maybe it's not the cause of the problem, but maybe it is :-)

@BDonnot
Copy link
Collaborator

BDonnot commented Oct 7, 2024

Also (to keep track of it, I noticed it and did not want to "discover this again later")

I think you did not update the https://grid2op.readthedocs.io/en/latest/modeled_elements.html page of the doc nor the https://grid2op.readthedocs.io/en/latest/mdp.html, for example https://grid2op.readthedocs.io/en/latest/mdp.html#action-space or https://grid2op.readthedocs.io/en/latest/mdp.html#state-space

@BDonnot
Copy link
Collaborator

BDonnot commented Oct 10, 2024

Hello,

I fixed the issues caused by the install of gymnasium 1.0 in dev_1.10.4, I think once you'll have synched this will no longer be an issue :-)

Benjamin

@BDonnot BDonnot changed the base branch from dev_1.10.4 to dev_1.11.0 October 15, 2024 12:47
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@DEUCE1957 DEUCE1957 closed this Oct 23, 2024
@DEUCE1957
Copy link
Contributor Author

DEUCE1957 commented Oct 23, 2024

Closing due to migration to dev_1.11.0.
See new Pull Request: #654

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants