← All research

NeurIPS 2026 · Main Track

CONSTRAINER: Promptable Graph-Structured Optimization via Constraint Conditioning

Zeeshan Memon, Mingke Tian, Xinyuan Song, Hongwei Jin, Kibaek Kim, Liang Zhao

Department of Computer Science, Emory University · Argonne National Laboratory

Problem
Graph-structured constrained optimization
Domains
Power grids · MILP (routing, packing, scheduling)
Key idea
Constraints as structured prompts
Status
Accepted, to appear
CONSTRAINER architecture: constraints are parsed into operator DAGs and embedded by a GNN; a heterogeneous graph transformer over the problem graph attends to the constraint embeddings through a cross-attention block between its two halves; a task decoder outputs the solution.
Figure 1. Architecture. (a) Constraint embeddings and the problem graph enter a shared heterogeneous graph transformer (HGT). (b) Each constraint is parsed into an operator DAG and encoded by a GNN. (c) Between the two halves of the HGT, every variable node attends over the constraint embeddings.

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:

\[P=(G,\,C,\,f),\qquad X(C)=\{\,x\in\Omega \;:\; c(x)=\text{true}\ \ \forall c\in C\,\},\qquad x^\star\in\arg\min_{x\in X(C)} f(x).\]

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:

\[\hat{x}=F_\theta(G,\,C),\qquad \hat{x}\in X(C),\qquad f(\hat{x})\approx f(x^\star)\quad\text{for constraint sets } C \text{ not seen in training.}\]

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.

Table 1. Research questions, the component that addresses each, and the evidence reported below.
RQQuestionAddressed byEvidence
RQ1Can 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
RQ2Does 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
RQ3Do 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
RQ4Which 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.

Algorithm 1  CONSTRAINER forward pass

Input: problem graph \(G=(V,E)\); constraint set \(C\); typed instance features on \(V\).  Output: solution \(\hat{x}\).

  1. 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
  2. \(Z_C\leftarrow\{z_c\}_{c\in C}\)
  3. 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)
  4. for \(\ell=0,\dots,L/2-1\): \(h^{(\ell+1)}\leftarrow \mathrm{GT}^{(\ell)}(h^{(\ell)};G)\)  ▷ structural reasoning
  5. 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
  6. for \(\ell=L/2,\dots,L-1\): \(h^{(\ell+1)}\leftarrow \mathrm{GT}^{(\ell)}(h^{(\ell)};G)\)  ▷ propagate constraint context
  7. \(\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:

\[h_v^{(0)}=\begin{cases}\phi_{\mathrm{var}}(v) & v \text{ a variable}\\ \phi_{\mathrm{const}}(v) & v \text{ a constant or bound}\\ \phi_{\mathrm{op}}(v) & v \text{ an operator}\end{cases}\qquad h_v^{(\ell+1)}=\psi^{(\ell)}\Big(h_v^{(\ell)},\ \textstyle\sum_{u:(u,v)\in E_c}\phi^{(\ell)}\big(h_u^{(\ell)},e_{uv}\big)\Big)\]

A permutation-invariant attention pooling over the final node states gives the constraint embedding

\[z_c=\mathrm{POOL}\big\{h_v^{(L)} : v\in V_c\big\}\equiv\phi_\theta(c)\in\mathbb{R}^d.\]

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:

\[\mathcal{L}_{\mathrm{con}}(c)=-\log\frac{\exp\big(\mathrm{sim}(z_c,z_{c^+})/\tau\big)}{\exp\big(\mathrm{sim}(z_c,z_{c^+})/\tau\big)+\sum_{k=1}^{K}\exp\big(\mathrm{sim}(z_c,z_{c^-_k})/\tau\big)},\]

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).

Table 2. Contrastive pair construction by constraint type (from the appendix of the paper).
ConstraintGeometric objectPositive pairNegative pair
Linear equalityHyperplane \(a^\top x=b\)Rescale \((a,b)\); add redundant copies; reorder variablesRotate the normal; shift \(b\); inconsistent systems
Linear inequalityHalf-space \(a^\top x\le b\)Looser or tighter \(b'\) with the same normalReverse the inequality; change the normal; disjoint regions
AffineShifted subspaceApply \(x\mapsto Ax+c\); add dummy variablesNon-parallel normals; incompatible offsets
BoxHyperrectangle \(l_i\le x_i\le u_i\)Nested boxes; reordered dimensionsDisjoint, rotated, or contradictory boxes
IntegralityLattice \(\mathbb{Z}^n\)Integer versus relaxed version; equivalent parityArbitrary continuous sets; incompatible residue classes
Logical big-\(M\)Union of polyhedraSame implication with a different \(M\); reordered binariesDifferent logic; a large \(M\) that destroys the geometry
OrderingMonotone cone \(x_i\le x_j\)Same poset under renaming; added transitive closuresCyclic 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,

\[h_\tau=\phi_{\mathrm{var}}(\tau)\oplus\phi\big(\mathrm{value}(\tau)\big),\]
\[h_i^{(0)}=\textstyle\sum_{\tau \text{ applies to } i} h_\tau ,\]

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}\):

\[\tilde{h}_i=\sum_{c\in C}\alpha_{ic}\,W_v z_c,\qquad \alpha_{ic}=\operatorname*{softmax}_{c\in C}\big\langle W_q h_i^{(L/2)},\,W_k z_c\big\rangle,\qquad h_i^{(L/2)}\leftarrow h_i^{(L/2)}+\tilde{h}_i.\]

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:

\[\hat{x}=D_\theta(H),\qquad \hat{x}_i=g_\theta(h_i)\ \ (i\in V)\ \text{ for continuous variables}.\]

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

\[\delta=\max_{r\in\{1,\dots,R\}}\big\lVert A_{c,r}-A_{c',r}\big\rVert_2 .\]

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\).

Theorem 1 (stability under reparameterization)

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,

\[\lVert z_c-z_{c'}\rVert_2\;\le\;\lVert S\rVert_2\,\big\lVert \mathrm{vec}(H^{(0)})\big\rVert_2\,\big(a+bwR\Delta\big)^{L}\cdot\frac{L\,bwR\,\delta}{a+bwR\Delta}.\]

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.

Theorem 2 (transfer across constraint families)

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

\[\big\lVert F_\theta(G,f,Z_{C^{\mathrm{test}}})-F_\theta(G,f,Z_{C^{\mathrm{nn}}})\big\rVert\;\le\;L_F\sqrt{|C^{\mathrm{test}}|}\,\sqrt{2\big(1-\rho-\tau(\log K-\log(e^{\varepsilon}-1))\big)}.\]

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

Table 3. Tasks, data, metrics, and baselines.
DomainTasksData and reference solverMetricsBaselines
Power gridsPF (AC/DC), ACOPF, DCOPF, DCOTS, DCTNEPPowerModels.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)
MILPRouting (ATSP, CVRP, CVRPTW, OP), packing (KP), graph (MVC), scheduling (UMSP, JSSP); 8 further tasks held out for finetuning100-node instances; JSSP \(10\times10\), UMSP \(100\times20\)Optimality gap (%) ↓; all methods are feasible by constructionAM, 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)

Table 4. Power-grid optimization on IEEE-118. Feasibility (%) ↑ and optimality gap (%) ↓. Best in bold.
MethodPFACOPFDCOPFDCOTSDCTNEP
AC Feas↑DC Feas↑Gap↓Feas↑Gap↓Feas↑Gap↓Feas↑Gap↓Feas↑
GNN (CANOS)95.1197.144.8093.003.6094.206.1088.455.4085.32
GAN96.4297.864.1094.353.0595.655.3089.964.6086.71
GT (multi-task)97.8898.723.5595.602.3597.104.9090.853.8087.94
CONSTRAINER99.0399.503.0196.101.5099.024.5091.222.9088.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.

Table 5. MILP benchmarks, optimality gap (%) ↓, 100-node instances. “–”: not reported. Best in each column in bold.
MethodATSPCVRPCVRPTWOPKPMVCUMSPJSSP
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-NCO1.302.81–0.250.11–––
MatNet0.95–––––––
S2V-DQN–––––0.99––
COMPASS–––––––4.73
Gumbeldore–––––––3.20
Multi-task models (one model for all problems)
MVMoE/4E–1.684.95–––––
RouteFinder-TE–1.533.24–––––
OPTFM0.973.233.900.470.140.403.954.27
MTL0.943.193.860.450.130.383.894.18
GOAL0.913.163.820.430.120.373.844.13
CONSTRAINER0.502.983.010.270.110.382.143.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)

Table 6. Zero-shot transfer to DCOPF, a constraint composition not seen in training (trained on ACPF, DCPF, ACOPF). Multi-task baselines receive 50 steps of adapter finetuning on DCOPF.
ModelIEEE-30IEEE-57IEEE-118
Gap↓Feas↑Gap↓Feas↑Gap↓Feas↑
MTL (DCPF adapter, finetuned)7.1193.1111.3392.936.3591.11
MTL (ACOPF adapter, finetuned)5.8892.009.1190.316.5090.01
CONSTRAINER (zero-shot)1.5898.902.3695.823.1394.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.

Table 7. ATSP size generalization: optimality gap (%) ↓ against LKH-3. All models are trained on 100-node instances.
Model100 nodes500 nodes1000 nodes
GOAL0.652.372.17
OPTFM0.973.193.27
CONSTRAINER0.501.181.70
Table 8. CONSTRAINER on larger grids: IEEE cases (118, 300 buses) and PGLib-OPF cases derived from GOC networks (500, 2000 buses).
GridACPF Feas↑DCPF Feas↑ACOPF Gap↓ACOPF Feas↑
Case11899.0399.503.0196.10
Case30098.7099.103.3095.40
Case50097.9098.606.7093.00
Case200094.8096.1016.1088.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)

Table 9. ACOPF under strict feasibility: composing CONSTRAINER with the L-BFGS refinement stage of FSNet.
MethodCase30Case118
Feas↑Gap↓Feas↑Gap↓
FSNet∼1000.82∼1000.90
CONSTRAINER98.202.0596.103.01
CONSTRAINER + FSNet L-BFGS∼1001.03∼1001.39
Table 10. How constraints are supplied (optimality gap, %) ↓.
VariantATSPCVRPTWOP
Operator-DAG encoder (CONSTRAINER)0.503.010.27
Text embeddings of the constraint (text-embedding-3-small)0.783.420.36
No constraint conditioning (multi-task backbone)0.943.860.45
Table 11. Depth of constraint injection, MIS with 100 nodes (optimality gap, %) ↓.
Cross-attention placementLayer 1Layer \(L/2\)Layer \(L-1\)
Optimality gap0.5220.5000.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

  1. D. Drakulic, S. Michel, and J.-M. Andreoli. GOAL: A Generalist Combinatorial Optimization Agent Learner. ICLR, 2025.
  2. Z. Hu, Y. Dong, K. Wang, and Y. Sun. Heterogeneous Graph Transformer. The Web Conference (WWW), 2020.
  3. C. Coffrin, R. Bent, K. Sundar, Y. Ng, and M. Lubin. PowerModels.jl: An Open-Source Framework for Exploring Power Flow Formulations. PSCC, 2018.
  4. H. T. Nguyen and P. L. Donti. FSNet: Feasibility-Seeking Neural Network for Constrained Optimization with Guarantees. NeurIPS, 2025.
  5. P. L. Donti, D. Rolnick, and J. Z. Kolter. DC3: A Learning Method for Optimization with Hard Constraints. ICLR, 2021.