-
|
The grid2op document introduces the use of the ‘redispatch’ action to adjust the active power of generators. However, I also need to adjust the voltage of the generators in the Agent. How can I achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Hello, We did not focus the creation of our environment toward voltages. One of the reasons is when using "simple" power flow like pandapower or lightsim2grid the voltages are not perfectly modeled (the fidelity is pretty low). However, it's feasible in grid2op to have full control over generators voltage setpoints. The syntax is not "user friendly" and you can do it like: env.action_space({"injection": {"prod_v" : the_setpoint_vector}})(Or something similar, I did not had time to check using a grid2op environment) You might need to create the environment is another action_class if the above action raise an exception like "ambiguous action, impossible to set the generator action with this action type" or something similar, again I did not check with grid2op. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you, but this method doesn't seem to work. My test code is as follows: import grid2op
import numpy as np
from grid2op.Action import BaseAction
env_name = "l2rpn_case14_sandbox"
env = grid2op.make(env_name, action_class=BaseAction)
#do nothing
act = env.action_space() #do nothing
obs, reward, done, info = env.step(act)
print("load_p at time step 0: {}".format(obs.load_p))
print("gen_p at time step 0: {}".format(obs.gen_p))
print("gen_v at time step 0: {}".format(obs.gen_v))
print("\n")
#try to change the voltage of Generator 0, but no response was observed
new_prod_v = [150.0, 142.1, 22., 22., 13.200001, 142.1]
modify_prod_v_value = env.action_space({"injection": {"prod_v": new_prod_v}})
print(modify_prod_v_value)
obs, reward, done, info = env.step(modify_prod_v_value)
print("load_p at time step 1: {}".format(obs.load_p))
print("gen_p at time step 1: {}".format(obs.gen_p))
print("gen_v at time step 1: {}".format(obs.gen_v))
print(f"Is the environment done?: {done}")
print("\n")The console output is: This action will: |
Beta Was this translation helpful? Give feedback.
-
|
Hello, You are correct, this way was not possible due to different things (including a bug). I added a convient class and fixed the bug in this PR: I will deploy the fix on pypi (as soon as the PR is merged) and you will be able to install it with:
(the fix will be part of the next grid2op version, but I don't really know when it will be released, so if you are in a hurry I would suggest to use the development version that will be on pypi). EDIT The grid2op version 1.12.2.dev0 is not available on pypi at: https://pypi.org/project/grid2op/1.12.2.dev0/ Once you have the correct version, you will be able to do what you want with import grid2op
import numpy as np
from grid2op.Action import BaseAction
from grid2op.VoltageControler import VCFromFileAgentOverrides
env_name = "l2rpn_case14_sandbox"
env = grid2op.make(env_name,
action_class=BaseAction,
voltagecontroler_class=VCFromFileAgentOverrides)
obs = env.reset(seed=0, options={"time serie id": 0})
new_prod_v = 1.0 * obs.gen_v
new_prod_v[0] = 150.
modify_prod_v_value = env.action_space({"injection": {"prod_v": new_prod_v}})
obs, reward, done, info = env.step(modify_prod_v_value)
print(obs.gen_v)And it should work :-) Let me know if you have any other issues |
Beta Was this translation helpful? Give feedback.
Hello,
You are correct, this way was not possible due to different things (including a bug).
I added a convient class and fixed the bug in this PR:
#729
I will deploy the fix on pypi (as soon as the PR is merged) and you will be able to install it with:
(the fix will be part of the next grid2op version, but I don't really know when it will be released, so if you are in a hurry I would suggest to use the development version that will be on pypi).
EDIT The grid2op version 1.12.2.dev0 is not available on pypi at: https://pypi.org/project/grid2op/1.12.2.dev0/
Once you have the correct version, you will be able to do what you want with