Bidding strategies

Contents

Bidding strategies#

Submodules#

assume.strategies.advanced_orders module#

class assume.strategies.advanced_orders.EnergyHeuristicFlexableBlockStrategy(*args, **kwargs)#

Bases: EnergyHeuristicFlexableStrategy

A strategy that bids on the EOM-market with block bids.

foresight#

The foresight for the EOM-market.

Type:

pandas.Timedelta

Parameters:
  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Calculates block bids for the EOM-market and returns a list of bids consisting of the start time, end time, only hours, price, volume and bid type.

The bids take the following form: One block bid with the minimum acceptance ratio set to 1 spanning the total clearing period. It uses the inflexible power and the weighted average price of the inflexible power as the price. This price is based on the marginal cost of the inflexible power and the starting costs. The starting costs are split across inflexible power and the average operation or down time of the unit depending on the operation status before. Additionally, for every hour where the unit is on, a separate flexible bid is created using the flexible power and marginal costs as bidding price.

Parameters:
  • unit (SupportsMinMax) – A unit that the unit operator manages.

  • market_config (MarketConfig) – A market configuration.

  • product_tuples (list[Product]) – A list of tuples containing the start and end time of each product.

  • kwargs (dict) – Additional arguments.

Returns:

A list of bids.

Return type:

Orderbook

class assume.strategies.advanced_orders.EnergyHeuristicFlexableLinkedStrategy(*args, **kwargs)#

Bases: EnergyHeuristicFlexableStrategy

A strategy that bids on the EOM-market with block and linked bids.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Calculates block and linked bids for the EOM-market and returns a list of bids consisting of the start time, end time, only hours, price, volume and bid type.

The bids take the following form: One block bid with the minimum acceptance ratio set to 1 spanning the total clearing period. It uses the inflexible power and the weighted average price of the inflexible power as the price. This price is based on the marginal cost of the inflexible power and the starting costs. The starting costs are split across inflexible power and the average operation or down time of the unit depending on the operation status before. Additionally, for every hour where the unit is on, a separate flexible bid is created using the flexible power and marginal costs as bidding price. This bids are linked as children to the block bid.

Parameters:
  • unit (SupportsMinMax) – A unit that the unit operator manages.

  • market_config (MarketConfig) – A market configuration.

  • product_tuples (list[Product]) – A list of tuples containing the start and end time of each product.

  • kwargs (dict) – Additional arguments.

Returns:

A list of bids.

Return type:

Orderbook

assume.strategies.dmas_powerplant module#

class assume.strategies.dmas_powerplant.EnergyOptimizationDmasStrategy(steps=[-10, -1, 0, 1, 10], *args, **kwargs)#

Bases: MinMaxStrategy

build_model(unit: SupportsMinMax, start: datetime, hour_count: int, emission_prices, fuel_prices, power_prices, runtime: int = None, p0: float = None) ndarray#

Builds the optimization model and returns the cashflow.

Parameters:
  • unit (SupportsMinMax) – Unit to optimize.

  • start (datetime.datetime) – Start time.

  • hour_count (int) – Number of hours to optimize.

  • emission_prices (numpy.ndarray) – Emission prices.

  • fuel_prices (numpy.ndarray) – Fuel prices.

  • power_prices (numpy.ndarray) – Power prices.

  • runtime (int, optional) – Runtime of the unit. Defaults to None.

  • p0 (float, optional) – Initial power. Defaults to None.

Returns:

Cashflow.

Return type:

np.ndarray

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market Returns a list of bids that the unit operator will submit to the market

This works by optimizing multiple times for different pricing levels. From the optimization result, the relevant block bid scenarios are created. For the efficiency, a good price forecast is required.

The power plant assumes, that it is started in the first hour as a base block if possible. As it is not possible to combine block bids with exclusive bids, a few decisions on the behavior have to be made. One of these is the decision of to which block hours the startup cost should be added. Ideally, the difference is negligible, as the market takes care of the result optimization. Yet this can have a significant impact if the decision has to be made if the startup cost should be added to the last hour of the current clearing or to the first hours of the following.

TODO: ramp_down constraints are not yet respected by adding an additional block for the next day

Parameters:
Returns:

orderbook

Return type:

Orderbook

optimize(unit: SupportsMinMax, start: datetime, hour_count: int, prices: DataFrame = None, steps: tuple = None) ndarray#

optimizes the unit

Parameters:
  • unit (SupportsMinMax) – unit to optimize

  • start (datetime.datetime) – start time

  • hour_count (int) – number of hours to optimize

  • prices (pd.DataFrame) – prices

  • steps (tuple) – steps to optimize

Returns:

generation

Return type:

np.ndarray

assume.strategies.dmas_storage module#

class assume.strategies.dmas_storage.StorageEnergyOptimizationDmasStrategy(*args, **kwargs)#

Bases: MinMaxChargeStrategy

Strategy for a storage unit that uses DMAS to optimize its operation

build_model(unit: SupportsMinMaxCharge, start: datetime, hour_count: int) ndarray#

Builds the optimization model

Parameters:
Returns:

power

Return type:

np.ndarray

calculate_bids(unit: SupportsMinMaxCharge, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market

Returns a list of bids that the unit operator will submit to the market

Parameters:
Returns:

bids

Return type:

Orderbook

optimize(unit: SupportsMinMaxCharge, market_id: str, start: datetime, hour_count: int) dict[str, ndarray]#

Optimizes the unit operation

Parameters:
Returns:

optimization results

Return type:

dict

assume.strategies.dmas_storage.get_solver_factory(solvers_str=None) SolverFactoryClass#

Returns the first available solver from the list of solvers

Parameters:

solvers_str (list, optional) – list of default solvers

Raises:

Exception – if no solvers available

Returns:

the first working solver

Return type:

SolverFactory

assume.strategies.dmas_storage.shaping(prc, type_: str = 'peak') ndarray#

Shifts the price curve up or down

Parameters:
  • prc (numpy.ndarray) – price curve

  • type (str) – type of shift. default is ‘peak’. other options are ‘pv’ and ‘demand’.

  • type – str: (Default value = “peak”)

Returns:

shifted price curve

Return type:

np.ndarray

assume.strategies.dmas_storage.shift(prc, type_: str = 'first') ndarray#

Shifts the price curve up or down

Parameters:
  • prc (numpy.ndarray) – price curve

  • type (str) – type of shift. default is ‘first’

  • type – str: (Default value = “first”)

Returns:

shifted price curve

Return type:

np.ndarray

assume.strategies.extended module#

class assume.strategies.extended.EnergyNaiveOtcStrategy(*args, scale_firm_power_capacity=1.0, **kwargs)#

Bases: MinMaxStrategy

Strategy for OTC (over the counter trading) markets

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market.

Returns a list of bids that the unit operator will submit to the market.

Parameters:
  • unit (SupportsMinMax) – Unit to dispatch.

  • market_config (MarketConfig) – Market configuration.

  • product_tuples (list[Product]) – List of products to dispatch.

  • **kwargs (dict) – Additional arguments.

Returns:

Orderbook.

Return type:

Orderbook

class assume.strategies.extended.MarkupStrategy(*args, abs_markup=0, rel_markup=0, **kwargs)#

Bases: MinMaxStrategy

Strategy for Markup (over the counter trading) markets

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market

Returns a list of bids that the unit operator will submit to the market.

Parameters:
  • unit (SupportsMinMax) – Unit to dispatch.

  • market_config (MarketConfig) – Market configuration.

  • product_tuples (list[Product]) – List of products to dispatch.

  • **kwargs (dict) – Additional arguments.

Returns:

The orderbook.

Return type:

Orderbook

class assume.strategies.extended.SupportStrategy(contract_types: list[str] = [], contract_value=0, contract_amount_fraction=1, evaluation_frequency=2, *args, **kwargs)#

Bases: EnergyNaiveStrategy

Strategy for support markets. A list of allowed contract_types is given, as well as a value which is used to bid contracts. As often not everything which is possible should be bid on contracts, this can be defined through contract_amount_fraction - as well as an execution schedule.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market.

Parameters:
  • unit (SupportsMinMax) – Unit to dispatch.

  • market_config (MarketConfig) – Market configuration.

  • product_tuples (List[Product]) – List of products to dispatch.

  • **kwargs (dict) – Additional arguments.

Returns:

The orderbook.

Return type:

Orderbook

assume.strategies.extended.is_co2emissionless(units)#

assume.strategies.flexable module#

class assume.strategies.flexable.CapacityHeuristicBalancingNegStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

A strategy that bids the energy_price or the capacity_price of the unit on the negative CRM(reserve market).

foresight#

The foresight of the unit.

Type:

datetime.timedelta

Parameters:
  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market. Returns a list of bids consisting of the start time, end time, only hours, price and volume.

Parameters:
  • unit (SupportsMinMax) – A unit that the unit operator manages.

  • market_config (MarketConfig) – A market configuration.

  • product_tuples (list[Product]) – A list of tuples containing the start and end time of each product.

  • kwargs (dict) – Additional arguments.

Returns:

A list of bids.

Return type:

Orderbook

class assume.strategies.flexable.CapacityHeuristicBalancingPosStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

A strategy that bids the energy_price or the capacity_price of the unit on the CRM (reserve market).

foresight#

The foresight of the unit.

Type:

datetime.timedelta

Parameters:
  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Calculates bids for the CRM-market.

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market. Returns a list of bids consisting of the start time, end time, only hours, price and volume.

Parameters:
  • unit (SupportsMinMax) – A unit that the unit operator manages.

  • market_config (MarketConfig) – A market configuration.

  • product_tuples (list[Product]) – A list of tuples containing the start and end time of each product.

  • kwargs (dict) – Additional arguments.

Returns:

A list of bids.

Return type:

Orderbook

class assume.strategies.flexable.EnergyHeuristicFlexableStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

A strategy that bids on the EOM-market.

foresight#

The foresight of the unit.

Type:

datetime.timedelta

Parameters:
  • *args – Variable length argument list.

  • **kwargs – Arbitrary keyword arguments.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Calculates bids for the EOM-market and returns a list of bids consisting of the start time, end time, only hours, price, volume and bid type.

The bids take the following form: For each hour one inflexible and one flexible bid is formulated. The inflexible bid is the minimum power of the unit depending on the ramp up limitations. The price for this bid is calculated by the marginal cost of the unit plus a markup for the startup costs. The flexible bid is the maximum power of the unit depending on the ramp up limitations minus the inflexible bid. Here, the price is equal to the marginal costs of the unit.

Parameters:
  • unit (SupportsMinMax) – A unit that the unit operator manages.

  • market_config (MarketConfig) – A market configuration.

  • product_tuples (list[Product]) – A list of tuples containing the start and end time of each product.

  • kwargs (dict) – Additional arguments.

Returns:

A list of bids.

Return type:

Orderbook

calculate_reward(unit, marketconfig: MarketConfig, orderbook: list[Order])#

Calculates and writes the reward (costs and profit).

Parameters:
  • unit (SupportsMinMax) – A unit that the unit operator manages.

  • marketconfig (MarketConfig) – A market configuration.

  • orderbook (Orderbook) – An orderbook with accepted and rejected orders for the unit.

Note

The reward is calculated as the profit minus the opportunity cost, which is the loss of income we have because we are not running at full power. The regret is the opportunity cost. Because the regret_scale is set to 0 the reward equals the profit. The profit is the income we have from the accepted bids. The total costs are the running costs and the start-up costs.

assume.strategies.flexable.calculate_EOM_price_if_off(unit: SupportsMinMax, marginal_cost_inflex, bid_quantity_inflex, op_time)#

The powerplant is currently off and calculates a startup markup as an extra to the marginal cost.

The startup markup is calculated as follows: starting_cost / avg_operating_time / bid_quantity_inflex

Parameters:
  • unit (SupportsMinMax) – A unit that the unit operator manages.

  • marginal_cost_inflex (float) – The marginal cost of the unit.

  • bid_quantity_inflex (float) – The bid quantity of the unit.

  • op_time (int) – The operation time of the unit.

Returns:

The inflexible bid price of the unit.

Return type:

float

assume.strategies.flexable.calculate_EOM_price_if_on(unit: SupportsMinMax, market_id: str, start, marginal_cost_flex, bid_quantity_inflex, foresight)#

The powerplant is currently on and calculates a price reduction to prevent shutdowns.

The price reduction is calculated as follows: starting_cost / min_down_time / bid_quantity_inflex If the unit is a CHP, the heat generation costs are added to the price reduction with the following formula: heat_gen_cost = (heat_output * (natural_gas_price / 0.9)) / bid_quantity_inflex If the estimated revenue for the time defined in foresight is positive, but the marginal costs are below the forecasted market clearing price, the marginal costs are set to 0.

Parameters:
  • unit (SupportsMinMax) – A unit that the unit operator manages.

  • start (datetime.datetime) – The start time of the product.

  • marginal_cost_flex (float) – The marginal cost of the unit.

  • bid_quantity_inflex (float) – The bid quantity of the unit.

  • foresight (datetime.timedelta) – The foresight of the unit.

Returns:

The inflexible bid price of the unit.

Return type:

float

assume.strategies.flexable.get_specific_revenue(price_forecast, marginal_cost: float, t: datetime, foresight: timedelta)#

Calculates the specific revenue as difference between price forecast and marginal costs for the time defined by the foresight.

Parameters:
  • price_forecast (FastSeries) – The price forecast.

  • marginal_cost (float) – The marginal cost of the unit.

  • t (datetime.datetime) – The start time of the product.

  • foresight (datetime.timedelta) – The foresight of the unit.

Returns:

The specific revenue of the unit.

Return type:

float

assume.strategies.flexable.update_avg_op_time(unit, product_type, start, end)#

Updates the average operation time for the unit based on the specified slice of outputs.

Parameters:
  • unit – The unit object containing outputs, total_op_time, and avg_op_time.

  • product_type – The product type to update.

  • start – The start index of the slice being updated.

  • end – The end index of the slice being updated (inclusive).

assume.strategies.flexable_storage module#

class assume.strategies.flexable_storage.StorageCapacityHeuristicBalancingNegStrategy(*args, **kwargs)#

Bases: MinMaxChargeStrategy

A strategy that bids the energy_price or the capacity_price of the unit on the negative CRM(reserve market).

foresight#

Foresight for the average price calculation.

Type:

datetime.timedelta

Parameters:
  • *args – Additional arguments.

  • **kwargs – Additional keyword arguments.

calculate_bids(unit: SupportsMinMaxCharge, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market. Returns a list of bids consisting of the start time, end time, only hours, price and volume.

Parameters:
  • unit (SupportsMinMax) – A unit that the unit operator manages.

  • market_config (MarketConfig) – A market configuration.

  • product_tuples (list[Product]) – A list of tuples containing the start and end time of each product.

  • kwargs (dict) – Additional arguments.

Returns:

A list of bids.

Return type:

Orderbook

class assume.strategies.flexable_storage.StorageCapacityHeuristicBalancingPosStrategy(*args, **kwargs)#

Bases: MinMaxChargeStrategy

The strategy is analogue to the storage strategy in flexABLE.

The strategy bids the energy_price for the energy_pos product if the specific revenue is positive. Otherwise, the strategy bids the capacity_price for the capacity_pos product.

foresight#

Foresight for the average price calculation.

Type:

datetime.timedelta

Parameters:
  • *args – Additional arguments.

  • **kwargs – Additional keyword arguments.

calculate_bids(unit: SupportsMinMaxCharge, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Calculates bids for the positive CRM market.

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market and returns bids containing start_time, end_time, only_hours, price, volume.

Parameters:
  • unit (SupportsMinMaxCharge) – The unit that is dispatched.

  • market_config (MarketConfig) – The market configuration.

  • product_tuples (list[Product]) – List of product tuples.

  • **kwargs – Additional keyword arguments.

Returns:

A list of bids.

Return type:

Orderbook

class assume.strategies.flexable_storage.StorageEnergyHeuristicFlexableStrategy(*args, **kwargs)#

Bases: MinMaxChargeStrategy

The strategy is analogue to the storage strategy in flexABLE.

If the current price forecast is higher than the average price forecast for a given foresight, the unit will discharge. The price is then set as the average price divided by the discharge efficiency of the unit. Otherwise, the unit will charge with the price defined as the average price multiplied by the charge efficiency of the unit.

foresight#

Foresight for the average price calculation.

Type:

datetime.timedelta

Parameters:
  • *args – Additional arguments.

  • **kwargs – Additional keyword arguments.

calculate_bids(unit: SupportsMinMaxCharge, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market.

Parameters:
  • unit (SupportsMinMaxCharge) – The unit that is dispatched.

  • market_config (MarketConfig) – The market configuration.

  • product_tuples (list[Product]) – List of product tuples.

  • **kwargs – Additional keyword arguments.

Returns:

Bids containing start_time, end_time, only_hours, price, volume.

Return type:

Orderbook

Note

The strategy is analogue to flexABLE

calculate_reward(unit: SupportsMinMaxCharge, marketconfig: MarketConfig, orderbook: list[Order])#

Calculates the reward (costs and profit).

The profit is defined by the cashflow minus the costs.

Parameters:
  • unit (SupportsMinMaxCharge) – The unit to calculate reward for.

  • marketconfig (MarketConfig) – The market configuration.

  • orderbook (Orderbook) – The orderbook.

assume.strategies.flexable_storage.calculate_price_average(current_time, foresight, price_forecast)#

Calculates the average price for a given foresight and returns the average price.

Parameters:
Returns:

The average price.

Return type:

float

assume.strategies.flexable_storage.get_specific_revenue(unit, marginal_cost, t, foresight, price_forecast)#

Calculates the specific revenue as difference between price forecast and marginal costs for the time defined by the foresight.

Parameters:
Returns:

The specific revenue.

Return type:

float

assume.strategies.learning_strategies module#

class assume.strategies.learning_strategies.EnergyLearningSingleBidStrategy(*args, **kwargs)#

Bases: EnergyLearningStrategy, MinMaxStrategy

Reinforcement Learning Strategy with Single-Bid Structure for Energy-Only Markets.

This strategy is a simplified variant of the standard EnergyLearningStrategy, which typically submits two separate price bids for inflexible (P_min) and flexible (P_max - P_min) components. Instead, EnergyLearningSingleBidStrategy submits a single bid that always offers the unit’s maximum power, effectively treating the full capacity as inflexible from a bidding perspective.

The core reinforcement learning mechanics, including the observation structure, actor network architecture, and reward formulation, remain consistent with the two-bid EnergyLearningStrategy. However, this strategy modifies the action space to produce only a single bid price, and omits the decomposition of capacity into flexible and inflexible parts.

Inherits all attributes from EnergyLearningStrategy, with the exception of
- act_dim

Reduced to 1 to reflect single bid pricing.

Type:

int

- foresight

Set to 24 to match typical storage strategy setups.

Type:

int

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Generates a single price bid for the full available capacity (max_power).

The method observes market and unit state, derives an action (bid price) from the actor network, and constructs one bid covering the entire capacity, without distinguishing between flexible and inflexible components.

Returns:

A list containing one bid with start/end time, full volume, and calculated price.

Return type:

Orderbook

class assume.strategies.learning_strategies.EnergyLearningStrategy(*args, **kwargs)#

Bases: TorchLearningStrategy, MinMaxStrategy

Reinforcement Learning Strategy that enables the agent to learn optimal bidding strategies on an Energy-Only Market.

The agent submits two price bids: one for the inflexible component (P_min) and another for the flexible component (P_max - P_min) of its capacity. This strategy utilizes a set of 38 observations to generate actions, which are then transformed into market bids. The observation space comprises two unique values: the marginal cost and the current capacity of the unit.

The observation space for this strategy consists of 38 elements, drawn from both the forecaster and the unit’s internal state. Observations include the following components:

  • Forecasted Residual Load: Forecasted load over the foresight period, scaled by the maximum demand of the unit, indicating anticipated grid conditions.

  • Forecasted Price: Price forecast over the foresight period, scaled by the maximum bid price, providing a sense of expected market prices.

  • Total Capacity and Marginal Cost: The last two elements of the observation vector, representing the unique state of the unit itself. Here, total capacity is scaled by the unit’s maximum power, while marginal cost is scaled by the maximum bid price. These specific values reflect the unit’s operational capacity and production costs, helping the agent determine the optimal bid.

Actions are formulated as two values, representing bid prices for both the inflexible and flexible components of the unit’s capacity. Actions are scaled from a range of [-1, 1] to real bid prices in the calculate_bids method, where they translate into specific bid volumes for the inflexible (P_min) and flexible (P_max - P_min) components.

Rewards are based on profit from transactions, minus operational and opportunity costs. Key components include:

  • Profit: Determined from the income generated by accepted bids, calculated as the product of accepted price, volume, and duration.

  • Operational Costs: Includes marginal costs and start-up costs when the unit transitions between on and off states.

  • Opportunity Cost: Calculated as the potential income lost when the unit is not running at full capacity. High opportunity costs result in a penalty, encouraging full utilization of capacity.

  • Scaling and Regret Term: The final reward combines profit, opportunity costs, and a regret term to penalize missed revenue opportunities. The reward is scaled to guide learning, with a regret term applied to reduce high opportunity costs.

foresight#

Number of time steps for which the agent forecasts market conditions. Defaults to 12.

Type:

int

max_bid_price#

Maximum allowable bid price. Defaults to 100.

Type:

float

max_demand#

Maximum demand capacity of the unit. Defaults to 10e3.

Type:

float

device#

Device for computation, such as “cpu” or “cuda”. Defaults to “cpu”.

Type:

str

float_type#

Data type for floating-point calculations, typically “float32”. Defaults to “float32”.

Type:

str

learning_mode#

Indicates whether the agent is in learning mode. Defaults to False.

Type:

bool

algorithm#

Name of the RL algorithm in use. Defaults to “matd3”.

Type:

str

actor_architecture_class#

Class of the neural network architecture used for the actor network. Defaults to MLPActor.

Type:

type[torch.nn.Module]

actor#

Actor network for determining actions.

Type:

torch.nn.Module

order_types#

Types of market orders supported by the strategy. Defaults to [“SB”].

Type:

list[str]

action_noise#

Noise model added to actions during learning to encourage exploration. Defaults to None.

Type:

NormalActionNoise

collect_initial_experience_mode#

Whether the agent is collecting initial experience through exploration. Defaults to True.

Type:

bool

Parameters:
  • *args (Variable length argument list.)

  • **kwargs (Arbitrary keyword arguments.)

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Calculates bids based on the current observations and actions derived from the actor network.

Parameters:
  • unit (SupportsMinMax) – The unit for which to calculate bids, with details on capacity constraints.

  • market_config (MarketConfig) – The configuration settings of the energy market.

  • product_tuples (list[Product]) – List of products with start and end times for bidding.

  • **kwargs (Additional keyword arguments.)

Returns:

Contains bid entries for each product, including start time, end time, price, and volume.

Return type:

Orderbook

Notes

This method structures bids in two parts: - Inflexible Bid (P_min): A bid for the minimum operational capacity. - Flexible Bid (P_max - P_min): A bid for the flexible capacity available after P_min. The actions are scaled to reflect real bid prices and volumes, which are then converted into orderbook entries.

calculate_reward(unit, marketconfig: MarketConfig, orderbook: list[Order])#

Calculates the reward for the unit based on profits, costs, and opportunity costs from market transactions.

Parameters:
  • unit (SupportsMinMax) – The unit for which to calculate the reward.

  • marketconfig (MarketConfig) – Market configuration settings.

  • orderbook (Orderbook) – Orderbook containing executed bids and details.

Notes

The reward is computed by combining the following: Profit: Income from accepted bids minus marginal and start-up costs. Opportunity Cost: Penalty for underutilizing capacity, calculated as potential lost income. Regret Term: A scaled regret term penalizes high opportunity costs to guide effective bidding.

The reward is scaled and stored along with other outputs in the unit’s data to support learning.

get_actions(next_observation)#

Compute actions based on the current observation.

Parameters:

next_observation (torch.Tensor) – The current observation, where the last element is assumed to be the marginal cost.

Returns:

A tuple containing: Actions to be taken (with or without noise). The noise component (if any), useful for diagnostics.

Return type:

tuple of torch.Tensor

Notes

During learning, exploratory noise is applied and already part of the curr_action unless in evaluation mode. In initial exploration mode, actions are sampled around the marginal cost to explore its vicinity. We assume the final element of next_observation is the marginal cost.

get_individual_observations(unit: SupportsMinMax, start: datetime, end: datetime)#

Retrieves the unit-specific observations. For dispatchable units, this includes the last dispatched volume and the current marginal costs.

Parameters:
Returns:

individual_observations – Scaled total dispatched capacity and marginal cost.

Return type:

np.ndarray

Notes

The last two values in the observation vector represent the total capacity and marginal cost, scaled by maximum power and bid price, respectively.

class assume.strategies.learning_strategies.RenewableEnergyLearningSingleBidStrategy(*args, **kwargs)#

Bases: EnergyLearningSingleBidStrategy

Reinforcement Learning Strategy for a renewable unit that enables the agent to learn optimal bidding strategies on an Energy-Only Market.

The observation space for this strategy consists of 75 elements. Key components include: - Price Forecasts - Residual Load Forecasts - Historic Prices As individual observations we provide the - Renewable Generation Forecasts - Marginal Costs - Previous Time Step Generation

The agent’s actions are formulated as one value, representing the bid price at which it bids its full capacity. These actions are scaled and interpreted to form actionable market bids, with specific conditions dictating the bid type.

  • Bid Price: The one action value determines the price at which the agent will bid.

Rewards are based on the profit generated by the agent’s market bids.

foresight#

Number of time steps for forecasting market conditions. Defaults to 24.

Type:

int

max_bid_price#

Maximum allowable bid price. Defaults to 100.

Type:

float

device#

Device used for computation (“cpu” or “cuda”). Defaults to “cpu”.

Type:

str

float_type#

Data type for floating-point calculations. Defaults to “float32”.

Type:

str

learning_mode#

Whether the agent is in learning mode. Defaults to False.

Type:

bool

algorithm#

RL algorithm used by the agent. Defaults to “matd3”.

Type:

str

actor_architecture_class#

Class of the neural network for the actor network. Defaults to MLPActor.

Type:

type[torch.nn.Module]

actor#

The neural network used to predict actions.

Type:

torch.nn.Module

order_types#

Types of market orders used by the strategy. Defaults to [“SB”].

Type:

list[str]

action_noise#

Noise model added to actions during learning for exploration. Defaults to None.

Type:

NormalActionNoise

collect_initial_experience_mode#

Whether the agent is in an exploration mode for initial experience. Defaults to True.

Type:

bool

Parameters:
  • *args (Variable length argument list.)

  • **kwargs (Arbitrary keyword arguments.)

calculate_reward(unit: SupportsMinMaxCharge, marketconfig: MarketConfig, orderbook: list[Order])#

Calculates the reward for the renewable unit based on profits, costs, and opportunity costs from market transactions.

Parameters:
  • unit (SupportsMinMax) – The unit for which to calculate the reward.

  • marketconfig (MarketConfig) – Market configuration settings.

  • orderbook (Orderbook) – Orderbook containing executed bids and details.

Notes

The reward is computed by combining the following: Profit: Income from accepted bids minus marginal and start-up costs. Opportunity Cost: Penalty for underutilizing capacity, calculated as potential lost income. Regret Term: A scaled regret term penalizes high opportunity costs to guide effective bidding.

The reward is scaled and stored along with other outputs in the unit’s data to support learning.

get_individual_observations(unit: SupportsMinMaxCharge, start: datetime, end: datetime)#

Retrieves the unit-specific observations for renewable units. For them we add the availabilities of the generation in the observation space.

Parameters:
Returns:

individual_observations – Array containing state of charge and energy cost.

Return type:

np.ndarray

Notes

Observations are scaled by the unit’s max power and the max bid price.

class assume.strategies.learning_strategies.StorageEnergyLearningStrategy(*args, **kwargs)#

Bases: TorchLearningStrategy, MinMaxChargeStrategy

Reinforcement Learning Strategy for a storage unit that enables the agent to learn optimal bidding strategies on an Energy-Only Market.

The observation space for this strategy consists of 74 elements. Key components include:

  • State of Charge: Represents the current level of energy in the storage unit, influencing the bid direction and capacity.

  • Energy Cost: The cost associated with the energy content in the storage unit, which helps determine bid prices and profitability.

  • Price Forecasts

  • Residual Load Forecasts

The agent’s actions are formulated as two values, representing the bid price and the bid direction. These actions are scaled and interpreted to form actionable market bids, with specific conditions dictating the bid type. The storage agent can also decide to stay inactive by submitting a zero bid as this can be a valid strategy in some market conditions and also improves the learning process.

  • Bid Price: The one action value determines the price at which the agent will bid.

  • Bid Direction: This is implicitly set based on the action:
    • If action < 0: The agent submits a buy bid.

    • If action >= 0: The agent submits a sell bid.

Rewards are based on the profit generated by the agent’s market bids, with sell bids contributing positive profit and buy bids contributing negative profit. Additional components in the reward calculation include:

  • Profit: Calculated from the income of successful sell bids minus costs from buy bids.

  • Fixed Costs: Charges associated with storage operations, including charging and discharging costs, which are deducted from the reward.

foresight#

Number of time steps for forecasting market conditions. Defaults to 24.

Type:

int

max_bid_price#

Maximum allowable bid price. Defaults to 100.

Type:

float

max_demand#

Maximum demand capacity of the storage. Defaults to 10e3.

Type:

float

device#

Device used for computation (“cpu” or “cuda”). Defaults to “cpu”.

Type:

str

float_type#

Data type for floating-point calculations. Defaults to “float32”.

Type:

str

learning_mode#

Whether the agent is in learning mode. Defaults to False.

Type:

bool

algorithm#

RL algorithm used by the agent. Defaults to “matd3”.

Type:

str

actor_architecture_class#

Class of the neural network for the actor network. Defaults to MLPActor.

Type:

type[torch.nn.Module]

actor#

The neural network used to predict actions.

Type:

torch.nn.Module

order_types#

Types of market orders used by the strategy. Defaults to [“SB”].

Type:

list[str]

action_noise#

Noise model added to actions during learning for exploration. Defaults to None.

Type:

NormalActionNoise

collect_initial_experience_mode#

Whether the agent is in an exploration mode for initial experience. Defaults to True.

Type:

bool

Parameters:
  • *args (Variable length argument list.)

  • **kwargs (Arbitrary keyword arguments.)

calculate_bids(unit: SupportsMinMaxCharge, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Generates market bids based on the unit’s current state and observations.

Parameters:
  • unit (SupportsMinMaxCharge) – The storage unit with information on charging/discharging capacity.

  • market_config (MarketConfig) – Configuration of the energy market.

  • product_tuples (list[Product]) – List of market products to bid on, each containing start and end times.

  • **kwargs (Additional keyword arguments.)

Returns:

Structured bids including price, volume, and bid direction.

Return type:

Orderbook

Notes

Observations are used to calculate bid actions, which are then scaled and processed into bids for submission in the market.

calculate_reward(unit: SupportsMinMaxCharge, marketconfig: MarketConfig, orderbook: list[Order])#

Calculates the reward based on profit generated by bids after market feedback.

Parameters:
  • unit (SupportsMinMaxCharge) – The storage unit associated with the agent.

  • marketconfig (MarketConfig) – Configuration of the energy market.

  • orderbook (Orderbook) – Contains executed bids and transaction details.

Notes

Rewards are based on profit and include fixed costs for charging and discharging.

get_individual_observations(unit: SupportsMinMaxCharge, start: datetime, end: datetime)#

Retrieves the unit-specific observations for storage units. For storages we use the state of charge and cost of currently stored energy as the individual observations. We define the latter as the average volume weighted procurement costs of the currently stored energy.

Parameters:
Returns:

individual_observations – Array containing state of charge and energy cost.

Return type:

np.ndarray

Notes

Observations are scaled by the unit’s max state of charge and energy costs, creating input for the agent’s action selection.

class assume.strategies.learning_strategies.TorchLearningStrategy(*args, **kwargs)#

Bases: LearningStrategy

A strategy to enable machine learning with pytorch.

create_observation(unit: BaseUnit, market_id: str, start: datetime, end: datetime)#

Constructs a scaled observation tensor based on the unit’s forecast data and internal state.

Parameters:
  • unit (BaseUnit) – The unit providing forecast and internal state data.

  • market_id (str) – Identifier for the specific market.

  • start (datetime) – Start time for the observation period.

  • end (datetime) – End time for the observation period.

Returns:

Observation tensor with data on forecasted residual load, price, and unit-specific values.

Return type:

torch.Tensor

Notes

Observations are constructed from forecasted residual load and price over the foresight period, scaled by maximum demand and bid price. The last values in the observation vector represent unit-specific values, depending on the strategy and unit-type.

get_actions(next_observation)#

Determines actions based on the current observation, applying noise for exploration if in learning mode.

Parameters:

next_observation (torch.Tensor) – Observation data influencing bid price and direction.

Returns:

  • torch.Tensor – Actions that include bid price and direction.

  • torch.Tensor – Noise component which is already added to actions for exploration, if applicable.

Notes

In learning mode, actions incorporate noise for exploration. Initial exploration relies solely on noise to cover the action space broadly.

get_individual_observations(unit: BaseUnit, start: datetime, end: datetime)#

Retrieves the unit-specific observations.

Parameters:
  • unit (BaseUnit) – The unit providing forecast and internal state data.

  • start (datetime) – Start time for the observation period.

Returns:

individual_observations – Strategy and unit-specific observations.

Return type:

np.ndarray

load_actor_params(load_path)#

Load actor parameters.

Parameters:

load_path (str) – The path to load parameters from.

prepare_observations(unit, market_id)#

assume.strategies.naive_strategies module#

class assume.strategies.naive_strategies.DsmCapacityHeuristicBalancingNegStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

Strategy for Negative CRM Reserve (Demand Side, i.e., up & down, symmetric).

calculate_bids(unit, market_config, product_tuples, **kwargs)#

Calculates the bids for the next time step.

Parameters:
Returns:

The bids.

Return type:

Orderbook

class assume.strategies.naive_strategies.DsmCapacityHeuristicBalancingPosStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

Strategy for Positive CRM Reserve (Demand Side, i.e., up & down, symmetric).

calculate_bids(unit, market_config, product_tuples, **kwargs)#

Calculates the bids for the next time step.

Parameters:
Returns:

The bids.

Return type:

Orderbook

class assume.strategies.naive_strategies.DsmEnergyNaiveRedispatchStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

A naive strategy of a Demand Side Management (DSM) unit that bids the available flexibility of the unit on the redispatch market. The bid volume is the flexible power requirement of the unit at the start time of the product. The bid price is the marginal cost of the unit at the start time of the product.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Calculates the bids for the next time step.

Parameters:
Returns:

The bids.

Return type:

Orderbook

class assume.strategies.naive_strategies.DsmEnergyOptimizationStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

A naive strategy of a Demand Side Management (DSM) unit. The bid volume is the optimal power requirement of the unit at the start time of the product. The bid price is the marginal cost of the unit at the start time of the product.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market.

Parameters:
  • unit (SupportsMinMax) – The unit to be dispatched.

  • market_config (MarketConfig) – The market configuration.

  • product_tuples (list[Product]) – The list of all products the unit can offer.

Returns:

The bids consisting of the start time, end time, only hours, price and volume.

Return type:

Orderbook

class assume.strategies.naive_strategies.EnergyHeuristicElasticStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

A bidding strategy for a demand unit that submits multiple bids to approximate a marginal utility curve, based on linear or isoelastic demand theory. P = Price, Q = Quantity, E = Elasticity.

  • Linear model: P = P_max + slope * Q (slope is only defined by P_max and Q_max, negative value)

  • Isoelastic model: P = (Q/Q_max) ** (1/E) (E is negative) (derived from log-log price elasticity of demand)

See: - https://en.wikipedia.org/wiki/Price_elasticity_of_demand - Arnold, Fabian. 2023. https://hdl.handle.net/10419/286380 - Hirth, Lion et al. 2024. https://doi.org/10.1016/j.eneco.2024.107652.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Calculates the bids for the next time step.

Parameters:
Returns:

The bids.

Return type:

Orderbook

find_first_block_bid(elasticity: float, max_price: float, max_power: float) float#

Calculate the first block bid volume at max_price. P = Price, Q = Quantity, E = Elasticity. Assumes isoelastic demand:

\[Q = Q_{max} * P^E\]

The first block bid is the volume that is always bid at maximum price, because the willingness to pay for it is higher than the markets maximal price. The first block bid volume is calculated by finding the intersection of the isoelastic demand curve and the maximum price in the marginal utility plot. All demand left of the intersection is always bought at maximum price and is called $Q_{first}$.

\[Q_{first} = Q Q_{first} = Q_{max} * P^E\]

Therefore:

\[Q_{first} = power_{max} * (price_{max} ^ E)\]
Returns:

Volume > 0, demand that is always bought at max willingness to pay

Return type:

float

class assume.strategies.naive_strategies.EnergyNaiveProfileStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

A naive strategy that bids the marginal cost of the unit as block bids over 24 hours on the day ahead market.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market.

Parameters:
  • unit (SupportsMinMax) – The unit to be dispatched.

  • market_config (MarketConfig) – The market configuration.

  • product_tuples (list[Product]) – The list of all products the unit can offer.

Returns:

The bids consisting of the start time, end time, only hours, price and volume.

Return type:

Orderbook

class assume.strategies.naive_strategies.EnergyNaiveRedispatchStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

A naive strategy that simply submits all information about the unit and currently dispatched power for the following hours to the redispatch market. Information includes the marginal cost, the ramp up and down values, and the dispatch.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market

Parameters:
  • unit (SupportsMinMax) – the unit to be dispatched

  • market_config (MarketConfig) – the market configuration

  • product_tuples (list[Product]) – list of all products the unit can offer

Returns:

the bids consisting of the start time, end time, only hours, price and volume.

Return type:

Orderbook

class assume.strategies.naive_strategies.EnergyNaiveStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

A naive strategy that bids the marginal cost of the unit on the market.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market.

Parameters:
  • unit (SupportsMinMax) – The unit to be dispatched.

  • market_config (MarketConfig) – The market configuration.

  • product_tuples (list[Product]) – The list of all products the unit can offer.

Returns:

The bids consisting of the start time, end time, only hours, price and volume.

Return type:

Orderbook

class assume.strategies.naive_strategies.ExchangeEnergyNaiveStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

A naive strategy for an exchange unit that bids the defined import and export prices on the market. It submits two bids, one for import and one for export, with the respective prices and volumes. Export bids have negative volumes and are treated as demand on the market. Import bids have positive volumes and are treated as supply on the market.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market.

Parameters:
  • unit (SupportsMinMax) – The unit to be dispatched.

  • market_config (MarketConfig) – The market configuration.

  • product_tuples (list[Product]) – The list of all products the unit can offer.

Returns:

The bids consisting of the start time, end time, only hours, price and volume.

Return type:

Orderbook

assume.strategies.interactive_strategies module#

class assume.strategies.interactive_strategies.EnergyInteractiveStrategy(*args, **kwargs)#

Bases: MinMaxStrategy

A simple strategy where the user can input the bids of an agent manually. Only one agent should have this strategy in a simulation in one process, so that the terminal does not wait for multiple responses.

calculate_bids(unit: SupportsMinMax, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market.

Parameters:
  • unit (SupportsMinMax) – The unit to be dispatched.

  • market_config (MarketConfig) – The market configuration.

  • product_tuples (list[Product]) – The list of all products the unit can offer.

Returns:

The bids consisting of the start time, end time, only hours, price and volume.

Return type:

Orderbook

assume.strategies.portfolio_strategies module#

class assume.strategies.portfolio_strategies.UnitOperatorStrategy(*args, **kwargs)#

Bases: object

The UnitOperatorStrategy is similar to the UnitStrategy. A UnitOperatorStrategy calculates the bids for all units of a units operator.

calculate_bids(units_operator, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a units operator and defines how the units managed by it should bid.

This gives a lot of flexibility to the market bids.

Parameters:
  • units_operator (UnitsOperator) – The operator handling the units.

  • market_config (MarketConfig) – The market configuration.

  • product_tuples (list[Product]) – The list of all products the unit can offer.

Returns:

The bids consisting of the start time, end time, only hours, price and volume.

Return type:

Orderbook

total_capacity(units_operator) dict[str, dict[str, float]]#

Computes the total capacity of the units owned by a unit operator by market and technology.

Parameters:

units_operator (UnitsOperator) – The operator that bids on the market(s).

Returns:

a nested dictionary indexed by market and by technology.

Return type:

dict

class assume.strategies.portfolio_strategies.UnitsOperatorDirectStrategy(*args, **kwargs)#

Bases: UnitOperatorStrategy

calculate_bids(units_operator, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Formulates the bids to the market according to the bidding strategy of the each unit individually. This calls calculate_bids of each unit and returns the aggregated list of all individual bids of all units.

Parameters:
  • units_operator – The units operator whose units are queried

  • market_config (MarketConfig) – The market to formulate bids for.

  • product_tuples (list[tuple]) – The products to formulate bids for.

Returns:

The orderbook that is submitted as a bid to the market.

Return type:

OrderBook

class assume.strategies.portfolio_strategies.UnitsOperatorEnergyHeuristicCournotStrategy(*args, **kwargs)#

Bases: UnitOperatorStrategy

A Cournot strategy that adds a markup to the marginal cost of each unit of the units operator. The marginal cost is computed with EnergyNaiveStrategy, and the markup depends on the total capacity of the unit operator.

calculate_bids(units_operator, market_config: MarketConfig, product_tuples: list[Product], **kwargs) list[Order]#

Takes information from a unit that the unit operator manages and defines how it is dispatched to the market.

Parameters:
  • units_operator (UnitsOperator) – The units operator that bids on the market.

  • market_config (MarketConfig) – The configuration of the market.

  • product_tuples (list[Product]) – The list of all products open for bidding.

Returns:

The bids consisting of the start time, end time, price and volume.

Return type:

Orderbook

Module contents#