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

Changing option for --output-sced-demands to --output-sced-loads. #119

Merged
merged 1 commit into from
Oct 26, 2021
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
6 changes: 3 additions & 3 deletions doc/horse_configurations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Simulator Options:
--plot-individual-generators
--traceback
--output-sced-initial-conditions
--output-sced-demands
--output-sced-loads
--output-sced-solutions
--output-ruc-initial-conditions
--output-ruc-solutions
Expand All @@ -39,9 +39,9 @@ Simulator Options:
--plot-individual-generators
--traceback
--output-sced-initial-conditions
--output-sced-demands
--output-sced-loads
--output-sced-solutions
--output-ruc-initial-conditions
--output-ruc-solutions
--output-ruc-dispatches
--output-directory output_horse_racer/horse2_sim
--output-directory output_horse_racer/horse2_sim
2 changes: 1 addition & 1 deletion examples/prescient_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
" - `--traceback`: If enabled, the simulator will print a trace if it failed.\n",
" - `--random-seed`: Unused currently.\n",
" - `--output-sced-initial-conditions`: Prints the initial conditions for the economic dispatch problem to the screen.\n",
" - `--output-sced-demands`: Prints the demands for the economic dispatch problem to the screen.\n",
" - `--output-sced-loads`: Prints the loads for the economic dispatch problem to the screen.\n",
" - `--output-sced-solutions`: Prints the solution for the economic dispatch problem to the screen.\n",
" - `--output-ruc-initial-conditions`: Prints the initial conditions for the unit commitment problem to the screen.\n",
" - `--output-ruc-solutions`: Prints the commitment solution for the unit commitment problem to the screen.\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ command/exec simulator.py
--num-days=7
--sced-horizon=4
--output-sced-initial-conditions
--output-sced-demands
--output-sced-loads
--output-ruc-initial-conditions
--output-ruc-solutions
--output-solver-logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ command/exec simulator.py
--num-days=364
--sced-horizon=4
--output-sced-initial-conditions
--output-sced-demands
--output-sced-loads
--output-ruc-initial-conditions
--output-ruc-solutions
--output-solver-logs
Expand Down
17 changes: 16 additions & 1 deletion prescient/engine/data_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def get_buses(self, sced: OperationsModel) -> Iterable[B]:
"""Get all buses in the model."""
pass

@abstractmethod
def get_loads(self, sced: OperationsModel) -> Iterable[L]:
"""Get all loads in the model."""
pass

@abstractmethod
def get_transmission_lines(self, sced: OperationsModel) -> Iterable[L]:
"""Get all transmission lines in the model."""
Expand Down Expand Up @@ -123,7 +128,17 @@ def get_power_generated_T0(self, sced: OperationsModel, g: G) -> float:
@abstractmethod
def get_bus_demand(self, sced: OperationsModel, bus: B) -> float:
"""Get the demand at a specific bus."""
pass
pass

@abstractmethod
def get_load_bus(self, sced: OperationsModel, load: L) -> float:
"""Get the bus for a specific load."""
pass

@abstractmethod
def get_load_demand(self, sced: OperationsModel, load: L) -> float:
"""Get the demand for a specific load."""
pass

@abstractmethod
def get_bus_mismatch(self, sced: OperationsModel, bus: B) -> float:
Expand Down
11 changes: 11 additions & 0 deletions prescient/engine/egret/data_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def get_sced_duration_minutes(self, sced: OperationsModel) -> int:
def get_buses(self, sced: OperationsModel) -> Iterable[B]:
return sced.data['elements']['bus'].keys()

def get_loads(self, sced: OperationsModel) -> Iterable[L]:
return sced.data['elements']['load'].keys()

def get_transmission_lines(self, sced: OperationsModel) -> Iterable[L]:
return sced.data['elements']['branch'].keys()

Expand Down Expand Up @@ -205,6 +208,14 @@ def get_bus_demand(self, sced: OperationsModel, bus: B) -> float:
''' get the demand on a bus in a given time period '''
return sced.data['elements']['bus'][bus]['pl']['values'][0]

def get_load_bus(self, sced: OperationsModel, load: L) -> float:
''' get the bus associated with a given load '''
return sced.data['elements']['load'][load]['bus']

def get_load_demand(self, sced: OperationsModel, load: L) -> float:
''' get the demand associated with a load in a given time period '''
return sced.data['elements']['load'][load]['p_load']['values'][0]

def get_reserve_RT_price(self, lmp_sced: OperationsModel) -> float:
if 'reserve_price' in lmp_sced.data['system']:
return lmp_sced.data['system']['reserve_price']['values'][0]
Expand Down
29 changes: 18 additions & 11 deletions prescient/engine/egret/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def solve_sced_instance(self,
options,
sced_instance,
output_initial_conditions = False,
output_demands = False,
output_loads = False,
lp_filename: str = None):

ptdf_manager = self._ptdf_manager
Expand All @@ -158,7 +158,7 @@ def solve_sced_instance(self,

self._p._zero_out_costs(pyo_model, self._hours_in_objective)

self._print_sced_info(sced_instance, output_initial_conditions, output_demands)
self._print_sced_info(sced_instance, output_initial_conditions, output_loads)
if options.output_solver_logs:
print("")
print("------------------------------------------------------------------------------")
Expand Down Expand Up @@ -300,16 +300,20 @@ def _transform_for_lmp(self, pyo_model, pyo_solver, lmp_sced_instance):
def _print_sced_info(self,
sced_instance: OperationsSced,
output_initial_conditions: bool,
output_demands: bool):
if not output_initial_conditions and not output_demands:
output_loads: bool):
if not output_initial_conditions and not output_loads:
return

sced_data_extractor = self.operations_data_extractor

# for pretty-printing purposes, compute the maximum bus and generator label lengths.
# for pretty-printing purposes, compute the maximum label lengths for various set types.

buses = list(sced_data_extractor.get_buses(sced_instance))
max_bus_label_length = max((len(this_bus) for this_bus in buses))

loads = list(sced_data_extractor.get_loads(sced_instance))
max_load_label_length = max((len(this_load) for this_load in loads))

lines = list(sced_data_extractor.get_transmission_lines(sced_instance))
if len(lines) == 0:
max_line_label_length = None
Expand All @@ -331,6 +335,7 @@ def _print_sced_info(self,
(len(this_generator) for this_generator in nondispatchable_gens))

if output_initial_conditions:
print("")
print("Initial condition detail (gen-name t0-unit-on t0-power-generated t1-unit-on ):")
for g in thermal_gens:
print(("%-" + str(max_thermal_generator_label_length) + "s %5d %12.2f %5d") %
Expand All @@ -340,12 +345,14 @@ def _print_sced_info(self,
sced_data_extractor.is_generator_on(sced_instance, g),
))

if output_demands:
print("Demand detail:")
for b in buses:
print(("%-" + str(max_bus_label_length) + "s %12.2f") %
(b,
sced_data_extractor.get_bus_demand(sced_instance,b)))
if output_loads:
print("")
print("Load detail (load bus demand):")
for l in loads:
print(("%-" + str(max_load_label_length) + "s %-" + str(max_bus_label_length) + "s %12.2f") %
(l,
sced_data_extractor.get_load_bus(sced_instance,l),
sced_data_extractor.get_load_demand(sced_instance,l)))

print("")
print(("%-" + str(max_bus_label_length) + "s %12.2f") %
Expand Down
2 changes: 1 addition & 1 deletion prescient/engine/modeling_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def solve_sced_instance(self,
options: Options,
sced_instance: OperationsModel,
output_initial_conditions: bool = False,
output_demands: bool = False,
output_loads: bool = False,
lp_filename: str = None
) -> Tuple[OperationsModel, float]:
'''
Expand Down
8 changes: 4 additions & 4 deletions prescient/gosm/horse_configurations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Simulator Options:
--plot-individual-generators
--traceback
--output-sced-initial-conditions
--output-sced-demands
--output-sced-loads
--output-sced-solutions
--output-ruc-initial-conditions
--output-ruc-solutions
Expand All @@ -49,7 +49,7 @@ Simulator Options:
--plot-individual-generators
--traceback
--output-sced-initial-conditions
--output-sced-demands
--output-sced-loads
--output-sced-solutions
--output-ruc-initial-conditions
--output-ruc-solutions
Expand All @@ -76,7 +76,7 @@ Simulator Options:
--plot-individual-generators
--traceback
--output-sced-initial-conditions
--output-sced-demands
--output-sced-loads
--output-sced-solutions
--output-ruc-initial-conditions
--output-ruc-solutions
Expand All @@ -103,7 +103,7 @@ Simulator Options:
--plot-individual-generators
--traceback
--output-sced-initial-conditions
--output-sced-demands
--output-sced-loads
--output-sced-solutions
--output-ruc-initial-conditions
--output-ruc-solutions
Expand Down
6 changes: 3 additions & 3 deletions prescient/gosm/prescient_test.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion prescient/gosm/runcombo.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
--plot-individual-generators
--traceback
--output-sced-initial-conditions
--output-sced-demands
--output-sced-loads
--output-sced-solutions
--output-ruc-initial-conditions
--output-ruc-solutions
Expand Down
4 changes: 2 additions & 2 deletions prescient/simulator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ def register_plugin(key, value):
description="Output sced initial conditions prior to each solve. Default is False.",
)).declare_as_argument()

self.declare("output_sced_demands", ConfigValue(
self.declare("output_sced_loads", ConfigValue(
domain=bool,
default=False,
description="Output sced demands prior to each solve. Default is False.",
description="Output sced loads prior to each solve. Default is False.",
)).declare_as_argument()

self.declare("output_solver_logs", ConfigValue(
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 @@ -223,7 +223,7 @@ def call_operation_oracle(self, options: Options, time_step: PrescientTime):

current_sced_instance, solve_time = self.engine.solve_sced_instance(options, current_sced_instance,
options.output_sced_initial_conditions,
options.output_sced_demands,
options.output_sced_loads,
lp_filename)

pre_quickstart_cache = None
Expand Down
2 changes: 1 addition & 1 deletion tests/simulator_tests/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
'--random-seed=10',
'--output-max-decimal-places=4',
'--output-sced-initial-conditions',
'--output-sced-demands',
'--output-sced-loads',
'--output-sced-solutions',
'--output-ruc-initial-conditions',
'--output-ruc-solutions',
Expand Down