arXiv:2610.30388math.OCOct 2026

Manuscript Offprint

arXiv:2610.30388

A Transformer-based Approach for Real-time Multi-agent Path Planning with Varying Initial/Final Conditions

Qian Zhang, Shanqing Liu, Jerome Darbon, George Karniadakis

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

QIAN ZHANG, SHANQING LIU, JEROME DARBON, AND GEORGE KARNIADAKIS ∗^{*}

ABSTRACT. We address the problem of real-time multi-agent path planning under prescribed initial and final configurations, formulated as a high-dimensional optimal control problem subject to inter-agent collision avoidance and obstacle constraints. Classical solvers based on the Hamilton–Jacobi–Bellman equation or Pontryagin's maximum principle (PMP) become computationally intractable as the number of agents grows, due to the curse of dimensionality and the non-convexity introduced by interaction constraints. We propose OCFformer, a transformer-based neural network that parameterizes the inverse of a coordinate transformation mapping a simple, analytically tractable latent space, in which agents evolve independently under a decoupled Hamiltonian, to the physical space of the coupled, interacting system. The model is trained by minimizing a physics-informed loss comprising the Hamiltonian ODE residual from the PMP and a boundary matching term, without requiring pre-computed trajectory data. The self-attention mechanism endows OCFformer with permutation equivariance over agents, a structural symmetry that prior symplectic network approaches do not natively enforce. When trained on a distribution of boundary conditions, the amortized OCFformer produces near-optimal trajectories for unseen initial and final configurations in a single forward pass ( ∼\sim220 ms), enabling real-time inference without retraining. We further introduce a lightweight transfer learning framework that adapts a pretrained OCFformer to out-of-distribution perturbations in seconds via L-BFGS fine-tuning. Numerical experiments on two- and three-dimensional multi-agent navigation with up to 128 agents demonstrate the scalability and efficiency of the proposed approach.

1. INTRODUCTION

1.1. Motivation and Context. Optimal control problems arise in a wide range of applications, from robotics and autonomous navigation to multi-agent coordination and financial optimization. The goal is to steer a dynamical system from prescribed initial conditions to a desired final state while minimizing a cost functional. Two complementary theoretical frameworks underpin numerical approaches to these problems: Bellman's dynamic programming principle [Bel57], which characterizes the value function as the unique viscosity solution of the Hamilton–Jacobi–Bellman (HJB) equation, and Pontryagin's maximum principle (PMP) [AS13, Tré05], which gives first-order necessary optimality conditions through the introduction of a co-state variable. Despite their theoretical power, both frameworks face severe computational challenges as the state dimension grows. Grid-based methods for the HJB equation suffer from the curse of dimensionality [Bel57]: their complexity scales exponentially with the number of state variables, making them infeasible beyond a few dimensions. Indirect shooting methods based on the PMP avoid explicit gridding of the state space but require repeated numerical integration of the Hamiltonian system and are highly

Division of Applied Mathematics, Brown University, Providence, RI 02912, USA.

QIAN ZHANG, SHANQING LIU, JEROME DARBON, AND GEORGE KARNIADAKIS ∗^{*}

sensitive to the initial guess of the co-state, often failing to converge without a careful initialization [Tré05]. In multi-agent path planning, where M agents with individual state dimension dxd_x yield a joint state of dimension MdxMd_x, these difficulties are compounded by the need to enforce inter-agent collision avoidance constraints that introduce non-convexity and long-range coupling among the agents, rendering classical solvers impractical for real-time use at scale.

To overcome these scalability limits, deep learning has motivated mesh-free methods that parametrize solutions directly with neural networks, avoiding explicit state-space discretization. Building on early residual-based parametrizations of differential equations [LLF98], high-dimensional extensions such as the Deep Ritz method [EY18] and backward-stochastic-differential-equation reformulations [HJE18] scaled these ideas to hundreds of dimensions, and physics-informed neural networks (PINNs) [RPK19] unified them by encoding governing equations and boundary conditions as soft loss constraints, a paradigm that has since grown into the broader field of scientific machine learning [ZSX+22, ZKKS24, TZK+24, ZWK+25, ZKK25, KZGK26, WZK26, ZK26]. In the optimal control setting, the PMP's Hamiltonian ODE system provides a natural PINN residual; SympOCNet [MZDK22] pioneered this for multi-agent path planning by pairing a symplectic architecture [JZZ+20] with PINN training, later extended to time-dependent and non-convex settings [ZWL+24]. However, these architectures process agents in a fixed sequential order and impose a possibly-unnecessary symplectic constraint. Neither property reflects the permutation symmetry inherent to multi-agent problems.

Beyond the symplectic-PINN line of work, several alternative paradigms merit mention: optimal-transport-based continuous normalizing flows for mean-field control [OWFLR21], adaptive deep learning for the HJB equation [NZGK21], and Hopf–Lax representation formulas that solve Hamilton–Jacobi equations without spatial gridding [DO16, LCO18]. In the multi-robot community, graph neural networks [LGRP20] target decentralized collision avoidance with a similar permutation-equivariance motivation but distributed rather than centralized optimality. Classical planners such as ORCA [VDBGLM11], conflict-based search [SSFS15], and sequential convex programming [ASD12] remain practical workhorses that trade global optimality for tractability.

The transformer architecture [VSP +^{+}17] directly addresses this gap. Its self-attention mechanism computes pairwise interactions among all sequence elements simultaneously, capturing long-range dependencies and permutation symmetries that convolutional or recurrent architectures handle only approximately, and it is theoretically a universal approximator of continuous, permutation-equivariant sequence-to-sequence functions [YBR +^{+}19], consistent with its empirical dominance across NLP [DCLT19, BMR +^{+}20] and vision [DBK +^{+}21]. This permutation-equivariant structure is especially relevant for multi-agent problems, where agents are interchangeable and a solution method should be invariant to their indexing, allowing a transformer to learn collective, collision-avoidance behaviors that generalize across agent configurations without a fixed ordering.

1.2. Contribution. In this work we propose OCFormer, a transformer-based framework that addresses multi-agent optimal control by combining the structural inductive biases of attention with physics-informed training. The central idea is to learn a parameterized inverse coordinate transformation ϕ~θ\tilde{\phi}^{\theta} that maps analytically tractable latent trajectories, corresponding to non-interacting agents with a decoupled Hamiltonian, to the physical trajectories of the interacting system. OCFormer is built from alternating transformer blocks that mirror the leapfrog structure of Störmer–Verlet integration [JZZ +^{+}20], and is trained by minimizing a physics-informed loss comprising the Hamiltonian ODE residual from the PMP together with a boundary matching term enforcing prescribed initial and final configurations. Unlike SympOCNet [MZDK22], OCFormer is not constrained to be symplectic; instead, it achieves permutation equivariance through the self-attention mechanism, which is essential for generalization over varying agent counts and configurations. Once trained on a distribution of boundary conditions, OCFormer infers near-optimal trajectories for unseen initial and final configurations in a single forward pass ( ∼\sim220 ms), enabling real-time multi-agent path planning. We further develop a transfer learning strategy that efficiently adapts a pretrained OCFormer to perturbed boundary conditions, avoiding costly retraining from scratch. The framework is validated on two- and three-dimensional multi-agent navigation benchmarks, demonstrating competitive trajectory quality and significantly reduced inference time compared to existing methods.

References (30)