---
title: 'CoPlanner: Adaptive Diffusion Trajectory Planning'
url: https://www.emergentmind.com/topics/coplanner
type: topic
---

# CoPlanner: Adaptive Diffusion Trajectory Planning

The Variable Horizon Diffuser (VHD) is a time-aware, goal-conditioned trajectory planning framework that enables diffusion-based planners to generate instance-specific trajectories of variable length. Traditional diffusion planners employ a fixed horizon for both training and inference, leading to mismatches between the specified trajectory length and the true optimal path length for individual start–goal pairs. VHD addresses these limitations by combining a learned horizon predictor with length-agnostic diffusion models, maintaining full compatibility with existing diffusion planning architectures while explicitly controlling trajectory length through initial noise shaping and curriculum-based training procedures [2509.11930].

## 1. Background: Diffusion Planning and Horizon Mismatch

Diffusion-based planners, such as Diffuser, DecisionDiffuser, and DiffusionPolicy, formulate trajectory planning as a conditional generative modeling task. They operate by learning to map pure Gaussian noise to feasible trajectories under start and goal constraints, using a Denoising Diffusion Probabilistic Model (DDPM). Conventionally, these models operate with a predetermined, fixed horizon $H$:

- Fixed $H$ introduces **length–mismatch**. If $H$ is too small, the plan may undershoot the goal; if $H$ is too large, trajectories exhibit excessive dithering or inefficiency (see Fig. 1 in [2509.11930]).
- Empirically, fixed-horizon designs exhibit brittle performance over instances with diverse geometric or dynamic requirements.

The motivation for VHD arises from the need to treat horizon selection as a flexible, data-driven variable, not a static hyperparameter.

## 2. Diffusion Model for Trajectory Generation

The VHD framework employs the standard DDPM construction for trajectories $\tau^0 \in \mathbb{R}^{L \times d}$:

- **Forward noising process**: 
  $$
  q(\tau^i|\tau^{i-1}) = \mathcal{N}(\tau^i; \sqrt{1-\beta_i}~\tau^{i-1}, \beta_i I),\qquad i=1,\ldots,N
  $$
  yielding
  $$
  \tau^i = \sqrt{\bar{\alpha}_i}\,\tau^0 + \sqrt{1 - \bar{\alpha}_i}\,\epsilon,\qquad \bar{\alpha}_i \equiv \prod_{j=1}^{i}(1 - \beta_j),~\epsilon \sim \mathcal{N}(0, I)
  $$

- **Reverse denoising process**:
  $$
  p_\phi(\tau^{i-1}|\tau^i) = \mathcal{N}(\tau^{i-1}; \mu_\phi(\tau^i, i), \Sigma^i)
  $$
  where $\mu_\phi$ is implemented by a noise-prediction network $\epsilon_\phi(\tau^i, i)$. $\Sigma^i$ is typically fixed.

- **Training objective**: Minimize the expected squared error between sampled noise and the model's prediction:
  $$
  \mathcal{L}_\text{diff}(\phi) = \mathbb{E}_{i, \tau^0, \epsilon}\|\epsilon - \epsilon_\phi(\sqrt{\bar{\alpha}_i}\tau^0 + \sqrt{1-\bar{\alpha}_i}\epsilon, i)\|^2
  $$

- **Conditional planning**: Start and goal constraints are enforced by clamping trajectory endpoints at each reverse step: $\tau^{i-1}_0 = s_0,~\tau^{i-1}_{L-1} = g$.

## 3. Length Predictor Architecture and Supervision

VHD disentangles **“when to stop”** (horizon selection) from **“how to move”** (trajectory generation) by introducing a **Length Predictor** $f_\theta(s, g)$ that estimates the shortest-step distance $D^*(s, g)$. The network processes a state pair $(s,g)$ and outputs a normalized distance $\tilde{D} \in [0, 1]$, used to compute the predicted horizon:
$$
\hat{H} = \text{clip}(\gamma \cdot (f_\theta(s, g) \cdot T_\text{max} + 1), L_\text{min}, T_\text{max})
$$

**Architecture**:

1. States are embedded using randomized Fourier features: $\Phi(x) = [\sin(2\pi B x), \cos(2\pi B x), x]$ with $B$ a random Gaussian matrix.
2. Concatenate: $z = [\Phi(s), \Phi(g), (\Phi(s) - \Phi(g))]$.
3. A compact MLP with normalization, ReLU, and softplus activation outputs $f_\theta(s,g)$.

**Hybrid supervision signals** (Eqs. (6)–(9)):

- **Exact anchors**: For trajectory pairs $k$ steps apart: $f_\theta(s_t, s_{t+k}) \approx \min(1, k/T_\text{max})$.
- **DP upper-bounds**: For $k$-step successor $s \to s_k$: enforce $f_\theta(s, g) \leq k/T_\text{max} + f_{\bar \theta}(s_k, g)$.
- **Triangle-relay constraints**: For relay state $h$, enforce $f_\theta(s,g) \leq f_{\bar \theta}(s,h) + f_{\bar \theta}(h,g)$.

**Training loss** (Eq. (9)) combines terms for target matching ($\mathcal{L}_\text{TD}$ with Huber loss), DP-consistency ($\mathcal{L}_\text{cons}$), triangle constraints ($\mathcal{L}_\Delta$), start/goal penalties ($\mathcal{L}_\text{bdry}$ and $\mathcal{L}_\text{clip}$).

Training proceeds in phases: warming up on intra-trajectory pairs, DP expansion, and relay (triangle) strengthening.

## 4. Length-Agnostic Training and Horizon Control

To make the diffusion model robust to varying lengths:

- **Initial noise shaping at inference**: The length $\hat{H}$ determined by the Length Predictor directly sets the dimensionality of the sampled Gaussian noise: $\tau^N \sim \mathcal{N}(0, I)^{\hat{H} \times d}$. The reverse process generates a trajectory with exactly $\hat{H}$ steps, without additional architectural input.
- **Random sub-trajectory cropping during training**: For each mini-batch, a demonstration is cropped to random length $L \sim \operatorname{Uniform}[L_\text{min}, T_\text{max}]$ to train the diffusion backbone across the full spectrum of possible segment lengths. This procedure yields a length-agnostic planner capable of generating any test-time length in $[L_\text{min}, T_\text{max}]$.

## 5. Experimental Protocol and Results

VHD was evaluated on Maze2d (D4RL) in umaze, medium, and large variants; AntMaze (OGBench, medium); and the Cube-robot arm task (UR5e end-effector, OGBench). Key environment hyperparameters include fixed horizons $H_1,H_2,H_3$ and goal tolerance $\epsilon$ (see Tab. 1 in [2509.11930]).

**Evaluation metrics**:

- **Success Rate (SR)**: Fraction of runs whose final state $\infty$-norm distance to the goal is $\leq \epsilon$.
- **Average Executed Steps (AES)**: Mean number of actions to reach the goal; lower is better.

**Comparison methods**:

| Variant      | Training horizon | Test horizon         | Adaptivity |
|--------------|-----------------|----------------------|------------|
| FH-H$_j$     | Fixed $H_j$     | Fixed $H_j$          | No         |
| FH+LP        | Fixed           | $\lceil f_\theta(s,g)\cdot T_\text{max} + 1\rceil$ | At test    |
| VHD (SS)     | Variable        | Predicted $\hat{H}$  | Yes        |
| VHD (RP)     | Variable        | Predicted $\hat{H}$, replan-on-deviation | Yes        |

**Key results** from Table 2 and related analyses:

- **VHD(RP)** achieves the highest SR across all tested environments and the lowest or second-lowest AES.
- **VHD(SS)** closely matches or slightly trails the best fixed-horizon SR but consistently exhibits superior AES, often producing shorter, more efficient trajectories.
- Training the diffuser on random-length sub-trajectories is crucial; FH+LP (fixed-horizon train, variable-horizon test only) underperforms VHD in all cases, illustrating the need for random-length exposure during training.

Qualitative analysis (e.g., Maze2d-large, Fig. 3) shows that VHD adaptively modulates planned segment length to the residual distance, yielding nearly direct paths with minimal replanning. In contrast, fixed-horizon methods either overshoot, dither near the goal, or fail to reach within the allocated steps.

## 6. Limitations and Prospects for Extension

- **Coverage limitations**: Offline datasets may inadequately represent rare, long-range start/goal pairs, restricting Length Predictor generalization. Hybrid supervision offers some mitigation but does not entirely eliminate under-coverage.
- **Uncertainty calibration**: The Length Predictor provides point estimates without calibrated uncertainty, increasing susceptibility to horizon mis-estimation.
- **Potential future directions** include:
  - Uncertainty-aware horizon prediction (e.g., conformal methods [Angelopoulos & Bates 2021]),
  - Active data augmentation or trajectory stitching to address coverage gaps [Li et al. 2024],
  - End-to-end joint training of the predictor and planner,
  - Risk-sensitive or soft-horizon objective formulations,
  - Testing in real-robot scenarios and integration with adaptive low-level controllers.

## 7. Significance and Contributions

VHD demonstrates that elevating the planning horizon to a learnable, instance-dependent variable eliminates brittle length-mismatch effects endemic to fixed-horizon planners. Its approach requires no architectural changes to established diffusion backbones, leveraging initial noise shaping and length-agnostic training regimes to robustly generalize across task domains. Empirical evidence establishes VHD as state-of-the-art in success-efficiency tradeoff for offline navigation and control, with minimal additional engineering complexity [2509.11930].

Source: https://www.emergentmind.com/topics/coplanner