When a power grid operator faces a load pattern that the network cannot serve safely, the practical question is which few loads to cut, by how much, and at what price in safety margin. A recent line of work treats this as a counterfactual explanation problem. A counterfactual explanation, also called algorithmic recourse, is the smallest change to an input that flips a model's decision. In the grid setting, a classifier predicts "infeasible," and the method searches for nearby load profiles that the classifier calls "feasible." Restoring Feasibility in Power Grid Optimization: A Counterfactual ML Approach reports 100% feasibility recovery and up to a 43x speedup on the IEEE 300-bus system. Both numbers have two qualifiers. "Feasible" was judged against a learned classifier, and only under the linearized DC power-flow model, which ignores voltage magnitudes and reactive power. Counterfactual search is known to behave like an adversarial attack: it pushes inputs into regions where the model's decision boundary is unsupported by training data. A recourse that satisfies a classifier may therefore break Kirchhoff's laws once the full nonlinear physics are checked.
We propose to make physical consistency hold by construction rather than by approximation. The search runs only over the loads the operator can actually change, under a mask of actionable buses. Each candidate adjustment is passed through an exact AC power-flow solve, so every state the search scores satisfies the physics, and validity means the solver reports no voltage or thermal-limit violation. A Pareto search then returns the full set of non-dominated trade-offs among three quantities: megawatts shed, number of buses touched, and remaining voltage and thermal margin. To keep latency low, a learned proposal model suggests sparse candidates. A repair step restricted to each candidate's support fixes them, so the solver never spreads small adjustments across the whole network. The central empirical claim, which we test first, is that classifier-validated DC recourse has a large and measurable physical failure rate under AC power flow. Our second claim is that solver-in-the-loop Pareto search closes that gap without giving up the sparsity that makes recourse usable.
What exists and where this sits
Multi-objective counterfactual search was established by Multi-Objective Counterfactual Explanations. That work, called MOC, runs the NSGA-II evolutionary algorithm over prediction distance, feature distance, sparsity and data plausibility. It reports Pareto sets that dominate scalarized baselines, with near-100% coverage on tabular data. We reuse its search machinery and its argument against hiding trade-offs behind fixed loss weights. We replace its statistical plausibility objective with a hard physical equality constraint. Counterfactual Explanations for Deep Learning-Based Traffic Forecasting shows that MOC transfers to network-structured physical systems. Its plausibility, however, still comes only from data correlations. It therefore motivates our concern that recourse in physical networks can be statistically plausible yet physically impossible.
Fast generative recourse, as in DiCoFlex, uses a conditional normalizing flow, an invertible generator mapping Gaussian noise to samples. Conditioned on target class, sparsity level and an actionability mask, it reaches about 0.12 s per instance with 1.000 validity on tabular benchmarks. We borrow its conditioning design for our proposal model. A flow, however, cannot enforce nonlinear equalities, which is why our design adds a repair step. Density- and energy-based plausibility methods aim to keep recourse near the training data: Generating Likely Counterfactuals Using Sum-Product Networks, Faithful Model Explanations through Energy-Constrained Conformal Counterfactuals, and Convex Density Constraints. We treat them as the data-manifold alternative that our experiments must beat.
From the physics side, Deep Conservation supplies the methodological lesson. It enforces conservation as an equality constraint inside each solve. Its unconstrained counterpart violated global conservation by more than an order of magnitude more. That result constrains our design: we expect soft physics penalties to leave residual violations. PreDiff nudges generation with physics gradients, cutting energy error on N-body MNIST from 0.0226 to 0.0039. Even so, this soft nudging reduces violations without eliminating them. Neural Counterfactual Reasoning for Interacting Systems uses a physics-informed simulator to evaluate prescribed what-if interventions in the forward direction. It never solves the inverse problem of finding sparse, non-dominated interventions, and that inverse problem is what we address.
Core Claim
Let $a \in \mathbb{R}^n$ be the load adjustment on $n$ buses, restricted by an actionability mask. Let $s(a)$ be the voltage magnitudes, angles and branch flows returned by the AC power-flow equations $g(s, d_0 + a) = 0$ at base demand $d_0$. Define the safety margin $\mu(s)$ as the smallest normalized slack across voltage and thermal limits. The recourse problem is
$$\min_{a} \big(\, \|a\|_1,\ \|a\|_0,\ -\mu(s(a)) \,\big) \quad \text{subject to } g(s(a), d_0 + a) = 0,\ \mu(s(a)) \ge 0.$$
Prior grid recourse replaced both the equality constraint and the feasibility test with a classifier output. Prior multi-objective recourse never had the equality at all. Our claim is that the gap between the two matters. Under AC physics, a substantial fraction of classifier-certified recourses will fail. Solving the problem as written returns fronts that a practitioner can act on directly, within a latency budget comparable to classifier-based methods.
Research Program
The work has three parts. The first is a measurement study. We generate infeasible scenarios on IEEE 30-bus and 300-bus by perturbing loads, following the setup of Restoring Feasibility. We reproduce their feedforward and decision-tree classifier recourse, then re-check every returned profile with a full AC power flow plus limit checks. The quantity of interest is the surrogate gap: the share of recourses the classifier accepts that the physics rejects. We also record which limits fail, voltage or thermal.
The second part is the exact search. NSGA-II operates on masked, sparse adjustments $a$. We initialize it with buses ranked by sensitivity of the violated limits, analogous to MOC's ICE-curve initialization. Every candidate is scored after a Newton–Raphson power-flow solve. A candidate whose solve diverges is infeasible by definition.
The third part is amortization through support-preserving repair. A conditional flow in the style of DiCoFlex is trained on fronts from the exact search. It proposes adjustments conditioned on base demand, mask and a target sparsity. Each proposal is then repaired by a small constrained solve that may change only the buses in the proposal's support. The repair minimizes $\|a - a_{\text{prop}}\|$ subject to AC feasibility. Restricting repair to the support is the ingredient that answers the projection objection. A full projection spreads adjustments everywhere, whereas this repair keeps the sparsity pattern the proposal chose. Its cost is a handful of solver calls on a reduced variable set.
Baselines
The naive reference point is the original infeasible profile, together with uniform proportional load shedding across all actionable buses until AC feasibility is reached. This baseline shows how much any targeted method gains in megawatts and buses touched.
The strongest existing recourse method on this exact benchmark is the classifier-based counterfactual approach of Restoring Feasibility in Power Grid Optimization. It reports 100% feasibility recovery on IEEE 30- and 300-bus under DC-OPF and up to 43x speedup over the analytical solver on 300-bus. It reports load adjustments described only as "competitive" with, and slightly larger than, the solver baseline, with no exact figure given. We rerun it on our scenarios with its diversity setting of at least ten candidates. Training data and tuning budget match ours, and its outputs are scored by the same AC check. Beating it means a higher AC-validated feasibility rate. Our median wall-clock time per scenario must stay within the same order of magnitude, and every recourse it shares with ours must be physically valid. No reported result found on Lacuna exists for this method under AC power flow, which is the point of the measurement study.
The strongest classical competitor is a scalarized AC optimal power flow. It minimizes shed load with an added count penalty or an epsilon-constraint on buses touched, solved with a standard nonlinear solver, and swept across weights to trace an approximate front. It receives the same total solver-time budget as our search. Beating it means a larger dominated hypervolume, including regions where it gets trapped in local optima, at equal time. We also run MOC with its original statistical plausibility objective scored by the AC check, and a soft-penalty variant that adds the power-flow residual as a fourth objective without enforcing it.
Two ablations isolate our contributions. The first replaces physics-based validity with the classifier during search, which tests whether solver-in-the-loop validity is what matters. The second replaces support-preserving repair with unrestricted projection, which tests whether the restriction preserves sparsity at equal feasibility.
Why not just…?
Why not just add the power-flow residual as a penalty term? Deep Conservation found that its unconstrained model left conservation violations more than an order of magnitude larger than its exactly constrained one. PreDiff's soft physics guidance reduced energy error rather than removing it. In grid recourse, any residual mismatch means the profile is not an operating point. Our soft-penalty baseline will show whether the residual stays above solver tolerance, and how the penalty weight trades this against sparsity.
Why not just generate standard counterfactuals and project them onto the feasible set with a solver? This is a real threat. If unrestricted projection kept sparsity, our repair step would add nothing. The ablation compares buses touched and megawatts shed before and after projection, against our support-restricted repair, at matched feasibility. If the full projection does not inflate the support, we will report that and keep only the measurement study and the exact search as contributions.
Why not rely on the data manifold, since real grid data already obeys physics? Recourse searches near decision boundaries and off the data, where density estimates are least reliable, as Convex Density Constraints argues. Being near realistic points does not make a load profile solvable. MOC with plausibility, scored by AC power flow, directly measures how often the data manifold certifies physically invalid recourse.
Why not just run a load-shedding optimal power flow, the tool operators already use? This is the most serious alternative, and it is why it appears as a baseline. Its weakness is structural. A count-of-buses objective is combinatorial and nonconvex under AC physics, and a weighted sweep reveals only one point per solve. If the sweep matches our hypervolume at equal time, the honest conclusion is that ML adds speed only through amortization. The amortized proposal-plus-repair timing then becomes the result that must hold up.
Proposed Experiments
On IEEE 30-bus and 300-bus we report five quantities: AC-validated feasibility rate, Pareto hypervolume over shed megawatts, buses touched and margin, median wall-clock time, and the surrogate gap. We use several hundred infeasible scenarios per system, split by stress level, and include held-out stress levels to test extrapolation of the amortized proposer.
Two checks are decisive. The first is whether the surrogate gap of classifier-based recourse is materially above zero on 300-bus. If it is near zero, the motivation weakens and the paper becomes a negative result about AC risk. The second is whether support-preserving amortized recourse reaches the exact-search hypervolume within a small margin. It must do so while running within the same order of magnitude of time as the classifier baseline and well below the scalarized-OPF sweep.
A secondary transfer test applies the same action-space, solver-in-the-loop recipe to the parameterized Burgers equation from Deep Conservation. There, the actions are sparse boundary or source adjustments, and validity is checked by the finite-volume solver. The test asks whether the gap between classifier and physics, and the benefit of repair, appear beyond power grids.
References
- Restoring Feasibility in Power Grid Optimization: A Counterfactual ML Approach
- Multi-Objective Counterfactual Explanations
- Counterfactual explanations for deep learning-based traffic forecasting
- DiCoFlex: Model-Agnostic Diverse Counterfactuals with Flexible Control
- Generating Likely Counterfactuals Using Sum-Product Networks
- Faithful Model Explanations through Energy-Constrained Conformal Counterfactuals
- Convex Density Constraints for Computing Plausible Counterfactual Explanations
- Deep Conservation: A Latent-Dynamics Model for Exact Satisfaction of Physical Conservation Laws
- PreDiff: Precipitation Nowcasting with Latent Diffusion Models
- Neural Counterfactual Reasoning for Interacting Systems: Bridging Physics-Informed Learning and Reasoning for PHM