1Problem and significance
A graph-structured constrained optimization problem is a triple of a graph, a constraint set, and an objective. Decision variables live on the nodes and edges of the graph, and the constraints determine which assignments are feasible:
Here \(G=(V,E)\) is the problem graph (buses and lines, cities and roads), \(\Omega\) the space of complete assignments, and \(C\) a set of equality, inequality, and domain predicates, including integrality.
In deployed systems such as power grids, logistics, and scheduling, \(G\) and \(f\) are comparatively stable, while \(C\) changes with operating conditions, regulation, and reliability criteria. Two consequences follow.
- Feasible sets are built from a small number of recurring constraint families: conservation and capacity in physical networks, and degree, flow, capacity, and time-window constraints in combinatorial problems. The constraint set, not the instance, is therefore the shared structure across tasks.
- Learned solvers fix \(C\) at training time. A solver \(F^{(T)}_\theta\) trained for task \(T\) absorbs its constraints into its weights, so adding or tightening a single constraint requires a new model or a task adapter.
The goal is a single solver whose input includes the constraint specification itself, so that changing \(C\) changes the input, not the parameters:
2Research questions
Equation (2) raises three requirements: constraints must be represented in a way that respects their algebraic structure, the representation must not depend on how a constraint is written, and it must be composed with the instance so that new combinations generalize. Each requirement becomes a research question, answered by a component of the method and tested by a specific experiment.
| RQ | Question | Addressed by | Evidence |
|---|---|---|---|
| RQ1 | Can a constraint be embedded so that admissible rewrites map to nearby points while feasibility-changing edits do not? | Operator-DAG encoder, contrastive invariance (§3.2–3.3) | Theorems 1–2 (§4); Table 10 |
| RQ2 | Does conditioning one shared backbone on the constraint set improve optimality and feasibility across heterogeneous problem families? | Cross-attention conditioning, task decoder (§3.4–3.5) | Tables 4–5 |
| RQ3 | Do the learned representations transfer to unseen constraint compositions, larger graphs, and new tasks? | Shared embedding space for constraints and features (§3.4) | Tables 6–8 |
| RQ4 | Which design choices are responsible: structured versus textual constraint encoding, and the depth at which constraints are injected? | Ablations (§6.3) | Tables 9–11 |
3Method
CONSTRAINER has three components: a constraint encoder that maps each \(c\in C\) to an embedding \(z_c\in\mathbb{R}^d\); a heterogeneous graph transformer over \(G\) that reads those embeddings through cross-attention; and a task decoder. Algorithm 1 gives the forward pass; the subsections define each step.
Input: problem graph \(G=(V,E)\); constraint set \(C\); typed instance features on \(V\). Output: solution \(\hat{x}\).
- for each \(c\in C\): parse \(c\) into an operator DAG \(A_c\); \(z_c\leftarrow \mathrm{POOL}\big(\mathrm{MPNN}_L(A_c)\big)\) ▷ Eqs. (3)–(5); cached across instances
- \(Z_C\leftarrow\{z_c\}_{c\in C}\)
- for each \(i\in V\): \(h_i^{(0)}\leftarrow\sum_{\tau\ \text{on}\ i}\big[\phi_{\mathrm{var}}(\tau)\oplus\phi(\mathrm{value}(\tau))\big]\) ▷ Eq. (7)
- for \(\ell=0,\dots,L/2-1\): \(h^{(\ell+1)}\leftarrow \mathrm{GT}^{(\ell)}(h^{(\ell)};G)\) ▷ structural reasoning
- for each \(i\in V\): \(h_i^{(L/2)}\leftarrow h_i^{(L/2)}+\sum_{c\in C}\alpha_{ic}W_v z_c\) ▷ Eq. (8), constraint conditioning
- for \(\ell=L/2,\dots,L-1\): \(h^{(\ell+1)}\leftarrow \mathrm{GT}^{(\ell)}(h^{(\ell)};G)\) ▷ propagate constraint context
- \(\hat{x}\leftarrow D_\theta(\{h_i^{(L)}\}_{i\in V})\) ▷ Eq. (9): parallel readout or masked autoregressive decoding
3.1Constraints as operator graphs
Each constraint is written as the computation graph of its expression, a directed acyclic graph \(A_c=(V_c,E_c)\). Leaves are decision variables and numerical constants; internal nodes are operators (\(+\), \(\times\), \(\mathrm{pow}\), \(\le\), \(=\), \(\ge\)); edges carry argument roles. The line-flow limit \(P^2+Q^2\le S_{\max}^2\), for example, is a tree rooted at \(\le\) (Figure 1b). Node states are initialized by type and refined by \(L\) rounds of typed message passing:
A permutation-invariant attention pooling over the final node states gives the constraint embedding
The representable class is exactly the set of constraints that reduce to a finite DAG over the operator vocabulary: linear, quadratic, polynomial, and algebraic nonlinear constraints, and structural properties with compact algebraic reformulations (flow- and cut-based encodings). A new operator is added by extending the lookup table \(\phi_{\mathrm{op}}\); the backbone, cross-attention, and decoder are unchanged.
3.2Contrastive invariance (RQ1)
The embedding should depend on the feasible region a constraint defines, not on its surface syntax. The encoder is trained with an InfoNCE objective in which positives \(c^+=T(c)\) are admissible DAG-level rewrites and negatives \(\{c^-_k\}_{k=1}^K\) are structurally similar but change feasibility:
with \(\mathrm{sim}\) the cosine similarity and \(\tau\) a temperature. Pairs are constructed per constraint type from the geometry of the set it defines (Table 2).
| Constraint | Geometric object | Positive pair | Negative pair |
|---|---|---|---|
| Linear equality | Hyperplane \(a^\top x=b\) | Rescale \((a,b)\); add redundant copies; reorder variables | Rotate the normal; shift \(b\); inconsistent systems |
| Linear inequality | Half-space \(a^\top x\le b\) | Looser or tighter \(b'\) with the same normal | Reverse the inequality; change the normal; disjoint regions |
| Affine | Shifted subspace | Apply \(x\mapsto Ax+c\); add dummy variables | Non-parallel normals; incompatible offsets |
| Box | Hyperrectangle \(l_i\le x_i\le u_i\) | Nested boxes; reordered dimensions | Disjoint, rotated, or contradictory boxes |
| Integrality | Lattice \(\mathbb{Z}^n\) | Integer versus relaxed version; equivalent parity | Arbitrary continuous sets; incompatible residue classes |
| Logical big-\(M\) | Union of polyhedra | Same implication with a different \(M\); reordered binaries | Different logic; a large \(M\) that destroys the geometry |
| Ordering | Monotone cone \(x_i\le x_j\) | Same poset under renaming; added transitive closures | Cyclic or reversed orders; inconsistent chains |
3.3Typed feature tokens
Instance data (power, capacity, demand, distance) enter as typed tokens that share the variable-type table \(\phi_{\mathrm{var}}\) with the constraint encoder, so the symbol \(P\) has the same type embedding in an instance feature and in a constraint. For a token \(\tau\) with type and scalar value,
where \(\oplus\) is element-wise addition and the sum is permutation-invariant over the token set of node \(i\).
3.4Constraint-conditioned backbone (RQ2, RQ3)
The backbone is a heterogeneous graph transformer with \(L\) layers. Layers \(0,\dots,L/2-1\) reason over \(G\) alone. At depth \(L/2\), each variable queries the constraint set \(Z_C=\{z_c\}_{c\in C}\in\mathbb{R}^{|C|\times d}\):
Layers \(L/2,\dots,L-1\) then propagate the constraint-conditioned states across structurally related variables. Constraints enter only through the keys and values of Eq. (8), so adding, removing, or replacing a constraint changes the attention set and leaves the parameters unchanged. The cost of conditioning is the \(|V|\times|C|\) score matrix, linear in graph size for a fixed constraint set; constraint embeddings are computed once and cached at inference.
3.5Task decoder and training
The decoder maps \(H=\{h_i\}_{i\in V}\) to a solution. Continuous problems use a shared MLP applied to every variable in parallel; discrete problems use a masked autoregressive decoder that excludes constraint-violating actions at every step, so outputs on the MILP tasks are feasible by construction:
The backbone and decoder are trained with supervised losses against solver-optimal solutions \(x^\star\), augmented with penalties on constraint violation; the encoder is trained with Eq. (5). Grid tasks train for 300 epochs and MILP tasks for 450, on NVIDIA H100 GPUs.
4Theoretical guarantees (RQ1)
For constraint \(c\), let \(A_{c,r}\in\{0,1\}^{n_c\times n_c}\) be the adjacency matrix of edges of type \(r\in\{1,\dots,R\}\) in its operator DAG, and define the reparameterization budget of a rewrite \(c'\) as
Assumption. The encoder is a linear instantiation of Eq. (3): \(h_v^{(0)}=W_{\mathrm{init}}x_v\), messages \(m^{(\ell)}_{u\to v}=W^{(\ell)}_{r_{uv}}h^{(\ell)}_u\), and updates \(h^{(\ell+1)}_v=A^{(\ell)}h^{(\ell)}_v+B^{(\ell)}\sum_{u:(u,v)\in E_c}m^{(\ell)}_{u\to v}\), with \(\lVert A^{(\ell)}\rVert_2\le a\), \(\lVert B^{(\ell)}\rVert_2\le b\), \(\lVert W^{(\ell)}_r\rVert_2\le w\), and \(\lVert A_{c,r}\rVert_2\le\Delta\).
Under the assumption above, for any pair \((c,c')\) with budget \(\delta\), and with \(S=\mathbf{1}_n^\top\otimes I_d\) the sum-pooling operator,
The bound is linear in \(\delta\). The factor \((a+bwR\Delta)^L\) is the per-layer gain raised to the depth: near one, the encoder is close to non-expansive, and larger gains amplify perturbations with depth. Eq. (5) directly contracts embeddings of admissible rewrites and tightens the bound in practice.
Assume every test constraint is an admissible rewrite of some training constraint, and let \(F_\theta\) be \(L_F\)-Lipschitz in its stacked constraint embeddings. Replace each test constraint by its nearest training neighbor in embedding space, giving \(Z_{C^{\mathrm{nn}}}\). If training achieves \(\mathcal{L}_{\mathrm{con}}\le\varepsilon\) with \(K\) negatives and every negative satisfies \(\mathrm{sim}(z_c,z_{c^-_k})\le\rho<1\), then
The prediction shift grows linearly in the predictor's sensitivity \(L_F\) and only as \(\sqrt{|C^{\mathrm{test}}|}\) in the number of test constraints. A lower contrastive loss \(\varepsilon\) or more negatives \(K\) tighten it.
5Experimental protocol
| Domain | Tasks | Data and reference solver | Metrics | Baselines |
|---|---|---|---|---|
| Power grids | PF (AC/DC), ACOPF, DCOPF, DCOTS, DCTNEP | PowerModels.jl formulations on IEEE-30/57/118 and PGLib-OPF cases; IPOPT (nonlinear), HiGHS (mixed-integer) | Feasibility (%) ↑, optimality gap (%) ↓ | CANOS, GAT-based OPF (single task); graph transformer with task adapters (multi-task) |
| MILP | Routing (ATSP, CVRP, CVRPTW, OP), packing (KP), graph (MVC), scheduling (UMSP, JSSP); 8 further tasks held out for finetuning | 100-node instances; JSSP \(10\times10\), UMSP \(100\times20\) | Optimality gap (%) ↓; all methods are feasible by construction | AM, MDAM, POMO, Sym-NCO, BQ-NCO, MatNet, S2V-DQN, COMPASS, Gumbeldore (single task); MVMoE, RouteFinder, OPTFM, MTL, GOAL (multi-task) |
6Results
6.1One model across problem families (RQ2)
| Method | PF | ACOPF | DCOPF | DCOTS | DCTNEP | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| AC Feas↑ | DC Feas↑ | Gap↓ | Feas↑ | Gap↓ | Feas↑ | Gap↓ | Feas↑ | Gap↓ | Feas↑ | |
| GNN (CANOS) | 95.11 | 97.14 | 4.80 | 93.00 | 3.60 | 94.20 | 6.10 | 88.45 | 5.40 | 85.32 |
| GAN | 96.42 | 97.86 | 4.10 | 94.35 | 3.05 | 95.65 | 5.30 | 89.96 | 4.60 | 86.71 |
| GT (multi-task) | 97.88 | 98.72 | 3.55 | 95.60 | 2.35 | 97.10 | 4.90 | 90.85 | 3.80 | 87.94 |
| CONSTRAINER | 99.03 | 99.50 | 3.01 | 96.10 | 1.50 | 99.02 | 4.50 | 91.22 | 2.90 | 88.91 |
Finding. CONSTRAINER is best on every grid formulation and metric. The largest margins over the multi-task transformer are on DCOPF (gap 2.35 → 1.50) and DCTNEP (3.80 → 2.90), where discrete topology or expansion decisions are coupled with power-flow constraints.
| Method | ATSP | CVRP | CVRPTW | OP | KP | MVC | UMSP | JSSP |
|---|---|---|---|---|---|---|---|---|
| Single-task models (one model per problem) | ||||||||
| AM | – | 7.17 | – | 5.39 | – | – | – | – |
| MDAM | – | 4.87 | – | 2.91 | – | – | – | – |
| Sym-NCO | – | 3.36 | – | 2.06 | – | – | – | – |
| POMO | – | 1.23 | – | – | 0.20 | – | – | – |
| BQ-NCO | 1.30 | 2.81 | – | 0.25 | 0.11 | – | – | – |
| MatNet | 0.95 | – | – | – | – | – | – | – |
| S2V-DQN | – | – | – | – | – | 0.99 | – | – |
| COMPASS | – | – | – | – | – | – | – | 4.73 |
| Gumbeldore | – | – | – | – | – | – | – | 3.20 |
| Multi-task models (one model for all problems) | ||||||||
| MVMoE/4E | – | 1.68 | 4.95 | – | – | – | – | – |
| RouteFinder-TE | – | 1.53 | 3.24 | – | – | – | – | – |
| OPTFM | 0.97 | 3.23 | 3.90 | 0.47 | 0.14 | 0.40 | 3.95 | 4.27 |
| MTL | 0.94 | 3.19 | 3.86 | 0.45 | 0.13 | 0.38 | 3.89 | 4.18 |
| GOAL | 0.91 | 3.16 | 3.82 | 0.43 | 0.12 | 0.37 | 3.84 | 4.13 |
| CONSTRAINER | 0.50 | 2.98 | 3.01 | 0.27 | 0.11 | 0.38 | 2.14 | 3.68 |
Finding. Among the generalist models that cover all eight problems (OPTFM, MTL, GOAL), CONSTRAINER has the lowest gap on seven of eight; it trails GOAL on MVC by 0.01. The gains concentrate where feasibility is defined by several interacting constraint families: ATSP (0.91 → 0.50), CVRPTW (3.82 → 3.01), and UMSP (3.84 → 2.14). Packing and graph problems, governed by a single dominant family, change little. Single-task specialists remain stronger on CVRP (POMO), OP (BQ-NCO), and JSSP (Gumbeldore).
6.2Transfer (RQ3)
| Model | IEEE-30 | IEEE-57 | IEEE-118 | |||
|---|---|---|---|---|---|---|
| Gap↓ | Feas↑ | Gap↓ | Feas↑ | Gap↓ | Feas↑ | |
| MTL (DCPF adapter, finetuned) | 7.11 | 93.11 | 11.33 | 92.93 | 6.35 | 91.11 |
| MTL (ACOPF adapter, finetuned) | 5.88 | 92.00 | 9.11 | 90.31 | 6.50 | 90.01 |
| CONSTRAINER (zero-shot) | 1.58 | 98.90 | 2.36 | 95.82 | 3.13 | 94.65 |
Finding. Without any DCOPF data, CONSTRAINER has a lower gap and higher feasibility than both finetuned adapters at every grid size, for example a 2.36% gap against 9.11% and 11.33% on IEEE-57.
| Model | 100 nodes | 500 nodes | 1000 nodes |
|---|---|---|---|
| GOAL | 0.65 | 2.37 | 2.17 |
| OPTFM | 0.97 | 3.19 | 3.27 |
| CONSTRAINER | 0.50 | 1.18 | 1.70 |
| Grid | ACPF Feas↑ | DCPF Feas↑ | ACOPF Gap↓ | ACOPF Feas↑ |
|---|---|---|---|---|
| Case118 | 99.03 | 99.50 | 3.01 | 96.10 |
| Case300 | 98.70 | 99.10 | 3.30 | 95.40 |
| Case500 | 97.90 | 98.60 | 6.70 | 93.00 |
| Case2000 | 94.80 | 96.10 | 16.10 | 88.00 |
Finding. On ATSP, CONSTRAINER keeps the lowest gap at five and ten times the training size. On power grids, feasibility degrades gracefully up to 2000 buses, while the ACOPF gap grows to 16.1%, which marks the current scaling limit.
Finetuning on unseen tasks. On eight held-out MILP problems, CONSTRAINER converges faster and to lower gaps than finetuned OPTFM, MTL, and GOAL, with the largest advantage early in finetuning. On DCOTS and DCTNEP it reaches convergence in roughly 30% fewer epochs.
6.3Ablations (RQ1, RQ4)
| Method | Case30 | Case118 | ||
|---|---|---|---|---|
| Feas↑ | Gap↓ | Feas↑ | Gap↓ | |
| FSNet | ∼100 | 0.82 | ∼100 | 0.90 |
| CONSTRAINER | 98.20 | 2.05 | 96.10 | 3.01 |
| CONSTRAINER + FSNet L-BFGS | ∼100 | 1.03 | ∼100 | 1.39 |
| Variant | ATSP | CVRPTW | OP |
|---|---|---|---|
| Operator-DAG encoder (CONSTRAINER) | 0.50 | 3.01 | 0.27 |
| Text embeddings of the constraint (text-embedding-3-small) | 0.78 | 3.42 | 0.36 |
| No constraint conditioning (multi-task backbone) | 0.94 | 3.86 | 0.45 |
| Cross-attention placement | Layer 1 | Layer \(L/2\) | Layer \(L-1\) |
|---|---|---|---|
| Optimality gap | 0.522 | 0.500 | 0.533 |
Finding. Composing the prediction with a feasibility-seeking refinement gives ∼100% ACOPF feasibility at a gap close to that of FSNet. Text embeddings recover only part of the benefit of structured encoding, so the operator graph carries compositional information that surface semantics lose. Injection at \(L/2\) is best: earlier injection precedes enough structural context, and later injection leaves too few layers to propagate it.
7Future directions
Three extensions follow from the results. The operator vocabulary can be extended to logical and global combinatorial constraints that currently enter only through algebraic reformulations. Feasibility repair, now a post-hoc step (Table 9), can be moved into the decoder as a differentiable projection onto \(X(C)\). Finally, the gap growth on 2000-bus grids (Table 8) motivates hierarchical or sparse constraint attention for large networks.
Citation
@inproceedings{memon2026constrainer,
title = {{CONSTRAINER}: Promptable Graph-Structured Optimization via Constraint Conditioning},
author = {Memon, Zeeshan and Tian, Mingke and Song, Xinyuan and Jin, Hongwei and Kim, Kibaek and Zhao, Liang},
booktitle = {Advances in Neural Information Processing Systems (NeurIPS)},
year = {2026}
}Key references
- D. Drakulic, S. Michel, and J.-M. Andreoli. GOAL: A Generalist Combinatorial Optimization Agent Learner. ICLR, 2025.
- Z. Hu, Y. Dong, K. Wang, and Y. Sun. Heterogeneous Graph Transformer. The Web Conference (WWW), 2020.
- C. Coffrin, R. Bent, K. Sundar, Y. Ng, and M. Lubin. PowerModels.jl: An Open-Source Framework for Exploring Power Flow Formulations. PSCC, 2018.
- H. T. Nguyen and P. L. Donti. FSNet: Feasibility-Seeking Neural Network for Constrained Optimization with Guarantees. NeurIPS, 2025.
- P. L. Donti, D. Rolnick, and J. Z. Kolter. DC3: A Learning Method for Optimization with Hard Constraints. ICLR, 2021.