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#
ConfigLoaderreads and validates model-scoped configuration.MarketModels/market_modelsresolve selected market model.execution_chaindispatches to:unit-based solve flow, or
order-book Euphemia flow.
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:
objectEntry 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]
Core#
API path: apem.core
Market Models#
API path: apem.market_models
- class MarketModel[source]#
Bases:
ABCAbstract marker base class for high-level market model families.
- class order_book_based_model[source]#
Bases:
MarketModelOrder-book-based (Euphemia-style) workflow family.
- class unit_based_model[source]#
Bases:
MarketModelUnit-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,
Run post-pricing analysis and write stats/plot data to the run folder.
This validates that pricing succeeded, builds a
PriceAnalysisobject, computes all configured analysis outputs, and returns the populated analysis instance.- Parameters:
scenario (Scenario)
allocation (Allocation)
pricing (Pricing)
configuration (SolverConfiguration)
base_scenario (Scenario | None)
results_root (str | None)
- 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,
Run the selected market-model workflow and produce analysis outputs.
For
order_book_based_model, this executes the Euphemia pipeline. Forunit_based_model, this runs allocation/pricing (and redispatch when applicable) and then computes analysis artifacts.- Parameters:
unit_based_dataset (UnitBased_Datasets)
order_book_based_dataset (OrderBookBased_Datasets)
market_model (MarketModels)
power_flow_model (PowerFlowModel)
cut_type (CutTypes)
pricing_algorithm (PricingAlgorithms)
redispatch_algorithm (RedispatchAlgorithms)
redispatch_constraint_units (bool)
redispatch_threshold (float)
alpha (float)
- solve_unit_based_allocation_and_redispatch_only(
- dataset,
- power_flow_model,
- redispatch_algorithm=RedispatchAlgorithms.MinCostRD,
- redispatch_constraint_units=False,
- redispatch_threshold=0,
Compute allocation plus redispatch only and return the run root for redispatch analyses.
- Parameters:
dataset (UnitBased_Datasets)
power_flow_model (PowerFlowModel)
redispatch_algorithm (RedispatchAlgorithms)
redispatch_constraint_units (bool)
redispatch_threshold (float)
- 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:
dataset (UnitBased_Datasets)
power_flow_model (PowerFlowModel)
- Return type:
str
- solve_unit_based_scenario(
- dataset,
- power_flow_model,
- pricing_algorithm,
- redispatch_algorithm=RedispatchAlgorithms.MinCostRD,
- redispatch_constraint_units=False,
- redispatch_threshold=0,
Run allocation and pricing for one unit-based scenario.
- Parameters:
dataset (UnitBased_Datasets)
power_flow_model (PowerFlowModel)
pricing_algorithm (PricingAlgorithms)
redispatch_algorithm (RedispatchAlgorithms)
redispatch_constraint_units (bool)
redispatch_threshold (float)
- Return type:
PriceAnalysis