Unit-Based Model#

The unit-based model represents the market at the level of individual generating units and demand blocks. It combines operational constraints, network constraints, and pricing algorithms to study how market design choices affect dispatch, prices, welfare, and redispatch outcomes.

This page is the API entry point for apem.unit_based_model.

What This Module Covers#

  • Data: scenario loading/parsing and model-ready data structures.

  • Allocation: market-clearing formulations (nodal and zonal), including redispatch extensions.

  • Pricing: post-allocation pricing algorithms (for example ELMP, IP, Join, Markup, Min-MWP).

  • Evaluation: post-run analysis of prices, welfare, redispatch, and lost opportunity costs.

  • Solver Configuration: shared optimizer settings used by allocation and pricing routines.

Typical Execution Flow#

  1. Parse or load a dataset into a Scenario.

  2. Choose allocation settings (power-flow model, redispatch, solver config).

  3. Solve allocation/dispatch.

  4. Run a pricing algorithm on the solved allocation.

  5. Evaluate outputs across runs and configurations.

See Also#

Support APIs#

Solver Configuration#

API path: apem.unit_based_model.solver_configuration

Solver configuration shared by the unit-based allocation and pricing layers.

class SolverConfiguration(
MIP_gap,
optimality_tol,
time_limit,
work_limit,
threads,
presparsify,
strict_supply_demand_eq,
relaxation,
output_flag,
verbosity,
slack_penalty=1000000000000000.0,
)[source]#

Bases: object

Collects the optimizer parameters applied to unit-based solves.

The same object is passed to allocation, redispatch, and pricing routines so they use consistent solver settings across a run.

Initialize solver settings used for Gurobi-backed unit-based runs.

Parameters:
  • MIP_gap – relative MIP gap target for mixed-integer solves

  • optimality_tol – optimality tolerance passed to Gurobi

  • time_limit – wall-clock time limit in seconds

  • work_limit – Gurobi work limit

  • threads – number of solver threads; 0 lets Gurobi decide

  • presparsify – value for the Gurobi Presparsify parameter

  • strict_supply_demand_eq – whether supply-demand balance should be enforced strictly

  • relaxation – whether the optimization model should be solved as a relaxation

  • output_flag – Gurobi output flag controlling solver log output

  • verbosity – whether APEM should print progress information around solves

  • slack_penalty – penalty coefficient used where slack variables are introduced

apply_to_model(model)[source]#

Apply the stored settings to a Gurobi model instance.

Parameters:

model – Gurobi model to configure before optimization

Enums#

API path: apem.unit_based_model.enums

class FBMCBaseCases(value)[source]#

Bases: Enum

class PowerFlowModels(value)[source]#

Bases: Enum

class PricingAlgorithms(value)[source]#

Bases: Enum

class RedispatchAlgorithms(value)[source]#

Bases: Enum

class UnitBased_Datasets(value)[source]#

Bases: Enum

Utilities#

API path: apem.unit_based_model.utils

ensure_dir(path)[source]#

Ensure the given directory exists.

Parameters:

path (Path)

Error#

API path: apem.unit_based_model.error

class Error(status)[source]#

Bases: Exception

Lightweight status-carrying error object returned by solver routines.

Parameters:

status – numeric status code describing the failure condition

property status#

Return the stored failure status code.