Skip to main content
Back

Tsinghua's PolyFormer Shrinks Power Grid Optimization by 6,400x

PolyFormer uses physics-informed ML to reshape complex constraints into simple polytopes, delivering up to 6,400x speedups and 99.87% memory savings on real engineering problems

Pro

  • PolyFormer learns to replace complex physical constraints with compact polytopes, letting standard solvers run orders of magnitude faster.
  • Achieves up to 6,400x speedup and 99.87% memory reduction across three benchmark problem classes.
  • A tunable parameter lambda lets users control the trade-off between strict feasibility and solution optimality.
  • Handles parameterized constraints (e.g., voltage-dependent power regions) via two small neural networks without retraining.
  • Outperforms or matches state-of-the-art methods on resource aggregation, power flow, and distributionally robust portfolio optimization.
  • Code is open source at github.com/wenyl16/PolyFormer; limited to convex or convex-hull-approximable feasible regions.

Constrained optimization sits at the heart of some of the most consequential decisions in modern engineering: scheduling power grids, routing fleets, managing financial risk. The problem is that real-world physical constraints are messy. They are nonlinear, high-dimensional, and deeply coupled, making them brutally expensive to solve at scale. A new paper from researchers at Tsinghua University, EPFL, and collaborating institutions introduces PolyFormer, a framework that takes a fundamentally different approach: instead of building smarter solvers, it learns to make the problem itself simpler.

The wall every optimizer hits

Real-world optimization problems are governed by complex physical constraints that limit their scalability. Three recurring sources of this complexity show up across almost every domain:

  • Scale: thousands of individual devices (electric vehicles, batteries, heat pumps) each with their own physical limits
  • Network interdependence: power grids, communication networks, and transport systems where every node affects every other
  • Uncertainty: decisions that must remain robust against unknown future conditions

These characteristics make optimization-based decision-making problems high-dimensional, nonlinear, and mixed-integer, substantially complicating the search for effective solutions. The stakes are real: the paper cites the 2025 Iberian blackout, caused by suboptimal power system scheduling, as an example of what happens when optimization fails at scale.

Existing approaches fall into two camps, and both have ceilings. Analytical methods like decomposition and convex relaxation require problem-specific derivations and can suffer from unstable convergence. Machine learning methods that directly predict solutions often lack feasibility guarantees, while solver-acceleration methods still have to operate on the full, uncompressed problem model.

Geometry is the key

The key insight is that many complex constraints, despite their diverse forms, define a geometric shape that can be learned by PIML and approximated by a compact polytopic reformulation. A polytope (think: a multi-dimensional polygon defined by a set of linear inequalities) is something any standard solver can handle efficiently. The question is whether you can accurately approximate a complex, nonlinear feasible region with one.

PolyFormer opens a new direction for physics-informed machine learning (PIML) in prescriptive optimization tasks, where physical and geometric knowledge is not merely used to regularize learning models, but to simplify the problems themselves. PolyFormer captures geometric structures behind constraints and transforms them into efficient polytopic reformulations, thereby decoupling problem complexity from solution difficulty. Once the polytope is learned, you swap out the original constraints and hand the simplified problem to any off-the-shelf solver.

PolyFormer architecture: workflow, training pipeline, and neural network components A-net and b-net

How it actually works

PolyFormer learns a matrix A and vector b that define the polytope P = {x | Ax ≤ b}. Training is driven by two competing error signals:

  • Feasibility error: how much the learned polytope sticks out beyond the true feasible region (solutions inside the polytope but outside the real region are infeasible)
  • Optimality error: how much of the true feasible region the polytope fails to cover (the optimal solution might be in a part you missed)

A single hyperparameter lambda controls the trade-off. Setting lambda = 1 forces an inner approximation (every point in the polytope is guaranteed feasible). Setting lambda = 0 gives an outer approximation (you never miss the optimal, but some solutions may violate constraints). Values in between balance the two.

Training works by repeatedly sampling a random direction, computing how far the polytope boundary deviates from the true constraint boundary in that direction, and updating A and b via gradient descent. The loss function is explicitly differentiable, so standard PyTorch or TensorFlow autograd handles the gradients. No implicit differentiation or matrix inversions required.

For problems where the feasible region shifts with changing parameters (temperature, voltage, risk level), PolyFormer adds two small neural networks, called A-net and b-net, that map the parameter to the polytope matrices. This means the model can instantly re-estimate the polytope for new conditions without retraining from scratch.

Three benchmarks, three domains

Through evaluations across three important problems (large-scale resource aggregation, network-constrained optimization, and optimization under uncertainty), PolyFormer achieves computational speedups up to 6,400-fold and memory reductions up to 99.87%, while maintaining solution quality competitive with or superior to state-of-the-art methods.

Resource aggregation (smart grids): The task is to characterize the combined power flexibility of 1,000 electric vehicles, batteries, and heat pumps as a single compact constraint set. The full model requires 57,696 constraints. PolyFormer represents the same region with just 96 constraints (0.17% of the original), with an optimality error only 21% that of the best competing method. Crucially, it also handles mixed continuous-discrete controls, a case where competing methods simply fail to converge.

Network-constrained power flow: For a two-layer transmission-distribution power system, PolyFormer compresses each distribution subnetwork's thousands of nonlinear constraints into a small polytope defined only at the boundary interface node. For the largest system, the solver time is over 6,400x faster, and memory usage decreases by 99.6%. This is achieved by simplifying the original model with 715,055 constraints and 477,691 variables into an approximate model containing only 2,239 constraints and 1,785 variables.

Pareto front comparison of PolyFormer vs DRCC-linear across four portfolio optimization scenarios

Optimization under uncertainty (portfolio finance): Distributionally robust chance constraints (DRCCs) are a way of making decisions that remain valid even when the probability distribution of uncertain outcomes is not precisely known. Standard reformulations of DRCCs introduce enormous numbers of auxiliary variables. PolyFormer dramatically reduces the problem size from up to 1,044,497 constraints and 1,034,656 variables to 1,617 constraints and 400 variables, corresponding to reductions of over 99.8% and 99.9%, respectively. It also finds non-inferior solutions on average, and in some configurations strictly dominates the baseline on both return and risk.

What it cannot do

PolyFormer has a clear limitation with non-convex feasible regions. Because the error metrics are direction-based, the method naturally converges toward the convex hull of the original region rather than its exact non-convex shape. For many engineering applications, the convex hull is a perfectly acceptable approximation, but for problems requiring tight feasibility guarantees in non-convex spaces, the current version falls short. The authors flag adaptive sampling strategies for non-convex inner approximations as an open direction.

Training also requires access to an oracle that can solve optimization problems over the original feasible region (to compute the directional errors). If the original constraints are themselves intractable to query, the training loop breaks down. And while the offline training phase is computationally intensive (up to 124 minutes in the largest resource aggregation case), the online deployment is extremely fast.

The real shift

What makes PolyFormer notable is not just the numbers. Physics-informed machine learning offers a powerful paradigm of integrating data with physical laws to address important problems in engineering, such as parameter estimation, inferring hidden physics, equation discovery, and state prediction. But almost all of that work has been about prediction: train a model to satisfy physical equations, then use it to forecast or simulate. PolyFormer is one of the first frameworks to apply PIML to the prescriptive side, using geometric knowledge not to make better predictions but to make optimization problems structurally simpler.

The practical upshot is that PolyFormer is solver-agnostic. Once the polytope is learned, you can plug it into Gurobi, IPOPT, or any linear programming solver you already use. There is no need to retrain models for each new problem instance, and the feasibility-optimality trade-off is explicitly controllable via a single parameter. The full implementation of PolyFormer is publicly available at github.com/wenyl16/PolyFormer, with a user guide and step-by-step examples included in the paper's supplementary material.

The domains where this matters most are exactly the ones facing the sharpest scaling pressure right now: power grid optimization as renewable penetration grows, logistics and fleet management at city scale, and financial risk management across large asset universes. If the offline training cost can be amortized across many online deployments, the economics of PolyFormer look compelling.