arXiv:2610.35505math.OCOct 2026

Manuscript Offprint

arXiv:2610.35505

Constraint Learning by Optimizing over Trained Neural Networks: A Pragmatic Tutorial

Jiaxiao Fang, Thiago Serra

Abstract

Constraint learning is an emerging paradigm of modeling optimization problems with the help of machine learning. In this paradigm, trained machine learning models are embedded into the optimization model. For example, we can learn constraints empirically from available data, or we can avoid using a nonlinear objective function by learning a simpler approximation for it. Neural networks become a compelling option if the machine learning models must capture more elaborate and nuanced relationships. However, optimization models embedding neural networks may become too large or too slow to solve. In this tutorial, we present practical considerations for an effective and efficient use of constraint learning with neural networks and validate it with a case study highlighting the benefit of smaller and sparser networks.

Keywords: Constraint learning, Mixed-integer programming, Neural networks, Piecewise-linear optimization, Rectified linear units, Surrogate models

1 Introduction

We may not fully understand how neural networks arrive at a conclusion, but we know that they can handle complex tasks better than more intuitive counterparts, such as decision trees (Baldi et al., 2014, LeCun et al., 2015). That fits into a broader narrative outlined in Sutton's manifesto The Bitter Lesson about how general-purpose methods backed by massive computation led to the most effective advances in AI, from playing chess and Go at competitive levels to achieving reliable results in speech recognition and computer vision (Sutton, 2019). And this narrative begets the question: what if some parts of a mathematical optimization model were learned with neural networks? In machine learning, the cost of producing a model (training) is generally orders of magnitude above the cost of using it (inference). However, if neural networks are embedded into a mathematical optimization model and possibly queried several times while solving the optimization model, then the inference cost adds up to another order of magnitude. This tutorial is about when to use neural networks in optimization models—and how to circumvent their computational cost.

We define as constraint learning the use of neural networks, or other machine learning models, as a proxy for some parts of a mathematical optimization model. However, that term is also used more generally for the automatic process of learning the model of a problem in Constraint Programming (CP) 1^{1} (Kolb, 2016, Lombardi and Milano, 2018). As observed by Raedt et al. (2018), constraint learning stands for an inductive (probabilistic) approach of learning constraints, in contrast to the deductive (provable) approach used for inferring valid constraints (cuts). When machine learning is involved, this probabilistic approach translates into approximating through data a complex or unknown constraint or term of the objective function. The special case of using neural networks has been first explored in CP models by Bartolini et al. (2011) and in mathematical optimization models by Say et al. (2017) and Cheng et al. (2017), to which many other studies followed in both communities.

Curiously, the term constraint learning would only find its way into mathematical optimization six years later, but would soon become widely used as a synonym for embedding neural networks in optimization models. 2^{2} However, other terms have been used to denote special or general cases of constraint learning. While Lombardi et al. (2017) suggested denoting the use of general-purpose machine learning models for constraint learning as empirical model learning, the practice of using simpler models to approximate complex or unknown relationships in engineering has been generally denoted as surrogate modeling (Bhosekar and Ierapetritou, 2018, Grimstad and Andersson, 2019).

Naming controversies aside, there are some important considerations for achieving a successful use of constraining learning with neural networks. This tutorial covers them in the following order:

  • We discuss why neural networks can be helpful; what type of neural network to use and how to incorporate them in mathematical optimization models; and where they have been applied in Why, What, and Where to Use Neural Networks in Modeling? This is our summary of positives.

  • We briefly discuss when neural networks exceed the modeling needs and we present alternatives for such cases in When Not to Use a Neural Network in Optimization Models? This is our warning.

  • Most importantly, we discuss what technical choices lead to a more effective use by illustrating those choices with experiments on a synthetic dataset in How to Use Neural Networks in Optimization Models? This is our practical advice, which we support with experimental results.

1^{1}CP is another technique for solving discrete optimization problems. For more information, see About CP (in Appendix).

2^{2}For a list of references, see Adopting the Term Constraint Learning in Mathematical Optimization (in Appendix).

• Finally, we briefly discuss advanced topics and related areas beyond the scope of this tutorial in Other Topics in Constraint Learning and at the AI-Optimization Interface.

References (100)

Couldn't load all references. Reload the page to try again.