Software Architecture#
The implementation follows a modular, object-oriented architecture designed for extensibility and maintainability. The core components are:
PowerFlowEngine: An abstract base class defining the interface for power flow calculations and network manipulation. This allows the underlying solver (e.g., PandaPower) to be swapped without affecting the rest of the system (Strategy Pattern).
EnhancementStrategy: An abstract base class for all grid enhancement strategies. Concrete implementations (e.g.,
TapChangeStrategy,LineUpgradeStrategy) encapsulate specific logic for addressing constraints. This adheres to the Open/Closed Principle, allowing new strategies to be added without modifying existing code.GridEnhancementAlgorithm: The main orchestrator that executes the sequential greedy heuristic. It utilizes a
StrategyRegistryto manage available strategies and their priority.CostModel: A separate component for economic evaluation, decoupling technical optimization from financial parameters.
The system is designed to be easily extended by:
Implementing new strategies by subclassing
EnhancementStrategyand registering them with the algorithm.Integrating different power flow solvers by implementing the
PowerFlowEngineinterface.Customizing the cost model or adding new constraint types.
New MV/LV Substations and Planning Profiles#
The new MV/LV substation strategy and the planning profiles add these pieces, each in the layer it belongs to:
Engine (
gridforge.core.power_flow,PowerFlowEngine): the operations that a new substation needs (split_line,open_line,add_bus,add_line,add_transformer,set_transformer_parallel), the reads of the network for the strategy (get_bus_coordinates,get_line_geometry,get_buses_info,get_transformer_parameters,get_transformer_type_parameters), and the reads of the rule of dedicated lines,get_customer_busesandget_open_links. The operations and the reads raiseNotImplementedErrorby default, exceptget_open_links, which returns an empty list;PandaPowerEngineimplements all of them.Placement core (
gridforge.strategies.substation_placement): pure functions with no engine: the split of a radial LV network by the nearest unit along the cables, LinDistFlow, the ranking of candidate buses and taps, the placement of units one at a time with a power flow passed in as a check, Enedis’s sizing of a unit, and the projection on the MV lines.Strategies (
gridforge.strategies):NewSubstationStrategy(new_substation) places the units, teeing them into the MV network, opening the LV lines between parts and taking back the upgrades of a network when asked;NoLoadTapStrategy(no_load_tap) moves the no-load tap of a unit in place. Both are planning strategies on the levels ofConstraintViolation.level.LineUpgradeStrategytakes the cap on conductors in parallel, by level of network, and the exemption ofuncapped_lines, such asdedicated_lines.Orders and levels (
gridforge.core.grid_enhancement): the priority order names a violation type at a level (TypeAtLevel),TOP_DOWN_ORDERis the MV network first, and each strategy declares its levels withapplicable_levels(). The algorithm lends the strategies the states of the run at its start (lines_at_start,transformers_at_start,tap_positions_at_start) and the origins of the elements an action created, so that a later upgrade of a new element is priced from its creation.Costs (
gridforge.core.cost_model): the works, unit and cable of a new substation (calculate_new_substation_cost,calculate_new_substation_works_cost), and the per-intervention price of a no-load tap (calculate_no_load_tap_cost).Profiles (
gridforge.core.profiles):PROFILES,ORDERS,PlanningProfileandget_profile. A profile holds settings only: it gives the priority order, the choice of the strategies, whether the run is priced, and the strategies with their options, whichmv_lv_feeder.create_runandcreate_strategy_registryturn into a registry. A study that builds its own strategies takes the settings it needs from a profile. See Planning profiles.
Transparency and Explainability#
To ensure trust and facilitate operator decision-making, the system emphasizes transparency and explainability. Every action taken by the algorithm is logged with a detailed justification. The logging mechanism captures:
Grid State: A snapshot of the network conditions (e.g., violation magnitudes) before the action.
Target Selection: The specific constraint violation being addressed.
Action Details: The precise modification applied (e.g., “Tap Change on transformer T1: Shift +2 steps”).
Mathematical Justification: The quantitative reasoning behind the decision. For example, in flexibility management, the system logs the calculated sensitivity factor and efficiency score that led to the selection of a specific asset. In tap changer control, it records the ideal voltage adjustment versus the available tap steps.
This granular logging allows operators to trace the algorithm’s decision path, verify the underlying mathematical basis (e.g., sensitivity values), and understand why a specific strategy was prioritized over others.