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

Adding methods for initial status for every device #159

Merged
merged 2 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions prescient/data/simulation_state/mutable_simulation_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from types import Iterable, Tuple
from prescient.engine.abstract_types import G, S

from collections import deque
Expand Down Expand Up @@ -69,14 +70,26 @@ def get_initial_generator_state(self, g:G) -> float:
''' Get the generator's state in the previous time period '''
return self._init_gen_state[g]

def get_all_initial_generator_state(self) -> Iterable[Tuple[G,float]]:
''' Get the generator's state in the previous time period for each generator '''
yield from self._init_gen_state.items()

def get_initial_power_generated(self, g:G) -> float:
''' Get how much power was generated in the previous time period '''
return self._init_power_gen[g]

def get_all_initial_power_generated(self) -> Iterable[Tuple[G,float]]:
''' Get how much power was generated in the previous time period for each generator '''
yield from self._init_power_gen.items()

def get_initial_state_of_charge(self, s:S) -> float:
''' Get state of charge in the previous time period '''
return self._init_soc[s]

def get_all_initial_state_of_charge(self) -> Iterable[Tuple[S,float]]:
''' Get state of charge in the previous time period for each storage device '''
yield from self._init_soc.items()

def get_current_actuals(self, forecastable:str) -> float:
''' Get the current actual value for forecastable

Expand Down
15 changes: 15 additions & 0 deletions prescient/data/simulation_state/simulation_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,31 @@ def get_initial_generator_state(self, g:G):
''' Get the generator's state in the previous time period '''
pass

@abstractmethod
def get_all_initial_generator_state(self):
''' Get the generator's state in the previous time period for each generator '''
pass

@abstractmethod
def get_initial_power_generated(self, g:G):
''' Get how much power was generated in the previous time period '''
pass

@abstractmethod
def get_all_initial_power_generated(self):
''' Get how much power was generated in the previous time period for each generator '''
pass

@abstractmethod
def get_initial_state_of_charge(self, s:S):
''' Get state of charge in the previous time period '''
pass

@abstractmethod
def get_all_initial_state_of_charge(self):
''' Get state of charge in the previous time period for each storage device '''
pass

@abstractmethod
def get_current_actuals(self, forecastable:str) -> float:
''' Get the current actual value for a forecastable data item
Expand Down
13 changes: 13 additions & 0 deletions prescient/data/simulation_state/state_with_offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from types import Iterable, Tuple
from prescient.engine.abstract_types import G, S, EgretModel
from prescient.data.simulation_state.simulation_state import SimulationState

Expand Down Expand Up @@ -74,14 +75,26 @@ def get_initial_generator_state(self, g:G):
''' Get the generator's state in the previous time period '''
return self._init_gen_state[g]

def get_all_initial_generator_state(self) -> Iterable[Tuple[G,float]]:
''' Get the generator's state in the previous time period for each generator '''
yield from self._init_gen_state.items()

def get_initial_power_generated(self, g:G):
''' Get how much power was generated in the previous time period '''
return self._init_power_gen[g]

def get_all_initial_power_generated(self) -> Iterable[Tuple[G,float]]:
''' Get how much power was generated in the previous time period for each generator '''
yield from self._init_power_gen.items()

def get_initial_state_of_charge(self, s:S):
''' Get state of charge in the previous time period '''
return self._init_soc[s]

def get_all_initial_state_of_charge(self) -> Iterable[Tuple[S,float]]:
''' Get state of charge in the previous time period for each storage device '''
yield from self._init_soc.items()

def get_current_actuals(self, forecastable:str) -> float:
''' Get the current actual value for a forecastable data item

Expand Down
13 changes: 13 additions & 0 deletions prescient/data/simulation_state/time_interpolated_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from types import Iterable, Tuple
from prescient.engine.abstract_types import G, S

import math
Expand Down Expand Up @@ -122,14 +123,26 @@ def get_initial_generator_state(self, g:G):
''' Get the generator's state in the previous time period '''
return self._inner_state.get_initial_generator_state(g)

def get_all_initial_generator_state(self) -> Iterable[Tuple[G,float]]:
''' Get the generator's state in the previous time period for each generator '''
yield from self._inner_state.get_all_initial_generator_state()

def get_initial_power_generated(self, g:G):
''' Get how much power was generated in the previous time period '''
return self._inner_state.get_initial_power_generated(g)

def get_all_initial_power_generated(self) -> Iterable[Tuple[G,float]]:
''' Get how much power was generated in the previous time period for each generator '''
yield from self._inner_state.get_all_initial_power_generated()

def get_initial_state_of_charge(self, s:S):
''' Get state of charge in the previous time period '''
return self._inner_state.get_initial_state_of_charge(s)

def get_all_initial_state_of_charge(self) -> Iterable[Tuple[S,float]]:
''' Get state of charge in the previous time period for each storage device '''
yield from self._inner_state.get_all_initial_state_of_charge()

def get_current_actuals(self, forecastable:str) -> float:
''' Get the current actual value for a forecastable data item

Expand Down
11 changes: 6 additions & 5 deletions prescient/engine/egret/egret_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,12 @@ def _ensure_contingencies_monitored(options:Options, md:EgretModel, initial_ruc:
def _copy_initial_state_into_model(options:Options,
current_state:SimulationState,
md:EgretModel):
for g, g_dict in md.elements('generator', generator_type='thermal'):
g_dict['initial_status'] = current_state.get_initial_generator_state(g)
g_dict['initial_p_output'] = current_state.get_initial_power_generated(g)
for s,s_dict in md.elements('storage'):
s_dict['initial_state_of_charge'] = current_state.get_initial_state_of_charge(s)
for g, initial_status in current_state.get_all_initial_generator_state():
md.data['elements']['generator'][g]['initial_status'] = initial_status
for g, initial_p_output in current_state.get_all_initial_power_generated():
md.data['elements']['generator'][g]['initial_p_output'] = initial_p_output
for s, initial_state_of_charge in current_state.get_all_initial_state_of_charge():
md.data['elements']['storage'][s]['initial_state_of_charge'] = initial_state_of_charge

def get_attrs_to_price_option(options:Options):
'''
Expand Down
2 changes: 1 addition & 1 deletion prescient/simulator/tests/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def _run_simulator(self):
Prescient().simulate(**options)

# test options are correctly re-freshed, Python, and network
@pytest.mark.xfail(sys.platform == "darwin", reason="unknown -- only seems to fail on GHA")
@pytest.mark.xfail(sys.platform in ("darwin", "win32"), reason="unknown -- only seems to fail on GHA")
class TestSimulatorModRtsGmlcNetwork_python_csv(SimulatorRegressionBase, unittest.TestCase):

def _set_names(self):
Expand Down