An optimization approach for mapping and measuring the divergence and correspondence between paths
 1.4k Downloads
 2 Citations
Abstract
Many domains of empirical research produce or analyze spatial paths as a measure of behavior. Previously, approaches for measuring the similarity or deviation between two paths have either required timing information or have used ad hoc or manual coding schemes. In this paper, we describe an optimization approach for robustly measuring the areabased deviation between two paths we call ALCAMP (Algorithm for finding the LeastCost Areal Mapping between Paths). ALCAMP measures the deviation between two paths and produces a mapping between corresponding points on the two paths. The method is robust to a number of aspects in real path data, such as crossovers, selfintersections, differences in path segmentation, and partial or incomplete paths. Unlike similar algorithms that produce distance metrics between trajectories (i.e., paths that include timing information), this algorithm uses only the order of observed path segments to determine the mapping. We describe the algorithm and show its results on a number of sample problems and data sets, and demonstrate its effectiveness for assessing human memory for paths. We also describe available software code written in the R statistical computing language that implements the algorithm to enable data analysis.
Keywords
Path correspondence Path mapping OptimizationBehavioral paths and trajectories
Paths are multidimensional spatial data series that represent an ordered sequence of locations in space. In contrast to trajectories (which refer to paths as a function of time), a path typically ignores or lacks timing information, making it both more general and at times less informative. Importantly, two trajectories that mismatch in their timing might be judged as very different, even if their paths are nearly identical. Nevertheless, both paths and trajectories have become important data sources in scientific research and machine intelligence applications, and their use is only bound to increase as research and applications take advantage of mobile GPSenabled devices and other automated means of recording location. Computational research in this area has typically focused on trajectories (Yanagisawa et al., 2003; Chen et al., 2005) where timing is available, but in many cases the timing is either not known or is irrelevant, and so there remains a gap in algorithms and tools for analyzing paths and measuring path similarity and deviation based on their shapes alone.
Potential applications of a generalpurpose path mapping technique
In this paper, our main objective is to present a set of algorithms and software tools that analyze paths produced in laboratory and realworld settings, allowing measurement of the deviation between paths, as well as determining how points on one path correspond to points on a second path. In behavioral science, these tools have potential applications in a number of domains, including spatial reasoning, memory, and communication. Specific examples include: the analysis of path data produced in studies using variations of the HCRC Map task (Anderson et al., 1991; Brown et al., 1984; Veinott et al., 1999), in which one person must verbally communicate a path to a second person who cannot see the path, but must reproduce it; spatial search tasks, in which a person or animal must search for a target or reward (Mueller et al., 2010; 2013); the traveling salesman problem (MacGregor & Ormerod, 1996; Pizlo et al., 2006), in which an efficient path must be planned that visits a set of targets; eyetracking research (van der Stigchel et al., 2006), in which the eye fixation pattern is recorded; mousetracking studies (Freeman & Ambady, 2010), in which a computer mouse path is recorded in a dynamic task; motor control research (Abend et al., 1982), in which the physical path of an effector is tracked; and human–computer interaction, for example in research that compares navigation through virtual and physical space (Ruddle & Lessels, 2009; Zhang et al., 2012).
Although applications in behavioral science are our primary concern, our methods may also have utility in any domain for which path data is available. Examples include: neuroscience research examining neural information pathways (Tuch et al., 2003); the domains of geography and anthropology which study the migration and movement of nomadic pastoral groups (Erdenebaatar & Humphrey, 1996; Istomin & Dwyer, 2009), especially to the extent that they compare simulated paths to observed data (Kennedy et al., 2010); zoology, in the study of migration paths of animals (Croxall et al., 2005; Egevang et al., 2010; Guilford et al., 2009; Weimerskirch & Wilson, 2000; Ceriani et al., 2012); and earth sciences including the measurement and assessment of how river routes (Fisk, 1944), ocean surface currents (Gawarkiewicz et al., 2012), atmospheric jet streams (Barton & Ellis, 2009), and the paths of hurricanes and tropical storms (Demuth et al., 2006) differ over time or events. Consequently, the potential applications of these methods may extend far beyond human behavioral science.
Goals of a path mapping algorithm and related problems
In any of these problem domains, two common goals emerge: first, one would like to measure how similar two paths are to one another (to score performance, give feedback, perform a clustering analysis, evaluate an experimental manipulation, etc.); second, one may want to determine the point on one path that best corresponds to a point on another path. This correspondence could be used to judge, for example, whether path memory errors produce a bowed serial position function, whether a remembered path was incompletely recalled, whether particular features of one path (e.g., loops, nonrectilinear corners, etc.) are reproduced accurately, or whether a set of paths are evidence for a single common strategy.
Nonordered mappings
Measuring trajectory similarity
A number of algorithms have been developed for measuring similarity of trajectories (i.e., paths with timing information). These have proven useful for machine vision applications that track objects, people, or animals, and for storing and indexing these in databases to enable later retrieval by similarity. For example, Yanagisawa et al. (2003) developed a shapebased similarity and indexing scheme for trajectories, and similarly Chen et al. (2005) compared a number of methods for measuring distance between trajectories, and introduced a measure called Edit Distance on Real Sequence (EDR). These methods rely to some extent on the timebased nature of the trajectories, which are implicitly ordinal, to help determine how elements from one path map onto elements on the second path. Trajectories sampled at regular time intervals produce a natural division of a path into equalduration path segments, and even with irregular sampling, trajectory times can be interpolated to produce equalduration segments. The EDR method relies on timing information and its measure of similarity is a generalization of the edit distance, which counts the number of operations that are required to make one trajectory match the other in terms of timing and position. These approaches have also focused on the practical problems related to efficiently storing, indexing, and retrieving trajectories, which involves other tradeoffs we will not address here.
Such methods do not work directly for paths that lack timing information. In many cases, one or both paths lack a measured timeseries component. This is especially true when one path is the experimental stimulus and the other path is generated by a subject as a measure of memory, search, or communication. Yet even when timing information is available, the timescale of one trajectory may necessarily be different from the timescale of another trajectory. For example, it may take only seconds to remember and draw a flown flight path that took minutes or hours to complete; similarly, flying a planned flight route may take hours, even if the plan was generated in seconds. And in both of these cases, it is not always the case that the timing information is relevant. Thus, even when some timing information is available, it may not be helpful or possible to use it to compare paths.
Shape similarity algorithms
A third relevant domain is the study of shape and object representation and matching (see, e.g., Latecki and Lakämper (2000), Belongie et al. (2001), Belongie et al. (2002), and Gorelick et al. (2006)), and related work on human movement analysis (Gorelick et al. 2007). Although there is little fundamental difference between paths and polygons, the goals for object and shape matching typically differ from those of path mapping. For example, shape algorithms typically ignore absolute coordinates, orientation, scale, and arbitrary affine transformations, in an attempt to identify the best mapping between two polygons based on their overall shape. These allow automated analysis of imagery that present similar objects from different perspectives, in different sizes and with variations on shape, as might be expected from natural objects and natural views (Pizlo, 2010; Mueller, 2010). These details that are specifically ignored by shapematching algorithms can be critical for measuring the similarity between two paths, because here location and scale typically do matter. For shape matching, the value that is optimized is not typically related to the distance between shapes, but often involves statistics related to the relative angles between consecutive line segments (Latecki & Lakamper̈, 2000). Thus, although shape similarity algorithms may not be directly useful, their basic approach of using optimization to find a mapping between corresponding contours is quite relevant.
In summary, although there are several related existing approaches that could be used to map paths (nonordered mappings, trajectory similarity, and shape similarity), none will be completely adequate for comparing paths. In the next section, we will identify some of the specific challenges a path mapping algorithm must be able to handle.
Challenges for path mapping and alignment algorithms
To help define the ideal properties of a path mapping algorithm, we have identified a number of potential challenges that such an algorithm must deal with, illustrated in Fig. 1. Once we review these challenges, we will examine the extent to which several candidate methods address these challenges. Then, we will describe a method designed to robustly measure path correspondence in the face of these challenges, and introduce a free software package that implements the algorithm.
When measuring the deviation between two paths, one issue is that two paths are not guaranteed to be partitioned into equallength segments (a problem that trajectories may not have, because the timebased partitioning is an important part of the trajectory). Panel A shows an example of this. These paths might be produced by a memory test in which a given path is defined by just a few line segments, but a recalled path may be a digitized line which has hundreds of small elements. To handle this, an algorithm must be able to map multiple points and segments of one path onto a single segment of another path. A second issue (Panel B) is that two similar paths often intersect one another. As we will see later, not all measures handle intersections easily. A third issue (Panel C) is that one path may be substantially shorter in length than another. In the case of the paths in Panel C, the shorter path should probably be mapped onto the similar section of the longer path rather than being mapped proportionally from start to end onto the other path. At the same time, paths that are perhaps simplified versions of a more complex path (Panel D) should map one to the other in a reasonable way. Another issue is that a path may loop or intersect itself (also Panel D), and the algorithm should handle these situations robustly, including (as in Panel E) where both paths loop in parallel. Finally, as we will discuss in greater detail later, there are deviations such as in Panel F that are not measured well by area deviation alone, as they may represent large differences that produce a smallarea polygon, and an algorithm should be sensitive to these.
Candidate methods for measuring divergence between paths
Although no widely used methods exist for measuring the divergence and correspondence between paths, an intuitive solution is to measure the area between two paths. In this section, we will review a number of alternatives for computing areabased divergence, as well as several based on path shape, before introducing our approach.
Areabased measures
Many potential methods for finding the similarity between paths rely on measuring the area subtended by the polygon formed by connecting the paths. In previous behavioral research, the typical approach for measuring the area deviation between two paths (cf. Veinott et al., 1999) has been to overlay the paths with transparent graph paper and count the grid cells within their deviation. A polygon whose area can be measured can be formed from two paths by connecting the starting point of each path to the ending point of the other path. Such an areabased measure has the advantage of being identical regardless of whether a path has been segmented or digitized. Thus, areabased measures can be invariant to the details of path creation that may impact path segmentation. Furthermore, an areabased measure is interpretable by dividing the area by the mean path length, which gives the mean deviation per unit length. Many trajectory similarity algorithms are areabased in some way (Yanagisawa et al., 2003; Chen et al., 2005), but rely on the fact that a timebased natural segmentation exists, enabling one to use the areabased difference between two segments to determine the best mapping between segments. Without timing information, areabased methods are still applicable. Next we will review and evaluate several methods that can be used to measure the area of a polygon.
The graph planimeter, Green’s theorem, and the surveyor’s formula
Physical computers called planimeters have been available for measuring the area of bounded regions since Johann Hermann introduced a device in 1814 (see Care 2010, Chapter 2). The most famous of these was developed by Amsler (1856), as a mechanical implementation of Green’s theorem.^{1} Green’s theorem shows how a double integral over a region (i.e., its area) can be computed via a line integral over its boundary (see Gatterdam, 1981, for an accessible explanation of this device). For polygons (i.e., area domains that are bounded by line segments), the solution offered by Green’s theorem can be simplified to an algorithm relying on determinants of consecutive line segments known as the surveyor’s formula, or the simplified but algebraically identical shoelace formula (Braden, 1986). These are perhaps more convenient for digitized paths, where a path can easily be transformed into a series of line segments and the area can be automatically computed via software.
These methods are fairly simple and can be used to efficiently compute the area of the polygon formed by two paths that do not intersect. However, they will not provide the correct answer in a number of cases, and so cannot be used as a general solution. For example, when two paths cross, this creates regions of negative area that need to be detected and handled separately. We will consider this type of strategy next.
Surveyor’s formula applied to segmented polygons
The surveyor’s formula approach could be salvaged by searching for the points where a line segment from one path intersects with a segment from the other path. Then, using this information to isolate each nonintersected subpolygon, one could compute areas using the surveyor’s formula and find the sum. However, this method still has a number of problems. First, the approach still presents difficulties when paths intersect themselves. For example, consider Panel D of Fig. 1. Here, one path loops, while the other does not. The isolated polygons produce one area, but a better deviation might be the grey area indicated in the figure. But more importantly, this hypothetical algorithm now requires substantial search and analysis to use, and so the goal of a simple solution has been lost. Consequently, we might consider digital approaches akin to the graphpaper solution based on floodfill algorithms.
Floodfill algorithms
Using a floodfill algorithm (e.g., Asundi & Wensen, 1998; Shaw, 2004) might be a way to avoid some of the complexity involved in the surveyor’s formula. In this approach, one would render the two paths on a pixelbased background, connect the ends, and use floodfill to ‘paint’ everything outside the resulting polygon. Then, one could simply count the number of unpainted pixels and determine an areabased deviation. This method could be very accurate (limited only by the pixel size) and it may avoid the need for identifying and isolating each subpolygon. However, this approach also faces some of the same problems as the earlier approaches, especially when paths intersect themselves. For example, if a pair of closely intertwined paths formed a larger loop that intersected itself, a simple floodfill algorithm would mismeasure the correspondence unless the area in the center of the loop was subtracted. Attempts to improve on floodfill would require identifying and isolating parts of paths and larger loops, and so again the hope of a simple algorithm is lost.
General limitations of areabased solutions
In general, simple areabased solutions appear to be untenable, primarily because of the need to handle path intersections, which requires additional analysis. However, even if simple crossovers and intersections can be identified, other problems persist. For example, in Panel E of Fig. 1, two paths may match one another fairly accurately, but together they form a set of parallel loops. A naive areabased solution might count the entire loop as a mismatch, as it might be ambiguous what corresponds to what. Clearly, if the two paths deviate from one another very little, the deviation of the paths should be close to 0, but substantial logic could be necessary to know which areas between line segments should or should not be counted in this deviation. Furthermore, suppose a pair of paths looped several times (e.g., if a pair of aircraft circled over a target)—this might be very difficult for a simple areabased measure to handle. Next, even for a simple polygon, there are situations where total area may not be the best measure of path deviation. For example, consider Panel F of Fig. 1. Here, one path is linear, but the second path is jagged. Because of the zigzag followed by this second path mapping, there is relatively little area within this polygon. In cases such as this, a simple polygon area approach is probably not even appropriate, and the dissimilarity measure should be greater than what would be obtained by area alone. For comparison, consider the third (dashed) path in Panel F, which has an overall larger distance deviation from the straight path than the wavy path, but is subjectively and objectively more similar in most ways. Finally, areabased solutions in general can provide dissatisfying results, because they do not determine how two paths actually correspond or map onto one another. This information could be very useful, and we would like to obtain this mapping as a consequence of measuring the deviation between paths.
For these reasons, we argue that simple areabased measures must be abandoned. However, the optimization approaches used in both shapematching and trajectorymapping algorithms offer an alternative that might avoid the need to analyze the topology of crossing paths and determine which areas should or should not count. In this approach, if we can determine a measure of the deviation between any segment on one path and any point or segment on a second path, we may be able to apply standard mathematical programming algorithms that find a mapping having the smallest overall deviation. Thus, the smallest possible deviation between two paths will be identified, and a correspondence that maps points on one path to points on the second will be produced as a consequence. We will describe this approach next.
An algorithm for finding the leastcost areal mapping between Paths (ALCAMP)
The goal of finding pointtoset and settoset mappings (sometimes called setvalued maps or setvalued functions) has been studied in a number of domains of applied and pure mathematics, and general proofs for optimizing such mappings date back at least to Zangwill (see Zangwill, 1969; Hogan, 1973). Importantly, any mapping can be thought of as incurring a cost defined by a cost function or objective function, and the goal of optimization is to find the mapping that incurs the least cost. In our approach, we use optimization to find a mapping between paths that produces the least total cost, where cost is the area between corresponding points and segments. This approach shares some of the same logic as shapebased similarity measures (Latecki & Lakämper, 2000) and trajectorymapping algorithms (Yanagisawa et al., 2003; Chen et al., 2005), in that it finds an optimal mapping by applying a cost function to deviations between paths. Formally, we use the same general dynamic programming algorithms used to compute sequence distance in many contexts, perhaps most widely for aligning sequential data such as letter strings or DNA sequences (the socalled edit or Levenshtein distance; cf. Levenshtein, 1966). For a string of letters, the goal of the edit distance is to find the minimum number of changes needed to transform one string into another, permitting additions or subtractions, each having an equal cost. For the EDR trajectorymapping approach of Chen et al. (2005), the goal is to find the minimum number of changes of one path (in either timing or position) required to transform it into another path. There, each change also incurs a cost, but the cost depends on the distance each segment must be moved, and is not fixed for each operation. This distance, if weighted by segment length, is analogous to an areabased cost function, which is roughly the same as our approach.
The primary goal of our algorithm is to determine a mapping between two paths that minimizes a cost function. To begin with, we must first define three things: the specific meanings of paths, mappings, and cost functions. Once this is complete, we will apply a dynamic programming optimization algorithm to efficiently identify the cost of the best mapping.
Defining a path
where each singlenumber (or doublednumber) subscript element indicates a point, and each twosubscript element indicates a line segment. Note that although A _{ p o i n t s } is unconstrained, the end point of each element of A _{ e d g e s } must be connected to the starting point of the next element. Within A _{ m e r g e d }, we will generically refer to points and segments as nodes, using point to refer to odd nodes and segment to refer to even nodes.
Determining a mapping between two paths

∀x∈X _{ p o i n t s }, y∈Y _{ m e r g e d }, \({\sum }_{y}{M(X_{i},Y_{j})} \geq 1\)

∀y∈Y _{ p o i n t s }, x∈X _{ m e r g e d }, \({\sum }_{x}{M(Y_{i},X_{j})}\geq 1\)

if M(A _{ i },B _{ j })=1, then M(A _{ s },B _{ t })=0 if s>j and t<i, or if s<j and t>i
Note that we do not require or consider the mapping between two edges. This is mainly done to simplify the optimization problem, and it is typically possible to infer whether two edges correspond by using a ‘sandwich’ rule (i.e., an edge is sandwiched between its endpoints which always have an explicit mapping to the other path), and similarly to identify how any point lying on one path corresponds to the other path (even when it lies in the middle of a segment).
The proper mapping between path A and B shown in Fig. 2. Connected nodes are indicated with a 1; a ‘.’ indicates nodes are unconnected
A _{11}  A _{12}  A _{22}  A _{23}  A _{33}  A _{34}  A _{44}  

B _{11}  1  .  .  .  .  .  . 
B _{12}  1  .  1  .  .  .  . 
B _{22}  .  .  1  .  .  .  . 
B _{23}  .  .  .  .  .  .  . 
B _{33}  .  .  1  1  .  .  . 
B _{34}  .  .  .  .  .  .  . 
B _{44}  .  .  .  1  1  1  . 
B _{45}  .  .  .  .  .  .  . 
B _{55}  .  .  .  .  .  1  . 
B _{56}  .  .  .  .  .  .  . 
B _{66}  .  .  .  .  .  1  . 
B _{67}  .  .  .  .  .  .  . 
B _{77}  .  .  .  .  .  .  1 
Computing the areabased cost for any mapping
As discussed earlier, there are no nodes corresponding to edgeedge connections (indicated by a small unfilled circle). Moving from one nodenode connection to an adjacent nodenode connection incurs a cost equal to the area deviation of the polygon formed by this movement. These transitions form either 0area polygons, triangles, or quadrilaterals whose areabased costs can be computed by geometric formulas, or (less efficiently) by the Surveyor’s formula, or (hypothetically) by other cost functions. Consequently, we will use S() to represent the areabased cost, with the assumption that it could be computed in various ways, or perhaps substituted with another cost function. Before a final cost of a path can be computed, we first must determine how to measure the area for consecutive points on one path that are mapped onto the same segment on another path.
Here, o _{ i } represents the proportion along the segment’s length to which a point is mapped: a value of 0 indicates one end of the segment, a value of 1 indicates the other end, and a value between 0 and 1 indicates an intermediate point. This can be used to compute the distance of one side of a quadrilateral or triangle represented by a transition, and it allows the areal deviation to be carved into multiple polygons whenever a single point on one path is mapped to a segment on the other path.
If several consecutive points are mapped onto a single segment, we can simply map each point onto its nearest point on the segment (as shown in Fig. 4). However, this has the potential for reversing direction of the mapping. For example, if comparing a straight segment to a loop whose points are all opposite the segment, the mapping from each point on the loop to the closest point on the segment will march forward, reverse, and forward again. The proper way to handle this is to break the long segment into subsegments and solve the mapping problem using the same optimization approach we use to solve the entire problem. This will obtain the smallest cost independent of path segmentation. We provide tools for doing this, but it can come at the cost of a substantially more complex (and timeconsuming) optimization, because paths may be segmented into dozens or hundreds of subsegments if one of the paths has many segments. In our tests using this approach, adding these additional segments typically had little or no impact on the final mapping.
For v, the two paths may in fact cross one another, and a naive cost function might not be able to detect or compensate for this. Under our approach, we handle this by detecting crossovers in a preprocessing step, and divide both crossing segments into two line segments at the crossover point.
Next, consider mappings between a segment A _{ i−1,i } on path A and a point B _{ j } on path B. Transitions to this mapping are obtained either by moving from a point–segment mapping (between B _{ j−1} and A _{ i−1,i }; the previous point of B mapped to the same segment of A), or from a point–point mapping (between B _{ j } and A _{ i−1}; the current point of B and the end point of the A segment). These transitions incur costs s and p, respectively. If we consider the corresponding case of segment B _{ j−1,j } mapped onto point A _{ i }, the transition costs are q and r. In these formulas, r and s both represent the cost associated with two consecutive points mapped onto a single segment, whereas p and q both represent the cost associated with a consecutive point and edge on one path mapped onto a single point on the other path.
These seven formulas provide the complete cost function for all possible transitions within the graph. Together, the cost of any proper mapping, which is a route through the graph from the upper left to lower right, can be computed as the sum of the costs along that route. Of all the possible routes, a subset will incur the minimal cost, and our goal is to identify that cost and the mappings that produce it. Before we introduce an algorithm that will optimize this, we will first consider several preprocessing steps that might be used.
Preprocessing steps
Prior to applying ALCAMP to a pairing of paths, three distinct preprocessing steps might be needed. We offer specific solutions to two of these, although one might use a number of alternate approaches.
So far, we have assumed that a path is a relatively true representation of the original behavior, sampled without considerable noise. If a path is known to be sampled with noise, one may wish to first preprocess the path with some timeseries smoothing or interpolation algorithms. The details of this approach would need to be fairly specific to the type of data one is considering. A smoothed representation of a noisy data source may enable the path to be represented using fewer points or path segments, and thus could allow for a more efficient optimization. However, this step is not necessary to apply the algorithm, and it may not even typically provide a better measure of path similarity, given the current approach already optimizes a cost function. Consequently, we have merely mentioned the possibility but do not explore it in this paper.
A second preprocessing step can be done to improve efficiency. One can remove redundant points, simplifying the path by merging segments that lie on the same line, or that do not contribute significantly to the shape of the path. A robust algorithm has been proposed by Latecki and Lakämper (2000), and we provide an implementation of their algorithm in our software library in a routine called SimplifyPath. This not only removes completely redundant points, but it also can remove points that only impact the shape of the overall path in small ways.
Finally, a third approach is to do further interpolation to ensure that a series of points on one path can map in a monotonic fashion to points on a second path. For example, we can add points implied by each Q point from Fig. 4, allowing each point to connect directly to another point, and eliminating any need to allow multiple consecutive points to map onto the same segment. This interpolation approach can reduce efficiency of the overall algorithm, but its advantage is that it enforces a strictly nondecreasing mapping along each path segment. The alternative approach, allowing consecutive leastarea mappings of points onto a single segment, can produce a larger cost, and is thus sensitive to how paths are segmented, but typically has only a minor impact and can be substantially more efficient.
Finding the leastcost mapping
Once a pair of paths has undergone preprocessing, we can construct a graph such as in Fig. 3 and compute costs associated with each transition between nodes. Any legal route from the upper left to the lower right corresponds to a mapping between paths, and the sum of the transitions is the cost of that mapping. For paths with nontrivial curvature, some of these mappings will produce greater area costs than others, because they will create a map that produces overlapping regions whose areas are counted multiple times. However, there will typically be a set of mappings whose costs are identical and equal to the minimum cost.
For any network, the total number of possible paths is finite but large, and for paths with only a handful of nodes, one could perform exhaustive search to find the leastcost path. For complex mappings (e.g., for paths where at least one is smoothly generated and so includes hundreds of nodes), a complete search would be computationally infeasible. However, there exists a standard dynamic programming algorithm that allows the cost of the shortest path in such a graph to be computed in a time proportional to M×N, where M and N refer to the number of nodes in paths A and B.
An efficient solution to finding the leastcost mapping for such a graph is closely related to the algorithm for computing edit distance. The mechanics and proofs of the optimality of such algorithms are well understood and appear in many textbooks on dynamic programming (see Marzal and Vidal 1993 for a detailed explanation using edit distance). Despite the fact that there are a large number of routes through the network, the cost of the best route(s) can be found by visiting each node only once, provided that all the incoming nodes to any node can be computed (i.e., there are no circuits in the directed graph). An intuitive explanation for this uses a recursive argument. Consider that any partial route through the network (e.g., starting at the upper left node but ending at an intermediate node) represents a partial mapping between the paths. Thus, suppose we have identified the leastcost route to the three intermediate nodes that precede the final (bottom right) node of the graph. Then the best route can be identified by computing the transition costs between each of these three previous nodes and the final node mapping, and choosing the minimum value. But finding the leastcost route to any of these previous nodes can likewise be computed if the minimum costs of the incoming nodes are also known. Applying the algorithm recursively, one can continue until one arrives at the upperleft node of the network, which has no input nodes and thus a cost of 0. Once this first node is known, the leastcost route through the first row can be computed easily, moving left to right on each row, and handling each row top to bottom in sequence, as the prior costs that need to be known have already been computed. Thus, each node of the network is visited once, and at the end the cost of the best mapping is available. The algorithm to find the smallest cost has computational complexity O(n×m), although an additional pass through the network is required to determine the set of mappings that produce this optimal cost. Importantly, multiple routes could (and in our case typically do) produce a leastcost mapping, and although this method can determine the cost of best mapping, it does not identify the set of all leastcost mappings.
Finding the family of leastcost mappings
These three mappings have the same areabased cost, which illustrates how areabased measures alone often cannot identify a best mapping between paths. A number of additional constraints can be considered for this situation, but one we suggest aims to minimize the mean distance of the connections between paths. To do this, a second pass is made through the network to determine all possible minimalcost mappings. Finally, this leastcost subnetwork is searched using the same dynamic programming approach used in the first pass to find the mapping that minimizes the sum of the nodenode, nodesegment, and segmentnode distances (rather than areas). The third mapping in Fig. 5 (corresponding to the center route in Fig. 6) is a result of this minimization, which produces the smallest average distance between nodes among all mappings having the same area. Visually, this mapping is one that appears to directly connect each point on one path with its closest point on the opposite path.
This completes the basic description of the ALCAMP procedure. Software for implementing these methods is available in the pathmapping package for the R statistical computing language. Next, we will examine how this process fares on example toy and realworld problems.
Applications and example
Conceptually, the algorithms described here are fairly simple, but the implementation requires substantial programming. We have implemented the algorithm using the R statistical computing language (R Core Team 2013). The complete source code is available for download from https://sites.google.com/a/mtu.edu/mapping/tasks, and is available in the pathmapping package via the Comprehensive R Archive Network (CRAN). A description of the functions is provided in Appendix.
Validating areabased deviation as an index of memory
The bottom row of Fig. 7 shows three trials from a task whose data and methods were originally reported by (Perelman and Mueller 2013). In this task, 21 undergraduate participants each took part in five trials of a simulated aerial search task^{3} implemented using the PEBL experimentation software platform (Mueller & Piper, 2014). In the task, participants were given a fixed amount of fuel (corresponding to 1,000 screen updates, or about 80 s) to fly a simulated aircraft over a map in search of specific targets located at half of 12 prespecified hot zones. Flight was controlled using a touch screen monitor that changed the current destination of the aircraft. Once the aircraft reached that location, it smoothly circled that point until redirected (leading to circles in the flight route). To encourage participants to search efficiently, the fuel provided was not sufficient to search all targets, and participants found about half of the targets on any given trial. Once completed, two memory tests were performed: first, the participant drew their best memory of their flown path on the touch screen; then, they were asked to identify the locations of the found targets within the 12 unlabeled hot zones. For the second task, the hit rate (proportion of originally found targets remembered) and false alarm rate (proportion of foils incorrectly remembered) were both computed, and a simple difference score of HRFAR served as a memory performance measure (Signal detection statistics such as d ^{′} were untenable because many participants had hit rates or false alarm rates of 1 or 0).
We wanted to examine whether individual differences in memory for the path would predict differences in target localization accuracy. To the extent that localization accuracy is negatively correlated with giventoremembered path deviation, this would indicate that a common set of representations, processes, or strategies is responsible.
Because the flown distances were all roughly the same, total areabased deviation provided a good measure of path dissimilarity, and thus memory precision. The mappings in the bottom row of Fig. 7 were fairly representative of performance in this task. Total areabased deviation ranged from about 35,000 pixels to around 80,000 pixels, with a few trials even larger than that.
Discussion
The method we describe seeks to measure the deviation between two paths, and along the way identifies a mapping between the paths that enables additional analytics. We believe this algorithm will offer new ways to examine current data, inspire new types of experiments enabled by the method, and provide new ideas for data mining of path data. As currently defined, the method is sufficient for many applications, although there are a number of limitations that should be recognized (and that could be the source of future development).
Limitations
Areabased costs
The present algorithm uses the area between paths to measure the cost of a deviation. This has a drawback, in that there are often many ways in which the area between paths can be segmented, and so there is some ambiguity in determining a specific mapping. We have dealt with this by performing a second pass over the subnetwork that produces the minimal area, and minimizing a second value that corresponds, roughly, to the sum of the distance between all the points on each path and the other path.
Areabased cost can be viewed as the integral of a constant cost function over the length of corresponding segments. It may be possible to use a different cost function to constrain the optimization in a way that tends to produce a single best mapping in one step. For any application, the cost of deviations may not map directly onto the area (and the cost might either be concave or convex with the absolute deviation). Any convex loss function, such as squared error, would satisfy Jensen’s inequality and insure that the mapping prefers segment mappings that have smaller absolute distances, and this could be a reasonable alternative cost function to adopt. Now, the polygoncost would no longer be computable with the Surveyor’s formula, but Green’s theorem would still hold and allow a relatively efficient means for computing this cost for each pair of segments. The pathmapping package allows using alternative cost functions, but we have not systematically explored the consequences of these alternative costs.
An areabased cost function can also be insensitive to complexity at different scales. That is, a long, smooth or straight path may be easily captured by just a few line segments, whereas a path with detailed curvature in a local region may require dozens of line segments to capture it. Yet, moving or deleting one point of the largescale region may have a large cost, but smoothing a detailed path may have only limited cost. For example, consider the center panel of the third row of Fig. 7. There, two mismatching points produced a large deviation.
Table A1 documents the main useraccessible functions. e, a path refers to a twocolumn matrix of x,y coordinates; a mapping refers to the data structure produced by the CreateMap function
Function name  arguments  Return value  Description 

CreateMap  path1, path2,  mapping  Finds a minimumcost 
plotgrid =F,  mapping between two paths  
Cost=Cost.area,  
nondecreasingos=F,  
verbose=F,  
insertopposites=T  
GetMinMap  mapping,leftbias=T,  mapping  Finds the minimumarea mapping 
verbose=F  that also minimizes linear distance  
between points on paths  
PlotMap  mapping, cols,  Plots the paths and the  
linecol, xlim, ylim  mapping between paths  
Insert  path1, path2,  mapping  Inserts points on one path that 
Intersections  insertopposites=T,  are opposite points on a second path.  
verbose=F  
SimplifyPath  path,  path  Removes points that do not 
tolerance=.075,faster=T,  significantly impact the shape  
verbose=F, plot=F  of the path, using method by Latecki and Lakämper (1999)  
surveyors  polygon  An area  Computes area inside polygon 
PathDist  path  A distance  Computes length of a path 
SummarizeMapping  map  A matrix  Returns a common matrix 
showing the direct correspondence  
between two paths.  
PathOverlap  map  A proportion  Proportion of paths that overlap in their mapping. 
Use of raw path data
A second limitation that should be acknowledged regards the nature of the path data. The algorithm takes as input a path, defined as an ordered sequence of (x,y) locations. However, many paths may not be defined in this way. For example, if one were measuring how closely a GPStracked path followed a road drawn on a map, the GPS trail might be an ordered sequence of points, but the road might be simply a wavy line drawn on the map. Alternately, jet stream paths may be inferred from a complex vector field, and other paths may be similarly inferred from some other primary measure. These paths and others might also be more like a stream, with their widths varying along their extent. To use the algorithm, one must still (manually or automatically) translate the path into a single ordered sequence of points. Algorithms for doing this are beyond the scope of the current research, and might depend on the types of paths being investigated.
Practical efficiency for long paths
Another related limitation is that for paths digitized or sampled from a continuous source, (e.g., GPS history trail, flight path, mouse tracking, etc.), the sampled path may have hundreds or thousands of points. Depending on computing resources, this may make the present algorithm impractical. In situations such as this, one could reduce the number of points in one or both paths using methods such as the shape evolution algorithm introduced by Latecki and Lakämper (1999). This would, at a minimal cost of precision, allow more efficient calculation of distance between paths.
Additional spatial, time, and other dimensions
Finally, an additional limitation is that the current algorithm only handles two spatial dimensions. This approach might be useful for threedimensional data, such as search behaviors (in aerial, waterbased, or virtual movements), or it could consider time as a third dimension (producing movement trajectories such as a football running route or military attack), or incorporate both (comparing landing or takeoff paths of pilots). The present implementation is limited to two dimensions, but in principle could be extended to larger dimensional spaces.
Summary and conclusions
Researchers in behavioral sciences often obtain spatial paths in which they wish to derive a measure of similarity to another path. Previous methods adopted have been ad hoc and have required tedious handcoding. Here, we propose an algorithm that (1) finds the distance between two paths, which can be used as a measure of dissimilarity; and (2) determines an optimal correspondence between elements of each path, mapping each point to a point or segment on the other path. An implementation of the algorithm using the R statistical computing language is available, and can provide useful metrics both within behavioral research and in other domains.
Footnotes
 1.
Green’s theorem had been known for some time, but had only recently been proven by Riemann (1851) in his dissertation.
 2.
In the notation of Hogan (1973), a pointtoset map Ω is defined as the mapping X→2^{ X }; i.e., the power set. For any node of A (corresponding to a row of the matrix implied by M(A _{ i },B _{ j })), the power set 2^{ X } is just all possible combinations of 1s and 0s on that row. Similarly, each column of M(A _{ i },B _{ j }) represents a pointtoset mapping between a node of B and the nodes of A.
 3.
This search task software is available at https://sites.google.com/a/mtu.edu/aerialste/.
Notes
Acknowledgments
The authors gratefully acknowledge the advice of and discussions with the late Prof. Arthur F. Veinott, Jr., who pointed us toward the dynamic programming solutions to this problem.
References
 Abend, W., Bizzi, E., & Morasso, P. (1982). Human arm trajectory formation. Brain: A Journal of Neurology, 105(2), 331–348.CrossRefGoogle Scholar
 Amsler, J. (1856). Über die mechanische Bestimmung des Flächeninhaltes, der statischen Momente und der Trägheitsmomente ebener Figuren insbesondere über einen neuen Planimeter (On the mechanical assessment of the area, the static moments, and the moment of inertia of figures in a plane, in particular on a new planimeter) Schaffhausen: Beck. available from. http://books.google.com/books?id=qpQ5AAAAcAAJ
 Anderson, A.H., Bader, M., Bard, E.G., Boyle, E., Doherty, G., & Garrod, S. (1991). The HCRC map task corpus. Language and Speech, 34(4), 351–366.Google Scholar
 Asundi, A., & Wensen, Z. (1998). Fast phaseunwrapping algorithm based on a grayscale mask and flood fill. Applied Optics, 37(23), 5416–5420.CrossRefPubMedGoogle Scholar
 Barton, N.P., & Ellis, A.W. (2009). Variability in wintertime position and strength of the North Pacific jet stream as represented by reanalysis data. International Journal of Climatology, 29(6), 851–862.CrossRefGoogle Scholar
 Belongie, S., Malik, J., & Puzicha, J. (2001). Matching shapes. In Proceedings of the Eighth IEEE International Conference on Computer Vision (ICCV2001) (Vol. 1,. pp. 454–461).Google Scholar
 Belongie, S., Malik, J., & Puzicha, J. (2002). Shape matching and object recognition using shape contexts. IEEE Transactions on Pattern Analysis and Machine Intelligence, 24(4), 509–522.CrossRefGoogle Scholar
 Braden, B. (1986). The surveyor’s area formula. The College Mathematics Journal, 17(4), 326–337.CrossRefGoogle Scholar
 Brown, G., Anderson, A.H., Shillcock, R., & Yule, G. (1984). Teaching talk. Cambridge University Press.Google Scholar
 Care, C. (2010). Technology for modelling: Electrical analogies, engineering practice, and the development of analogue computing, Chapter 2. Berlin: Springer. doi: 10.1007/9781848829480 CrossRefGoogle Scholar
 Ceriani, S.A., Roth, J.D., Evans, D.R., Weishampel, J.F., & Ehrhart, L.M. (2012). Inferring foraging areas of nesting loggerhead turtles using satellite telemetry and stable isotopes. PloS One, 7(9), e45335.CrossRefPubMedPubMedCentralGoogle Scholar
 Chen, L., Özsu, M.T., & Oria, V. (2005). Robust and fast similarity search for moving object trajectories. In: Proceedings of the 2005 ACM SIGMOD International Conference on Management of Data. (pp. 491–502).Google Scholar
 Croxall, J.P., Silk, J.R., Phillips, R.A., Afanasyev, V., & Briggs, D.R. (2005). Global circumnavigations: Tracking yearround ranges of nonbreeding albatrosses. Science, 307(5707), 249–250.Google Scholar
 Dasarathy, B.V. (1991). Nearest neighbor (NN) norms: NN pattern classification techniques. IEEE Computer Society Press.Google Scholar
 Demuth, J.L., DeMaria, M., & Knaff, J.A. (2006). Improvement of advanced microwave sounding unit tropical cyclone intensity and size estimation. Journal of Applied Meteorology and Climatology, 45(11), 1573–1581.CrossRefGoogle Scholar
 Egevang, C., Stenhouse, I.J., Phillips, R.A., Petersen, A., Fox, J.W., & Silk, J.R. (2010). Tracking of Arctic terns Sterna paradisaea reveals longest animal migration. Proceedings of the National Academy of Sciences, 107(5), 2078–2081.CrossRefGoogle Scholar
 Erdenebaatar, B., & Humphrey, C. (1996). Socioeconomic aspects of the pastoral movement patterns of mongolian herders. In C. Humphrey & D. Sneath (Eds.), (pp. 58–110). White Horse Press.Google Scholar
 Fisk, H.N. (1944). Geological investigation of the alluvial valley of the lower Mississippi River. War Department, Corps of Engineers. Retrieved from. http://biotech.law.lsu.edu/climate/mississippi/fisk/fisk.htm
 Freeman, J.B., & Ambady, N. (2010). MouseTracker: Software for studying realtime mental processing using a computer mousetracking method. Behavior Research Methods, 42(1), 226–241.CrossRefPubMedGoogle Scholar
 Gatterdam, R.W. (1981). The planimeter as an example of Green’s theorem. American Mathematical Monthly, 701–704.Google Scholar
 Gawarkiewicz, G.G., Todd, R.E., Plueddemann, A.J., Andres, M., & Manning, J.P. (2012). Direct interaction between the Gulf stream and the shelfbreak south of New England. Scientific Reports, 2.Google Scholar
 Gorelick, L., Blank, M., Shechtman, E., Irani, M., & Basri, R. (2007). Actions as spacetime shapes. IEEE Transactions on Pattern Analysis and Machine Intelligence, 29(12), 2247–2253.CrossRefGoogle Scholar
 Gorelick, L., Galun, M., Sharon, E., Basri, R., & Brandt, A. (2006). Shape representation and classification using the Poisson equation. IEEE Transactions on Pattern Analysis and Machine Intelligence, 28(12), 1991–2005.CrossRefGoogle Scholar
 Guilford, T., Meade, J., Willis, J., Phillips, R.A., Boyle, D., & Roberts, S. (2009). Migration and stopover in a small pelagic seabird, similar point, for: Manx shearwater Puffinus puffinus: Insights from machine learning. Proceedings of the Royal Society B: Biological Sciences. rspb–2008.Google Scholar
 Hogan, W.W. (1973). Pointtoset maps in mathematical programming. SIAM Review, 15(3), 591–603.CrossRefGoogle Scholar
 Istomin, K.V., & Dwyer, M.J. (2009). Finding the way. Current Anthropology, 50(1), 29–49.CrossRefPubMedGoogle Scholar
 Kennedy, W.G., Hailegiorgis, A., Rouleau, M., Bassett, J., Coletti, M., & Balan, G. (2010). MASON HerderLand: Modeling the origins of conflict in East Africa. Proceedings of the First Annual Conference of the Computational Social Science Society.Google Scholar
 Latecki, L.J., & Lakämper, R. (1999). Convexity rule for shape decomposition based on discrete contour evolution. Computer Vision and Image Understanding, 73(3), 441–454.CrossRefGoogle Scholar
 Latecki, L.J., & Lakämper, R. (2000). Shape similarity measure based on correspondence of visual parts. IEEE Transactions on Pattern Analysis and Machine Intelligence, 22(10), 1185–1190.CrossRefGoogle Scholar
 Levenshtein, V.I. (1966). Binary codes capable of correcting deletions, insertions and reversals. Soviet Physics Doklady, 10, 707.Google Scholar
 Littman, M.L., Dumais, S.T., & Landauer, T.K. (1998). Automatic crosslanguage information retrieval using latent semantic indexing. In Crosslanguage information retrieval (pp. 51–62) . Springer.Google Scholar
 MacGregor, J.N., & Ormerod, T. (1996). Human performance on the traveling salesman problem. Perception & Psychophysics, 58(4), 527–539.CrossRefGoogle Scholar
 Marzal, A., & Vidal, E. (1993). Computation of normalized edit distance and applications. IEEE Transactions on Pattern Analysis and Machine Intelligence, 15(9), 926–932.CrossRefGoogle Scholar
 Mueller, S.T. (2010). A partial implementation of the BICA cognitive decathlon using the Psychology Experiment Building Language (PEBL). International Journal of Machine Consciousness, 2(2), 273–288.CrossRefGoogle Scholar
 Mueller, S.T., Perelman, B.S., & Simpkins, B.G. (2013). Pathfinding in the cognitive map: Network models of mechanisms for search and planning. Biologically Inspired Cognitive Architectures, 5, 94–111.CrossRefGoogle Scholar
 Mueller, S.T., & Piper, B.J. (2014). The Psychology Experiment Building Language (PEBL) and PEBL test battery. Journal of Neuroscience Methods, 222, 250–259.CrossRefPubMedPubMedCentralGoogle Scholar
 Mueller, S.T., Price, O.T., McClellan, G.E., Fallon, C.K., Simpkins, B., & Cox, D.A. (2010). Cognitive Performance Prediction with the T3 Methodology, (Tech. Rep.). Dayton, OH: DTRA Technical report, HDTRA108C0025.Google Scholar
 Perelman, B.S., & Mueller, S.T. (2013). Examining memory for search using a simulated aerial search and rescue task. In Proceedings of the 17th International Symposium on Aviation Psychology (ISAP17) (pp. 302–309). Dayton, OH.Google Scholar
 Pizlo, Z. (2010). 3D shape: Its unique place in visual perception. MIT Press.Google Scholar
 Pizlo, Z., Stefanov, E., Saalweachter, J., Li, Z., Haxhimusa, Y. , & Kropatsch, W.G (2006). Traveling salesman problem: A foveating pyramid model. The Journal of Problem Solving, 1(1), 8.Google Scholar
 R Core Team (2013). R: A Language and Environment for Statistical Computing [computer software manual]. Vienna, Austria. http://www.Rproject.org/
 Riemann, B. (1851). Grundlagen für eine allgemeine Theorie der Functionen einer veränderlichen complexen Grösse (Doctoral dissertation, EA Huth). See reference at: http://www.emis.ams.org/classics/Riemann/Grund.pdf
 Ruddle, R. A., & Lessels, S. (2009). The benefits of using a walking interface to navigate virtual environments. ACM Transactions on ComputerHuman Interaction (TOCHI), 16(1), 5.CrossRefGoogle Scholar
 Shaw, J. (2004). QuickFill: An efficient flood fill algorithm. Online article Retrieved from: http://www.codeproject.com/Articles/6017/QuickFillAnefficientfloodfillalgorithm
 Tuch, D. S., Reese, T. G., Wiegell, M. R., & Wedeen, V. J. (2003). Diffusion MRI of complex neural architecture. Neuron, 40(5), 885–895.CrossRefPubMedGoogle Scholar
 van der Stigchel, S., Meeter, M., & Theeuwes, J. (2006). Eye movement trajectories and what they tell us. Neuroscience & Biobehavioral Reviews, 30(5), 666–679.CrossRefGoogle Scholar
 Tuch, D. S., Reese, T. G., Wiegell, M. R., & Wedeen, V. J. (2003). Diffusion MRI of complex neural architecture. Neuron, 40(5), 885–895.CrossRefPubMedGoogle Scholar
 Veinott, E. S., Olson, J., Olson, G. M., & Fu, X. (1999). Video helps remote work: Speakers who need to negotiate common ground benefit from seeing each other. In: Proceedings of the SIGCHI Conference on Human Factors in Computing Systems, (pp. 302–309).Google Scholar
 Weimerskirch, H., & Wilson, R. P (2000). Oceanic respite for wandering albatrosses. Nature, 406(6799), 955–956.CrossRefPubMedGoogle Scholar
 Yanagisawa, Y., Akahani, J., & Satoh, T. (2003). Shapebased similarity query for trajectory of mobile objects. In: Mobile Data Management. (pp. 63–77) . Springer.Google Scholar
 Zangwill, W. (1969). Nonlinear programming: A unified approach. PrenticeHall, Englewood Cliffs, NJ.Google Scholar
 Zhang, R., Nordman, A., Walker, J., & Kuhl, S. A (2012). Minification affects verbaland actionbased distance judgments differently in headmounted displays. ACM Transactions on Applied Perception (TAP), 9(3), 14.Google Scholar