arXiv:2610.33930cs.LGOct 2026

Manuscript Offprint

arXiv:2610.33930

EnerGNN: Learning Optimization-Compatible Energy Functions for Exact Constrained Combinatorial Inference

Niki Triantafyllou, Maria M. Papathanasiou

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Learning-based approaches to combinatorial optimization often predict solutions directly or use predictions to restrict search, while expressive energy-based models typically rely on approximate inference. We introduce EnerGNN, a framework that learns energy functions over complete binary configurations and minimizes them under explicit hard constraints through mixed integer programming (MIP). EnerGNN combines a graph neural network encoder with an optimization-compatible readout and a nonlinear energy head, enabling exact constrained inference over the learned energy. An optimality-aware contrastive loss trains the energy to reflect solution quality and constraint violations. Across Quadratic Knapsack, Combinatorial Auctions, and a personalized cell therapy supply chain problem, EnerGNN achieves near-optimal solutions with 100% feasibility. On the supply chain problem, it achieves a 0.05% mean primal gap and a 17.4× speedup over the monolithic MIP. The learned energy also generalizes to larger instances and supports zero-shot constraint injection, adapting to changing constraints without retraining while preserving feasibility.

1 Introduction

A central challenge in energy-based structured prediction is to combine expressive learned representations with tractable inference over structured outputs. Energy-based models (EBMs) assign scalar energies to complete output configurations, allowing dependencies and interactions between output variables to be captured through learned energy functions (LeCun et al., 2006; Belanger and McCallum, 2016). However, minimizing expressive neural energies over discrete decision spaces is generally challenging, particularly when solutions must satisfy hard operational, physical, or logical constraints. Mixed integer programming (MIP) provides a framework for enforcing such constraints and obtaining globally optimal solutions, but learned energy functions must admit suitable mathematical representations to be optimized directly. This creates an interface problem between neural learning and exact optimization: How can a neural model learn expressive energy functions that an exact optimizer can minimize under hard constraints?

Existing approaches address different aspects of this challenge. In learning-based combinatorial optimization, neural models have been used to construct solutions, predict variable assignments, and guide exact solvers (Bengio et al., 2021; Khalil et al., 2017; Gasse et al., 2019). Methods such as Neural Diving (Nair et al., 2020) and ConPaS (Huang et al., 2024) use learned variable-level predictions to identify promising regions of the solution space, which are then explored through restricted optimization. In energy-based structured prediction, inference with expressive neural

∗^{*}Corresponding author.

Preprint.

Figure

Figure 1: EnerGNN encodes an optimization instance using a bipartite message-passing GNN, learns an optimization-compatible energy function over binary configurations, and performs exact constrained inference by globally minimizing the learned energy over the encoded feasible set.

energies commonly relies on continuous relaxations, gradient-based optimization, or approximate decoding (Belanger and McCallum, 2016; Graber and Schwing, 2019). Meanwhile, ReLU neural networks can be represented exactly using mixed integer formulations (Fischetti and Jo, 2018; Anderson et al., 2020), providing a mechanism for optimizing learned nonlinear functions under explicit constraints. Together, these developments motivate learning energy functions that are designed to be directly optimized under explicit hard constraints, bringing expressive structured prediction and exact combinatorial inference into a unified framework.

We introduce EnerGNN, an energy-based framework that learns optimization-compatible energy functions over complete binary configurations and minimizes them subject to explicit hard constraints. As illustrated in Figure 1, EnerGNN combines a bipartite message-passing graph neural network (GNN) encoder with a decision-dependent readout and a piecewise linear ReLU energy head. The GNN encoder produces representations of the problem instance that are computed once and remain fixed during optimization. The readout combines these fixed representations with the binary decision variables to construct a configuration-dependent representation. Together, the readout and nonlinear ReLU energy head allow EnerGNN to model interactions between decision variables while admitting an exact MIP representation. At inference, the learned energy is minimized over the full encoded feasible region using a MIP solver, yielding a feasible solution that is globally optimal with respect to the learned energy when solved to optimality.

A key feature of EnerGNN is the separation of learned preferences from explicit feasibility constraints. The energy-based model learns to distinguish high-quality configurations from suboptimal alternatives through optimality-aware contrastive training, while hard constraints are enforced directly during inference. This separation allows the same learned energy to be optimized under different feasible regions, without retraining the model. In particular, deployment-time constraints can be added, removed, or modified by changing the inference MIP, enabling zero-shot constraint injection. This approach is complementary to neural algorithmic reasoning (Veličković and Blundell, 2021): rather than learning to execute an optimization algorithm, EnerGNN learns an energy function over structured decisions and delegates constrained inference to an exact optimizer.

Our contributions are threefold. First, we formulate constrained combinatorial inference as learning an optimization-compatible energy over complete binary configurations, separating learned preferences from explicit hard constraints. Second, we develop a graph-based energy architecture that captures nonlinear interactions between decision variables while admitting exact MIP representation and globally optimal inference with respect to the learned energy. Third, we develop an optimality-aware contrastive learning objective using feasible and infeasible candidate configurations to learn solution-level energy landscapes. We evaluate EnerGNN on Quadratic Knapsack (QKP), Combinatorial Auctions (CA), and a personalized cell therapy supply chain problem (CART). Our experiments demonstrate the benefits of nonlinear energy modeling for interaction-heavy objectives, the ability to obtain near-optimal solutions while satisfying hard constraints, generalization to larger problem sizes, and zero-shot constraint injection without retraining. The code and data used in this work are available at https://github.com/nikitrian/EnerGNN.

References (73)