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 lmp_sced to after_operations_callback #132

Merged
merged 3 commits into from
Jan 19, 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
15 changes: 12 additions & 3 deletions prescient/plugins/plugin_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,20 @@ def register_before_operations_solve_callback(

def register_after_operations_callback(
self,
callback: Callable[[Options, Simulator, OperationsModel], None]
callback: Callable[[Options, Simulator, OperationsModel, OperationsModel], None]
) -> None:
''' Register a callback to be called after the operations model has been created and
solved, but before the LMP has been solved, and before statistics have been
collected.
solved, before statistics have been collected.

The callback will be called with the following arguments:
options:Options
The options used for this simulation run
simulator:Simulator
The simulator managing the simulation and its data
sced:OperationsModel
The operations model that was just solved
lmp_sced:OperationsModel
The solved LMP model for the operations model that was just solved
'''
self.callback_manager.register_after_operations_callback(callback)

Expand Down
2 changes: 1 addition & 1 deletion prescient/simulator/oracle_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def call_operation_oracle(self, options: Options, time_step: PrescientTime):
lmp_sced = self.engine.create_and_solve_lmp(options, current_sced_instance)

self.data_manager.apply_sced(options, current_sced_instance)
self.simulator.callback_manager.invoke_after_operations_callbacks(options, self.simulator, current_sced_instance)
self.simulator.callback_manager.invoke_after_operations_callbacks(options, self.simulator, current_sced_instance, lmp_sced)

ops_stats = self.simulator.stats_manager.collect_operations(current_sced_instance,
solve_time,
Expand Down
2 changes: 1 addition & 1 deletion tests/simulator_tests/test_cases/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def before_operations_solve_callback(options, simulator, sced_model):
msg('before_operations_solve_callback', plugin_config)
context.register_before_operations_solve_callback(before_operations_solve_callback)

def after_operations_callback(options, simulator, sced_model):
def after_operations_callback(options, simulator, sced_model, lmp_model):
msg('after_operations_callback', plugin_config)
context.register_after_operations_callback(after_operations_callback)

Expand Down