{'fraction_non_alphanumeric': 0.02981043751125286, 'fraction_numerical': 0.007999176933563105, 'mean_word_length': 4.563823697767601, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
SimpleTrack:Adaptive Trajectory Compression with Deterministic Projection Matrix for Mobile Sensor Networks

Some mobile sensor network applications require the sensor nodes to transfer their trajectories to a data sink. This paper proposes an adaptive trajectory (lossy) compression algorithm based on compressive sensing. The algorithm has two innovative elements. First, we propose a method to compute a deterministic projection matrix from a learnt dictionary. Second, we propose a method for the mobile nodes to adaptively predict the number of projections needed based on the speed of the mobile nodes. Extensive evaluation of the proposed algorithm using 6 datasets shows that our proposed algorithm can achieve sub-metre accuracy. In addition, our method of computing projection matrices outperforms two existing methods. Finally, comparison of our algorithm against a state-of-the-art trajectory compression algorithm show that our algorithm can reduce the error by 10-60 cm for the same compression ratio.


I. INTRODUCTION
Mobile sensor networks (MSNs), which consists of autonomous embedded sensor nodes roaming freely, offer many new opportunities that are not available to their stationary counterparts. The Virtual Fencing (VF) [1] project that is being conducted out in our laboratory is one such example. A cattle farm generally covers an enormous area and it is costly to build fences around it. VF offers an alternative where no physical fencing is needed. The cattle carry an embedded device with GPS on board. The device constantly monitors the cow's location and if a cow tries to leave the farm, the device sends a stimulus (either an auditory or mild electric shock) to signal the cow to turn back. Ethical considerations are critical to the VF application. Locations of the animals and records of stimuli applied must be kept. This requires the device to record the trajectory of the animal. Given the limited storage capacity of the embedded device, these stored trajectories must be uploaded to some server at some time. Due to the enormous size of the farm, base stations can only be installed at certain places. Therefore VF operates as a delay tolerant network. When a cow is getting close to a base station, the device on the animal makes use of the short transmission opportunity R. Rana  available to transfer the stored trajectory to the server. Given this limited transmission opportunity, as well as limited storage on the device, trajectory compression is important.
Data compression is a richly researched field, with many well known algorithms such as Lempel-Ziv [2] and many others. However, in the context of trajectory compression in MSNs, we also need to take the limited computation and transmission resources of MSN nodes into consideration. This demands for us to look for simple compression algorithm with good space savings. The recently developed theory of Compressive Sensing (CS) [3], [4] offers such a possibility because its compression step is very simple. In fact, we demonstrated in our earlier work [5] that such type of compression is feasible on an 8-bit Atmel Amega 1281 microcontroller with 8 kB RAM. However, we could only achieve an accuracy in the order of metres for the reconstructed trajectories in [5]. In this paper, we propose an improved compression scheme SimpleTrack which achieves a sub-metre accuracy.
SimpleTrack is also based on CS. Given a n-dimensional data vector x to be compressed, SimpleTrack uses a m × n projection matrix Φ to compute compressed data vector y = Φx. This projection matrix Φ is fat (which means m < n), therefore the output of the compression step y has a lower dimension compared with the original data vector x. The number of projections m determines the size of the compressed data y. A smaller m means lower storage and transmission requirement. The compressed vector y is used during decompression to reconstruct an approximation of x. This reconstruction step requires the projection matrix Φ as well as a reconstruction basis Ψ. In order to achieve accurate reconstruction with low resource consumption, we need to make good choices of the three parameters: number of projections m, projection matrix Φ and reconstruction basis Ψ. In this paper, we make the following contributions: • We propose an adaptive method, based on support vector regression (SVR) [6], to enable the MSN nodes to dynamically choose the number of projections m based on the their speed. • We show that better reconstruction accuracy can be achieved by using a learnt dictionary together with a projection matrix computed from the dictionary. • We propose a new method to compute projection matrix from a dictionary. Experimental results show that our proposed method outperforms two existing methods. We also provide an explanation of why our proposed method arXiv:1404.6151v1 [cs.IT] 23 Apr 2014 works better. • We perform extensive evaluation by using 6 datasets. The results show that our method is 10-60cm more accurate than the state-of-the-art trajectory compression algorithm SQUISH [7]. This paper is organized as follows. Section II presents the background on CS and dictionary learning. We describe our proposed trajectory compression algorithm SimpleTrack in Section III. Evaluations of SimpleTrack are presented in Section IV. Section V discusses related work and Section VI concludes the paper.

II. BACKGROUND
SimpleTrack uses CS and dictionary learning. We present an overview of these two topics in this section.

A. Compressive Sensing (CS)
CS has received a lot of attention in the past decade because it can significantly reduce the sampling requirement in many applications ( [8], [9], [10]). CS has also been used in wireless sensor networks (WSNs) for reducing the energy consumption in data gathering ([11], [12], [13], [14], [15]) and the computational requirements on sensors ( [16], [17], [18]). We will review the aspects of CS which are necessary for understanding this paper, more details can be found in ( [4]).
Given a vector x ∈ R n , we can compute its representation θ ∈ R n in a basis Ψ ∈ R n×n by solving the linear equation The representation θ is said to be compressible if θ has a large number of elements with small magnitude. We can realise compression by setting these elements with small magnitude to zero. This can reduce the storage requirements. If we can find a basis in which a given vector x has a compressible representation, we will also say that x is compressible. The theory of CS applies to compressible vectors. CS considers the problem of recovering an unknown compressible vector x from its projections. Let Φ be a m × n projection matrix with m < n. Consider the equation: where z ∈ R n is a noise vector whose norm is bounded by . CS aims to recover (or reconstruct) x from y and Φ given the knowledge that x is compressible in the basis Ψ. CS shows that under certain conditions it is possible to recover x by solving the following 1 optimisation problem: Givenθ, we can get an estimate of x fromx = Ψθ.
In the context of trajectory compression, x is the trajectory measured by an MSN node. The dimension of x is large. The MSN node computes y = Φx and transmits y to the server. The server can compute an estimated trajectoryx by using y, Φ and Ψ, by solving (3). Note that the compression is lossy with 1 − m n represents both space savings and reduction in wireless transmission requirement.
The reconstruction error x − x depends on a number of factors. The number of projections m must be large enough. A larger m generally reduces the reconstruction error but increases computation and transmission requirements at the sensor. The theory of CS shows that the number of projections m needed depends on the compressibility of the vector x in the basis Ψ. We say that a vector x is more compressible if its representation has fewer number of dominant elements, i.e. fewer non-zero elements with large magnitude. The theory of CS shows that a smaller m is needed if x is more compressible. We will propose an adaptive method to determine m on the MSN nodes in Section III.
The choice of basis Ψ also affects the reconstruction error. A basic requirement is that x has to be compressible in the basis Ψ. In our previous work [5], we used standard bases for Ψ. In this paper, we show that learnt dictionary gives better performance.
Another parameter that determines the achievable reconstruction error is the projection matrix Φ. The requirements on Φ to achieve low reconstruction error is expressed in terms of sensing matrix A = ΦΨ. Two requirements have been stated in the literature, in terms of Restricted Isometry Property (RIP) [19] and coherence [20]. We will discuss coherence. The mutual coherence µ(A) for the sensing matrix A is defined as where a i and a j are columns of A. In words, the coherence measures the largest correlation between any two columns of A. If A contains highly correlated columns, the coherence is large. Otherwise, it is small. The role of the coherence is straightforward: the smaller the coherence is, the fewer number of projections m is needed for low reconstruction error. We will present a new method of computing Φ in Section III.

B. Learning Sparsifying Dictionary
In order that we can achieve good trajectory compression using CS, we need compressible representation of the trajectory in a certain basis. A method to obtain good basis is through learning sparisfying dictionary. The terms sparse and compressible are closely related. A vector x is said to be sparse in the basis Ψ if its representation in Ψ has few non-zero elements. One can therefore view sparse vectors as a special case of compressible vectors.
In dictionary learning, we assume that we are given a set of P vectors X = {x 1 , x 2 , ..., x P } from R n and we want to find a dictionary D ∈ R n×d such that the vectors x i are simultaneously sparse in this dictionary D. In other words, if we compute the representations θ i of x i via x i = Dθ i , we want all the vectors θ i from i = 1, ..., P to be sparse in D.
In the context of trajectory compression, X is a set of trajectories that we can use to learn a dictionary D. If a new trajectory x is similar to those in X, then we expect that x will have a fairly compressible representation in D. Since the more compressible x is, the lower the requirement on the number of projections m is, we can achieve the same reconstruction error with a smaller m, thus reducing wireless transmission requirement.
Dictionary learning can be formulated as an optimisation problem. Given the set {x 1 , x 2 , ..., x P }, we want to find n × d dictionary matrix D and coefficients s i ∈ R d such that x i = Ds i for i = 1, ..., P and s i are sparse. The requirement that s i is sparse can be imposed by forcing the vectors s i to have small 0 norm since the 0 norm of a vector counts the number of non-zero elements in the vector. However, using 0 norm makes the optimisation problem hard, an alternative it to impose that the 1 norm of s i be small. Let d j denote the j-th column of D. We define the optimisation problem The optimization problem (5) is convex with respect to each of the variables D and {s i }, when the other one is fixed. Therefore, practically it can be solved in two steps: learning the sparse coefficients s i keeping the dictionary D fixed, and then learning the dictionary D keeping the coefficients s i fixed [21], [22]. We use SPAMS [21] to solve (5). For dictionary learning, SPAMS uses the LARS-Lasso algorithm [23], which is a homotopy method [24] providing the solutions for all possible values of λ. We choose SPAMS because it uses block-coordinate descent with warm restarts [25], which guarantees the convergence to a global optimum.

III. SIMPLETRACK
This section describes our proposed trajectory compression algorithm SimpleTrack. The algorithm is based on CS and assumes that a number of trajectories are available for training. SimpleTrack has three parameters: number of projections m, dictionary D and projection matrix Φ. SimpleTrack uses dictionary learning to obtain D from the training trajectories. We assume that D has been computed in this section.
In this section, we present a new method to compute projection matrix Φ from the learnt dictionary D in Section III-A. We will show that the projection matrix obtained from our method gives better performance than other methods in Section IV. In order to reduce the computation and transmission requirements of MSN nodes, we propose a method to adaptively determine the number of projections m needed. This is based SVR and will be presented in Section III-B.

A. Deterministic Construction of Projection Matrix
We know from the theory of CS that a good choice of projection matrix Φ can reduce the reconstruction error. The projection matrix Φ should ideally be uncorrelated with the dictionary D (resp. the basis Ψ) such that the sensing matrix A = ΦD (A = ΦΨ) has low coherence. The problem of constructing good projection matrix has been considered in [26] and [27]. Our work is built on [27] and we will show that our proposed method performs better than those in [26] and [27] in Section IV.
We first describe the projection matrix construction method in [27]. The method assumes that the dictionary D ∈ R n×d and the number of projections m are the inputs. The method first computes the singular value decomposition (SVD) of D: where where T denotes matrix transpose, Λ ∈ R n×d contains the singular values in its main diagonal, and U ∈ R n×n and V ∈ R d×d are orthonormal matrices. The method in [27] is to randomly choose m columns from the matrix U . Let U m be a n × m matrix formed by these m randomly chosen columns from U . The method is to useŨ T m as the projection matrix. The rationale of the method is that the columns in U are highly uncorrelated with the dictionary D, therefore the sensing matrix ΨD =Ũ T m D will have low coherence. In our proposed method, we choose the m columns in U corresponding to the largest m singular values of D. We now explain why this is a better choice. To simplify notation, we assume that the SVD in (6) has been permuted so that singular values appear in non-increasing order in the diagonal of Λ. With this notation, let U m denotes the sub-matrix containing the left-most m columns of U ; note that these m columns correspond to the largest m singular values of D. Our choice of projection matrix is therefore U T m . To understand why U m is a better choice, note that the trajectory reconstruction problem can be stated as estimating the unknown coefficient vector s from the projection y by solving y = ΦDs. We assume that the unknown coefficient vector s comes from some probability distribution such that E[ss T ] = I where E and I denote respectively the expectation operator and the identity matrix. It can be shown that the mean signal power E[y T y] can be written as: If we impose the constraint that each row of the projection matrix Φ has unit norm, then the Φ that maximizes E[y T y] is given by the first m rows of U T (or U T m ), i.e. the m left singular vectors corresponding to the largest m singular values. This shows that our choice of projection matrix maximises the signal power of y. A higher signal power typically translates to lower estimation error. We will show, through numerical evaluations in Section IV, that our method of computing projection matrix has two advantages.
1) For a given number of projections m, it reduces the trajectory reconstruction error. 2) Because we use a deterministic way of computing the projection matrix, we get less variability in the error of trajectory reconstruction.

B. Adaptive Compression
The number of projections m is an important parameter in SimpleTrack because it controls the trade-off between the computation/transmission requirements at the MSN nodes and the reconstruction accuracy of the trajectory. For a given reconstruction error, we want to use the smallest m required. If the MSN nodes were powerful enough, they could compute the projection y for different choices of m and then perform the reconstruction to determine the exact reconstruction error; this would allow them to choose the best m for a given reconstruction error. However, this is not feasible for MSN nodes. In fact, we require a simple way for the MSN nodes to choose m.
Our proposal is to use off-line learning based on the hypothesis that number of projections required is correlated with the speed of movement. This is fairly intuitive. Low speed means little movement or little information in the trajectory, and vice versa. Therefore, we investigate the use of some function of speed to predict the number of projections required. Our offline learning method requires a set of training trajectories {x 1 , x 2 , ..., x P }, a parameter m max which is the maximum number of projections needed by the node and a parameter ξ which is the maximum trajectory reconstruction error that we can tolerate. We first perform the following: 1) Use the training trajectories to compute the dictionary D using the method in Section II-B. 2) Use D and m max to compute a projection matrix Φ with m max rows using the method in Section III-A. 3) For each trajectory x i , a) Determine s i which is a statistics of the speeds within the trajectory. b) Determine the smallest number of projections m i required so that the reconstruction error is less than the tolerance ξ. Note that for step 3a, there are many possible choices of statistics, e.g. mean or median speed. We will examine different choices in Section IV. After performing the above calculations, we have the training set {(s 1 , m 1 ), ..., (s P , m P )}. We use -SVR to determine a function m = g(s) where s is the speed statistics and m is the number of projections that should be used for s. The parameter in -SVR can be used to control the accuracy of the fit. The function m = g(s) can be implemented on the MSN nodes using a look-up table, see [5]. We use the matlab library LIBSVM [28] to implement -SVR. We choose radial basis function (RBF) kernel, rather than linear kernel, because it is more suitable for small number of features. We found that the RBF kernel performs better than the linear kernel for our datasets.

C. Pseudocode for SimpleTrack Encoding and Decoding
The pseudocode of the SimpleTrack encoding and decoding processes is shown in Algorithms 1 and 2 respectively. The encoding takes place on the MSN nodes while the decoding takes place at the sink. The encoding process turns an input trajectory segment x with n data points into a m-vector y with m < n, which is transmitted to the basestation. The decoding process uses y to recover an approximation of x.
SimpleTrack requires three inputs that are computed offline: a look-up table, matrixŨ and dictionary D. The look-up table is used to adaptively determine the number of projections m required for each trajectory segment using a speed statistics of that segment, see Section III-B. We will evaluate the performance of different choices of speed statistics in Section IV-E1. We see from Section III-A that if m projections are required, then the projection matrix is formed by the left-most m columns of U where U contains the left singular vectors arranged in descending order of singular values. The columns of U have to be stored on the sensor nodes to enable them to compute the projections but we do not need all the columns in U . Let m max be the maximum number of projections a sensor node has to perform. We extract the left-most m max columns of U and store them inŨ , which will be stored on the sensor nodes. Lastly, the dictionary D is obtained using the process described in Section II-B. Note that the dictionary D is only needed by the sink for decoding. The sensor nodes do not require the dictionary, but they need to store the m max × n projection matrixŨ , which has a smaller dimension compared with dictionary D. Finally, note that the input data size n is fixed for a given type of subjects (e.g. animal type), while the size of the encoding output m is variable and is determined by the look-up table.

D. Complexity Analysis
The SimpleTrack decoding takes place at the server with plentiful of resources. Therefore, this complexity analysis focuses on encoding which takes place at the sensor nodes. Table look-up and projection computation are the two key operations in encoding. Table look-up can be efficiently done by binary search. Our earlier experience in [5] shows that only a small look-up table is required. Therefore the dominant computation cost is to calculate the projections. The projection calculations require multiplying a m×n matrix with a n-vector which has a complexity of the order O(mn). Experimental results on computation time will be presented in Section IV-F.

A. Datasets
Our motivation for studying trajectory compression comes from the VF application. We will use a dataset obtained from VF for performance evaluation. In order to show that our proposed trajectory compression method is general, we supplement the evaluation by using 5 publicly available datasets on pedestrian mobility. 1) Animal Dataset: The data were collected from a cattle monitoring trial [1] with 36 cows for 49 hours. The data was collected using a wireless platform (mounted on cow collar) with a Nordic NRF905 transceiver. The platform was connected to a Ublox4 GPS receiver using the Serial Peripheral Interface. The GPS data was collected at a 2 Hz sampling rate.
2) Pedestrian Dataset: We use publicly available pedestrian mobility traces from the CRAWDAD data repository [29]. The datasets and the number of traces in each dataset are: (i) NCSU with 35 traces (ii) KAIST with 46 traces (iii) New York City with 30 traces (iv) North Carolina state fair with 8 traces (v) Disney World (Orlando) with 15 traces For all the traces in these datasets, positions were recorded by Garmin GPS 60CSx handheld receivers every 30 seconds. It is known that these GPS receivers are accurate to within 3 meters for 95% of the time in North America.
3) Speed Variability in the Dataset: Figure 1 shows the speed of a moving pedestrian and an animal over time. It can be seen that the subjects move at varying speed over time. This observation also applies to other datasets.
B. Methodology 1) Segment size and data format: We divide each trace into segments consisting of a fixed number of data points. We determine the segment size using the speed. For cattle which do not move quickly, each segment consists of 128 data points or 64 seconds. For pedestrians, which have a higher average speed, each segment consists of 32 data points. Note that another reason for choosing a shorter segment for the pedestrian data is because of a longer sampling period of 30s.
Each data point consists of two values: Easting (eastwardmeasured distance) and Northing (northward-measured distance). We encode/decode the easting and northing values in a segment separately. For the animal (resp. pedestrian) datasets, each trajectory segment gives two (resp. 32-) 128-vectors, one for easting and northing.
2) Preprocessing: In order to consider only walking we filtered out segments where a speed of 6km/hr was exceeded. All the measurements were converted into meters and the the data of the segment were subtracted by the mean of the segment.
3) Training and test sets: We used 80% of the segments for training and the remaining 20% for validation testing. For compression methods that require a dictionary, the training set is used to compute the dictionary. For the 5 pedestrian datasets, a separate dictionary is computed for each dataset.

4) Performance metrics:
We measure the performance of each compression method by the accuracy of the reconstructed trajectories. Let J be the number of segments in the test set. Let N j,i and E j,i denote, respectively, the Northing and Easting for the i-th data point in the j-th segment in the test set, with 1 ≤ i ≤ n 2 and 1 ≤ j ≤ J. We useN j,i and E j,i to denote the corresponding reconstructed Northing and Easting. We use the average distance between the original and reconstructed trajectories, Average Distance Error (ADE), to measure the reconstruction performance. ADE is defined as:

C. Compression methods
In order to show that SimpleTrack gives good performance, we compare it against a number of methods. Two key ideas of SimpleTrack are to use a learnt dictionary and a new projection matrix computation method to improve trajectory compression. We therefore compare SimpleTrack against methods that do not use learnt dictionary and other methods of computing projection matrix. The compressive sensing based trajectory compression methods that we will study are: • Method DCT-G We proposed a compressive sensing based trajectory compression method [5] which uses standard bases and random projection matrices. In [5], we compared the compressibility of animal trajectories in different bases, including Discrete Cosine Transform (DCT) and various wavelet bases. We found that the animal trajectories are most compressible in the DCT basis. Multiple types of random projection matrices have been proposed in compressive sensing as the projection matrix, including Gaussian and Bernoulli random matrices. We found that difference projection matrices gave similar reconstruction performance. The trajectory compression method DCT-G is based on using DCT basis and Gaussian projection matrices. • Method D-G The D-G trajectory compression methods uses a learnt dictionary, this is what the letter 'D' stands for. The method uses random Gaussian matrices as projection matrices. • Method D-SVDRandom The D-SVDRandom trajectory compression method uses a learnt dictionary. This method uses the algorithm in [27] to compute the projection matrix from the dictionary D. This method is based on choosing m random left singular vectors from the SVD of D and is discussed in section III-A. The "SVDRandom" part of the name is referring to this method of computing projection matrix. • Method D-Elad Other methods for computing projection matrices from dictionaries can also be found in the literature. Elad [26] proposed a method to obtain an optimised projection matrix from a dictionary by minimising the mutual coherence. The D-Elad method uses a learnt SimpleTrack uses a learnt dictionary and the projection matrix computation method proposed in Section III-A. SimpleTrack also uses an adaptive method to determine the number of projections m described in Section III-B. Finally, we compare the compression performance of Sim-pleTrack against SQUISH [7]. SQUISH is a powerful GPS compression algorithm recently proposed by Muckell et al. [7]. It is a non-dictionary based method and works on the principles of synchronous Euclidian distance. Muckell et al. have shown that SQUISH performs better than other prominent trajectory compression methods such as Uniform Sampling, Online Dead Reckoning, and Online Douglas-Peucker.
In this section, we study the reconstruction performance measured by ADE for the different compressive sensing based trajectory compression methods. We vary the space savings 1 − m n between 0.9 and 0.6 and calculate the ADE for each method. Note that space savings lower than 0.6 are not shown because their achievable ADE is comparable to that of 0.6 space savings. For SimpleTrack, we disable the adaptive computation of m and assume the value m is given.

D. ADE for different space savings
We first compare DCT-G, D-G and D-Elad to show that learnt dictionary and optimised projection matrix together give much better ADE for each space savings. Figure 2 shows the ADE versus space savings for the 6 datasets. The vertical axes of these plots show ADE measured in metres. The central horizontal lines are at the level of 1m for ADE. If a method achieves an ADE below 1m (i.e., sub-metre accuracy), the bar will appear below this line in the plots. Note that the vertical axes use logarithmic scale so that the magnitudes of sub-metre ADE can be distinguished. These results show that D-Elad outperforms DCT-G and D-G for all datasets and all space savings. This shows learnt dictionary, together with a good projection matrix, can improve the accuracy for a given m. We will now use D-Elad as the benchmark for the next study.
In this study, we assume dictionary is used and we compare D-Elad, D-SVDRandom and SimpleTrack. Note that these three methods use the same dictionary, the difference is the method to compute the projection matrix. The ADE versus space savings plots for the six datasets are shown in Figure  3. It can be seen that SimpleTrack outperforms the other two methods for all datasets and space savings. In particular, Sim-pleTrack achieves sub-metre accuracy for all the space savings used. We can therefore conclude that: (1) SimpleTrack has the best performance compared to other compressive sensing based trajectory compression methods. (2) SimpleTrack can achieve sub-metre accuracy. (3) Our method of computing a projection matrix from a dictionary performs well. (4) The error bars also show our projection matrix reduces the variability in ADE.
Finally, we contrast the performance of SimpleTrack with that of SQUISH in Figure 4. For the cattle datasets Simple-Track performs marginally better than SQUISH. For example, its reconstruction error is 10 cm less than SQUISH. However, for the pedestrian datasets, SimpleTrack performs much better. The reconstruction error can be 60 cm less than SQUISH.
The complexity of SimpleTrack is O(mn), where m is the number of projections and n is the number of data points in the trajectory segment. SQUISH has a complexity O(n log (β)), where β is the size of the buffer. There is no indication on the buffer size is in the SQUISH paper [7]. We know from compressive sensing that m n, therefore, it may be reasonable to assume that m ∼ log (β). Thus, the complexity of SimpleTrack is comparable to that of SQUISH. In summary, SimpleTrack offers better accuracy while being similarly complex as SQUISH.  We first determine which speed statistics to be used in prediction the number of projections m. We use 5 speed statistics: mean, variance, median, maximum and minimum. For each training segment, we compute these 5 speed statistics as well as the minimum number of projections m needed to achieve a 50cm trajectory reconstruction error. In order to determine which speed statistics is the best, we compute the correlation between the speed statistics and the required m. The correlations are shown in Table I. We will use mean speed as speed statistics since it has the highest correlation for both pedestrian and animal datasets. We then follow the SVR-based method in Section III-B to determine m as a function of mean speed.
2) Performance: We compare SimpleTrack, which determines m adaptively, against a non-adaptive version of Sim-pleTrack. We first use SimpleTrack on the test datasets and determine the mean number of projectionsm used by Simple-Track for each test dataset. SimpleTrack (non-adaptive) uses a constant number of projectionsm. Figure 5(a) compares the ADE realised by SimpleTrack and SimpleTrack (nonadaptive). It shows that SimpleTrack can achieve sub-metre accuracy and performs similar to SimpleTrack(non-adaptive), however, the latter requires the number of projections to be known beforehand, which is un-realistic.
We also test how well SimpleTrack predicts m. Recall that the training is based on predicting the minimum m needed for a reconstruction error of 50cm. For each test segments, we compute the actual m needed to achieve 50cm reconstruction error; the actual m needed is used as the reference. Figure 5 shows the percentage error in predicting the actual m needed to achieve 50cm reconstruction accuracy. It shows that the SVR-based algorithm gives accurate prediction.

F. System Performance
We implemented the SimpleTrack encoding process on a real world sensor platform to understand its resource requirements. We use the Tmote Sky sensor node platform [30], which features an 8MHz Texas Instruments MSP430 microcontroller with 10 kB Random Access Memory (RAM) and 48 kB flash programmable Read-Only Memory (ROM), as our hardware test environment. We use Contiki [31] as our software test environment. Contiki is a C-based cooperative multi-threaded operating system for WSNs.
We use the animal dataset which has a higher number (128) data points in each trajectory segment. The maximum number of projections m max needed for this dataset is 47. In principle, we need two different projection matrices, one for Northing and Easting. However, we find that using one projection matrix for both Northing and Easting can give us the same ADE so our implementation uses only one projection matrix. The dimension of the projection matrixŨ (see Algorithm 1) that a sensor node needs to store in this case is 47 × 128, which requires 24kB of memory storage. We also use a relatively large look-up table with 100 data pairs to stress the system. Table II shows the computation time and energy consumption of the one look-up and one projection computation. Since each trajectory requires two projection matrix calculations (for northing and easting) and one look-up, the worst computation time (when 47 projections are needed) is 2 × 47 × 1.86 + 22. 27 = 197.11ms. Comparing to the duration of a trajectory, which is 128×0.5 = 64s, the computation time is less than 1% of the time of a segment. Finally, the power consumption is based on the method described in [32].

V. RELATED WORK
The solution provided in this paper spans two key aspects: (1) Adaptive compression; (2) Deterministic construction of the projection matrix. We will therefore discuss the literature in these two areas. In addition, we discuss trajectory compression algorithms for WSNs.

A. Adaptive Compression in WSNs
Most adaptive compression algorithms proposed for WSN are motivated by energy savings. Most of the them considered slowly changing natural phenomena, which intrinsically require relatively low sampling. For example, [33] proposed an adaptive compression algorithm, wherein compression is adapted at the sensing node by analyzing the correlation in a centralized data store. Since the approach requires central server to node communication, it is suitable for slowly changing phenomena e.g., soil moisture. However, we consider trajectory sampled at as high as 2 Hz sampling rate, therefore, such technique may result in enormous node to base communication causing quick depletion of the sensor node battery.
Some other adaptive compression algorithms, although not requiring enormous inter-node communication, however require a large number of on-node processing. For example, [34] proposed an adaptive wavelet compression algorithm for WSNs. In the proposed method each receiving sensor computes the space savings, and calculates the total energy dissipation to make a decision about whether to adjust the wavelet transform level. Clearly, this method will involve enormous computation given that for each trajectory segment it has to iterate multiple times to determine the optimal transform level for the best compression and energy trade-off.
A similar problem will be experienced with the algorithm proposed in [35], which employs a feedback approach in which the space savings is compared to a pre-determined threshold. The compression model used in the previous frame can be retained and used for the next frame, if space savings is greater than the predefined threshold. Otherwise, the system will produce a new compression model.
A slightly different adaptive compression principle is proposed in [36]. The authors design an on-line adaptive algorithm that dynamically makes compression decisions to accommodate the changing state of WSNs. By using the queueing model, the algorithm predicts the compression effect on the average packet delay and performs compression only when it can reduce the packet delay.

B. Deterministic Construction of Projection Matrix
Random projection matrices are often used in compressive sensing because they are easy to generate and have provably good performance. However, random projection matrices may give rise to variability in performance [37]. This problem can be overcome by using deterministic construction of projection matrices. This gives rise to some well known methods to compute optimised projection matrices, see [26], [38], [27]. These methods have already been discussed in the main text so we will not repeat the discussion here. A main contribution of this paper is a new method to compute a good projection matrix from dictionary.

C. Trajectory/GPS Compression Algorithms for Wireless Sensor Networks
A very small number of papers can be found in the literature wherein trajectory compression algorithm for WSNs or other embedded platforms have been proposed. An example is [39]. This algorithm performs recursive segmentation of the trajectory, until a trajectory segment can be modeled with an interpolation function with a small error. Compression is achieved by only transmitting the relevant parameters of the interpolation function. However, computation requirement of this compression algorithm is high.
In [40] the authors propose a trajectory compression algorithm which uses various line simplification methods, for example, Dead-Reckoning and the Douglas-Peuker algorithm, and a variant of a CG-based optimal algorithm for polyline reduction. In particular, the authors also propose a hybrid approach, which combines some of the above methods. Note that out of the three methods, Douglas-Peuker is most popular. In our previous work [5], we have already shown that the non-optimized version of compressive sensing based trajectory compression method (the DCT-G method in Section IV) performed better than the improved Douglas-Peuker method proposed by Meratina et al [41]. In this paper, we show that our proposed method SimpleTrack outperforms DCT-G, SQUISH and a number of other methods.

VI. CONCLUSIONS
Motivated by applications in mobile sensor networks, we investigate trajectory compression on resource constrained sensor nodes. We propose an adaptive trajectory compression method which is based on compressive sensing. Our proposed method has three key aspects. First, it uses dictionary learning. Second, it uses a new method to compute a good projection matrix from the dictionary. Third, it uses an adaptive algorithm to determine the number of projections required. We evaluate the performance of our proposed method using 6 datasets. We show that our algorithm outperforms many existing algorithms. In fact, our algorithm can achieve sub-metre accuracy. The algorithm also has low computation requirements and can be used on resource impoverished sensor platforms.