dove.models package#

Model registry and builder pattern implementation for DOVE.

This module provides a registry system for model builders in the DOVE framework. It allows different model building strategies to be registered and retrieved by name.

The module defines:
  • BUILDER_REGISTRY: A dictionary mapping model builder names to their classes

  • register_builder: A decorator for registering model builder classes

Examples

To register a new model builder:

``` @register_builder(β€œmy_model”) class MyModelBuilder(BaseModelBuilder):

…

```

To access a registered builder:

` builder_cls = BUILDER_REGISTRY["my_model"] builder = builder_cls(...) `

class dove.models.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

Subpackages#

Submodules#

dove.models.base module#

dove.models.base#

Base module providing abstract base classes for model builders in the DOVE system.

This module defines the foundation for all model builders, which are responsible for creating, solving, and extracting results from computational models.

class dove.models.base.BaseModelBuilder[source]#

Bases: ABC

Abstract base class for all model builders in the DOVE system.

This class defines the interface that all model builders must implement, providing a consistent workflow for building, solving, and extracting results from models.

system#

Reference to the DOVE system instance.

Type:

System

model#

The constructed model object (initialized to None).

Type:

Any

Parameters:

system (System)

__init__(system)[source]#

Initialize a model builder.

Parameters:

system (System) – Reference to the DOVE system instance.

Return type:

None

abstractmethod build()[source]#

Build a model based on the system configuration.

This method should create and populate the model structure based on the current system state.

Returns:

The built model object.

Return type:

Any

abstractmethod solve()[source]#

Solve the built model.

This method should execute the model and obtain solutions for the problem defined in the model.

Returns:

The solution or results from solving the model.

Return type:

Any

abstractmethod extract_results()[source]#

Extract and process results from the solved model.

This method should convert the raw model solution into a format usable by the rest of the DOVE system.

Returns:

The processed results from the model.

Return type:

Any