Skip to content

[ENH] Optimize memory complexity for elastic distances #3261

@SebastianSchmidl

Description

@SebastianSchmidl

Describe the feature or idea you want to propose

@raphaelgimenezneto reduced the memory complexity of the DTW distance computation by using a standard dynamic programming optimization. This optimization approach is applicable to almost all of our elastic distances (with minor or major additions).

The optimization drastically reduces the memory usage (from quadratic to linear complexity) and, due to higher data locality, also leads to a runtime speedup of ~2x.

Describe your proposed solution

We should apply the dynamic programming optimization described in #3257 to our other elastic distances as well.

For each distance,

  • implement the optimization for the distance computation
  • test whether the new implementation produces the same results as the original one
  • perform a performance benchmark to demonstrate the memory reduction and runtime speedup

The following distances (also see sub-issues) should be optimized (in order from easy to more complex):

  • DTW [ENH] Implement O(N) space complexity for dtw_distance #3258
  • DDTW (for free with [ENH] Implement O(N) space complexity for dtw_distance #3258 because it calls _dtw_distance() internally)
  • ADTW (additional warp_penalty parameter)
  • WDTW (additional g parameter and different cost function)
  • SoftDTW (additional gamma parameter and different cost function)
  • EDR (different margin initialization and cost function, additional epsilon parameter)
  • ERP (different margin initialization and cost function, additional g parameter)
  • LCSS (different margin initialization, uses other matrix references to compute cost, additional epsilon parameter)
  • MSM (also dynamic programming, but requires a couple of additional modifications)
  • TWE (also dynamic programming, but requires a couple of additional modifications)
  • ShapeDTW (not applicable because it operates on the full cost matrix)

Sub-issues

Metadata

Metadata

Labels

distancesDistances packageenhancementNew feature, improvement request or other non-bug code enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions