dove.models.price_taker package#

dove.models.price_taker#

Price Taker model building functionality.

This module provides tools for building and configuring price taker models within the DOVE framework. Price taker models represent entities that accept market prices as given without influencing them.

Classes#

PriceTakerBuilder

Builder class for creating and configuring price taker models.

class dove.models.price_taker.PriceTakerBuilder[source]#

Bases: BaseModelBuilder

Builder class for creating price taker optimization models.

This class implements the builder pattern to construct a price taker optimization model step by step. A price taker model represents a participant in an energy market that accepts prices as given and optimizes their operations accordingly.

The builder adds sets, variables, constraints, and an objective function to the optimization model, and provides methods to solve it and extract results.

model#

The Pyomo concrete model being constructed.

Type:

pyo.ConcreteModel

system#

The energy system being modeled, containing components, resources, and time indices.

Type:

object

Examples

>>> builder = PriceTakerBuilder(system)
>>> model = builder.build().solve()
>>> results = builder.extract_results()
Parameters:

system (System)

build()[source]#

Build the price taker optimization model.

Creates a Pyomo concrete model and adds the necessary sets, variables, constraints, and objective function to formulate the price taker optimization problem.

Returns:

The builder instance, allowing for method chaining.

Return type:

Self

extract_results()[source]#

Extract results from the solved model into a DataFrame.

Collects flow values for all resources produced or consumed by components, as well as state of charge and charge/discharge rates for storage components.

Returns:

A DataFrame containing the optimization results with time index and columns for each component-resource flow and storage variables.

Return type:

pd.DataFrame

solve(**kw)[source]#

Solve the built optimization model.

Parameters:

**kw (Any) –

Keyword arguments for the solver configuration. - solver : str, optional

The solver to use for optimization, default is β€˜cbc’.

Returns:

The solved Pyomo model.

Return type:

pyo.ConcreteModel

Submodules#

dove.models.price_taker.builder module#

dove.models.price_taker.builder#

Price Taker Builder Module

This module provides a builder class for creating price taker optimization models within the DOVE framework. A price taker represents a market participant that accepts energy market prices as given and optimizes operations accordingly.

The PriceTakerBuilder constructs a Pyomo optimization model with: - Sets for components (storage and non-storage), resources, and time periods - Variables for resource flows, state of charge, and charge/discharge rates - Constraints for resource balances, capacity limits, and storage operations - An economic objective function optimizing market participation

The model incorporates both standard generation/consumption components and storage components with their associated charge/discharge dynamics and state of charge tracking.

Notes

The price taker model focuses on economic optimization of resource flows without attempting to influence market prices.

See Also dove.models.base.BaseModelBuilder : Parent class providing the base builder interface

class dove.models.price_taker.builder.PriceTakerBuilder[source]#

Bases: BaseModelBuilder

Builder class for creating price taker optimization models.

This class implements the builder pattern to construct a price taker optimization model step by step. A price taker model represents a participant in an energy market that accepts prices as given and optimizes their operations accordingly.

The builder adds sets, variables, constraints, and an objective function to the optimization model, and provides methods to solve it and extract results.

model#

The Pyomo concrete model being constructed.

Type:

pyo.ConcreteModel

system#

The energy system being modeled, containing components, resources, and time indices.

Type:

object

Examples

>>> builder = PriceTakerBuilder(system)
>>> model = builder.build().solve()
>>> results = builder.extract_results()
Parameters:

system (System)

build()[source]#

Build the price taker optimization model.

Creates a Pyomo concrete model and adds the necessary sets, variables, constraints, and objective function to formulate the price taker optimization problem.

Returns:

The builder instance, allowing for method chaining.

Return type:

Self

solve(**kw)[source]#

Solve the built optimization model.

Parameters:

**kw (Any) –

Keyword arguments for the solver configuration. - solver : str, optional

The solver to use for optimization, default is β€˜cbc’.

Returns:

The solved Pyomo model.

Return type:

pyo.ConcreteModel

extract_results()[source]#

Extract results from the solved model into a DataFrame.

Collects flow values for all resources produced or consumed by components, as well as state of charge and charge/discharge rates for storage components.

Returns:

A DataFrame containing the optimization results with time index and columns for each component-resource flow and storage variables.

Return type:

pd.DataFrame

dove.models.price_taker.rulelib module#

dove.models.price_taker.rulelib#

Rule functions for price-taker pyomo optimization models.

This module provides a collection of rules that can be used to define constraints and objectives in price-taker optimization models using the Pyomo framework. The rules define mathematical relationships that govern how components interact within an energy system, including resource transfers, capacity limitations, and storage dynamics.

The module includes functions for: - Component transfer constraints (input/output relationships) - Capacity constraints (min/max capacity limits) - Resource balance constraints (ensuring conservation) - Storage-specific constraints (charge/discharge rates, state of charge) - Objective function formulation for economic optimization

These rules are designed to be used with Pyomo’s rule-based constraint and objective declaration syntax. Each function returns a Pyomo expression that defines the mathematical relationship for the respective constraint or objective.

All rule functions assume the existence of a PyomoConcreteModel with appropriate variables, parameters, and sets already defined. The model is expected to have a β€˜system’ attribute containing component and resource information.

dove.models.price_taker.rulelib.transfer_rule(m, cname, t)[source]#

Create a PyomoExpression for a price-taker component’s transfer rule.

This function implements the conservation rule for price-taker components, applying the component-specific transfer function to relate inputs to outputs at the specified time step.

Parameters:
  • m (pyo.ConcreteModel) – The Pyomo model containing the system representation.

  • cname (str) – The name of the component.

  • t (int) – The time step for which the constraint applies.

Returns:

A Pyomo expression representing the transfer equation for the component at time t.

Return type:

pyo.Expression

Notes

The component’s transfer_fn method is called with dictionaries of input and output flow variables, indexed by resource name.

dove.models.price_taker.rulelib.max_capacity_rule(m, cname, t)[source]#

Creates a constraint rule for limiting resource flow up to component’s max capacity at the given timestep.

The function creates a Pyomo rule expression that constrains the flow of the capacity resource for a given component at a specific time period to be less than or equal to the maximum capacity of that component at the given timestep.

Parameters:
  • m (pyo.ConcreteModel) – The Pyomo model containing the system components and variables.

  • cname (str) – The name of the component for which the max capacity constraint is being defined.

  • t (int) – The time step for which the constraint applies.

Returns:

A Pyomo expression representing the capacity constraint for the given component at the specified time period.

Return type:

pyo.Expression

Notes

This function assumes that the component has a defined capacity_resource attribute and a time-dependent max_capacity_profile. These values should already been validated.

dove.models.price_taker.rulelib.min_capacity_rule(m, cname, t)[source]#

Generate a constraint that enforces minimum capacity for a component at a given timestep.

This function creates a pyomo expression that constrains the flow of a component to be greater than or equal to its minimum capacity at the given timestep.

Parameters:
  • m (pyo.ConcreteModel) – The pyomo model to which the constraint will be added.

  • cname (str) – The name of the component.

  • t (int) – The time step for which the constraint applies.

Return type:

Expression

Returns:

  • pyo.Expression – A pyomo expression representing the minimum capacity constraint.

  • Notes

  • Assumes that min_capacity_profile is a time-dependent attribute of the component.

dove.models.price_taker.rulelib.ramp_up_rule(m, cname, t)[source]#

Limit rate of increase in component output between time periods.

Parameters:
  • m (pyo.ConcreteModel) – Pyomo model

  • cname (str) – Component name

  • t (int) – Time period

Returns:

Constraint limiting upward ramping or Constraint.Skip

Return type:

pyo.Constraint

dove.models.price_taker.rulelib.ramp_down_rule(m, cname, t)[source]#

Limit rate of decrease in component output between time periods.

Parameters:
  • m (pyo.ConcreteModel) – Pyomo model

  • cname (str) – Component name

  • t (int) – Time period

Returns:

Constraint limiting downward ramping or Constraint.Skip

Return type:

pyo.Constraint

dove.models.price_taker.rulelib.ramp_track_up_rule(m, cname, t)[source]#

Track upward ramps for a component.

Parameters:
  • m (pyo.ConcreteModel) – Pyomo model

  • cname (str) – Component name

  • t (int) – Time period

Returns:

Constraint tracking upward ramps or Constraint.Skip

Return type:

pyo.Constraint

dove.models.price_taker.rulelib.ramp_track_down_rule(m, cname, t)[source]#

Track downward ramps for a component.

Parameters:
  • m (pyo.ConcreteModel) – Pyomo model

  • cname (str) – Component name

  • t (int) – Time period

Returns:

Constraint tracking downward ramps or Constraint.Skip

Return type:

pyo.Constraint

dove.models.price_taker.rulelib.ramp_bin_up_rule(m, cname, t)[source]#

Limit upward ramp size based on binary variable.

Parameters:
  • m (pyo.ConcreteModel) – Pyomo model

  • cname (str) – Component name

  • t (int) – Time period

Returns:

Constraint limiting ramp size or Constraint.Skip

Return type:

pyo.Constraint

dove.models.price_taker.rulelib.ramp_bin_down_rule(m, cname, t)[source]#

Limit downward ramp size based on binary variable.

Parameters:
  • m (pyo.ConcreteModel) – Pyomo model

  • cname (str) – Component name

  • t (int) – Time period

Returns:

Constraint limiting ramp size or Constraint.Skip

Return type:

pyo.Constraint

dove.models.price_taker.rulelib.ramp_freq_window_rule(m, cname, t)[source]#

Limit frequency of ramping events within a time window.

Parameters:
  • m (pyo.ConcreteModel) – Pyomo model

  • cname (str) – Component name

  • t (int) – Time period

Returns:

Constraint limiting ramp frequency or Constraint.Skip

Return type:

pyo.Constraint

dove.models.price_taker.rulelib.steady_state_upper_rule(m, cname, t)[source]#

Define upper bound for steady state operation (no flow increase if in steady state).

Parameters:
  • m (pyo.ConcreteModel) – Pyomo model

  • cname (str) – Component name

  • t (int) – Time period

Returns:

Upper bound constraint for steady state or Constraint.Skip

Return type:

pyo.Constraint

dove.models.price_taker.rulelib.steady_state_lower_rule(m, cname, t)[source]#

Define lower bound for steady state operation (no flow decrease if in steady state).

Parameters:
  • m (pyo.ConcreteModel) – Pyomo model

  • cname (str) – Component name

  • t (int) – Time period

Returns:

Lower bound constraint for steady state or Constraint.Skip

Return type:

pyo.Constraint

dove.models.price_taker.rulelib.state_selection_rule(m, cname, t)[source]#

Ensure exactly one operational state is active at each time step.

Parameters:
  • m (pyo.ConcreteModel) – Pyomo model

  • cname (str) – Component name

  • t (int) – Time period

Returns:

Component must be in exactly one state (up, down, or steady)

Return type:

pyo.Constraint

dove.models.price_taker.rulelib.balance_rule(m, rname, t)[source]#

Calculate the balance rule for a specific resource at a given time step.

This function creates a constraint ensuring the balance of the resource flow: production + storage discharge = consumption + storage charge.

Parameters:
  • m (pyo.ConcreteModel) – The pyomo model containing the optimization variables and parameters.

  • rname (str) – The name of the resource for which to calculate the balance.

  • t (int) – The time step at which to calculate the balance.

Returns:

A Pyomo expression representing the balance constraint for the resource. The constraint ensures that production + storage discharge equals consumption + storage charge.

Return type:

pyo.Expression

dove.models.price_taker.rulelib.storage_balance_rule(m, sname, t)[source]#

Create an expression to ensure state of charge balance for a storage component at time t.

Parameters:
  • m (pyo.ConcreteModel) – The Pyomo model instance containing system components and variables.

  • sname (str) – The name of the storage component.

  • t (int) – The time index at which to calculate the storage balance.

Returns:

A Pyomo expression representing the constraint that the state of charge at time t equals the previous state of charge plus charging (accounting for charging efficiency) minus discharging (accounting for discharging efficiency).

Return type:

pyo.Expression

Notes

For the first time step, the previous state of charge is determined by the initial stored energy parameter of the storage component. The round-trip efficiency (rte) is applied as a square root to both charging and discharging, with charging multiplied by rte^0.5 and discharging divided by rte^0.5.

dove.models.price_taker.rulelib.charge_limit_rule(m, sname, t)[source]#

Create a rule for the maximum charging rate limit of a storage component.

This function returns a pyomo expression that constrains the charging rate of a storage component to its maximum charging rate, which is defined as a fraction of its maximum capacity at the given timestep.

Parameters:
  • m (pyo.ConcreteModel) – The Pyomo model being constructed

  • sname (str) – The name of the storage component

  • t (int) – The time step/period

Returns:

An expression stating that the charging rate at time t must be less than or equal to the maximum charging rate (as a proportion of maximum capacity)

Return type:

pyo.Expression

dove.models.price_taker.rulelib.discharge_limit_rule(m, sname, t)[source]#

Create an expression for the maximum discharge rate of a storage component.

Parameters:
  • m (pyo.ConcreteModel) – The pyomo model containing the system and its components

  • sname (str) – The name of the storage component

  • t (int) – The time index for which to create the discharge limit constraint

Returns:

An expression representing the constraint that discharge at time t cannot exceed the maximum discharge rate times the maximum capacity of the storage component at the given timestep

Return type:

pyo.Expression

dove.models.price_taker.rulelib.soc_limit_rule(m, sname, t)[source]#

Create an expression that constrains the state of charge (SOC) of a storage component to not exceed its maximum capacity at the given timestep.

Parameters:
  • m (pyo.ConcreteModel) – The Pyomo model instance containing system components and variables

  • sname (str) – The name of the storage component in the system

  • t (int) – The time step index

Returns:

A Pyomo expression that limits SOC to the storage component’s maximum capacity at the given timestep

Return type:

pyo.Expression

dove.models.price_taker.rulelib.periodic_storage_rule(m, sname)[source]#

Enforce periodic storage level for a storage component.

This constraint ensures that the state of charge (SOC) at the final time step equals the initial state of charge, respecting the initial_stored attribute.

Parameters:
  • m (pyo.ConcreteModel) – The Pyomo model instance containing system components and variables.

  • sname (str) – The name of the storage component.

Returns:

A Pyomo constraint enforcing periodic storage level.

Return type:

pyo.Constraint

dove.models.price_taker.rulelib.objective_rule(m)[source]#

Calculate the objective function expression for a price-taker optimization model.

This function computes the total economic value from all system components by evaluating the cashflows associated with the dispatch decisions. Each cashflow is scaled according to its price profile and scaling parameters.

Parameters:

m (pyo.ConcreteModel) – The Pyomo model containing system components, dispatch variables, and time periods

Returns:

The objective function expression representing total economic value

Return type:

pyo.Expression

Notes

The function iterates through all components in the system, accessing their cashflows and calculating the contribution to the objective based on: - The dispatch level of the component at each time period - The price profile associated with each cashflow - Scaling parameters (dprime and scalex) that allow for non-linear relationships