Trajectory Outlier Detection Library
 All Classes Functions Variables Pages
OutlierDetector.h
1 #pragma once
2 
3 #include "TrajData.h"
4 #include "Trajectory.h"
5 #include "Outlier.h"
6 #include "Param.h"
7 
8 #include <set>
9 #include <map>
10 #include <vector>
11 using namespace std;
12 
13 
14 // COutlierDetector
15 
16 typedef pair<int,int> IntIntPair;
17 typedef pair<CMDPoint*,CMDPoint*> PointPointPair;
18 typedef vector<float> FloatArray;
19 
27 {
28 public:
31  virtual ~COutlierDetector();
32 public:
33  TrajData* m_data;
34 private:
35  int m_nTotalLineSegments;
36  vector<IntIntPair> m_idArray;
37  vector<PointPointPair> m_lineSegmentArray;
38  vector<FloatArray> m_distanceIndex; // an array of the distances between partitions
39  FloatArray m_lengthArray;
40  vector<PartitionInfo*> m_partitionInfoArray;
41  // programming trick: avoid frequent execution of the new and delete operations
42  CMDPoint m_vector1, m_vector2;
43  CMDPoint m_projectionPoint;
44  float m_coefficient, m_coefficient1, m_coefficient2;
45 #if defined(__PARTITION_PRUNING_OPTIMIZATION__)
46  // added for partition pruning optimization
47  PartitionInfo m_partitionInfo;
48  float m_distance1, m_distance2, m_theta, m_cosTheta;
49  float m_lowerBoundPerp, m_lowerBoundPara, m_lowerBoundAngle;
50  float m_upperBoundPerp, m_upperBoundPara, m_upperBoundAngle;
51  map<IntIntPair,int> m_closePartitionArrayIndexMap;
52  vector<vector<IntIntPair> > m_closePartitionArray;
53  map<IntIntPair,float> m_finePartitionLengthMap;
54  map<IntIntPair,int> m_coarsePartitionIdMap;
55 #endif /* #if defined(__PARTITION_PRUNING_OPTIMIZATION__) */
56 public:
57  bool ResetOutlierDetector();
58  bool PartitionTrajectory();
59  bool DetectOutlier();
60 private:
61  bool FindOptimalPartition(CTrajectory* pTrajectory);
62  bool StoreTrajectoryPartitionIntoIndex();
63  bool CheckOutlyingProportion(CTrajectory* pTrajectory, float minProportion);
64  bool GenerateAndSetupOutlier(CTrajectory* pTrajectory, int outlierId);
65 private:
66  int ComputeModelCost(CTrajectory* pTrajectory, int startPIndex, int endPIndex);
67  int ComputeEncodingCost(CTrajectory* pTrajectory, int startPIndex, int endPIndex);
68  float MeasurePerpendicularDistance(CMDPoint* s1, CMDPoint* e1, CMDPoint* s2, CMDPoint* e2);
69  float MeasureDistanceFromPointToLineSegment(CMDPoint* s, CMDPoint* e, CMDPoint* p);
70  float MeasureDistanceFromPointToPoint(CMDPoint* point1, CMDPoint* point2);
71  float ComputeVectorLength(CMDPoint* vector);
72  float ComputeInnerProduct(CMDPoint* vector1, CMDPoint* vector2);
73  float MeasureAngleDisntance(CMDPoint* s1, CMDPoint* e1, CMDPoint* s2, CMDPoint* e2);
74  float ComputeDistanceBetweenTwoLineSegments(CMDPoint* startPoint1, CMDPoint* endPoint1, CMDPoint* startPoint2, CMDPoint* endPoint2);
75  void ComputeDistanceBetweenTwoLineSegments(CMDPoint* startPoint1, CMDPoint* endPoint1, CMDPoint* startPoint2, CMDPoint* endPoint2, float* distanceVector);
76  void SubComputeDistanceBetweenTwoLineSegments(CMDPoint* startPoint1, CMDPoint* endPoint1, CMDPoint* startPoint2, CMDPoint* endPoint2, float& perpendicularDistance, float& parallelDistance, float& angleDistance);
77 };
A simple point class.
Definition: MDPoint.h:10
Information required to derive the lower and upper bounds for optimized partition pruning...
Definition: Trajectory.h:16
A high-level class to perform the outlier detection.
Definition: OutlierDetector.h:26
The main storage for information about a trajectory.
Definition: Trajectory.h:28
The main class, and handler for all of the trajectory data.
Definition: TrajData.h:22