Skip to content

Commit

Permalink
Updating black and rerunning it on all files
Browse files Browse the repository at this point in the history
  • Loading branch information
ksbeattie committed Mar 29, 2024
1 parent 8948c6c commit 107302c
Show file tree
Hide file tree
Showing 60 changed files with 270 additions and 564 deletions.
1 change: 1 addition & 0 deletions .github/actions/run-examples/examples_for_idaes_ci.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
pytest plugin for testing IDAES "through" IDAES/examples within the IDAES/idaes-pse CI
"""

from contextlib import contextmanager
from dataclasses import dataclass, field
import fnmatch
Expand Down
1 change: 1 addition & 0 deletions .pylint/idaes_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
See #1159 for more information.
"""

from dataclasses import dataclass
import sys
import functools
Expand Down
42 changes: 0 additions & 42 deletions idaes/apps/grid_integration/bidder.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@


class AbstractBidder(ABC):

"""
The abstract class for all the bidder and self-schedulers.
"""

@abstractmethod
def update_day_ahead_model(self, **kwargs):

"""
Update the day-ahead model (advance timesteps) with necessary parameters in kwargs.
Expand All @@ -45,7 +43,6 @@ def update_day_ahead_model(self, **kwargs):

@abstractmethod
def update_real_time_model(self, **kwargs):

"""
Update the real-time model (advance timesteps) with necessary parameters in kwargs.
Expand All @@ -58,7 +55,6 @@ def update_real_time_model(self, **kwargs):

@abstractmethod
def compute_day_ahead_bids(self, date, hour, **kwargs):

"""
Solve the model to bid/self-schedule into the day-ahead market. After solving,
record the schedule from the solve.
Expand All @@ -77,7 +73,6 @@ def compute_day_ahead_bids(self, date, hour, **kwargs):

@abstractmethod
def compute_real_time_bids(self, date, hour, **kwargs):

"""
Solve the model to bid/self-schedule into the real-time market. After solving,
record the schedule from the solve.
Expand All @@ -96,7 +91,6 @@ def compute_real_time_bids(self, date, hour, **kwargs):

@abstractmethod
def write_results(self, path):

"""
This methods writes the saved results into an csv file.
Expand All @@ -109,7 +103,6 @@ def write_results(self, path):

@abstractmethod
def formulate_DA_bidding_problem(self):

"""
Formulate the day-ahead bidding optimization problem by adding necessary
parameters, constraints, and objective function.
Expand All @@ -123,7 +116,6 @@ def formulate_DA_bidding_problem(self):

@abstractmethod
def formulate_RT_bidding_problem(self):

"""
Formulate the real-time bidding optimization problem by adding necessary
parameters, constraints, and objective function.
Expand All @@ -137,7 +129,6 @@ def formulate_RT_bidding_problem(self):

@abstractmethod
def record_bids(self, bids, model, date, hour):

"""
This function records the bids (schedule) and the details in the
underlying bidding model.
Expand All @@ -162,7 +153,6 @@ def generator(self):
return "AbstractGenerator"

def _check_inputs(self):

"""
Check if the inputs to construct the tracker is valid. If not raise errors.
"""
Expand All @@ -172,7 +162,6 @@ def _check_inputs(self):
self._check_solver()

def _check_bidding_model_object(self):

"""
Check if tracking model object has the necessary methods and attributes.
"""
Expand All @@ -198,7 +187,6 @@ def _check_bidding_model_object(self):
)

def _check_n_scenario(self):

"""
Check if the number of LMP scenarios is an integer and greater than 0.
"""
Expand All @@ -215,7 +203,6 @@ def _check_n_scenario(self):
)

def _check_solver(self):

"""
Check if provides solver is a valid Pyomo solver object.
"""
Expand All @@ -227,7 +214,6 @@ def _check_solver(self):


class StochasticProgramBidder(AbstractBidder):

"""
Template class for bidders that use scenario-based stochastic programs.
"""
Expand All @@ -242,7 +228,6 @@ def __init__(
forecaster,
real_time_underbid_penalty,
):

"""
Initializes the stochastic bidder object.
Expand Down Expand Up @@ -313,7 +298,6 @@ def _set_up_bidding_problem(self, horizon):
return model

def formulate_DA_bidding_problem(self):

"""
Set up the day-ahead stochastic programming bidding problems.
Expand All @@ -332,7 +316,6 @@ def formulate_DA_bidding_problem(self):
return model

def formulate_RT_bidding_problem(self):

"""
Set up the real-time stochastic programming bidding problems.
Expand All @@ -351,7 +334,6 @@ def formulate_RT_bidding_problem(self):
return model

def _save_power_outputs(self, model):

"""
Create references of the power output variable in each price scenario
block.
Expand All @@ -373,7 +355,6 @@ def _save_power_outputs(self, model):
return

def _add_bidding_params(self, model):

"""
Add necessary bidding parameters to the model, i.e., market energy price.
Expand All @@ -399,7 +380,6 @@ def _add_bidding_params(self, model):
return

def _add_bidding_vars(self, model):

"""
Add necessary bidding parameters to the model, i.e., market energy price.
Expand Down Expand Up @@ -433,7 +413,6 @@ def relaxed_day_ahead_power_ub_rule(fs, t):
return

def _add_bidding_objective(self, model):

"""
Add objective function to the model, i.e., maximizing the expected profit
of the energy system.
Expand Down Expand Up @@ -482,7 +461,6 @@ def _compute_bids(
energy_price_param_name,
market,
):

"""
Solve the model to bid into the markets. After solving, record the bids from the solve.
Expand Down Expand Up @@ -525,7 +503,6 @@ def _compute_bids(
return bids

def compute_day_ahead_bids(self, date, hour=0):

"""
Solve the model to bid into the day-ahead market. After solving, record
the bids from the solve.
Expand Down Expand Up @@ -565,7 +542,6 @@ def compute_day_ahead_bids(self, date, hour=0):
def compute_real_time_bids(
self, date, hour, realized_day_ahead_prices, realized_day_ahead_dispatches
):

"""
Solve the model to bid into the real-time market. After solving, record
the bids from the solve.
Expand Down Expand Up @@ -603,7 +579,6 @@ def compute_real_time_bids(
)

def _pass_realized_day_ahead_prices(self, realized_day_ahead_prices, date, hour):

"""
Pass the realized day-ahead prices into model parameters.
Expand Down Expand Up @@ -642,7 +617,6 @@ def _pass_realized_day_ahead_prices(self, realized_day_ahead_prices, date, hour)
self.real_time_model.fs[s].day_ahead_energy_price[t] = price

def _pass_realized_day_ahead_dispatches(self, realized_day_ahead_dispatches, hour):

"""
Pass the realized day-ahead dispatches into model and fix the corresponding variables.
Expand Down Expand Up @@ -670,7 +644,6 @@ def _pass_realized_day_ahead_dispatches(self, realized_day_ahead_dispatches, hou
self.real_time_model.fs[s].real_time_underbid_power[t].unfix()

def update_day_ahead_model(self, **kwargs):

"""
This method updates the parameters in the day-ahead model based on the implemented profiles.
Expand All @@ -684,7 +657,6 @@ def update_day_ahead_model(self, **kwargs):
self._update_model(self.day_ahead_model, **kwargs)

def update_real_time_model(self, **kwargs):

"""
This method updates the parameters in the real-time model based on the implemented profiles.
Expand All @@ -698,7 +670,6 @@ def update_real_time_model(self, **kwargs):
self._update_model(self.real_time_model, **kwargs)

def _update_model(self, model, **kwargs):

"""
Update the flowsheets in all the price scenario blocks to advance time
step.
Expand All @@ -719,7 +690,6 @@ def _update_model(self, model, **kwargs):
return

def record_bids(self, bids, model, date, hour, market):

"""
This function records the bids and the details in the underlying bidding model.
Expand Down Expand Up @@ -749,7 +719,6 @@ def record_bids(self, bids, model, date, hour, market):
return

def _pass_price_forecasts(self, model, day_ahead_price, real_time_energy_price):

"""
Pass the price forecasts into model parameters.
Expand Down Expand Up @@ -807,7 +776,6 @@ def generator(self, name):


class SelfScheduler(StochasticProgramBidder):

"""
Wrap a model object to self schedule into the market using stochastic programming.
"""
Expand Down Expand Up @@ -857,7 +825,6 @@ def __init__(
self.fixed_to_schedule = fixed_to_schedule

def _add_DA_bidding_constraints(self, model):

"""
Add bidding constraints to the model, i.e., power outputs in the first
stage need to be the same across all the scenarios.
Expand Down Expand Up @@ -887,7 +854,6 @@ def day_ahead_bidding_constraints_rule(model, s1, s2, t):
return

def _add_RT_bidding_constraints(self, model):

"""
Add bidding constraints to the model, i.e., power outputs in the first
stage need to be the same across all the scenarios.
Expand Down Expand Up @@ -917,7 +883,6 @@ def real_time_bidding_constraints_rule(model, s1, s2, t):
return

def _assemble_bids(self, model, power_var_name, energy_price_param_name, hour):

"""
This methods extract the bids out of the stochastic programming model and
organize them into self-schedule bids.
Expand Down Expand Up @@ -988,7 +953,6 @@ def _assemble_bids(self, model, power_var_name, energy_price_param_name, hour):
return bids

def _record_bids(self, bids, date, hour, **kwargs):

"""
This function records the bids (schedule) we computed for the given date into a
DataFrame and temporarily stores the DataFrame in an instance attribute
Expand Down Expand Up @@ -1032,7 +996,6 @@ def _record_bids(self, bids, date, hour, **kwargs):


class Bidder(StochasticProgramBidder):

"""
Wrap a model object to bid into the market using stochastic programming.
"""
Expand All @@ -1047,7 +1010,6 @@ def __init__(
forecaster,
real_time_underbid_penalty=10000,
):

"""
Initializes the bidder object.
Expand Down Expand Up @@ -1081,7 +1043,6 @@ def __init__(
)

def _add_DA_bidding_constraints(self, model):

"""
Add bidding constraints to the model, i.e., the bid curves need to be
nondecreasing.
Expand Down Expand Up @@ -1115,7 +1076,6 @@ def day_ahead_bidding_constraints_rule(model, s1, s2, t):
return

def _add_RT_bidding_constraints(self, model):

"""
Add bidding constraints to the model, i.e., the bid curves need to be
nondecreasing.
Expand Down Expand Up @@ -1149,7 +1109,6 @@ def real_time_bidding_constraints_rule(model, s1, s2, t):
return

def _assemble_bids(self, model, power_var_name, energy_price_param_name, hour):

"""
This methods extract the bids out of the stochastic programming model and
organize them into ( MWh, $ ) pairs.
Expand Down Expand Up @@ -1279,7 +1238,6 @@ def _assemble_bids(self, model, power_var_name, energy_price_param_name, hour):
return full_bids

def _record_bids(self, bids, date, hour, **kwargs):

"""
This method records the bids we computed for the given date into a
DataFrame. This DataFrame has the following columns: gen, date, hour,
Expand Down
Loading

0 comments on commit 107302c

Please sign in to comment.