APEM Core#

The APEM Core layer coordinates configuration, model selection, and execution flow across the project. It serves as the integration layer that connects configuration loading, model dispatch, and run orchestration into a consistent workflow.

Note

For a high-level introduction to the full project, see APEM: Allocation and Pricing in Electricity Markets.

Scope#

Core responsibilities:

  • Normalize and validate runtime configuration from config.json.

  • Map high-level model selections to concrete implementations.

  • Orchestrate allocation, pricing, redispatch, and result analysis runs.

  • Persist run metadata and output directory structure.

Execution Flow#

  1. ConfigLoader reads and validates model-scoped configuration.

  2. MarketModels / market_models resolve selected market model.

  3. execution_chain dispatches to:

    • unit-based solve flow, or

    • order-book Euphemia flow.

  4. Results and metadata are written under results/....

Extension Points#

Common extension points in the core layer:

  • Add new config fields in apem.config_loader.ConfigLoader.

  • Add/adjust core model registry in apem.core / apem.market_models.

  • Extend execution orchestration in apem.execution_chain.

Config Loader#

API path: apem.config_loader

class ConfigLoader(config_path='config.json')[source]#

Bases: object

Entry point for reading config.json. It normalizes the user-facing schema, validates allowed combinations (datasets, models, pricing, redispatch, solver options), and exposes typed getters used by the execution layer.

Initialize a configuration from disk.

Parameters:

config_path (str) – Path to a JSON configuration file.

get_euphemia_configuration()[source]#

Return Euphemia-specific options for order-book runs.

Return type:

Dict[str, Any]

get_market_model()[source]#

Return the selected high-level market model enum.

Return type:

MarketModels

get_power_flow_model()[source]#

Instantiate the configured power-flow model object.

get_unit_based_solver_congiruation()[source]#

Return the normalized unit-based solver configuration object.

Return type:

Dict[str, Any]

Core#

API path: apem.core

class MarketModels(value)[source]#

Bases: Enum

Supported high-level market model families.

Market Models#

API path: apem.market_models

class MarketModel[source]#

Bases: ABC

Abstract marker base class for high-level market model families.

class order_book_based_model[source]#

Bases: MarketModel

Order-book-based (Euphemia-style) workflow family.

class unit_based_model[source]#

Bases: MarketModel

Unit-based market workflow family.

Execution Chain#

API path: apem.execution_chain

Orchestrates end-to-end runs. It builds run directories, dispatches allocation/pricing/redispatch (or Euphemia), and triggers result analysis and output generation.

analyse_results(
scenario,
allocation,
pricing,
configuration,
pf_model_value,
base_scenario=None,
results_root=None,
)[source]#

Run post-pricing analysis and write stats/plot data to the run folder.

This validates that pricing succeeded, builds a PriceAnalysis object, computes all configured analysis outputs, and returns the populated analysis instance.

Parameters:
Return type:

PriceAnalysis

solve_and_analyse_scenario(
unit_based_dataset,
order_book_based_dataset,
market_model,
power_flow_model,
cut_type,
pricing_algorithm,
redispatch_algorithm=RedispatchAlgorithms.MinCostRD,
redispatch_constraint_units=False,
redispatch_threshold=0,
alpha=0,
)[source]#

Run the selected market-model workflow and produce analysis outputs.

For order_book_based_model, this executes the Euphemia pipeline. For unit_based_model, this runs allocation/pricing (and redispatch when applicable) and then computes analysis artifacts.

Parameters:
solve_unit_based_allocation_and_redispatch_only(
dataset,
power_flow_model,
redispatch_algorithm=RedispatchAlgorithms.MinCostRD,
redispatch_constraint_units=False,
redispatch_threshold=0,
)[source]#

Compute allocation plus redispatch only and return the run root for redispatch analyses.

Parameters:
Return type:

str

solve_unit_based_allocation_only(dataset, power_flow_model)[source]#

Compute only the allocation stage and return the run root for welfare-style analyses.

Parameters:
Return type:

str

solve_unit_based_scenario(
dataset,
power_flow_model,
pricing_algorithm,
redispatch_algorithm=RedispatchAlgorithms.MinCostRD,
redispatch_constraint_units=False,
redispatch_threshold=0,
)[source]#

Run allocation and pricing for one unit-based scenario.

Parameters:
Return type:

PriceAnalysis