NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

DC3: A learning method for optimization with hard constraints

Priya L. Donti, David Rolnick, J. Zico Kolter

Deep learning is famously good at finding patterns, but it’s historically been terrible at following rules. In fields like power systems or climate modeling, "rules" aren't just suggestions—they are hard physical laws expressed as mathematical constraints. If a neural network predicts a power grid state that violates Kirchhoff’s laws, that prediction is worse than useless; it’s nonsensical.

In their ICLR 2021 paper, DC3: A Learning Method for Optimization with Hard Constraints, Priya L. Donti and colleagues introduce a framework that forces neural networks to respect the boundaries of the real world.

TL;DR

DC3 (Deep Constraint Completion and Correction) is a framework that embeds differentiable "completion" and "correction" steps into neural networks to solve optimization problems with hard constraints. It allows models to produce near-optimal solutions that satisfy complex equality and inequality constraints significantly faster than traditional solvers.

What Problem Does This Paper Address?

Traditional optimization solvers (like those used to manage the electrical grid) are mathematically rigorous but computationally expensive, especially for non-convex problems. Deep learning offers a tempting alternative because it is incredibly fast at "inference" time.

However, standard neural networks struggle with hard constraints. Usually, researchers try to handle constraints by adding a "penalty" to the loss function (soft constraints). This is like telling a teenager they shouldn't stay out past midnight; they might listen, but they often won't. In critical infrastructure, "close enough" isn't good enough. We need a way to ensure the network's output is actually feasible—meaning it satisfies every single equality and inequality constraint—without sacrificing the speed of deep learning.

Methods

The authors propose a two-step differentiable procedure integrated directly into the network architecture:

The DC3 framework integrates differentiable completion and correction steps to enforce hard constraints.
  1. Equality Completion: Instead of asking the network to predict every variable in a problem, the network only predicts a partial set of variables. The remaining variables are then "completed" by solving the equality constraints. For example, if you know the power demand at most nodes, the physics of the grid dictates the rest. By using the Implicit Function Theorem, the authors make this completion step differentiable, allowing the network to learn through the solver.
  2. Inequality Correction: Once the equality constraints are satisfied, the solution might still violate inequality constraints (like a voltage being too high). DC3 applies a gradient-based correction—essentially a few steps of internal gradient descent—to push the solution into the feasible region while staying on the "manifold" defined by the equality constraints.

Because both steps are differentiable, the entire system can be trained end-to-end using standard deep learning tools.

Datasets

The authors evaluated DC3 on three distinct tasks:

  • Convex Quadratic Programs (QP): A standard benchmark with 100 variables and 50 equality/inequality constraints.
  • Simple Non-convex Optimization: A synthetic task designed to test the algorithm's ability to handle non-linear objectives.
  • AC Optimal Power Flow (ACOPF): A high-stakes, real-world non-convex problem using a 57-node power system model. This is the "gold standard" test for whether an optimization method can handle the complex physics of the electrical grid.

Key Insights and Ideas

  • Partial Prediction is Powerful: The "aha moment" here is that the network doesn't need to learn the whole solution. By only predicting a subset of variables and letting math fill in the rest, the model's search space is drastically reduced, and feasibility is guaranteed by construction.
  • Differentiable Solvers: By treating the completion process (like Newton’s method) as an "implicit layer," the authors bridge the gap between classical optimization and modern deep learning.
  • The "Soft Loss" Still Matters: Even though the architecture enforces constraints, the authors found that keeping a "soft" penalty in the loss function during training helps guide the network toward regions where the correction step is easier to perform.

Key Results

Performance comparison showing DC3 achieving near-zero constraint violations while remaining computationally efficient.
  • Feasibility: Unlike standard neural networks (NN) or "Eq. NN" baselines, DC3 consistently achieved zero or near-zero constraint violations across all tasks.
  • Speed: On the ACOPF task, DC3 was approximately 10x faster than the traditional PYPOWER solver. On simpler quadratic programs, it was up to 78x faster than differentiable solvers like qpth.
  • Optimality: DC3 doesn't just find any feasible solution; it finds good ones. In the ACOPF task, the "optimality gap" (how much worse the objective was compared to the perfect solver) was a mere 0.22%.

Limitations and Future Work

While DC3 is a major step forward, it has some hurdles:

  • Computational Overhead: The completion step often involves Newton’s method, which requires inverting matrices. While faster than a full solver, it’s still heavier than a standard "vanilla" neural network.
  • Convergence: The gradient-based inequality correction is effective but not mathematically guaranteed to find a feasible point for every possible non-convex constraint, though it performed well in the tested scenarios.
  • Problem-Specific Design: The "completion" step requires the user to identify which variables can be solved for given others, which might require domain expertise for new types of problems.

The authors suggest that future work could involve designing more specialized correction procedures tailored to specific industries, further closing the gap between the speed of AI and the rigor of classical math.

Summary updated

BibTeX
@inproceedings{donti2021dc,
  author = {Priya L. Donti and David Rolnick and J. Zico Kolter},
  title = {{DC3: A learning method for optimization with hard constraints}},
  booktitle = {International Conference on Learning Representations},
  year = {2021},
}
Figure