annular.market_model
Attributes
Functions
|
Create the central market clearing model. |
|
Create gross surplus expression and set mutual exclusivity constraint. |
|
Constrain that total demand must equal total generation at all times. |
Create generation cost expression to be used in the objective function. |
|
Set the objective function as social welfare maximization. |
|
|
Get market price as the dual of the power balance constraint. |
|
Fix all integer variables of the solved model instance to their current values. |
|
Run market model and return market_price and demand_met. |
|
Extract scheduled demand from market model. |
|
Extract generator dispatch from market model. |
|
Prepare the relevant market clearing results that should be logged. |
Module Contents
- annular.market_model.create_market_model(demand_bids: pandas.DataFrame, generator_configs: dict[str, dict], timeseries_data: pandas.DataFrame, snapshots: pandas.DatetimeIndex) pyomo.environ.AbstractModel[source]
Create the central market clearing model.
- Parameters:
demand_bids – MultiIndex DataFrame of demand bids for all consumers/prosumers.
generator_configs – dict of configurations defining of all generators.
timeseries_data – DataFrame containing all timeseries_data.
snapshots – snapshots/timesteps for which the market model is created.
- Returns:
Pyomo model representing the market-clearing optimization problem.
- annular.market_model.encode_block_bids_into_model(model: pyomo.environ.Model, demand_bids: pandas.DataFrame) None[source]
Create gross surplus expression and set mutual exclusivity constraint.
This takes bids in the following format:
satellite
exclusive_group_id
profile_block_id
timestamp
quantity
price
…
…
…
…
…
…
where:
satellite: indicates which satellite this bid originates from
exclusive_group_id: ID of which exclusive group this bid belongs to
profile_block_id: ID of which profile block this bid belongs to
timestamp: timestamp for this bid
quantity: quantity for this bid
price: price for this bid
and (satellite, exclusive_group_id, profile_block_id, timestamp) are its Index.
Multiple bids sharing the same profile_block_id will be encoded to be met together, i.e., all-or-none. If multiple profiles share the same exclusive_group_id, at most one of them will be satisfied.
Every bid must have a profile_block_id and exclusive_group_id. If a bid does not make use of profile block or exclusive group functionality, the exclusive_group_id must be unique, while profile_block_id can be any value.
- Parameters:
model – Pyomo model to which the gross surplus expression is added.
demand_bids – MultiIndex DataFrame of demand bids for all consumers/prosumers.
- annular.market_model.constrain_power_balance(model)[source]
Constrain that total demand must equal total generation at all times.
Assumes model.gen_power and model.demand_met have been defined.
- Parameters:
model – Pyomo model to which the power balance constraint is added.
- annular.market_model.create_generation_cost_expression(model: pyomo.environ.AbstractModel) None[source]
Create generation cost expression to be used in the objective function.
- Parameters:
model – Pyomo model to which the generation cost expression is added.
- annular.market_model.set_objective_as_social_welfare_maximization(model: pyomo.environ.AbstractModel) None[source]
Set the objective function as social welfare maximization.
Social welfare is defined as: gross surplus - generation cost.
- Parameters:
model – Pyomo model to which the objective is added.
- annular.market_model.get_market_clearing_price_as_dual(model_instance: pyomo.environ.ConcreteModel) pandas.DataFrame[source]
Get market price as the dual of the power balance constraint.
Note: Market price might be determined by bids from the demand side.
- Parameters:
model_instance – Solved pyomo instance of the market model (LP)
- Returns:
DataFrame representing the market clearing price for each timestamp.
- annular.market_model.fix_integer_variables(model_instance: pyomo.environ.Model) pyomo.environ.ConcreteModel[source]
Fix all integer variables of the solved model instance to their current values.
- Parameters:
model_instance – Solved pyomo instance of the market model (MILP).
- Returns:
Pyomo model instance with integer/binary variables fixed to their current values from the solved MILP instance (making it an LP).
- annular.market_model.run_market_model(model: pyomo.environ.AbstractModel, output_path: pathlib.Path) tuple[numpy.ndarray, numpy.ndarray][source]
Run market model and return market_price and demand_met.
- Parameters:
model – Pyomo model to run/solve.
output_path – path to save the results to.
- Returns:
market clearing price and demand met by the market.
- Return type:
- Raises:
RuntimeError – if the optimization problem is infeasible or unbounded.
- annular.market_model.extract_scheduled_demand(model_instance: pyomo.environ.ConcreteModel) pandas.DataFrame[source]
Extract scheduled demand from market model.
- Parameters:
model_instance – solved market-clearning pyomo model.
- Returns:
amount of scheduled demand per bid.
- annular.market_model.extract_generator_dispatch(model_instance: pyomo.environ.ConcreteModel) pandas.DataFrame[source]
Extract generator dispatch from market model.
- Parameters:
model_instance – solved market-clearing pyomo model.
- Returns:
amount of generator dispatch per timestamp.
- annular.market_model.market_results_to_df(generator_dispatch: pandas.DataFrame, market_price: pandas.DataFrame, scheduled_demand: pandas.DataFrame) pandas.DataFrame[source]
Prepare the relevant market clearing results that should be logged.
The market results are returned as one row per timestamp. Columns are market price, dispatch per generator, and scheduled demand per satellite. I.e.,
timestamp
market_price
Generator 1
Generator 2
…
Satellite 1
Satellite 2
…
…
…
…
…
…
…
with ‘Generator N’ and ‘Satellite N’ replaced by their actual provided names.
- Parameters:
generator_dispatch – dataframe of generator dispatch per generator and timestamp.
market_price – dataframe of market clearing price per timestamp.
scheduled_demand – dataframe of demand scheduled per bid table entry.
- Returns:
combined table of market price, generator dispatch and satellite supply per timestamp.