DTWLIB.DLL is the function library that implements the DTW algorithm.
Testing the DTWLIB presents some problems because generating correct reference results for the DTW algorithm is hard. This problem is solved by
calculating some test cases by hand. Unfortunately these cases must be very small-scale.
Test Cases:
M-DL01: Add and get templates
Tests whether storing and getting templates from the DLL works correctly.
100 random template vectors with variable length between 3 and 300 are stored into the DLL using the DTAddTemplate
function. After this
they are loaded from the DLL using the DTGetTemplate
function.
The DLL should return the same vectors that were stored into it.
M-DL02: Add, delete and get templates
Tests whether deleting the templates from the DLL works correctly.
Do the following loop 10 times:
DTAddTemplate
.
DTDelTemplate
(one template must not be deleted twice)
DTGetTemplate
function.
The loaded vectors should be the same as the ones that were saved.
M-DL03: Compare to one
Check the comparison function with short vectors. The reference results are calculated with Microsoft Excel.
Observation: 1.2, 3.5, 2.2, 7.7, 4.4
Template: 2.2, 4.5, 3.3, 9.9, 1.1
Euclidean metrics, no warping window and fixed start and end points.
Total cost: 3.16
Warping path: (0,0); (1,1); (1,2); (2,2); (3,3); (4,4)
M-DL04: Compare to one, random stretched vectors
The DTW algorithm should cope with templates and observations that are stretched on time axis. This test case will test such situations
Generate a random vector of length 30. Then copy its contents into another vector so that every element will be copied into 1-4 elements of the new vector. E.g. vector (3 5 7 9) could become (3 3 3 5 7 7 9 9 9 9). Compare these two generated vectors with same parameters as in M-DL03.
Total cost: 0.
M-DL05: Compare to one, warping window
The objective of this test case is to ensure that the warping path
For the latter point, we check only that the path may go through points that are on the lower and upper limit of the window.
Random vectors of length 60 are compared with DTCompareOne
with euclidean distance metrics, warping window width 5 and fixed start and end points.
The test is run ten times.
Every point of the warping path should be inside the warping path. We should also get such warping path points that are on the upper and on the lower limit of the warping window. (However, this is not 100% sure because random vectors are used).
M-DL06: Compare to one, relaxed start and end points
The objective of this test case is to ensure that the start and end points
Random vectors of length 20 are compared with DTCompareOne
with euclidean distance metrics, no warping window and start and end point offset 4.
The test is run 300 times.
The start and end points should always be inside the limits. We should also get start and end points into every allowed point at least once.
M-DL07: Calculate estimated derivatives
Such a debugging code is added to the DLL that it prints the calculated derivatives into a text file. This allows us to check that the derivatives are calculated correctly. The reference values are calculated with Excel.
Template: 4.4, 5.5, 7.3, 11.8, 5.5, 4.3, 2.7, 3.3
Observation: 1.1, 2.2, 4.4, 7.7, 7.7, 4.4, 2.2, 1.1
Calculated derivatives:
Template: 1.28, 1.28, 2.48, 1.8, -5.03, -1.3, -1.05, -1.05
Observation: 1.38, 1.38, 2.48, 2.48, -0.83, -3.03, -1.93, -1.93
M-DL08: DTCompareOne, Warping window and relaxed start and end points
Using a strict warping window may limit the number of possible start and end points. The purpose of this test is to ensure that in such a case, the start and end points are inside the warping window and that they are allowed to be on the upper and lower limit of the warping window.
Same as in M-DL06 with following parameters: Euclidiean distance metrics, warping window width 3, start and end point offset 5.
All the start and end points should be inside the warping window. Some of the start and end points should be on upper and lower limits of the window.
M-DL09: DTCompareAll
The purpose of this test case is to test, whether DTCompareAll
functions correctly. The most important points are that
First, 100 random templates are added and 50 are deleted with the same method as in test case M-DL02. After this, a random
observation is generated and a streched version of this observation is saved as template as in test case M-DL04. Finally,
DTCompareAll
function is called with following parameters: Euclidean distance metrics, no warping window, fixed start and end points.
The template that was added last should be first on the list with distance 0. After this, the list should contain every template that was not deleted. The templates should be in ascending order by DTW distance.