Loop-OPF: Solver-Informed Learning for Optimal Power Flow with Inference-Time Topology Adaptivity

Mohamad Chehade, Hao Zhu

It’s late, the coffee is cold, and you’re staring at a power grid simulation that refuses to converge. You need to solve the Optimal Power Flow (OPF) problem—finding the cheapest way to generate power without melting transmission lines—and you need to do it now.

Traditional solvers are mathematically rigorous but slow. Modern "Learning-for-OPF" neural networks are lightning-fast but have a nasty habit of "hallucinating" solutions that violate the laws of physics or grid safety limits. Even worse, if a single transmission line trips, most AI models become useless because they weren't trained for that specific grid layout.

Enter Loop-OPF. This paper introduces a "solver-informed" neural network that doesn't just guess the answer; it embeds the logic of a mathematical optimizer directly into its DNA.

TL;DR

Loop-OPF is a neural network architecture that mimics a classical optimization algorithm (PDHG) to guarantee that its predictions are both optimal and physically feasible. Unlike previous AI methods, it can handle unexpected equipment failures (topology changes) on the fly without needing to be retrained, and it uses a clever "Deep Equilibrium" trick to keep its memory footprint tiny.

What Problem Does This Paper Address?

The power grid is a moving target. Operators constantly solve OPF to balance supply and demand. We face a "trilemma" in the AI approach to this:

  1. Feasibility: Can we trust the AI not to overload a line?
  2. Optimality: Is the AI actually saving us money, or just giving a "safe" but expensive answer?
  3. Adaptivity: If a storm knocks out a generator or a line, does the AI model break?

Existing models usually fail at least one of these. They either use "penalty terms" (which are more like suggestions than rules) or they are "topology-dependent," meaning they are hard-coded to one specific grid map.

Methods

The authors didn't just build a black-box regressor. They used a technique called Algorithm Unrolling.

They took a powerful optimization algorithm called the Primal-Dual Hybrid Gradient (PDHG) and turned its iterations into the layers of a neural network.

  • Solver-Informed: Each "layer" of Loop-OPF is actually one step of the PDHG solver. Because the math of PDHG is baked into the architecture, if the network converges, the answer is guaranteed to be the mathematically optimal and feasible solution.
  • Deep Equilibrium (DEQ): Normally, if you want 1,000 iterations of a solver, you need a 1,000-layer neural network, which would destroy your GPU's memory. Loop-OPF uses the DEQ framework to treat the network as a single "loop" that runs until it hits a fixed point. This keeps memory usage constant regardless of how many iterations you run.
  • Self-Supervised Learning: The model doesn't need "labels" (pre-solved answers). It trains itself by looking at the OPF cost function and constraints directly, learning the best "step sizes" to reach the answer as fast as possible.
Fig. 1. (a) Loop-OPF as a stack of identical layers T ; (b) its equivalent looped form; (c) one layer T . Topology-dependent quantities carry the superscript (c), and the step sizes are in purple.

Datasets

The authors put Loop-OPF through the wringer using standard industry benchmarks:

  • IEEE 300-bus system: A medium-sized classic.
  • PEGASE systems (1354, 2869, and 9241 buses): Large-scale, high-fidelity models of the European high-voltage grid.
  • Contingency Scenarios: They generated thousands of samples involving random line and generator outages to test if the model could adapt to "unseen" grid failures.

Key Insights and Ideas

  • Training for Speed, Not Just Accuracy: In Loop-OPF, the "math" ensures the answer is right. The "learning" part is just there to tune the parameters so the solver reaches that right answer in 10 steps instead of 1,000.
  • The "Anytime" Property: This is a huge win for real-time operations. Because it’s an iterative loop, you can stop the model at any time. Need a "good enough" answer in 2 milliseconds? Stop early. Have 10 milliseconds? Let it run a few more loops for a perfect answer.
  • Zero-Shot Adaptivity: Because the grid topology (the "H" matrix) is an input to every layer, you can change the grid layout at inference time. The model doesn't care if a line is missing; it just plugs the new matrix into the same learned logic.

Key Results

Loop-OPF consistently outperformed state-of-the-art models like DeepOPF and GNN-based approaches:

  • Feasibility: In "Security-Constrained" tests (where the grid must survive any single line failure), Loop-OPF was the only method that achieved 100% feasibility across all test samples without needing a secondary "repair" step.
  • Accuracy: On the massive 9241-bus system, Loop-OPF achieved an RMSE of 0.051%, significantly lower than competing AI models.
  • Cost Gap: The "cost gap" (how much extra money you spend vs. a perfect solver) was nearly zero ($6 \times 10^{-7}\%$), while other AI methods often had gaps of 0.4% to 3.5%.
Comparison of secure samples and cost gaps. Loop-OPF (blue) hits 100% security with a near-zero cost gap compared to other methods.

Limitations and Future Work

  • DC vs. AC: This paper focuses on DC-OPF, which is a linearized (simplified) version of power flow. While DC-OPF is widely used in electricity markets, the real world is AC, which is non-convex and much harder. The authors note that PDHG can work for AC, but the guarantees of global optimality are harder to maintain.
  • Training Time: Training on the largest networks took up to 40 hours. While this is a "one-time" cost, it's still significant.
  • Scenario-Specific Tuning: Currently, the model learns one set of step sizes for all scenarios. The authors suggest that future versions could use "meta-learning" to predict custom step sizes for specific types of grid stress.

Final Thought: If you've ever felt that AI in critical infrastructure is a bit too much like "guessing," Loop-OPF is the reality check we needed. It proves you can have the speed of a neural network without throwing the physics textbook out the window.

Summary updated

Abstract

Learning for optimal power flow (OPF) has recently been advocated to accelerate OPF solutions by using a pre-trained neural network (NN) to predict directly from given inputs such as the load demand. However, existing learning-for-OPF methods largely fall short of ensuring the optimality and feasibility of their predictions. They also struggle to adapt at inference time to unseen topology scenarios, such as those caused by line or generator outages. This work puts forth Loop-OPF, a solver-informed NN that builds its layers from the iterations of the primal-dual hybrid gradient (PDHG) method. Under standard convexity and regularity conditions on DC-OPF, the resultant fixed-point output of Loop-OPF is thus optimal and feasible. To speed up PDHG across diverse OPF scenarios, Loop-OPF learns certain PDHG parameters in a self-supervised manner, without any OPF solution labels. We adopt the deep equilibrium (DEQ) framework for training so that the memory cost does not grow with the number of layers. As the grid topology enters every layer as an input, the same trained Loop-OPF directly adapts to unseen contingencies without retraining. Numerical tests on the IEEE 300-bus and PEGASE 1354-, 2869-, and 9241-bus networks have demonstrated the accuracy and topology adaptivity of the proposed Loop-OPF over competing learning-for-OPF methods.
BibTeX
@misc{chehade2026loop,
  author = {Mohamad Chehade and Hao Zhu},
  title = {{Loop-OPF: Solver-Informed Learning for Optimal Power Flow with Inference-Time Topology Adaptivity}},
  year = {2026},
  eprint = {2611.27013},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.27013},
}
Figure