Capability Composition in Heterogeneous Teams via Barrier-Guided Diffusion Sampling
The agents in a heterogeneous team can cooperate to accomplish tasks that exceed their individual capabilities. The team trajectories for a cooperative task can be generated by a generative model, provided that the model has been trained on demonstrations of the agents cooperating.
From the abstract. Our summary is in progress.
Full paper
Capability Composition in Heterogeneous Teams via Barrier-Guided Diffusion Sampling
Published under CC BY 4.0. Reproduced with attribution; original at arXiv:2611.23149 (PDF).
Abstract
The agents in a heterogeneous team can cooperate to accomplish tasks that exceed their individual capabilities. The team trajectories for a cooperative task can be generated by a generative model, provided that the model has been trained on demonstrations of the agents cooperating. Yet, demonstrations of cooperation are costly and may not exist for tasks that the team has never performed. The conditions under which the agents can combine their capabilities, however, are physical properties of the team and are known before any demonstration is collected. We encode the conditions as constraints on the team trajectories, and we enforce the constraints while sampling from generative models trained on demonstrations of each agent alone. We prove that the proposed method can generate every team trajectory that satisfies the constraints, although the demonstrations contain no cooperation. Hence the constraints determine which team trajectories can be generated, and the demonstrations determine how likely each team trajectory is. Numerical results on two cooperative tasks show the effectiveness of the method, which generates cooperative team trajectories that satisfy the constraints and requires no retraining when agents join or leave the team. Finally, we implement the method on a multi-robot testbed.
Keywords Multi-agent systems, cooperating robots, capability composition, integrated planning and learning
1 Introduction
Cooperation allows the agents in a team to accomplish tasks that exceed their individual capabilities. Cooperation in multi-agent teams has long been studied, from the allocation and scheduling of tasks [1, 2] to the control of several robots acting on a common object [3, 4]. Existing methods assume that the capabilities of the team are specified in advance, together with the conditions under which each capability can be used. The capabilities that a task requires, however, depend on the environment where the agents are deployed, and the environment is often unknown when the agents are trained. The task may then require a capability that no agent has alone, and that the agents obtain only by combining their individual capabilities. Hence the required cooperation can be neither specified nor demonstrated in advance, and generating cooperative behaviors for the task remains a challenge.
Generative models, and diffusion models in particular, are effective methods to generate the trajectories of an agent [5, 6] or of a team [7, 8], provided that the demonstrations contain the desired behavior. To overcome this limitation, we observe that the conditions under which the agents can combine their capabilities follow from the physics of the team. Hence the conditions can be written as constraints on the team trajectories without any demonstration. We then sample the team trajectories from generative models trained on demonstrations of each agent alone, and we impose the constraints during sampling using a guidance method [9, 5]. This results in a method to sample cooperative team trajectories from models pre-trained on non-cooperative demonstrations.
Related work. Task allocation and scheduling decide which agent performs which task and when [1, 2], and a trajectory planner then realizes the decision. We sample the trajectories directly from diffusion models and read the pattern of cooperation off the result, with nothing computed in advance. One line of multi-agent diffusion planners trains on demonstrations of cooperation where they exist [7, 8], and reproduces only the cooperation those demonstrations contain. Another trains on single-robot data and reconciles the resulting plans by search [10] or by projection [11]. These approaches combine constraints by intersection, as for collision avoidance. We combine them by union, because cooperation admits configurations that no agent reaches alone. Cooperation is available only while the agents are physically arranged for it, and has to be encoded as a constraint that holds at every timestep of a trajectory. Control barrier functions [12] (barriers, for short) encode such constraints. A barrier keeps a trajectory inside the set it defines. Boolean combinations of barriers give intersections and unions of the admissible sets [13, 14]. On the generative side, barriers have been used to keep diffusion samples inside a safe set [15] and to guide sampling with a constricting condition that tightens as noise falls [16]. Barriers also make flow-matching samplers safe [17, 18]. In multi-agent systems, guidance can be distributed, so that each agent computes its own Lyapunov-based guidance input [19].
Contributions. Our contributions are as follows. First, we formulate cooperative trajectory generation without demonstrations of cooperation as barrier-guided diffusion sampling, with constraints that encode the individual capabilities of the agents and the cooperative ones. Second, we propose a scheme in which the scores trained independently for each agent are summed into a product prior, and we prove that the sum is the exact score of that product at every noise level, since the densities of different agents depend on disjoint sets of variables. Third, we prove that the sampler can generate every team trajectory satisfying the constraints with nonzero probability and, when its guidance succeeds at every step, no other. Thus, every pattern of cooperation the constraints permit can be generated, and none is specified or pre-computed. Fourth, we demonstrate the method on a river crossing task, in simulation and on the Robotarium. The generated trajectories cross the river cooperatively, while sampling the prior alone yields agents that ignore each other and fail the task. We also show that the sampler requires no retraining to generate trajectories when agents join or leave the team. Finally, we consider a task in which cooperation also has to be timed. The sampler generates such trajectories without demonstrations, but less often than in the river crossing. Most failures of the sampler are consistent with local maxima of the barrier.
2 Problem formulation
Consider a team of N agents with states x_{i}\in\mathbb{R}^{n_{i}} and inputs u_{i}\in\mathbb{R}^{m_{i}}, evolving in discrete time as
x_{i}(t+1)=f_{i}\big(x_{i}(t),u_{i}(t)\big),\quad t=0,\dots,T-1.Let x=(x_{1},\dots,x_{N})\in\mathbb{R}^{n} be the team state and u=(u_{1},\dots,u_{N})\in\mathbb{R}^{m} the team input, with n=\sum_{i}n_{i} and m=\sum_{i}m_{i}. A team trajectory is the matrix X=\big(x(0),\dots,x(T)\big)\in\mathbb{R}^{n\times(T+1)}, whose row block X_{i}\in\mathbb{R}^{n_{i}\times(T+1)} corresponds to the trajectory of agent i.
Without cooperation, agent i is constrained to the states and controls satisfying c_{i}(x_{i},u_{i})\geq 0, where c_{i}:\mathbb{R}^{n_{i}}\times\mathbb{R}^{m_{i}}\to\mathbb{R} is a problem-dependent constraint function. Cooperation enlarges this set. Let c_{\mathrm{coup},i}:\mathbb{R}^{n}\times\mathbb{R}^{m}\to\mathbb{R} describe the allowable configurations while cooperating with the rest of the team, so that the constraint set of agent i is
\mathcal{A}_{i}=\{(x,u):c_{i}(x_{i},u_{i})\geq 0\}\cup\{(x,u):c_{\mathrm{coup},i}(x,u)\geq 0\}.A team trajectory is admissible when the pair (x(t),u(t)) lies in \mathcal{A}_{i} for every agent i and at all times. Cooperation enlarges the set of admissible states and controls, while the dynamics (1) remain the same whether or not c_{\mathrm{coup},i}\geq 0. Combining constraint sets is standard in the safe control literature [13]. Multi-robot planning combines them by intersection, since collision avoidance asks that a plan satisfy every agent’s constraints, and the feasible set may shrink [10]. In (2), instead, the second set depends on the other agents, so \mathcal{A}_{i} admits configurations that agent i cannot reach alone.
A task is specified by a problem-dependent function c_{\mathrm{task}}:\mathbb{R}^{n\times(T+1)}\to\mathbb{R}, and a team trajectory successfully completes the task when c_{\mathrm{task}}(X)\geq 0. We are interested in tasks that no agent can complete alone and the team can complete together. This motivates the following assumption.
Assumption 2.1.
(Cooperation is necessary and sufficient to complete the task) Every admissible team trajectory X that completes the task also satisfies c_{i}(x_{i}(t),u_{i}(t))<0\leq c_{\mathrm{coup},i}(x(t),u(t)) for some agent i and some time t. Moreover, at least one such trajectory exists. \square
Assumption 2.1 requires that, along every trajectory that completes the task, some agent at some timestep violates its own constraint c_{i} and is admissible only through the coupling constraint c_{\mathrm{coup},i}. Hence no trajectory in which every agent always satisfies its own constraint completes the task, that is, cooperation is necessary. Cooperation is also sufficient, because at least one admissible trajectory completes the task.
\mathcal{A}_{1} in Example 1, for one position of the vessel (square): the land, by c_{1} (left), within r of the vessel, by c_{\mathrm{coup},1} (middle), and their union (right). The disc is narrower than the river, so it reaches land only when the vessel is near it. The vehicle (circle) is aboard the vessel when c_{1}<0 and c_{\mathrm{coup},1}\geq 0.Example 1.
(Crossing a river) Consider a team of two agents, a ground vehicle and a vessel, operating in a unit square environment divided across the middle by a river of width w. The task is for the vehicle to reach a location across the river. The vehicle cannot enter the water and the vessel cannot leave it, so the vehicle cannot satisfy the task alone.
Let x_{i}=(z_{i},q_{i}) be the position of agent i, with z_{i} and q_{i} as its horizontal and vertical coordinates, respectively. Agent i=1 is the vehicle and agent i=2 is the vessel, with dynamics f_{i}(x_{i},u_{i})=x_{i}+u_{i}. The constraint functions are
\displaystyle c_{1}(x_{1},u_{1}) \\ \displaystyle=\min\big(|q_{1}-\tfrac{1}{2}|-\tfrac{w}{2},\;v^{\max}-\left\lVert u_{1}\right\rVert\big), \\ \displaystyle c_{2}(x_{2},u_{2}) \\ \displaystyle=\min\big(\tfrac{w}{2}-|q_{2}-\tfrac{1}{2}|,\;v^{\max}-\left\lVert u_{2}\right\rVert\big), \\ \displaystyle c_{\mathrm{coup},1}(x,u) \\ \displaystyle=\min\big(r-\left\lVert x_{1}-x_{2}\right\rVert,\;v^{\max}-\left\lVert u_{1}-u_{2}\right\rVert\big),and c_{\mathrm{coup},2}<0 everywhere, since cooperation never lets the vessel leave the water. Hence c_{1}\geq 0 when the vehicle is on land and within its own speed limit, c_{2}\geq 0 when the vessel is on water and within its own, and c_{\mathrm{coup},1}\geq 0 when the two are within a tolerance radius r and the vehicle moves within v^{\max} of the vessel. Figure 1 shows these sets (positions). The vehicle may therefore be in the water only while riding the vessel. While the vehicle is aboard, its speed limit applies relative to the vessel, so its velocity is the velocity of the vessel plus an input of norm at most v^{\max}. Since c_{\mathrm{coup},2}<0 leaves \mathcal{A}_{2}=\{(x,u):c_{2}(x_{2},u_{2})\geq 0\}, the vessel is bound by \left\lVert u_{2}\right\rVert\leq v^{\max} at all times, and \left\lVert u_{1}\right\rVert\leq 2v^{\max} whenever the vehicle is within r of the vessel. The vehicle starts at a given position x_{1}^{0} on one side of the river, the vessel at a given position x_{2}^{0} on the water, and the vehicle must reach a goal g across the river:
c_{\mathrm{task}}(X)=\min\big(\delta-\left\lVert x_{1}(0)-x_{1}^{0}\right\rVert,\,\delta-\left\lVert x_{2}(0)-x_{2}^{0}\right\rVert,\,\delta-\left\lVert x_{1}(T)-g\right\rVert\big),where \delta>0 is the tolerance on each of the three positions. \square
We study the following capability composition problem: given a task c_{\mathrm{task}} and a team of N agents with constraint sets \mathcal{A}_{i}, sample team trajectories X with c_{\mathrm{task}}(X)\geq 0 and (x(t),u(t))\in\mathcal{A}_{i} for every i and every t. We generate trajectories with a denoising diffusion model, a dynamical system that transports a Gaussian into the data distribution [20, 21]. A forward process adds noise to X over diffusion time \tau\in[0,1] as
\mathrm{d}X=-\tfrac{1}{2}\,g^{2}(\tau)\,X\,\mathrm{d}\tau+g(\tau)\,\mathrm{d}w,where g>0 is the noise schedule and w is a Wiener process. We write p_{\tau} for the density of X at time \tau, so that p_{0} is the density of the demonstrations and p_{1} close to the standard Gaussian \mathcal{N}(0,I). The coefficients of (3) are scalar, so noise enters each coordinate independently. Sampling reverses (3), running from \tau=1 back to \tau=0, according to
\mathrm{d}X=f_{\theta}(X,\tau)\,\mathrm{d}\tau+g(\tau)\,\mathrm{d}w,with \mathrm{d}w now a reverse-time Wiener process and the drift f_{\theta} built from a score network trained to approximate the score \nabla_{X}\log p_{\tau}. We assume that no demonstration of cooperation is available for training. Let \mathcal{D}_{i} be a set of demonstrations X_{i}\in\mathbb{R}^{n_{i}\times(T+1)} of agent i alone, let p^{i} be their density, and let s_{\theta_{i}} be a score network trained on \mathcal{D}_{i}. The team prior is the product p^{\otimes}=\prod_{i}p^{i} of the per-agent densities. We assume that each \mathcal{D}_{i} is collected in an unconstrained environment, in which agent i is free to occupy any state. The demonstrations are therefore reusable across tasks, while c_{i} is task-specific and enforced at sampling time. In Example 1, \mathcal{D}_{1} and \mathcal{D}_{2} contain trajectories of the vehicle and the vessel.
3 Main results
Generating a team trajectory through (4) requires the team score at every diffusion time, and Section 2 leaves us with one score per agent. Let p^{\otimes}_{\tau} denote the density at time \tau of the forward process (3) started from p^{\otimes}. The separately trained per-agent scores yield the team score exactly, as we show next.
Proposition 3.1.
(Agent scores form the team score) Let p^{i}_{\tau} be the density of X_{i} at time \tau. Then the rows of the team score for agent i are its own score: for every \tau and i,
\nabla_{X_{i}}\log p^{\otimes}_{\tau}(X)=\nabla_{X_{i}}\log p^{i}_{\tau}(X_{i}).Proof.
Let k_{\tau}(X\mid X_{0}) be the density of X at time \tau when the forward process starts from the trajectory X_{0}. It factorizes across coordinates, so p^{\otimes}_{\tau}(X)=\prod_{i}\int p^{i}(Y_{i})\,k_{\tau}(X_{i}\mid Y_{i})\,\mathrm{d}Y_{i}, and the logarithm turns the product into a sum whose i-th term depends on X_{i} alone. ∎
The identity (5) holds whenever the densities in the product depend on disjoint sets of variables. The forward process adds noise to each coordinate independently, so it smooths each variable separately. When the densities are over the same variable, as in a product of experts, smoothing the product is not the same as multiplying the smoothed densities, and the identity holds only approximately [22].
Sampling (4) with this score returns team trajectories drawn from p^{\otimes}, and there is no reason for them to be admissible or to complete the task: the per-agent densities were trained on demonstrations and carry no information about \mathcal{A}_{i} or c_{\mathrm{task}}. The constraints must therefore be imposed while the trajectory is generated. Following [16], we add a control u to (4),
\mathrm{d}X=\big[f_{\theta}(X,\tau)+u\big]\,\mathrm{d}\tau+g(\tau)\,\mathrm{d}w,and choose u at each step so that a scalar barrier stays non-negative along the sampled trajectory. The barrier encodes all the constraints specified in Section 2. The sampler generates state trajectories only, while the constraint functions depend also on the inputs. We therefore assume that, for every agent i and state x_{i}, the map u_{i}\mapsto f_{i}(x_{i},u_{i}) in (1) is injective, so that u_{i}(t) is the unique input taking x_{i}(t) to x_{i}(t+1). In Example 1, u_{i}(t)=x_{i}(t+1)-x_{i}(t). Hence the constraints along a trajectory are functions of X only. Admissibility is an intersection over agents and times, and (2) is a union:
\underbrace{\min_{i,t}\,\max\big\{c_{i}(x_{i}(t),u_{i}(t)),\;c_{\mathrm{coup},i}(x(t),u(t))\big\}}_{h_{\mathrm{comp}}(X)},so that h_{\mathrm{comp}}\geq 0 when the trajectory is admissible. The actuation limits do not need a term of their own, since (2) already carries each agent’s actuation limit in c_{i} and the coupled regime’s in c_{\mathrm{coup},i}. The barrier then becomes
h(X)=\min\{h_{\mathrm{comp}}(X),c_{\mathrm{task}}(X)\},and the set \mathcal{C}=\{X:h(X)\geq 0\} contains exactly the admissible team trajectories that complete the task.
The sampler of [16] simulates (6) on a grid \tau_{K}>\dots>\tau_{0}=0 with steps \Delta\tau_{k}=\tau_{k}-\tau_{k-1},
X_{k-1}=X_{k}-\big[f_{\theta}(X_{k},\tau_{k})+u_{k}\big]\Delta\tau_{k}+g(\tau_{k})\sqrt{\Delta\tau_{k}}\,\zeta_{k},from X_{K}\sim\mathcal{N}(0,I) to the returned trajectory X^{\star}=X_{0}, where the \zeta_{k} are independent Gaussian increments. The control uses the relaxed barrier \tilde{h}(X,\tau)=h(X)+\epsilon(X_{K},\tau), whose margin is continuous, nondecreasing in \tau, vanishes at \tau_{0}, and equals \max\{0,-h(X_{K})\} at \tau_{K}, so that \tilde{h}(X_{K},\tau_{K})\geq 0. At each step \zeta_{k} is drawn first, then u_{k} is chosen so that
\tilde{h}(X_{k-1},\tau_{k-1})\geq(1-\alpha\Delta\tau_{k})\,\tilde{h}(X_{k},\tau_{k}),with \alpha>0 and \alpha\Delta\tau_{k}\leq 1. If (9) holds at every step, then \tilde{h} stays non-negative and h(X^{\star})\geq 0 for every realization of the noise [16]. In that case X^{\star} is admissible and completes the task, and, by Assumption 2.1, at some timestep some agent violates its own constraint c_{i} and is admissible only through its coupling constraint c_{\mathrm{coup},i}. Let X_{k-1}(u) denote the state that (8) gives with u_{k}=u and the noise \zeta_{k} already drawn, so that (9) depends on u_{k} through \tilde{h}(X_{k-1}(u_{k}),\tau_{k-1}). Linearizing \tilde{h}(\cdot,\tau_{k-1}) at a point \bar{X} gives the condition
\tilde{h}(\bar{X},\tau_{k-1})+\big\langle\nabla\tilde{h}(\bar{X},\tau_{k-1}),\,X_{k-1}(u)-\bar{X}\big\rangle\geq(1-\alpha\Delta\tau_{k})\,\tilde{h}(X_{k},\tau_{k}),which is linear in u, so the control of minimum norm that satisfies (10) is in closed form. The sampler of [16] takes the minimum-norm control with \bar{X}=X_{k}. As noted in [16], the linearization error is quadratic in the displacement X_{k-1}-X_{k}, which is dominated by the noise term g(\tau_{k})\sqrt{\Delta\tau_{k}}\,\zeta_{k}. The error is therefore of order g(\tau_{k})^{2}\Delta\tau_{k}, the same order as the decrease that (9) allows. Hence a control that satisfies (10) at \bar{X}=X_{k} can violate (9), and the guarantee is then lost.
To overcome this limitation, we use the sampler of [16] with three modifications. First, the relaxed barrier is evaluated on an estimate of the trajectory being formed rather than on the iterate itself, which for most of the reverse process is dominated by noise and carries little information about the trajectory the sampler returns. The estimate is the best affine estimate of X_{0} from X_{\tau}, given in Lemma 3.2 below. Second, the control is u_{k}=0 whenever the unguided update satisfies (9), instead of its linearization as in [16, Remark 2]. Third, when the unguided update violates (9), we search for u_{k} locally. We first set u_{k} to the control of minimum norm that satisfies (10) with \bar{X}=X_{k}, as in [16]. While (9) fails, we set \bar{X}=X_{k-1}(u_{k}), the state reached with the current control, and recompute u_{k} from (10). If no control satisfying (9) is found within j_{\max} iterations, as happens near a local maximum of \tilde{h}, where the gradient vanishes, we take the step with the last control. The guarantee is then lost, but the returned trajectory may still lie in \mathcal{C}, because later steps can increase \tilde{h} again. For this reason, Algorithm 1 returns h(X^{\star}) together with X^{\star}.
Lemma 3.2.
(Affine estimate of the returned trajectory) Let X_{0}\in\mathbb{R}^{n\times(T+1)} be a random variable with mean \mu and covariance \Sigma>0. Let X_{\tau} evolve from X_{0} according to (3), and let a_{\tau}=\exp\!\big(-\tfrac{1}{2}\int_{0}^{\tau}g^{2}(s)\,\mathrm{d}s\big) and \sigma_{\tau}^{2}=1-a_{\tau}^{2}. Then
(A_{\tau},b_{\tau})=\arg\min_{A,\,b}\,\mathbb{E}\left\lVert X_{0}-AX_{\tau}-b\right\rVert^{2}is given by A_{\tau}=a_{\tau}\Sigma\,\big(a_{\tau}^{2}\Sigma+\sigma_{\tau}^{2}I\big)^{-1} and b_{\tau}=(I-a_{\tau}A_{\tau})\mu, so that M_{\tau}X=A_{\tau}X+b_{\tau} satisfies
M_{\tau}X=\mu+A_{\tau}(X-a_{\tau}\mu).Moreover, M_{\tau} is invertible for every \tau\in[0,1], M_{0}=I, and M_{\tau}X=\mathbb{E}[X_{0}\mid X_{\tau}=X] when X_{0} is Gaussian.
Proof.
Equation (3) is linear with scalar coefficients, so X_{\tau}=a_{\tau}X_{0}+\sigma_{\tau}\xi, where \xi\sim\mathcal{N}(0,I) is independent of X_{0} and \sigma_{\tau}^{2}=a_{\tau}^{2}\int_{0}^{\tau}g^{2}(s)/a_{s}^{2}\,\mathrm{d}s=1-a_{\tau}^{2}. Hence X_{\tau} has mean a_{\tau}\mu and covariance a_{\tau}^{2}\Sigma+\sigma_{\tau}^{2}I, and its cross-covariance with X_{0} is a_{\tau}\Sigma. The minimizer is A_{\tau}=\mathrm{Cov}(X_{0},X_{\tau})\,\mathrm{Cov}(X_{\tau})^{-1} and b_{\tau}=\mathbb{E}[X_{0}]-A_{\tau}\,\mathbb{E}[X_{\tau}], which gives the expressions above. The eigenvalues \lambda_{j} of \Sigma are positive, and A_{\tau} has the same eigenvectors and the eigenvalues a_{\tau}\lambda_{j}/(a_{\tau}^{2}\lambda_{j}+\sigma_{\tau}^{2})>0, so M_{\tau} is invertible. Since a_{0}=1 and \sigma_{0}=0, A_{0}=I and b_{0}=0. When X_{0} is Gaussian, (X_{0},X_{\tau}) is jointly Gaussian, and its conditional mean is affine and equal to (11). ∎
Lemma 3.2 uses only the mean and the covariance of X_{0}, so M_{\tau} is computed in closed form and does not need to be learned. During sampling, X_{\tau} is the current iterate, and M_{\tau}X_{\tau} is the best affine estimate of the trajectory being formed. We therefore let \mu and \Sigma be the mean and covariance of the product prior p^{\otimes}, estimated from the training sets \mathcal{D}_{i}, and evaluate the relaxed barrier on this estimate, that is, \tilde{h}(X,\tau)=h(M_{\tau}X)+\epsilon(X_{K},\tau), with margin \epsilon(X_{K},\tau_{K})=\max\{0,-h(M_{\tau_{K}}X_{K})\}. Theorem 4.2 of [16] is stated for the barrier h(X)+\epsilon(X_{K},\tau), and it extends to the modified \tilde{h} above with the same proof. The margin gives \tilde{h}(X_{K},\tau_{K})\geq 0, and if (9) holds at every step, then \tilde{h}(X_{k-1},\tau_{k-1})\geq(1-\alpha\Delta\tau_{k})\,\tilde{h}(X_{k},\tau_{k})\geq 0 for every k, by induction. As \epsilon vanishes at \tau_{0} and M_{0}=I, h(X^{\star})=\tilde{h}(X_{0},\tau_{0})\geq 0, so X^{\star}\in\mathcal{C}. In our implementation, the right-hand side of (9) is replaced by its minimum with 0.15+\epsilon(X_{K},\tau_{k-1}), so that the guidance stops acting once a trajectory is well inside \mathcal{C}. The right-hand side remains non-negative, and the argument above still applies.
We next characterize the type of trajectories that the diffusion sampler can generate. In particular, we prove that any admissible team trajectory solving the task can be generated with arbitrary accuracy and nonzero probability, even when the training set does not contain such trajectories. To this end, we make the following technical assumption.
Assumption 3.3.
(Monotone reachability) For every X\in\mathcal{C} and s\leq 0, there exists X^{\prime} with h(X^{\prime})=s and a continuous path from X^{\prime} to X along which h is nondecreasing. \square
Assumption 3.3 asks that every trajectory in \mathcal{C} be reachable from below without lowering h. It fails when a trajectory in \mathcal{C} lies in a region enclosed by higher values of h, so that h first increases and then decreases along every path that reaches it from a lower level set. It involves only h, and neither the prior nor the data. For X\in\mathbb{R}^{n\times(T+1)} and \rho>0, B(X,\rho) denotes the open ball of radius \rho centered at X in the Frobenius norm, and \mathrm{supp}(\mu) denotes the support of a distribution \mu, that is, the smallest closed set of probability one.
Theorem 3.4.
(Every trajectory in \mathcal{C} can be generated) Let Assumption 3.3 hold, let f_{\theta} and h be continuous, with \mathcal{C} the closure of \{X:h(X)>0\}, and let \mu be the distribution of the trajectory X^{\star} returned by Algorithm 1. Then \mu\big(B(\bar{X},\rho)\cap\mathcal{C}\big)>0 for every \bar{X}\in\mathcal{C} and every \rho>0. If, in addition, (9) holds at every step, then \mathrm{supp}(\mu)=\mathcal{C}.
Proof.
Fix \bar{X} with h(\bar{X})>0 and \rho>0, and let \rho^{\prime}\in(0,\rho] be such that h>0 on B(\bar{X},\rho^{\prime}), which exists because h is continuous. Assumption 3.3 with any s<0 gives a trajectory \hat{Y}_{K} with h(\hat{Y}_{K})=s and a continuous path from \hat{Y}_{K} to \bar{X} along which h is nondecreasing. Let \hat{X}_{K}=M_{\tau_{K}}^{-1}\hat{Y}_{K}. At \hat{X}_{K} the margin is \epsilon(\hat{X}_{K},\tau_{K})=-s, so \tilde{h}(\hat{X}_{K},\tau_{K})=0, and as \epsilon vanishes at \tau_{0} and h(\bar{X})>0, \textstyle\sum_{k=1}^{K}\big[\epsilon(\tau_{k})-\epsilon(\tau_{k-1})\big]=-s<h(\bar{X})-h(\hat{Y}_{K}), so the path has points \hat{Y}_{K},\dots,\hat{Y}_{0}=\bar{X} with
h(\hat{Y}_{k-1})-h(\hat{Y}_{k})>\epsilon(\tau_{k})-\epsilon(\tau_{k-1}).Let \hat{X}_{k}=M_{\tau_{k}}^{-1}\hat{Y}_{k}, so that \hat{X}_{0}=\bar{X} as M_{0}=I, and \tilde{h}(\hat{X}_{k},\tau_{k})=h(\hat{Y}_{k})+\epsilon(\tau_{k}) increases strictly as k decreases.
Since \tilde{h} vanishes at \hat{X}_{K} it is non-negative at every step, and by (12) it increases strictly. Hence the unguided update from \hat{X}_{k} to \hat{X}_{k-1} satisfies (9) with strict inequality, and Algorithm 1 sets u_{k}=0 there. The recursion (8) adds g(\tau_{k})\sqrt{\Delta\tau_{k}}\,\zeta_{k} to a term set by X_{k} and u_{k}, and g(\tau_{k})>0, so exactly one increment \zeta^{\star}_{k} carries \hat{X}_{k} to \hat{X}_{k-1} and (\hat{X}_{K},\zeta^{\star}_{1:K}) returns \bar{X}.
The barrier \tilde{h} is continuous and (12) is strict, so induction on k gives u_{k}=0 at every step on a neighborhood of (\hat{X}_{K},\zeta^{\star}_{1:K}). The recursion is the unguided one there, hence continuous, and a smaller neighborhood is carried into B(\bar{X},\rho^{\prime}). That neighborhood has positive probability under the Gaussian initialization and increments, so \mu(B(\bar{X},\rho)\cap\mathcal{C})\geq\mu(B(\bar{X},\rho^{\prime}))>0. If instead h(\bar{X})=0, then B(\bar{X},\rho/2) contains a trajectory X^{\prime} with h(X^{\prime})>0, because \mathcal{C} is the closure of \{h>0\}, and the claim follows from B(X^{\prime},\rho/2)\subseteq B(\bar{X},\rho). Finally, we prove the second claim. If (9) holds at every step, then h(X_{0})\geq 0 for every realization of the noise, by the extension of [16, Theorem 4.2] given after Lemma 3.2, so that \mu(\mathcal{C})=1. Since h is continuous, \mathcal{C} is closed, and hence \mathrm{supp}(\mu)\subseteq\mathcal{C}. The reverse inclusion \mathcal{C}\subseteq\mathrm{supp}(\mu) is the first claim, since every ball around a point of \mathcal{C} has positive probability. ∎
We next ask which agents cooperate, and when. Let the times at which agent i is admissible only through its coupling constraint be
S_{i}(X)=\{t:c_{i}(x_{i}(t),u_{i}(t))<0\leq c_{\mathrm{coup},i}(x(t),u(t))\},and we call S(X)=(S_{1}(X),\dots,S_{N}(X)) the coupling pattern of X. The trajectories in \mathcal{C} with pattern S form the set \mathcal{C}_{S}=\{X\in\mathcal{C}:S(X)=S\}, and these sets partition \mathcal{C}. The sampler returns, with nonzero probability, the coupling pattern of every trajectory that satisfies the constraints strictly.
Corollary 3.5.
(Every coupling pattern can occur) Let the hypotheses of Theorem 3.4 hold and let X satisfy h(X)>0 and, for every t and i, either c_{i}(x_{i}(t),u_{i}(t))>0 or c_{i}(x_{i}(t),u_{i}(t))<0<c_{\mathrm{coup},i}(x(t),u(t)). Then the sampler returns a trajectory in \mathcal{C} with the coupling pattern of X with nonzero probability, that is, \mu(\mathcal{C}_{S(X)})>0.
Proof.
The inequalities in the hypothesis are strict and c_{i}, c_{\mathrm{coup},i} and h are continuous, so there is a \rho>0 such that every trajectory in B(X,\rho) satisfies them and has h>0. By (13) the coupling pattern is S(X) throughout B(X,\rho), and Theorem 3.4 gives \mu(\mathcal{C}_{S(X)})\geq\mu(B(X,\rho)\cap\mathcal{C})>0. ∎
The constraint functions c_{i}, c_{\mathrm{coup},i} and c_{\mathrm{task}} determine \mathcal{C}. By Theorem 3.4, the sampler can return every trajectory in \mathcal{C}, with probabilities determined by the demonstrations. The constraints do not prescribe a coupling pattern, because (x(t),u(t)) lies in \mathcal{A}_{i} whenever c_{i}\geq 0 or c_{\mathrm{coup},i}\geq 0. Hence \mathcal{C} contains trajectories with different coupling patterns, and Corollary 3.5 gives each of them a positive probability of being sampled. Finally, by Proposition 3.1, each agent contributes its own score to the product prior, while the constraints enter only through the guidance. Adding or removing an agent therefore changes only the constraint functions and the set of scores in the product, and no network needs to be retrained.
The probability that the sampler returns a trajectory in \mathcal{C} depends on whether (9) can be satisfied at every step, because (9) at every step guarantees that the returned trajectory lies in \mathcal{C}. Algorithm 1 searches for such a step locally, along gradients of \tilde{h}. Because h_{\mathrm{comp}} in (7) is a maximum over the two sets of each union, h can have local maxima at which h<0, and a search that reaches one may find no step satisfying (9) even when \mathcal{C} is nonempty. Controllers based on control barrier functions have the same limitation, since their quadratic programs can stall at points other than the intended ones [23]. The maxima that encode unions of sets [13] add such points.
4 Numerical results
We consider Example 1 over 50 timesteps, with w=0.16, v^{\max}=0.045, r=0.05 and \delta=0.06. The training sets \mathcal{D}_{1} and \mathcal{D}_{2} contain 2000 single-agent trajectories each, recorded in an environment of the same dimensions without the river. Hence the demonstrations describe how each agent moves, and contain neither the constraints nor any cooperation.1 To compute the guidance from the gradient of h, we replace the \min and \max in h by the smooth surrogates
\displaystyle\mathrm{smin}_{\kappa}(a) \\ \displaystyle=-\tfrac{1}{\kappa}\log\textstyle\sum_{j}e^{-\kappa a_{j}}, \\ \displaystyle\mathrm{smax}_{\kappa}(a) \\ \displaystyle=\tfrac{1}{\kappa}\log\textstyle\sum_{j}e^{\kappa a_{j}}-\tfrac{1}{\kappa}\log M,over the M entries of a, with \kappa=25. Both surrogates are bounded above by the exact minimum and maximum, so the smoothed barrier is non-negative only on trajectories in \mathcal{C}.
c_{\mathrm{task}} only, and one guided by all constraints h (Algorithm 1). The band is the river, open circles mark initial positions and the disc around \star is the goal. The vehicle’s path in the river is green where the vessel is within r and amber where it is not. Right: vehicle-vessel distance along the trajectory guided by h, shaded while the vessel carries the vehicle.500 trajectories from the learned prior and 500 from a Gaussian prior of matched moments, both guided by h. The shading counts the trajectories that cross at the coordinate z_{1} and the timestep t at which the two agents come closest. The red curves bound the crossings that allow reaching the goal by T. The learned prior spreads its crossings over that region, and the Gaussian concentrates them near the middle.The sampler generates cooperative trajectories, although neither training set contains one. No trajectory drawn from the team prior lies in \mathcal{C} (Table 1). Guided by c_{\mathrm{task}} alone, all 500 generated trajectories reach the goal, but in every one of them the vehicle enters the water without the vessel. Guided by h, all 500 lie in \mathcal{C}. Fig. 2 shows one trajectory of each kind. In the trajectory guided by h, the vessel meets the vehicle at the river, the two cross together, and the vehicle continues to the goal. This sequence appears in neither training set.
The constraints require the two agents to cross together, and the learned prior determines where and when they do. To separate the two contributions, we replace the learned prior by a Gaussian of matched moments and keep the barrier. For each of the 500 trajectories guided by h, we record the coordinate z_{1} and the timestep t at which the two agents come closest (Fig. 3). With the Gaussian prior all trajectories also lie in \mathcal{C}, and the crossings concentrate near the point where the straight line from x_{1}^{0} to g meets the river. With the learned prior, the trajectories inherit the turns and pauses of the demonstrations, which are walks through two or three random waypoints at constant speed, and their crossings spread over most of the region that the horizon allows. The number of timesteps on which the two agents are within r of each other varies in the same way, from 4 to 27. The constraints require only two such timesteps, so the longer couplings come from the prior.
The sampler requires no retraining when the team changes. We add a second vessel that can also carry the vehicle, so that \mathcal{A}_{1} in (2) gains a third set. Both vessels use the same score, and c_{\mathrm{task}} fixes the initial position of each, the new vessel starting on the water at distance 0.2 from x_{2}^{0}. All 500 trajectories generated for this team lie in \mathcal{C}, and in 127 of them the vehicle passes from one vessel to the other. With three vehicles and three vessels, all 500 trajectories lie in \mathcal{C}. They show 144 different coupling patterns, against 12 in 100 solutions of trajectory optimization without the prior. Removing agents works in the same way, unless the remaining team cannot complete the task. With no vessel, for example, Assumption 2.1 fails and no trajectory lies in \mathcal{C}.
We implement the river crossing on the Robotarium [24], a testbed of unicycle robots in an arena of 3.2 m by 2 m. The unit square of Example 1 is mapped to a square of side 2 m in the arena, and each timestep of a trajectory is executed in 1.2 s. The robots have a physical size, so we change the constraint functions and keep the networks and the sampler. The river widens to 80 cm and r grows to 32 cm, so that two robots fit within r of each other, while 2r<w still forces the vessel to carry the vehicle. We also add two constraints that the simulation does not need. The first requires every pair of robots to stay at least 20 cm apart, so that the robots do not collide. The second requires every robot to stay inside the arena. Finally, a constraint that holds at every timestep can still be violated between two consecutive timesteps, so we impose every constraint on the whole segment between them. We call this the Robotarium setting. Algorithm 1 places every trajectory in \mathcal{C}, with one vessel and with two. Each robot tracks its sampled positions through the Robotarium’s map from single-integrator to unicycle inputs, so the nonholonomic constraint appears only as tracking error. We execute the first 15 trajectories with one vessel and the first 5 with two. All 20 runs satisfy the constraints up to the tracking error, which stays below 5 cm. Fig. 4 shows a run with two vessels, in which one vessel hands the vehicle to the other.
In the second task, an escape room, cooperation also has to be timed. Two agents start on one side of a wall with a doorway, and both have to reach an exit on the other side by the end of the horizon. The door is open at time t when, at t-1, some agent was on a pad placed before the wall, or in the doorway. The state of agent i consists of its current and previous positions, p_{i} and p_{i}^{-}, because the door depends on the previous step. Let W be the wall with the door shut, W_{s}\subset W its solid part, so that W\setminus W_{s} is the doorway, P the pad, and d_{S} the signed distance to S, positive outside S. Then
\displaystyle c_{i}(x_{i},u_{i}) \\ \displaystyle=\min\big\{d_{W}(p_{i}),\ v^{\max}-\left\lVert u_{i}\right\rVert\big\}, \\ \displaystyle c_{\mathrm{coup},i}(x,u) \\ \displaystyle=\min\big\{d_{W_{s}}(p_{i}),\ o(x),\ v^{\max}-\left\lVert u_{i}\right\rVert\big\}, \\ \displaystyle o(x) \\ \displaystyle=\max_{j}\,\omega(p_{j}^{-}), \\ \displaystyle\omega(p) \\ \displaystyle=\max\big\{{-d_{P}(p)},\ \min\{d_{W_{s}}(p),-d_{W}(p)\}\big\},where \omega(p)\geq 0 when p is on the pad or in the doorway, so that o(x)\geq 0 when the door is open. The task function c_{\mathrm{task}} asks each agent to start within \delta of its initial position and to end within \delta of the exit. The wall is thicker than one step and the pad is more than one step from the doorway, so an agent alone cannot pass. Two agents can, one on the pad while the other enters the doorway and then holds the door. Both agents use the same score network, trained on 4000 single-agent trajectories recorded in the room without the wall.
Cooperation that has to be timed is harder to generate. In the escape room, about 30\% of the trajectories generated by Algorithm 1 lie in \mathcal{C}, and in each of them one agent stands on the pad while the other enters the doorway (Fig. 5). Without the local search, as in [16], no trajectory lies in \mathcal{C}. Most failures leave an agent at the shut door, which is consistent with the local maxima of h discussed in Section 3.
\mathcal{C}, at four timesteps (top) and over the horizon (bottom). Dots are the agents and faint lines their last five steps. The doorway is dark when the door is shut, the disc is the pad, and the dotted line is the exit. Agent 2 is on the pad from t=11 to t=15, so the door is open from t=12, agent 1 enters the doorway at t=16 and holds the door, and agent 2 enters at t=19. Bottom: timesteps on the pad (yellow), in the doorway (agent colour), and with the door open (shaded).- Algorithm 1
- 100
- 30
- 100
- per-step projection
- 100
- 36
- 99
- penalty guidance
- 16
- 0
- 14
- projection after sampling
- 44
- 2
- 54
- rejection
- 0
- 0
- 0
In all three settings, Algorithm 1 and per-step projection place far more trajectories in \mathcal{C} than the other three methods in Table 1. All methods use the same prior, barrier and noise. Per-step projection [25, 11] moves the sample toward \{h\geq 0.02\} after every reverse step with a few Newton steps, on X_{\tau} or on M_{\tau}X_{\tau}, and the table reports the better of the two. Penalty guidance [5] adds to the score the gradient of a penalty on constraint violation, with a weight chosen per task. Projection after sampling moves each sample of the prior onto \mathcal{C} once sampling ends. Rejection keeps the samples of the prior that lie in \mathcal{C}. These last three methods place at most about half of the trajectories in \mathcal{C}, and almost none in the escape room. Per-step projection comes with no guarantee that the returned trajectory lies in \mathcal{C}, while Algorithm 1 has one whenever (9) holds at every step. In the river crossing and in the Robotarium setting, both methods place almost every trajectory in \mathcal{C}, and projection is faster. In the escape room, projection places 36\% of the trajectories in \mathcal{C}, against 30\%. It moves the samples about 400 times more than Algorithm 1, as measured by the control energy of [16], and its trajectories end farther from the prior, as measured by the maximum mean discrepancy [26]. In the river crossing, projection moves the samples about 50 times more, and its trajectories are as close to the prior as those of Algorithm 1. On images, the larger correction of per-step projection visibly degrades the samples [16].
5 Conclusion
In this paper we study how to generate trajectories for a team of agents, without demonstrations of cooperation, when the task requires a capability that no agent has alone. We encode the capability as constraints on the team trajectory, and guide the sampling from diffusion models trained on each agent alone with a barrier function built from the constraints. The resulting sampler can provably generate every team trajectory that satisfies the constraints. Our numerical results show that the sampler generates cooperative trajectories that satisfy the constraints, and that it requires no retraining when agents join or leave the team. On the Robotarium, the generated trajectories satisfy the constraints also when unicycle robots execute them, up to the tracking error. Existing guidance methods, however, can fail when the constraint sets are complex, for example when cooperation also has to be timed. Future work includes the design of guidance methods for complex constraint sets, and learning the coupling constraints from demonstrations of interacting agents.
Acknowledgments
This work was supported in part by NSF under award CMMI-2622263.