diff --git a/prescient/engine/egret/egret_plugin.py b/prescient/engine/egret/egret_plugin.py index 8dd5101..e852e94 100644 --- a/prescient/engine/egret/egret_plugin.py +++ b/prescient/engine/egret/egret_plugin.py @@ -105,6 +105,7 @@ def _zero_out_costs(sced_model, hours_in_objective): # TBD - we probably want to grab topology from somewhere, even if the stochastic # RUC is not solved with the topology. def create_sced_instance(data_provider:DataProvider, + when: datetime.datetime, current_state:SimulationState, options, sced_horizon, @@ -239,6 +240,12 @@ def create_sced_instance(data_provider:DataProvider, # make sure the generator can immediately turn off g_dict['shutdown_capacity'] = max(g_dict['shutdown_capacity'], (60./current_state.minutes_per_step)*g_dict['initial_p_output'] + 1.) + # Set the time keys + timekey_array = sced_md.data['system']['time_keys'] + for t in range(sced_horizon): + dt = when + datetime.timedelta(minutes=t*current_state.minutes_per_step) + timekey_array[t] = dt.strftime('%Y-%m-%d %H:%M') + return sced_md # cache for shutdown curves diff --git a/prescient/engine/egret/engine.py b/prescient/engine/egret/engine.py index 2f1fcbe..b6ba408 100644 --- a/prescient/engine/egret/engine.py +++ b/prescient/engine/egret/engine.py @@ -133,6 +133,7 @@ def create_simulation_actuals( def create_sced_instance(self, options: Options, + when: datetime.datetime, current_state: SimulationState, hours_in_objective: int, sced_horizon: int, @@ -143,6 +144,7 @@ def create_sced_instance(self, current_sced_instance = self._p.create_sced_instance( self._data_provider, + when, current_state, options, sced_horizon, diff --git a/prescient/engine/modeling_engine.py b/prescient/engine/modeling_engine.py index ffb8395..fe3a9e3 100644 --- a/prescient/engine/modeling_engine.py +++ b/prescient/engine/modeling_engine.py @@ -95,6 +95,7 @@ def create_simulation_actuals( @abstractmethod def create_sced_instance(self, options: Options, + when: datetime.datetime, current_state: SimulationState, hours_in_objective: int, sced_horizon: int, diff --git a/prescient/simulator/oracle_manager.py b/prescient/simulator/oracle_manager.py index 54929c3..984bdb9 100644 --- a/prescient/simulator/oracle_manager.py +++ b/prescient/simulator/oracle_manager.py @@ -46,7 +46,7 @@ def _get_uc_activation_time(self, options, time_step): ruc_delay = self._get_ruc_delay(options) activation_time = time_step.datetime + timedelta(hours=ruc_delay) - return (activation_time.hour, activation_time.date()) + return activation_time def _get_projected_state(self, options: Options, time_step: PrescientTime) -> SimulationState: ''' Get the simulation state as we project it will appear after the RUC delay ''' @@ -59,10 +59,10 @@ def _get_projected_state(self, options: Options, time_step: PrescientTime) -> Si print("Drawing UC initial conditions for date:", time_step.date, "hour:", time_step.hour, "from prior SCED instance.") return self.data_manager.current_state - uc_hour, uc_date = self._get_uc_activation_time(options, time_step) + act_time = self._get_uc_activation_time(options, time_step) print("") - print("Creating and solving SCED to determine UC initial conditions for date:", str(uc_date), "hour:", uc_hour) + print("Creating and solving SCED to determine UC initial conditions for date:", str(act_time.date()), "hour:", act_time.hour) # determine the SCED execution mode, in terms of how discrepancies between forecast and actuals are handled. # prescient processing is identical in the case of deterministic and stochastic RUC. @@ -81,6 +81,7 @@ def _get_projected_state(self, options: Options, time_step: PrescientTime) -> Si current_state = self.data_manager.current_state.get_state_with_step_length(60) projected_sced_instance = self.engine.create_sced_instance( options, + act_time, current_state, hours_in_objective=min(24, current_state.timestep_count), sced_horizon=min(24, current_state.timestep_count), @@ -129,8 +130,8 @@ def call_planning_oracle(self, options: Options, time_step: PrescientTime) -> No ''' Create a new RUC and make it the pending RUC ''' projected_state = self._get_projected_state(options, time_step) - uc_hour, uc_date = self._get_uc_activation_time(options, time_step) - self._generate_pending_ruc(options, uc_date, uc_hour, projected_state) + act_time = self._get_uc_activation_time(options, time_step) + self._generate_pending_ruc(options, act_time.date(), act_time.hour, projected_state) def _formulate_ruc(self, options, uc_date, uc_hour, sim_state_for_ruc): '''Create a RUC model holding forecast data. @@ -251,6 +252,7 @@ def call_operation_oracle(self, options: Options, time_step: PrescientTime): sced_horizon_timesteps = options.sced_horizon current_sced_instance = self.engine.create_sced_instance( options, + time_step.datetime, self.data_manager.current_state.get_state_with_step_length(options.sced_frequency_minutes), hours_in_objective=1, sced_horizon=sced_horizon_timesteps,