Papers
Topics
Authors
Recent
Search
2000 character limit reached

Exact Algorithm for CDTW

Updated 2 December 2025
  • The paper introduces an exact polynomial-time algorithm for CDTW by using a dynamic programming framework that propagates piecewise-quadratic cost functions.
  • It employs a detailed cell-based approach to match continuous subsegments of 1D curves, ensuring bounded cost function complexity.
  • Extensions show that while exact solutions exist for 2D polygonal norms, approximations under Euclidean norms enhance practical applicability.

Continuous Dynamic Time Warping (CDTW) generalizes classical Dynamic Time Warping (DTW) to operate directly on the continuous parameterizations of polygonal curves. Unlike standard DTW—which matches sample points—CDTW matches subsegments flexibly, producing a similarity measure robust to sampling rate and outliers. Despite theoretical and practical advantages, the CDTW problem has required careful algorithmic development to realize exact polynomial-time solutions, particularly for 1D and certain 2D settings.

1. Formal Definition of CDTW

Given two 1D polygonal curves P=p1,,pnP=p_1,\ldots,p_n and Q=q1,,qmQ=q_1,\ldots,q_m (with respective arc-length parameter ranges [0,p][0,p], [0,q][0,q]), the CDTW similarity is defined via monotone parameterizations. The cost of matching is

dCDTW(P,Q)=infγ0p+qP(γ1(z))Q(γ2(z))dzd_{CDTW}(P,Q) = \inf_{\gamma} \int_{0}^{p+q} \|P(\gamma_1(z)) - Q(\gamma_2(z))\|\,dz

where γ:[0,p+q][0,p]×[0,q]\gamma: [0,p+q] \to [0,p]\times[0,q] is a monotone path from (0,0)(0,0) to (p,q)(p,q) with L1L_1 or L2L_2 norm in R\mathbb{R} (or Rd\mathbb{R}^d for multi-dimensional cases) (Buchin et al., 2022).

2. Dynamic Programming Framework for 1D Curves

The key challenge for CDTW is to propagate cost functions on cell boundaries in the continuous parameter space. The algorithm by Buchin et al. (Buchin et al., 2022) divides the domain [0,p]×[0,q][0,p]\times[0,q] into a grid, managing cost as piecewise-quadratic functions on cell boundaries.

  • On boundary y=yjy=y_j, for x[xi,xi+1]x\in[x_i,x_{i+1}], the maintained cost is

f(x)=akx2+bkx+ck,x[αk,αk+1]f(x) = a_kx^2 + b_kx + c_k, \quad x\in[\alpha_k,\alpha_{k+1}]

  • Propagation through cells considers all input points ss to an output tt, combining existing cost f(s)f(s) and the path integral sthdz\int_s^t h\,dz.

Each cell induces three cases for the optimal path structure, resulting in only O(1)O(1) new quadratic pieces per input piece, computable in O(1)O(1) time (Lemma~3.3, 4.3).

3. Polynomial-Time Algorithm and Complexity Bound

Combinatorial arguments show that the total number of quadratic pieces of all cost functions over the DP is O((n+m)5)O((n+m)^5) across the grid. The main steps are:

  • Partition the set of anti-diagonal boundaries into O(k2)O(k^2) subsegments (Lemma~5.1).
  • On each subsegment Ak,A_{k,\ell} of the kk-th anti-diagonal, there are at most O(k2)O(k^2) quadratic pieces (Lemma~5.2).
  • Construct lower envelopes of these quadratics via stack-based scanning in O(M)O(M) time per cell, where MM is the number of input pieces.

This yields an O(n5)O(n^5)-time and O(n4)O(n^4)-space exact algorithm for one-dimensional curves (Buchin et al., 2022).

4. Function Representation and Recurrence Propagation

Boundary cost functions on cell segments are maintained as lists of quadratic pieces (a,b,c)(a,b,c) over intervals. Propagation involves mapping each input quadratic to new output quadratics (types A, B, or C by optimal path type):

1
2
3
4
for each quadratic (a, b, c) in input:
    compute O(1) output quadratics via path structure analysis
    add to output list
envelope := build_lower_envelope(output_list)

The lower envelope maintenance is facilitated by the no-crossing property of optimal paths (Lemma 4.1), which ensures dominance can be resolved efficiently.

5. Extensions to 2D and General Norms

Exact computation under the Euclidean norm (L2L_2) for 2D curves is proven impossible in the algebraic computation model—certain CDTW values are transcendental and demand non-elementary operations (Baker's theorem; (Buchin et al., 25 Nov 2025)). However, for polygonal norms (e.g., the gauge norm induced by a regular kk-gon), an exact polynomial-time CDTW algorithm exists.

  • Parameter-space is partitioned into n×mn\times m cells.
  • Boundary cost functions are maintained as stacks of piecewise-quadratic segments.
  • Propagation in each cell exploits geometric properties (valley lines/direct crossings), and candidates for cost are derived as bivariate quadratics.
  • Overlay and lower envelope construction on border intervals scales as O(k2)O(k^2) per cell, with global complexity O(Nk2logkα(k))O(N\cdot k^2\log k\, \alpha(k)), where NN is the total number of pieces (Buchin et al., 25 Nov 2025).

For the Euclidean setting, a (1+ϵ)(1+\epsilon)-approximation is achievable by substituting the Euclidean norm with a polygonal norm RkR_k, with k=O(ϵ1/2)k=O(\epsilon^{-1/2}) capturing the desired precision.

6. Critical Properties and Algorithmic Guarantees

  • The 1D exact algorithm is the first to guarantee polynomial (quintic) bound on cost function complexity for CDTW (Buchin et al., 2022).
  • The method avoids any grid discretization, maintaining continuous DP propagation throughout.
  • For 2D polygonal norms, exact computability and polynomial-time guarantee hold; for L2L_2, only approximation is possible in algebraic models.
  • The dynamic programming propagation exploits invariants: local complexity growth is strictly bounded, cumulative minimality is stack-preserving, and envelope update does not explode the number of pieces.

7. Practical Considerations and Limitations

  • While O(n5)O(n^5) is polynomial, the exponent is high; heuristics and pruning strategies are needed for practical application.
  • Implementation demands robust representation and management of piecewise-quadratic functions and lower envelopes.
  • Extending to higher dimensions or different norms (beyond polygonal) may introduce further complexity or intractability.
  • Real-world clustering experiments demonstrate practical CDTW advantages over DTW and Fréchet measures (Buchin et al., 2022).

References:

  • Buchin et al. "Computing Continuous Dynamic Time Warping of Time Series in Polynomial Time" (Buchin et al., 2022)
  • "Fundamentals of Computing Continuous Dynamic Time Warping in 2D under Different Norms" (Buchin et al., 25 Nov 2025)
Definition Search Book Streamline Icon: https://streamlinehq.com
References (2)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Exact Algorithm for CDTW.