Energy Optimization for Outdoor Activity Recognition

The mobile phone is no longer only a communication device, but also a powerful environmental sensing unit that can monitor a user’s ambient context. Mobile users take their devices with them everywhere which increases the availability of persons’ traces. Extracting and analyzing knowledge from these traces represent a strong support for several applications domains, ranging from traffic management to advertisement and social studies. However, the limited battery capacity of mobile devices represents a big hurdle for context detection, no matter how useful the service may be. We present a novel approach to online recognizing users’ outdoor activities without depleting the mobile resources. We associate the places visited by individuals during their movements with meaningful human activities using a novel algorithm that clusters incrementally user’s moves into different types of activities. To optimize the battery consumption, the algorithm behaves variably on the basis of users’ behaviors and the remaining battery level. Studies using real GPS records from two big datasets demonstrate that the proposal is effective and is capable of inferring human activities without draining the phone resources.


Introduction
Human's activity recognition has represented an active topic of research for several decades.However, only in the recent years, with the increasing availability and facilities of collecting movement datasets from GSM or GPS equipped devices or even network wireless technologies like WI-FI [1] and RFID [2], have we had the possibility to study users' activities from their movement traces.
Mobile tracking devices, for example, phones and navigation systems, sense the movement of persons represented by positioning records that capture geolocation, time, and a number of other attributes.Sensing is based on a collection of information related to the achieved activity from raw sensor data (GPS, Wi-Fi, RFID, Bluetooth signals, microphone, camera, accelerometers, magnetometers, gyroscopes, barometers, proximity sensors, etc.) to extract a pertinent information about the current activity.In context awareness systems, the challenge relies on developing applications that sense and react to environmental changes to provide a value-added user experience.
As such, the mobile phone is no longer only a communication device, but also a powerful environmental sensing unit that can monitor a user's ambient context, both unobtrusively and in real time.Ambient sensing [3][4][5] has become a primary input for a new class of mobile services like activity recognition.In fact, real-time recognition of users' activities offers the possibility to understand what they are doing at the present moment and estimates their actions in the future.This context awareness property makes this field a major piece that provides services to a range of application domains such as real-time traffic monitoring [6,7], social networking [8], and cognitive assistance.
Smartphones are ubiquitous and becoming more and more sophisticated, with ever-growing computing, networking, and sensing powers.This has been changing the landscape of individuals' daily life and has opened the doors for many interesting data mining applications like activity (2) The majority of related works are based on the classification of historical records of people's trajectories using density based approach (see, e.g., [10]), where they try to identify the most visited place with posttreatment processes, for example, end of the day and every week.These methods fail in their ability to deal with the places less visited by people but important in their trajectories, for example, cemetery and airport, and cannot be used in fields like assistance where we need a real-time access to a person's activity.That is why we propose a new online solution which answers those difficulties.
(3) This work handles not only stationary behaviors but also moving activities like shopping.We introduce the speed and the variance of the orientation of people's trajectories as a new variable in our system for this purpose.
In this paper, we will demonstrate an innovative method to online switch raw GPS data to meaningful human activities.This method uses only a mobile device without network or historical record requirements, while consuming a minimum of mobile resources.The presented approach aims to enrich people's movements, represented in real time during their travel trajectories, with semantic information about the visited places.Our method is based on the real-time recognition of points of interest, "POI" (a place of interest is an (urban) georeferenced object where a person may carry out a specific activity), in users' trajectories.This service increases the use of this contribution, contrasting from economic uses like traffic management, public transportation, commercials, and advertising, to more serious uses like security, police, and risk management.
The following sections detail our contribution: Section 2 briefly reviews related work; Section 3 presents our approach in terms of three major components, that is, trajectory classification, spatial recognition, and activity discovery; Section 4 describes the experimentation by highlighting two dimensions: accuracy and power saving.Finally, conclusion and future focus, as well as the expected contributions, are summarized in Section 5.

Related Works
The emerging concept of activity recognition using mobile devices is a new topic for trajectory data analysis; however, research community's efforts are increasing day by day to carry clear definitions and common understandings [6].We will highlight two parts of related works, works on activity recognition and semantic trajectories and batteryaware works.

Activity Recognition and Semantic Trajectory Works.
Kang et al. in [1] utilized the access point MAC address of a WI-FI network to capture location data on a campus.They developed a time-based clustering algorithm to "extract places" taking advantage of the continuity of the WI-FI positioning.A new place is found when the distance of the new locations from the previous place is beyond a threshold and when the new locations span a significant time threshold.This algorithm is simple and works in an incremental way on mobile devices.However, the algorithm does not consider the reoccurrence of readings at the same location.More simply, each time it discovers a place, it is a "different" place.This also makes it difficult to discover places that are visited with high frequency but short-dwell time.Moreover, this method requires continuous location data collection with very fine intervals and, thus, large storage.Another shortage of this work is linked to the labeling of the discovered places; since it is made manually by authors, the work needs to be improved by providing an automatic way of labeling activities.
A clustering method called CB-SMOT (Clustering-Based Stops and Moves of Trajectories) is proposed in [10]; it is a clustering method based on the speed variation of the trajectory; it is used to infer semantic information from trajectories.Firstly, this method evaluates the trajectory sample points and generates clusters in places where the trajectory speed is lower than a given threshold for a minimal amount of time.In a second step, the method matches the clusters with a set of relevant geographic places defined by the user.However, the shortage in this solution is that data processing is nonincremental; it is not possible to analyze in real time users mobility using this solution.Moreover, as the capture of users' activities is based on stops, this solution fails to recognize moving activities, such as walking in a park.
CityVoyager, presented in [11], is a recommendation system designed for mobile devices, which recommends shops to users based on data analyzed from their past location history.Their system applies location data to the item-based collaborative filtering algorithm, an algorithm used in many online recommendation systems, by transforming location data history into a list that contains the names of each user's frequently visited shops and rating values indicating the user's preference for each shop.Authors track the visited shops by the loss of GPS signal.Nevertheless, it is known that GPS signals are frequently lost in urban areas even when the user is outdoors; these situations increase the possibilities of false detections.Furthermore, it is also known that it is possible to visit a shop without losing GPS signal, in a case where the shop does not include many obstacles hindering the diffusion of the GPS signal; this situation makes these shops unrecognizable by this work.
Authors claim to propose an approach designed for mobile phones.However, there is no adaptation noted to support this demanding environment.For instance, finding frequented shops requires heavy manipulation of the historical records of the users' visited shops.Authors seem to neglect the limited mobile's resources, since there is no support for limited battery life and there is no effort perceived to online detect and find the frequent shops.
In [12], an algorithm is proposed to associate each stop in a user's trajectory to a list of possible visited places and each of these places is associated with a probability.Finally, depending on the kinds of activities associated with the identified place, the trajectory is classified into probable trajectory behavior.In this work, authors assume the moving object is a person that travels using transportation means associated with a traceable (GPS) device (car, bus, metro, or train).The person gets off the transportation means to walk to the final destination.During this time interval, the person is not traceable; accordingly, authors have used probabilities to find the visited place.This work uses numerous thresholds that are set manually as minimum duration of an activity.Nevertheless, since these parameters may depend on user profiles, this work may be ineffective on large datasets that contain several profiles.
While developing a rich body of work for managing moving objects, the research community has shown a little interest in the online recognition of POI in users' trajectories.The majority of related works are based on the classification of historical records excluding problems linked to mobile's performance, like battery life and low-computational capacities.
Moreover, nearly all approaches are based on the detection of stops within people's movements, neglecting activities with movements, and only a minority of these studies try to automatically identify the background geographic information, since generally we request a set of relevant geographic places defined manually by the user.
The majority of outdoor activity recognition approaches use a fixed activity's minimum duration threshold that represents the minimum time a user has to spend in the POI (place of interest) to be declared as visited place.This threshold prevents false activity detection, such as traffic jams.However, previously fixing this threshold will increase error probability because when set to a small value, it will increase the number of false activities, like passing by a POI; setting it to a high value will miss detection of some short-dwell activities, such as buying cigarettes at the convenience store.Thus, we propose a novel approach to online recognize users' visited places; our algorithm will be totally unsupervised, which operates without any beforehand fixed threshold.

Battery-Aware
Works.The problem of power management on mobile devices has been well-explored.Viredaz et al. [13] surveyed many fundamental but effective methods for saving power on handheld devices.These methods concern a range of phone components such as processor, memory, display screen, audio system, and wireless networking.It has been suggested from the architectural point of view that the system hardware should be designed as a collection of interconnected building blocks that could function independently to enable independent power management.
In [14], authors proposed a dynamic frequency/voltage scaling (DVS) to reduce power consumption by configuring the processor based on the requirements of the executing applications.It is recognized as the basis of numerous energy management solutions [15].DVS exploits the fact that dynamic power consumption is a strictly convex function of the CPU speed and attempts to save energy by reducing the supply voltage and frequency at runtime.Hence, the power-saving scheme should be fully customized for realtime power consumption situations and specific application requirements.However, these methods are more suitable for lower-level system design rather than application development.
Shih et al. [16] introduced a technique to increase battery lifetime of a personal digital assistant-(PDA-) based phone by reducing its idle power, the power a device consumes in a "standby" state.To do so, they essentially shut down the device and its wireless network card when the device is not being used, avoiding energy waste while not activated.The device is powered only when an incoming call is received or when the user needs to use the PDA for other purposes.
Authors in [17] have gone further by proposing a whole framework of Energy Efficient Mobile Sensing System (EEMSS) for automatic user-state recognition.The core component of EEMSS is a sensor management scheme for mobile devices that operates sensors hierarchically, by selectively turning on the minimum set of sensors to monitor a user state, and triggers new set of sensors if necessary to achieve state transition detection.Energy consumption is reduced by shutting down unnecessary sensors at any particular time.
As seen above, significant efforts have been undertaken for a wise use of mobile resources; however, the proposed techniques try to limit the calculation capacities to gain in battery life.Our perspective is different from this one.We propose a self-adaptive approach that changes dynamically the calculation capacities on the basis of battery life and user state.Our work will also stand out by the flexibility that it offers to users, since they have the freedom to choose the degree of austerity in the use of the battery.

Overview of the Approach
We assume the person is GPS traceable via a smartphone.Usually, a person's activities are divided into two

POI POI
Moves "C 3 " Moves "C 3 " Stop "C 1 " Moving activity "C 2 " behaviors: stationary and nonstationary, where the second one is also divided into two categories moving to reach a goal and moving to do a goal.
For example, working in the office is a stationary activity while going from the workplace to a shopping center is nonstationary activity; shopping itself is also a nonstationary activity, but the goal is to do shopping, so it is an activity with movements (see Figure 1).Based on these concepts we introduce 3 types of clusters: (1) Stop concept, represented by " 1 ", characterizes stationary activities.
(2) Activity with movements " 2 " is nonstationary activities that require movement over a time interval.
(3) Moves, represented by " 3 ," are a set of actions that aim to move from a POI to another.
To deal with all these concepts, we present in Figure 2 the overall approach of our activity recognition mechanism.
In the first step, we introduced a real-time classification method based on -means to classify every new position data according to the three families (stops, moves, and activity with movements).At the same time, we observe the accumulation of types of clusters, such that, after a certain threshold of the same cluster's accumulation, we conclude that the person is probably doing something interesting.For the second step, we summarize the accumulated clusters to a probable POI and we begin a geospatial research for the closest and the most meaningful geographical entity.If the research process succeeds, we determine this point as a POI.The third step is to assign the POI to an activity, like a museum to a tourism activity and gym to a sports activity.

3.1.
Step 1: Trajectory Classification.The aim of this step is to incrementally classify the continuous users' positions into different kinds of activities.The most recent sequence of GPS collection is stored in a temporal window called TW. Definition 1. GPS collection is an assembly of GPS points  = { 1 ,  2 , . . .,   }.Each GPS point   ∈  contains a latitude (  .lat), a longitude (  .Lngt), a timestamp (  .), a speed (  .),and a bearing (  .).We add to this information the variance of bearing (  .) of the last  TW GPS points where  TW is the size of our temporal window TW and the weight (  .)represents the importance of the point   according to the time generation.Definition 2. Temporal window TW is a subgroup of a GPS collection with a variable length  TW .In fact TW contains all   with not null weight   .(see Figure 3 that represents the relation between a GPS collection and TW; every point in the GPS collection is a record row from the database).
Once new GPS data is received, we achieve three parallel processes like below.

Process 1: Classification. At the arrival of new GPS data,
is stored in TW.Classification process is not launched on every data arrival but after a threshold called  min that will be exposed in process 3. We classify   in TW using online means; we consider two variables, speed   .and variance of bearing   ..
The variance of bearing   . is calculated using this formula:   .= ∑(  −   )/, where   = ∑   / TW ; this calculation is made before recording the new   in TW and it represents the variance of user's orientation in the last  TW   .
Stops behaviors are characterized by a very low   .and   .;however, moves behaviors are characterized by high   .and low   .because a person's movements using transportation tend to be in a quick and straight manner.Moving activities are branded by a low   .and high   .(see Figure 4) since these activities are pedestrian actions which generally require a frequent shift of orientation like visiting a museum, shopping in a mall, or walking in a zoo.As said previously, these three types of clusters represent three families of activities and not three activities, each family containing a set of activities depending on the user's visited places.
Note that it is known that when a user stops somewhere, his positions during this stop may vary in the surroundings of the stop due to the positioning error of the tracking system.Consequently, in our algorithm, we automatically put

Stops Moves
Variance of orientation the bearing   .→ 0 when we detect that the speed   .→ 0 to avoid any error linked to this situation.

Process 2:
Distribution of Weights   ..Every   has a weight which determines the degree of resemblance of   's class to the current activity.Our methodology is inspired from the work in [18]; the weight of each data point decreases exponentially with the time  via a fading function   = () = 2 − , where  > 0. The exponentially fading function is widely used in temporal applications where it is desirable to gradually discount the history of the past behaviors.The parameter  is called exponential decay constant; the higher the value of , the lower the importance of the historical data compared to more recent data.The overall weight of the data stream is a constant  = ∑ where   (  → ∞) is the current time. can also be seen as the determining parameter of TW's length.When  approaches 1, TW shrinks to its smallest size.Inversely, when  approaches 0, TW spreads to its maximum size (see Figure 5).
Unlike [18], we chose a variable value of  between 0 and 1 depending on two parameters, the remaining battery level "" and the disorder of data "" that already exists in TW (class of every   ); the disorder is introduced in order to have an idea of the user instant state; for instance, if we have enough information on the user instant activity, there is no need to use a lot of data since the decision about the instant activity is already made; however, when the user state is difficult to be recognized, we will need more data to be able to detect the user activity; this ability to make a decision is called "disorder of data."Thus, these parameters are defined in the following definitions.
Definition 3. The remaining battery level is represented by  =   / th , where   is the real remaining battery level. th represents a battery threshold specified by the user from which the algorithm starts to minimize calculation (see Figure 6).This user-defined parameter adds some flexibility to the application.For instance, if the user prefers to keep good precision even if it drains the mobile battery,  th should take a small value (e.g., 10%).Conversely, when the user aims for a good preservation of the mobile battery,  th should be given a higher value of around 90% or 100%.Again, when the user knows that he will not spend much time outside, he can adjust  th to a small value to promote the precision and vice versa.
Definition 4. The disorder of data  represents the quality of TW's data that has a link with the ability to make a decision.When one is sure that an activity is performed, one needs less data to make a decision so  → 1, and  → 0 when one has problems finding out what type of activity is executed.In other terms, when the user behavior is unpredictable (because the data in TW is heterogeneous) one says that there is a disorder in his data ( → 1).Contrariwise, when one sees that the user behavior is stable, one says that there is a stability in the user data ( → 0).
The disorder of data is often calculated using the entropy, which is a measure of unpredictability of information content, or, in other terms, it measures the homogeneity in a set of information.Consequently,  is calculated using the entropy of Shannon [19];  of the new   is calculated using the entropy of the old data set in TW.The value of  is calculated as follows: where   =   /.After introducing the remaining battery level  and the data disorder , we propose a relation between the two parameters to calculate ; we put The equation demonstration is shown below.
Demonstration.Our reflection starts from the following logical rules: (1) We shrink the TW's length to reduce the number of clustered points (in order to reduce battery consumption) when the battery is low or when we have some certitude about the user's activity, in other terms, stability in the user's behavior characterized by a low disorder of data.
(2) We spread the length of TW when we need numerous position points to make a decision (high disorder in the user's TW data) as long as we have enough battery level.( If we parse the characteristics mentioned in (3) into a mathematical representation using the relations presented in Table 1, then, (3) will be written as follows: Let , , and  be Boolean parameters that take values as mentioned in Table 2.
The logical rules in (4) can be illustrated in the truth table, Table 3.
We notice that the truth table, Table 3, is that one of the Boolean implication function, where  ≡  (, ) ≡  ∧ ¬ ≡    → boolean .
(5) In Boolean logic, the truth values of variables may only be 0 or 1; however, our parameters , , and  take continuous values between 0 and 1.For instance,  = 1 means full battery and  = 0 means empty battery.Yet, in real life, there are many states between full and empty states.As such, the fuzzy logic was introduced [20] which is a form of many-valued logic in which the truth values of variables may be any real number between 0 and 1. Fuzzy logic has been extended to handle the concept of partial truth, where the truth value may range between completely true and completely false.In this context, our equation is called fuzzy implication: Using the inequality of Reichenbach [21], the fuzzy implication can be written as  =  (, ) = 1 −  + .
This equation has been tested in Figure 7 where we varied the two parameters  and  to observe the sensitivity of  (the length of TW) to these changes.In Figure 7, we notice that the sensitivity of TW's size (the value of ) is linked to the battery level  and disorder ; however, when  begins to drop, the size of TW continuously ignores the disorder  until it reaches a total ignorance when  = 0 (see Figure 7 when  = 0).
After having distributed the weights of each   in TW and calculated the size of TW on the basis of the battery level  and disorder , it is time to see if the user is performing some interesting activity.

Process 3: Cluster's Accumulation
Search.The algorithm recognizes that someone is doing an activity if the weight of its cluster   exceeds a value , where  = / with  representing the number of clusters (activities) used by means to classify TW; in our case  = 3 because we are trying to identify three families of clusters: stops; moves; and moving activities.
The most important question is "when do we search for a cluster accumulation?"To minimize the use of device resources, it is recommended to handle this step carefully.The research process is not launched on every data arrival  but after a time called  min in which it is expected to have an activity.Consequently, on every  min we check if there is any activity that its weight   exceeds ; if found, we summarize the points   to one point   (  ,   ), where   = ∑  =0   and   = ∑   /,  is the number of points in this cluster, and   represents the points   in the cluster .After that we move to the spatial recognition of the summarized point   .
As said previously,  is not static.It varies between 0 and 1 depending on the disorder of data in TW and the remaining battery level.From the relation between  and  min in Figure 8, we note that  min is also affected by these parameters.When  is near 1, TW will contain a minimum number of position points (see Figure 5) for the reason that the battery is low or there is some stability in the user's behavior (e.g., staying at home); in this case, there is no need to process the calculations on every step; otherwise, this useless calculation depletes the battery.Consequently,  min will take a maximum value (see Figure 8).
Conversely, when  is near 0, TW will contain a maximum number of position points (see Figure 5) for the reason that the battery is well charged and there is a big disorder in TW which troubles the users' activity identification.In this case the algorithm will process the calculations on every position-point arrival to quickly determine which type of activity the user is performing.Accordingly,  min will take a small value (see Figure 8).
Algorithm 1 achieves two processes; the first is to store every GPS data   when it arrives; the second is performed every  min to reduce the calculation.First step is to classify every point   in TW and then update the value of  depending on the disorder of the activities types in TW and the remaining battery level.After calculating the center of gravity   of each cluster and the threshold , we start to search for an accumulation of a cluster that is verified by the condition max(  ) > ; we use the max of clusters' weight to avoid the case where two clusters exceed  in the same time; if condition is verified we start to recognize the geographic environment of   .Finally, we update the value of  min that will determine the next repetition of the process.After searching for a cluster's accumulation, we move to Step 2, spatial recognition of   .

3.2.
Step 2: Spatial Recognition.This task aims further to understand the movement behavior of users, in terms of more semantically meaningful POI.In this step, we are going to transform a cluster of GPS points to an expressive human activity.First we are going to search for the nearest geographic entities to this cluster; thereafter, we are going to associate an activity type to the entity found.
We search for the closest and the most significant geographical feature compared to   ; it is performed using a spatial query in a spatial database.Our database is powered by OSM (OpenStreetMap (OSM) is a community-driven project aimed at producing a high-quality detailed map of the world; OSM datasets are freely available under the Open Database license terms) and stored in the users' device for local use.This technique aims to discard networks use by offering offline services that will save a user's money and a phone's battery.
In fact, many mobile GIS solutions [22,23] offer an offline version to avoid the constraints linked to the use of networks.For instance, Esri company [24] (one of the world's biggest GIS companies) has provided a whole runtime called "ArcGIS Runtime mobile SDK" [25] to support offline mapping; it includes map viewing, interaction, editing, and routing while fully disconnected from wireless.
Consequently, offline processing of geographic data has become easier.However, the limit of this technique is the size of the stored data, since geographic data may cause a massive use of the storage capacity; for instance, the size of the OSM planet database is over 666 GB [26].The usual solution to face this problem is to download a specific database to each user depending on the cities where they live (e.g., the size of the whole New York region is only 140 MB [27] including all geodata types such as roads, highways, buildings, and public parks); this can be done manually by the user, since he can define his area of interest while being online by choosing the area to download and panning/zooming to the area of capture.The second way is to download the geographic database automatically by the application by detecting the user's daily staying area; for instance, if the application detects that the user is living in Montreal city, it will wait until being online to download the OSM data of Montreal and its surroundings.
Many techniques to extract geographic data from OSM exist; the easiest way is to download and extract it from the OSM website.There are various web services that provide data extracts for a geographic area.For example, GeoFabrik is a company which specializes in working with Open-StreetMap.They provide a variety of free extracts in Shapefile (the Shapefile format is a geospatial vector data format for geographic information system (GIS) software) and raw OSM format on their download website (http://download .geofabrik.de/).After downloading raw OSM data and storing it in a spatial database, we use Algorithm 2 to search for the nearest spatial feature to   .
The querying process to search for the closest geographic entity is a famous technique based on identifying a proximity buffer; proximity analysis determines the relationship between selected geographic elements by identifying the locations of other elements within a specified distance (50 m in our case).Creating buffer zone regions is the most common method used in proximity analysis; for more details about the querying method please refer to the paper described in [28].
If the spatial recognition step finds a geographic entity in the neighborhood of the positions' cluster we can declare that the user has visited this place.

3.3.
Step 3: Activity Discovery.Activity discovery is based on the exploitation of tags in OSM.OpenStreetMap data adhere to a simple XML schema with three basic elements: (i) nodes, that is, single geospatial points; (ii) ways, intended as ordered sequences of nodes; (iii) relations, grouping multiple nodes and/or ways.Each element includes a unique identification code, latitude and longitude coordinates, versioning information, and optional general-purpose informative tags.A tag is a key-value pair of Unicode strings of up to 255 characters.Each tag describes a specific feature of a spatial data element (see [29] for more details).This step permits having a human meaningful semantic information about the user visited place.
Tags are written in OSM documentation as key = value.The key describes a broad class of features (e.g., highways or names).The value details the specific feature that was generally classified by the key; for example, the geographic entity that contains a tag "building = apartment" represents a building arranged into individual dwellings, often on separate floors.
We assume that each tag represents an activity and each activity belongs to an activity family (see Figure 9).
Activities are organized in a taxonomy which generalizes the kinds of activities of interest for the movement analysis.For example, the "going to college" activity can be specialized in "education."Subsequently, for example, if the nearest geographic entity to   has a tag "amenity = library" we deduce that the user is doing an educational activity in the library.This is performed using an algorithm (see Algorithm 3) that searches for the nearest geographic entity and extracts its tags to deduce the activity achieved.This taxonomy is also used to mine quickly users' past activities; for instance, if we search for the public transportation taken by the user, we just have to specify the activity type as "Transportation" in the SQL request and search for the transportation mode (bus station, taxi station, etc.).
Depending on the application requirements, the activity discovery process can extract further information about the visited POI, such as the address, the number of floors, the opening hours, and the building height.This semantic information permits enhancing the way users perceive and interact with their surroundings; for instance, authors in [30] proposed a system for a mobile navigation assistant fit for the purpose of moving within a complex built space.Their process of semantic-enhanced POI discovery is based on the exploitation of OSM tags, the same as our method; the results are used in an augmented indoor/outdoor navigation system.

Experimental Evaluation
In order to test our approach, we will divide the experimentation section into two parts: first, we will test the accuracy of our approach using the Family Coordination dataset [8] by comparing it with CB-SMOT method; then, we will test our approach's ability to save battery life by comparing our solution to LifeMap application described in [31].

Family Coordination Test
4.1.1.Dataset.We used the dataset described in [8] where researchers have conducted experiments in order to reveal the underlying causes of coordination that a routine learning system might be able to address.They tracked GPS locations of the members of six families during six months in Pittsburgh City in Pennsylvania, USA (see Figure 10); researchers made an effort to recruit a wide cross section, selecting families from a variety of ethnic and economic backgrounds, as well as expressing a variety of planning styles, child-rearing models, and transportation preferences.The GPS sampling for every family member including children (a total of 26 persons) was set at oneminute intervals which led to gathering more than two billion and half of GPS points.Moreover, every night during the study, a member of the research team would call the families and interview each parent about that day's management of their kids' activities.In preparation for the interviews, family members were asked to input their daily activities into a webbased survey.Researchers then used the survey to scaffold the phone interview, probing and documenting the overall family logistical plan at each point throughout the day.We used this information to compare the inferred activities to the real executed activities.

Test Scenario.
We compared our solution to CB-SMOT algorithm [10] described in the related works; CB-SMOT is widely used to extract visited places from locations' trajectories; we have implemented this algorithm using Weka-STPM platform [32], an extension that adds trajectory processing tools to Weka (Waikato Environment for Knowledge Analysis) and includes CB-SMOT as a clustering algorithm; however, since Weka-STPM is a desktop solution, we have created a mobile version using the CB-SMOT class included in Weka-STPM.The input was the Family Coordination dataset parsed into a Postgresql/PostGIS database and the output was the inferred semantic trajectories (tracking visited places retrieved using Weka-STPM).
Our solution was implemented using Huawei P7 android phone where we have deployed our application that contains the online recognition algorithm, Family Coordination dataset, and a SQLite database that contains the geographic entities of Pittsburgh city needed in the spatial recognition process.Note that, as said previously, this first part of the experimentation is dedicated to testing our approach in terms of accuracy; consequently we will suppose that the phone's battery is fully charged during all the processes principally because we do not have access to the battery's life data in Family Coordination dataset.The ability to save the phone's battery and its impact on the accuracy will be presented in the second part.4 represent the comparison of our approach with three versions of CB-SMOT algorithm, by varying its MinTime parameter each time; it was set to 60 s in version 1, to 180 s in version 2, and to 500 s in version 3.

Results. Results presented in Table
We have tested 10525 activities gathered from the activities of the 24 members of families.
Correct activities represent the number of activities recognized successfully, missed activities represent the number of activities that the users did but the algorithms have failed to recognize, and false activities represent the number of meaningless discovered activities like recognizing the stop of a car in a traffic jam as going to gas stations.The accuracy and the error are calculated as follows: Accuracy = Correct number of tested activities , Error = missed + false number of tested activities .
Globally, our algorithm behaves better than CB-SMOT in terms of accuracy and error.We have recorded the accuracy of 78% in our solution and 61% for the average accuracy of the three versions of CB-SMOT.On the other hand, our error was around 22%, while the average error of the three versions of  CB-SMOT was around 50%; these results are explained in the following points: (i) Our algorithm succeeds in recognizing more activities because it supports the recognition of moving activities; contrariwise CB-SMOT recognizes only stop and move activities (see Figure 11).(ii) CB-SMOT shows a higher error because of the MinTime threshold that is set manually (the time of staying from which the algorithm considers that the user has visited this place).Setting this threshold to a small value will increase the number of false alarms (see CB-SMOT V1 in Table 4), while setting it to high value will increase the number of missed activities (see CB-SMOT V2 in Table 4), and, in both cases, the error will be increased since it is calculated on the basis of the number of false and missed activities.
After having tested the accuracy of our approach, we will go further in the experimentation of our battery saving technique.The tracking application (called LifeMap) was running as a background service to automatically collect the user's mobility and to trace sensor usage time.To collect the ground truth, the participants explicitly labeled the place names and kept a diary of places they had visited with the entrance and departure times.Moreover, the advantage of using such dataset is the ability to compare the power consumption of our method to the authors' one, since authors tracked the battery status during all the experimentation process.

Test Scenario.
In this step we will compare our approach to the LifeMap application used to recognize users' motility; the project can be found in [2], the LifeMap dataset can be found in [33], and the LifeMap mobile application can be found on android play store.
We used the LifeMap dataset to test our battery-aware approach; to do so, we developed an android application that is fed by LifeMap datasets; the main idea is to make it out as if the users have moved holding our application in their phones; the application recuperates the GPS coordinates one by one and processes each point using our online approach; after that we compare the battery consumption of our application with LifeMap application's one (see Figure 12).
LifeMap application uses a set of sensors to recognize users' activities; these sensors include GPS, accelerometer, digital compass, and Wi-Fi; the application uses a combination of these sensors to retrieve the activity performed by the user; it is clear that the use of all these sensors represents a major source of power consumption.Consequently, in order to bring an objective comparison between the LifeMap application and our application, it is logical that we have to include the same sensors even if we use only the GPS sensor.Indeed, we have enriched our application with the same sensors used in LifeMap application but the processing of this information is made under the rules defined by our battery-aware approach; for example, the processing of data is made on the estimated  min that is calculated on the basis of the remaining battery level and the user's behavior.
Moreover, even if the GPS is activated, the application consumes more resources when it requests the users' position from the GPS satellites (the case of LifeMap) than when it retrieves it from a database (the case of our application); consequently, in order to compare objectively the two approaches, we continue to obtain the user position from the database; however, on every point retrieved, we request the GPS satellite for a GPS position.Surely, this position is useless but it enables consuming the same resources used by LifeMap application to get a GPS position.In order to automatically recognize users' activities, we have constructed a Spatialite geodatabase [34] where we stored the background geographic data needed in our spatial recognition (see Figure 13).Note that users' locations are recorded on different frequencies; authors in LifeMap dataset have linked the activity declared by the user to the sampling frequency in order to minimize the size of the database and the power consumption, which has sometimes led to low frequencies (e.g., every 10 minutes).In our approach, we try to recognize accurately users' activities while protecting their phones' battery; to test this service, we need to increase the sampling frequency to see if our work well behaves using a lot of location points.Consequently, we have implemented an interpolation algorithm that estimates the missing locations when the sampling frequency is high (more than one minute).
Our application was deployed on Samsung Galaxy S smartphone, one of the smartphones' models used by LifeMap application to recognize activity.
After having filled the necessities regarding the comparison between the two approaches, we will present the results of both of them.

Test Results
. The total number of recorded hours of battery status in LifeMap dataset is 48900 hours; in order to experiment on all the hours using one smartphone, we will need over five years of experimentations.Accordingly, we chose to use one random day of each user (rather than 30 days) using five smartphones; the total number of hours compared is 1632 hours.Due to insufficient space, we present  in Figure 14 the tracking of one user's battery life for 72 hours using LifeMap and three versions of our approach where we vary each time the value of the threshold  th from where the application starts to save battery life.
orientation.After detecting an important accumulation in a cluster's weight, the cluster is summarized into one point and another process will be launched that aims to search the most meaningful geographic entity near this point (POI); when found, we associate a semantic activity to it.Aiming to save phone batteries, our algorithm was implemented to change its computational complexity on the basis of the remaining battery level and the users' behaviors.
Our approach has been experimented in a real case study to test the accuracy of our recognition mechanism and to observe the impact of our technique on phone's resources.These tests demonstrate that, with a minimum of information, our proposals are capable of online recognizing a person's activities without depleting the phone resources.
Several promising directions for future works exist.First is the enhancement of spatial recognition process with the introduction of probability to assign a cluster to a geographic entity; this probability approach can take advantage of previously recognized activities; for example, a person doing tourist activities all day has more probability to finish his day in a restaurant or in a hotel than in other places.The second enhancement that can be applied to our inferring process is users' profiling.In fact move's pattern of individuals varies between young and old, healthy and sick, and male and female.The implementation of such reflections will improve the accuracy of our activity recognition process.

Figure 3 :
Figure 3: The relation between the GPS collection  and TW.

Figure 4 :
Figure 4: Inferring activity type using speed and the variance of orientation.

Figure 5 :
Figure 5: The impact of varying  on TW's length.

Figure 6 :
Figure 6: An example of  variation using a threshold  th = 50%.

Figure 7 :
Figure 7:  variation on the basis of  and .

Figure 9 :
Figure 9: The taxonomy of activities.

Figure 10 :
Figure 10: An example of our Spatialite database that contains the geographic entities of Pittsburgh.

Figure 11 :
Figure 11: An example of one user's GPS locations projected on the geographic entities layer of Pittsburgh; (A) stationary activity, (B) moving activity, and (C) moves.

Figure 12 :
Figure 12: Test scenario to compare our solution with LifeMap application using LifeMap dataset.

Figure 13 :Figure 14 :
Figure 13: An example of one user's trajectory projected on (1) OpenStreetMap raster layer and (2) vector layer retrieved from our geodatabase.

Table 1 :
Mathematical representation of the user, battery, and TW states.

Table 3 :
The truth table of , , and .
These conditions are sited as follows: Battery high + high disorder → TW spreads, Battery high + low disorder → TW shrinks, Battery low + high disorder → TW shrinks, Battery low + low disorder → TW shrinks.

Table 4 :
Comparison of our approach to CB-SMOT algorithm.