-
Notifications
You must be signed in to change notification settings - Fork 54
Environments
class environments.var_voltage_control.VoltageControl(args)
This class includes the following methods.
def reset(self, reset_time=True)
is the function that resets the state of the environment. If reset_time=True
, each time the reset will randomly select a date from the dataset.
def manual_reset(self, day, hour, interval)
is the function that manually reset the environment with the assigned day, hour and interval. E.g., if you would reset the environment on 365 days, 11 hours and 15 mins starting from the initial date in the dataset, it should be manual_reset(365, 11, 5)
.
def step(self, actions, add_noise=True)
is the function that yields the reward, termination_flag and info according to the current state and actions. actions
is the vector of agents' actions. If add_noise=True
, the observations will be added truncated Gaussian noise with no negative samples accepted.
def get_state(self)
is the function that gets the next state after step
or reset
.
def get_obs(self)
is the function that gets the (partial) observations of agents after step
or reset
.
def get_obs_agent(self, agent_id)
is the function that gets an agent's observation according to the agent ID.
def get_obs_size(self)
is the function that returns the observation size.
def get_state_size(self)
is the function that returns the state size.
def get_action(self)
is the function that returns a randomly sampled agents' actions.
def get_total_actions(self)
is the function that returns the cardinality of the action set of each agent. If the decentralised mode is applied, then the action set of each agent would be the outputs of all PVs and the actual action would be obtained by masks. If the distributed mode is applied, then the action set of each agent would be the output of 1 PV.
def get_avail_actions(self)
is the function that returns the vector of available actions for agents.
def get_avail_agent_actions(self, agent_id)
is the function that returns the available action for an agent.
def get_num_of_agents(self)
is the function that returns the number of agents.
def _get_voltage(self)
is the function that returns the voltages of all buses.
def _create_basenet(self, base_net)
is the function that creates an instance of a power network specified by base_net
.
def _select_start_hour(self)
is the function that selects the initial hour for each episode.
def _select_start_interval(self)
is the function that selects the initial interval (resolution) for each episode.
def _select_start_day(self)
is the function that selects the initial day for each episode.
def _load_network(self)
is the function that loads a power network.
def _load_pv_data(self)
is the function that loads PV data.
def _load_active_demand_data(self)
is the function that loads the active demand data.
def _load_reactive_demand_data(self)
is the function that loads the reactive demand data.
def _get_episode_pv_history(self)
is the function that returns an episode of PV data.
def _get_episode_active_demand_history(self)
is the function that returns an episode of active demand data.
def _get_episode_reactive_demand_history(self)
is the function that returns an episode of reactive demand data.
def _get_pv_history(self)
is the function that returns the history of PV. The default history length is 1 that means only the observation for the current time step is available.
def _get_active_demand_history(self)
is the function that returns the history of active demand. The default history length is 1 that means only the observation for the current time step is available.
def _get_reactive_demand_history(self)
is the function that returns the history of reactive demand. The default history length is 1 that means only the observation for the current time step is available.
def _set_demand_and_pv(self, add_noise=True)
is the function that sets the demand and PV according to the current time step. If add_noise=True
, a random noise is added to the observation.
def _set_reactive_power_boundary(self)
is the function that sets the reactive power boundry for each PV. Since the PV active power dynamically changes, the reactive power boundary also dynamically changes at each time step.
def _get_clusters_info(self)
is the function that returns the dictionary that mapping each agent to the related information it can know within the region where it is included.
def _take_action(self, actions)
is the function that takes the agents' actions and solves the power flow equation.
def _clip_reactive_power(self, reactive_actions, active_power)
is the function that returns constrained reactive power of each agent based on the action (i.e. the percentage of reactive PV power) and the current active PV power.
def _calc_reward(self, info={})
is the function that returns the reward for the current state and actions.
def _get_res_bus_v(self)
is the function that returns the voltages of buses after solving the power flow equation.
def _get_res_bus_active(self)
is the function that returns the active power of each bus after sovling the power flow equation.
def _get_res_bus_reactive(self)
is the function that returns the reactive power of each bus after solving the power flow equation.
def _get_res_line_loss(self)
is the function that returns the power loss (or line loss) after solving the power flow equation.
def _get_sgen_active(self)
is the function that returns the active power of each PV after solving the power flow equation.
def _get_sgen_reactive(self)
is the function that returns the reactive power of each PV after solving the power flow equation.
def render(self, mode="human")
is the function that renders the power network at each time step.
We implement 5 voltage barrier functions that are for evaluating the violance of voltages.
def environments.var_voltage_control.voltage_barrier.bowl.bowl(vs, v_ref=1.0, scale=.1)
is the function of the bowl-shape voltage barrier. vs
are an array of voltages. v_ref
and scale
are 2 hyperparameters that control the shape of the embedded Gaussian.
def environments.var_voltage_control.voltage_barrier.bump.bump(vs)
is the function of the bump-shape voltage barrier. vs
are an array of voltages.
def environments.var_voltage_control.voltage_barrier.courant_beltrami.courant_beltrami(vs, v_lower=0.95, v_upper=1.05)
is the function of the courant-beltrami-shape voltage barrier. vs
are an array of voltages. v_lower
and v_upper
are 2 hyperparameters that control the safety range of voltages.
def environments.var_voltage_control.voltage_barrier.l1.l1(vs, v_ref=1.0)
is the function of the l1-shape voltage barrier. vs
are an array of voltages. v_ref
is the reference voltage.
def environments.var_voltage_control.voltage_barrier.l2.l2(vs, v_ref=1.0)
is the function of the l2-shape voltage barrier. vs
are an array of voltages. v_ref
is the reference voltage.
If you would add new barrier functions, you should write a .py
file including a voltage varrier function that can process an arrary of voltages. Then, register the new barrier function in the voltage_barrier_registry.py
. E.g.,
from .bowl import bowl
from .bump import bump
from .courant_beltrami import courant_beltrami
from .l1 import l1
from .l2 import l2
from .[your voltage barrier] import [your voltage barrier]
Voltage_Barrier = dict(
l1=l1,
l2=l2,
bowl=bowl,
bump=bump,
courant_beltrami=courant_beltrami,
[your voltage barrier]=[your voltage barrier]
)