Static force field representation of environments based on agents’ nonlinear motions

This paper presents a methodology that aims at the incremental representation of areas inside environments in terms of attractive forces. It is proposed a parametric representation of velocity fields ruling the dynamics of moving agents. It is assumed that attractive spots in the environment are responsible for modifying the motion of agents. A switching model is used to describe near and far velocity fields, which in turn are used to learn attractive characteristics of environments. The effect of such areas is considered radial over all the scene. Based on the estimation of attractive areas, a map that describes their effects in terms of their localizations, ranges of action, and intensities is derived in an online way. Information of static attractive areas is added dynamically into a set of filters that describes possible interactions between moving agents and an environment. The proposed approach is first evaluated on synthetic data; posteriorly, the method is applied on real trajectories coming from moving pedestrians in an indoor environment.


Introduction
Analysis of trajectories performed by moving entities in environments is an important topic for different fields such as video surveillance [1], crowd/vehicle analysis [2,3] and in general for monitoring systems, on which the dynamics of agents can lead to a better understanding of patterns and situations of interest [4,5]. Abnormality detection is one of the most explored applications that involves analysis of trajectories. In such approach, by characterizing agents' motions, it is possible to learn and identify normal/abnormal situations in a certain environment.
In general, approaches for abnormality detection are based on a set of observations that define the regular behaviors in a scene. Afterwards, abnormalities are defined as behaviors that do not match with patterns previously learned as normal, i.e., behaviors that have not been observed before [6]. Accordingly, observations that deviate from the characterized normal patterns are classified as potential abnormalities. Abnormality detection has been successfully used in real applications such as identification of hazardous * Correspondence: damian.campo@ginevra.dibe.unige.it 1 University of Genova, Department of Naval, Electric, Electronic and Telecommunications Engineering, Via all'Opera Pia 11, Genova, ITA Full list of author information is available at the end of the article massive crowds [7,8], recognition of group activities [9,10], traffic event classification [3,[11][12][13][14], detection of anomalies in maritime trajectories [15,16], among others.
The recognition of motion patterns and interactions from trajectories is a challenging task, in particular when dynamics of moving agents are nonlinear through time and space. Moreover, a quick analysis of existent bibliography shows that current methods usually claim robustness and reliability for highly restricted scenarios, broad sensor availability and short video footages [17]. To alleviate these issues, a common approach is to represent the state of agents under a probabilistic framework and characterize the motion patterns by following a nonlinear Bayesian state estimation. This approach has been successfully applied in surveillance environments and complex motion patterns [12,18].
In the present work, abnormalities from a proposed baseline model are used to parameterize characteristics of environments by looking at trajectories of individuals in an online way.
The majority of approaches that deal with analysis of trajectories are focused on characterizing agents' dynamics through time [19][20][21] or learning interactive forces exerted by multiple moving agents. The latter can be understood as an evolution of the seminal paper of Helbing and Molnár [22], on which crowd motions are described by a combination of simple interactive forces between pedestrians. The methodology proposed by the authors is based on social force models, a concept originally introduced by [23]. In a recent work, Seer et al. [24] extend the work of Helbing by using three different shapes of social forces models, namely radial [22], elliptical [25] and a split version of forces [26]. The work of Seer is evaluated on real pedestrian trajectories.
A common trend in existent works, is the characterization of moving agents' trajectories based on their interactions among them, without taking into account the environment and its effects in the state of agents. Our work is motivated by the approach of Seer [24], with the main difference that the motion of our agents is characterized by environment forces revealed hierarchically due to interactions of the type agent-static zone.
This work tackles the analysis of moving agents in cases where the only information available is their location through time. The proposed strategy can be used in places on which a detailed map is unknown but agents' positions can be obtained via GPS or other localization systems like Wi-Fi fingerprint for indoor environments [27,28]. Furthermore, the proposed approach provides information of the moving agents' surroundings that can be useful in cases of places monitored by cameras that provide noisy measurements, partial/full occlusion or scenes with illumination changes [29].
The present work proposes a bank of Kalman filters (KFs) that explains the motion of agents in a hierarchical way. Models obtained from the bank of filters are incrementally learned by looking at abnormalities or deviations from a reference formulation based on a random walk behavior, such idea was first presented in [30], where an off-line non-parametric method was proposed to characterize effects of static external objects in simulated environments.
In the current work, dynamical models that describe agents' motions can be used to hypothesize a semantic representation of the environment effects [5,31]. In other words, the agents' motions incrementally reveal characteristics of the environment. By considering a Bayesian approach, the proposed method learns sequentially the nonlinear dynamics of moving agents over segments in which their orientations are relatively stable. Consequently, such segments can be seen as letters that are part of a vocabulary learned dynamically. As a future work, these vocabularies are proposed to be used for identifying normal and abnormal situations related to environment's characteristics revealed on the fly.
The novelties of this work are itemized as follows: i) It is proposed a Bayesian approach for understanding the physical and non-physical surrounding areas of moving agents based on their nonlinear dynamics. The proposed formulation allows to characterize parts of environments individually by using a bank of filters that encodes information about learned models in an incremental way. ii) A parametric force field model based on a switching process is proposed to understand agents' motions. Such model includes information about how static areas influence the dynamics of moving agents. Additionally, only agents' positions are necessary to understand the effect produced by static areas through time. iii) The proposed methodology does not need a broad sensor availability, since only location information is needed, any type of trajectory can be analyzed and modeled. Our approach is evaluated on synthetic data and real trajectories of pedestrians in an indoor place.
The rest of this article is organized as follows: A description of the agents considered in this work is provided in Section 2. Force model and problem definition are described in Section 3. A hierarchical representation of the environment is explained in Section 4. Results obtained with synthetic and real data are given in Section 5; and Section 6 concludes the article.

Agent paradigm
This work proposes a method for identifying and characterizing attractive areas in environments based on observations of cognitive entities that move through them. Accordingly, the present approach assumes that such moving entities can be represented as goal-based agents described in the work of Russell and Norvig [32]. Decisions made by such class of agents are based on a cognitive perception of their surroundings combined with a goal to be achieved. As can be seen in the diagram shown in Fig.1, the agent's goal plays a fundamental role at the moment of taking a decision.
In this work, agents' goals are considered to be areas in the environment where agents tend to go. For modeling such areas, it is considered to use a formulation based on social force models. An idea introduced by Helbing and Molnár in [22] for understanding pedestrian dynamics. Consistently, each main effect described in their work is here contextualized with the final purpose of explaining effects produced by unknown attractive areas in environments.
Helbing and Molnár propose that there are three main effects with which the motion of single pedestrians can be explained: i) Destination to reach: It consists in the shortest path to follow in order to go towards a goal. ii) Influences caused by other pedestrians and barriers: In which they define a repulsive force  Figure 1 Goal-based agent. Schematic diagram of an agent with explicit goals proposed by [32].
model for describing the effect that pedestrians exert among others at the moment of avoiding people. They also propose a repulsive model to explain the effect of barriers, such as borders of buildings or obstacles.
iii) Temporary attractive effects: They define a model that explains the sudden attractiveness that could be experienced by a pedestrian, it is the case of feeling attraction to other people (friends, street artists, etc.) or going towards static objects such as window displays. Based on the three main effects described previously for understanding pedestrian dynamics, it is proposed to use the same reasoning to understand goal-based agents dynamics. From this viewpoint, main goals are assumed to be represented as i) Destinations to reach that can be modeled as attractive fields in the environment. ii) Influences caused by other pedestrians and barriers and iii) Temporary attractive effects are proposed to be modeled as noise that deviates agents from their main destinations. Accordingly, the diagram in Fig.2 explains the proposed model to understand the dynamics of moving agents in a scene.
In literature, the majority of works that deal with analysis of trajectories are focused on modeling and learning agents' motions through time [4,12,16,[19][20][21]. However, in the proposed methodology, since an interaction between agents and the environment is assumed, it is useful to consider an attractive force model for explaining agents' dynamics. Such model includes information about environment properties that define how moving agents are influenced by static areas in the scene. Accordingly, when an agent's motion pattern is observed, the understanding of environment static characteristics is enriched.
By considering that dynamics of agents can be seen as the result of external forces acting on them, it is possible to associate such forces with the internal motivations that make agents perform certain actions (movements) [22] in order to reach a particular destination.  Figure 2 Schematic representation of processes that induce behavioral changes. Proposed scheme to represent the motions of agents based on [22].
From this perspective, each destination point is proposed to be modeled as an attractive area that exerts a force field in the environment. The methodology proposed in this paper aims at the incremental understanding of attractive effects that static areas exert over moving agents. This work can be seen a method to improve the situation awareness (SA) of an environment by looking at moving entities. Formally, SA is defined as "the perception of elements within a volume of time and space, the comprehension of their meaning, the explanation of their present (observed) status and the ability to project the same in near future instants." [33]. Subsequently, the methodology proposed in this paper increases the SA of environments incrementally as agents' motions are observed.
As an individual agent model is proposed, the current method aims at the understanding of agents' surroundings in terms of attractive areas (goals) in cases where interactions with other agents are momentary, i.e., in situations where interactions between individuals can be modeled as a noise parameter. In cases of multi-agent systems composed by a large density of individuals as proposed in [34], the main goal of agents can be confused with the constant evasion of multiple individuals and the proposed approach would not work properly. Based on that, our method is focused on cases where there is a low density of agents that interact with each other.

Force model and problem definition
Taking into consideration a classical mechanics approach, a force is defined as a vectorial quantity that acts on a body to cause a change in its state of motion [35]. Forces can be classified in action-reaction pairs: When bodies, which are in contact, change their momentum [35] and action-at-a-distance forces: When agents interact without being physically touched [36]. Throughout this work, motivations of agents are modeled as action-at-a-distance forces that can be characterized by looking at the motion of individuals.
A force field F is defined as a vector point-function which has the property that at every point of the space takes a particular value related to the magnitude and direction of a force acting on a particle placed there and whose mass is considered as one [37]. Accordingly, moving agents' dynamics are used to learn the effects produced by force fields in the environment.
A central force field F = f (r)r is a particular case of fields where the motion of agents is affected depending on the distance r to the location of an attractive/repulsive force source, called center of force. r is a unit vector that points in the direction of r. Based on that, this article proposes radial force fields for modeling dynamics of agents through time.
For characterizing the effect that an attractive area exerts over moving agents, it is considered the second Newton's law F = m a, where m = 1 as proposed before. Therefore, it is direct to infer that F = a, i.e., the force exerted by an attractive area in the environment can be measured as the agent's acceleration at a particular point where it is located.
It is hypothesized that information about the agent's speed V (t) can be inferred through time t. Then, it is possible to relate agents' speeds with their accelerations as can be seen in equation (1): where t 1 and t 2 are two consecutive time instants, a t1 represents the force magnitude that acts over an agent at time t 1 and c is an integration constant that represents the agent's velocity V t1 at the instant t 1 . By considering a number of n spatial dimensions from which trajectories of moving agents are observed, the location of a single agent can be expressed as shown in equation (2): The velocity field experienced by an agent influenced by a central force field in terms of its location X is shown in equation (3): where it is possible to observe that dependencies of time t can be substituted by spatial coordinates X . Since force fields are fixed in one location and their influences are assumed to remain equal through time, agents' dynamics will depend only on their own location X . A switching model is proposed to characterize the velocity fields perceived by agents due to the presence of attractive radial force fields. Based on this, two motion stages are defined: i) When the agent is near to an attractive center of force (near range of interaction) and ii) When the agent is far from it (far range of interaction).

Near range of interaction
In order to model the way by which moving agents arrive in attractive areas, it is considered a parametric function that describes their velocities depending on the distance r to a center of force. The proposed model is based on a top speed from which the agent continuously experiments a deceleration according to a function inspired by the repulsive terms offered by [22,25] and the deceleration factor described on [26].
Consistently, for characterizing the arrival of agents in attractive areas, it is proposed a velocity field G near (r) that defines how their dynamics vary as they approach closer to an attractive area. Two global terms can explain such velocity field, one related to a baseline velocity and other based on a deceleration term, as described in equation (4): where r is defined as the Euclidean distance between an agent and the attractive area in question, such that r = ||X − X 0 || 2 , where X represents the agent's location and X 0 is the unknown position of the attractive area. σ is an unknown parameter that defines the way in which moving agents decelerate while they approach the center of force X 0 . Low values of σ 2 are associated with abrupt agent decelerations; and high values are related to smooth decrements of speed while agents advance towards X 0 . β is the top speed from which agents start decelerating until they arrive at the attractive area. α defines the final speed that an agent will have when arrives at X 0 . In the ideal case α = β, which implies that moving agents reach the attractive point with a null speed. Fig.3 shows the proposed parametric function G near (r) for approximating velocity fields in a near range of interactions over a two-dimensional plane (x, y). For visualization purposes, it is consid- Proposed velocity field y 30 40 x 1 30 20 20 10 10 Figure 3 Attractive near velocity field representation. The proposed shape of the velocity field experienced by agents when they are approaching to an attractive area is illustrated.
For estimating each of them, it is proposed an iterative gradient descent method explained in detail on section 4.3.
As can be seen in equation (4), since β and α are always positive, it is assumed that moving agents decrease their speeds while they approach the attractive areas. Accordingly, the proposed model applies to moving agents that tend to remain on the attractive center of forces, i.e., their speeds tend to be null near it. By taking into consideration the latter assumption, it is possible to define a distance r switch , from which agents start decreasing their velocity at approaching to X 0 .
In this sense, the model described in equation (4) is valid for r ≤ r switch . When distances between agents' locations and attractive areas are greater than r switch , another model must be proposed to characterize the agents' dynamics in terms of attractive forces. Under this perspective, the following section introduces a way to model agents' velocities when they are located at far distances from X 0 .

Far range of interaction
When moving agents are located at a distance r > r switch from an attractive area, it is proposed to use a probability density function (PDF) to describe the agents' velocities until they start reducing their speeds due to a near range of interactions effect previously explained in section 3.1. From this viewpoint, the model of a far range of interaction works until agents present a continuous deceleration through time, which indicates they start approximating to an attractive area.
PDFs are proposed to characterize interactions at far distances from attractive centers of force due to their properties for representing stochastic phenomena. It is hypothesized that agents' velocities at far ranges of interaction can be slightly affected by multiple factors different from the effect of attractive forces in the environment. Nonetheless, at this stage it is assumed a predominant agents' velocity due to their interactions with an attractive area, i.e., it is assumed a main constant influence on the agents' velocity due to a particular destination point (goal) that makes them move towards a center of force X 0 .
In this work, it is proposed to represent the velocity's magnitude of an agent localized in r > r switch as the L 2 norm among the velocities experienced in each spatial axis, such that ||V X f ar || 2 , where V X f ar represents the agent's velocity in a single location measured in a far range of interaction. Based on that, the set of all velocities' magnitudes due to an attractive area in a far range of interaction can be written as: where J is the total number of measurements taken in a far range of interaction. Since a main constant velocity is assumed during this stage, it is defined a random variable γ that distributes according to the log-normal distribution lnN (µ, σ 2 f ar ) that is adjusted based on ||V f ar(set) || 2 . Such distribution allows to represent variables that are only defined for positive values and that can be concentrated mainly in one value, as it is the case of velocities' magnitudes in far range of interactions. From this viewpoint, velocity fields in such stage can be written as shown in equation (5): as explained before, γ is a random variable that distributes in accordance a log-normal distribution. After characterizing near and far interactions between agents and an attractive area of the environment, it is possible to define a full effect G m (r) produced by a particular area m, such as shown in equation (6): Consequently, as different agents move through an environment, a total set of fields G M (r) can be obtained, where M is the number of identified attractive areas that have been characterized inside a scene. From this perspective, each effect can be seen as a letter that is part of a vocabulary which is learned hierarchically as new agents move inside an environment. The next section describes a methodology that aims at the incremental learning of environment properties based on moving agents' observations.

Hierarchical environment representation
The present section explains a methodology by which effects generated by static attractive areas can be modeled as control parameters into an initial Kalman filter (KF) formulation from which effects of interactive areas can be extracted and then modeled into it. It is also shown how trajectories that are globally nonlinear in terms of space can be incrementally grouped into segments in which agents' dynamics preserve a constant orientation. Each identified segment is here explained by an attractive velocity field whose effect is modeled through the switching formulation described in 3. Finally, it is proposed that each trajectory can be seen as a sequence of attractive areas acting on the moving agents. This process can be considered as the activation of different letters in the environment (each one associated to an attractive area) that gives a semantic representation of activities in the environment.

Kalman filter modeling
Supposing location measurements of single agents in an environment are defined as Z k for each instant of time k and assuming that such measurements are equally time spaced, i.e., ∆k remains constant, it is possible to define the agent state vector X k as its position and velocity at k. Accordingly, let measurements and state of agents be related by the expression Z k = HX k + ν k , where ν k represents a zero-mean normal distributed noise due to errors on the measurements taken at time k and H is a matrix that maps the actual state space X k onto the observations Z k .
Since the proposed method aims at the hierarchical learning of agents' temporally non-linear motions, initially, a random walk model centered on agents' observations is hypothesized as the most general way to represent unknown dynamical behaviors. Based on this, observations of moving agents that deviate from a random walk model can be used to incrementally explain effects of attractive areas in a particular location Z k from which the deviation was observed.
Dynamics of agents are modeled by a bank of Kalman filters that grows sequentially as new patterns associated with attractive areas in the environment are revealed by looking at agents' motions through time. Accordingly, equation (7) shows the initial KF dynamical model based on a random walk model from which the bank of filters is built up afterwards.
where X k = X k X k , F = I n 0 n,n , w k is a zero-mean normal distribution associated with the random noise of the proposed dynamic model and n represents the number of observed dimensions of the environment as shown in equation (2). Let X 0 k|k−1 be the prediction of a KF based on the random walk model described in equation (7) given the updated state estimation at the time k − 1, i.e., X 0 k−1|k−1 . It is assumed that significant deviations from the KF's predictions carry information about effects of unknown attractive areas. Accordingly, when the measurement Z k arrives, it is possible to computẽ Y 0 k , called innovation of measurement residual, which is defined as shown in equation (8): where X 0 k|k−1 = F X 0 k−1|k−1 and it is defined as the random walk KF's prediction. In general, innovations can be seen as a quantity that measures the deviation that a proposed dynamical model presents respecting observations. In the ideal case, the valueỸ 0 k would tend to zero, which means that the proposed model, based on a random walk dynamics, can explain the observations of agents in the environment correctly. Following this reasoning, in cases where innovations are significantly different from zero, the dynamical model should be modified in order to describe more accurately the observed agents' dynamics. To do so, it is considered a modification in random walk model, the new model formulation is shown in equation (9): where a control parameter BU k is introduced in order to obtain innovations that tend to zero. U k can be seen as a velocity contribution that makes an agent follow certain motion when it is located at the coordinates Z k . B is a matrix that maps such velocity contribution into the agent's state, such that B = ∆kI n I n .
Similarly to the random walk model, innovations of the proposed new model are defined asỸ 1 k = Z k − HX 1 k|k−1 . Accordingly, in order to makeỸ 1 k = 0, it is proposed to use the innovations produced by the random walk model,Ỹ 0 k , into the control parameter BU k of the proposed new model. By taking into consideration that X 1 k|k−1 = F X 1 k−1|k−1 + BU k−1 , it is possible to rewrite the expression of innovations generated by the new model as shown in equation (10): By substituting the updated state produced by the KF based on the proposed new model with the updated state found with the random walk based model, such that X 1 k−1|k−1 := X 0 k−1|k−1 , it is possible to rewrite equation (10) as shown next: from which it is possible to infer that: As can be seen in equation (12), the control vector U k is a velocity quantity related to the effect that attractive forces exert over moving agents in the particular measurement Z k . For this viewpoint, since different agents localized in the same coordinated point Z k can be motivated by different attractive areas, each velocity field effect should be individuated and included into the KFs' dynamic models that compose the proposed bank of filters as shown (13): where U s k =Ỹ 0 k,s ∆k , s is the indexation of each potential attractive area and A s corresponds to the dynamical model associated to each of them. In this sense, each A s represents a new KF model built from the innovations produced by the random walk model described in (7). At the moment of defining an attractive model A s , information about innovations generated by the previously characterized set of dynamical models {A 1 , A 2 ..., A s−1 } should be taken into consideration in order to merge similar velocity field models. In this work, a merging process of similar velocity fields is considered as a post processing step and a classic kmeans algorithm is used to group similar fields. From this viewpoint, the proposed bank of KFs is created incrementally by observing deviations from a reference random walk model. Each learned new model includes information about attractive properties of the environment.
In order to relate the proposed attractive field described in equation (6) to the control inputs U s k , it is necessary to identify parts on a trajectory in which velocity effects produced by radial attractive force fields are valid. For this purpose, it is considered a method for segmenting trajectories explained in section 4.2.

Trajectory segmentation
Since it is hypothesized that movements of agents are produced by static areas that exert radial attractive force fields, it is expected that trajectories performed by agents are spatially quasilinear and pointing every time at the direction of a main attractive area. Nevertheless, in real cases, motions of agents do not have the same orientation in every moment. However, they can be divided into quasilinear segments on which the assumption of interactions with attractive radial fields is valid.
The possibility of dividing a trajectory into quasilinear segments can be associated with the presence of multiple motivations that an agent follows as time evolves. In other words, a moving agent can be attracted by multiple areas that can be seen as dynamical motivations that change in time as the agent moves through the environment reaching multiple goals. An example of this behavior can be clearly identified in airplane trajectories, where aircrafts perform different approaches to intermediate points during a flight. Fig.4 depicts an example of such behavior for a commercial flight that goes from Amsterdam to Brussels on a Latitude-Longitude plane.
In Fig.4, spatial quasilinear segments in the trajectory are identified with different colors. Red crosses show the points in which transitions between different quasilinear segments take place. Accordingly, from Fig.4, it is possible to see how multiple quasilinear paths can explain a single trajectory in terms of spatial transitions. Accordingly, each segment identified in Fig.4 is proposed to be explained by an attractive area that exerts a radial force field over the environment.
Angles produced by the estimated velocities U k are used in order to segment the trajectory into quasilinear motions in an online way. Since the control vector U k can be seen as the agent's velocity due to the interaction with external forces when at observing Z k , the orientation of this vector can be used as a measurement of alignment with attractive centers of force. If an agent is approaching to an attractive area in the environment, it is expected that orientations of U k do not change significantly through time. Based on this, it is proposed to define a window time t w in which directions of velocities U k remain stable. Let W a be the windowed version of the velocities U k such that: where a is the number of samples that fit in an interval of time t w . Once a number of a velocities U k is obtained, the window data W k is used to approximate the parameters of a von Mises distribution µ θ and κ θ . This distribution is selected due to its properties of  representing the direction of entities in a probabilistic way, µ θ represents distribution's mean and 1 κ θ is analogous to the variance in a normal distribution.
Definingμ θ,k andκ θ,k as the estimated parameters of the von Mises distribution based on the window data W k , it is proposed a deviation angle θ dev from which it is possible to distinguish when an agent moving aligned to a particular attractive area. Accordingly, when an accumulated probability higher than 0.9 is obtained in the range [μ θ,k − θ dev ,μ θ,k + θ dev ], it is hypothesized that the agent is attracted to an area. Velocity contributions calculated in following times, i.e., from U k+a+1 onwards are compared with the current von Mises distribution through a Mahalanobis distance D M [38], in order to evaluate whether it belongs to the previously estimated distribution of if it is necessary to hypothesize a new one. For doing so, a distance limit D θ is introduced, such that if a number of n θ velocities contributions produce a distance D M > D θ , the process is reinitialized with a new window W k+a * +1 , where a * is the minimum window size a together with the following velocity contributions that were classified as part of the von Mises distribution estimated from the window W k .
In this work, each quasilinear segment, indexed with the letter s, is associated with the presence of an at-tractive area in the environment, see equation (13). Accordingly, once a segment is detected, a velocity field approximation is iteratively performed based on an attractive force hypothesis. Algorithm 1 describes the proposed sequential process for identifying quasilinear motions in agents' dynamics and approximating velocity fields from them.  Some algorithms for segmenting signals into linear components and reconstruction of trajectories were identified. However, for the particular problem ad-dressed in this work, where moving agents are influenced by a main goal, information about the direction and magnitude of their velocities should be taken into consideration to make a correct segmentation in terms of attractive forces. The number of segments identified with this approach corresponds to the quantity of potential attractive areas in the environment. A list of the principal characteristics of identified algorithms for piecewise linear segmentation and reconstruction of trajectories are compared with the current proposal in table 1.
From table 1, it can be seen that the proposed method presents the advantage of being online. additionally, it uses the dynamics of agents as inputs for performing the segmentation process. Since produced segments are assigned to central force fields, the agents' velocity angles result to be an important feature for detecting alignment with goals that agents desire to reach by taking the shortest possible path.
It is possible to see from algorithm 1 that the final result of the proposed method consists of a set of velocity fields related to attractive areas identified by quasilinear segments in the agents' motions. Accordingly, as a segment grows in time, an iterative estimation of the velocity field's characteristics is performed based on the model described in sections 3.1 and 3.2. Section 4.3 explains in detail how this process is performed as new agents' observations are obtained.

Learning of environment properties
Let the pair of vectors [Z k , U k ] be the agent's observations with their respective control vectors obtained by the KF based on the random walk model proposed in equation (7). Additionally, suppose that [Z k , U k ] are acquired incrementally such that algorithm 1 is applied as new observations arrive such that [Z s k , U s k ] are vectors that belong to a particular segment s, i.e., they are produced due to an unique attractor.
Since parameters U s k are related to velocity components that deviate agents from a random walk behavior, it is proposed to use them in order to fit the velocity field model presented in equation (6). Accordingly, for distinguishing between far and near ranges of interaction, magnitudes of U s k are analyzed through consecutive time instants, such that: If ||U s k || 2 values decrease continuously in a range of time ∆K switch , the moving agent is assumed to be in a near range of interaction, proposed in equation (4). For this case, its measurements and control vectors will be labeled as [Z s k(near) , U s k(near) ]. Otherwise, the moving agent is assumed to follow the far range of interaction model described in equation (5), in such case, its measurements and control vectors will be labeled as [Z s k(f ar) , U s k(f ar) ]. In order to characterize the velocity field in a far range of interaction associated to a segment s, the magnitudes ||U s k(f ar) || 2 are used to estimate the random variable λ s , such as proposed in equation (5).
Estimating the center of force X 0 in a far range of interaction is not possible since there is not conclusive information about velocity decrements. Nonetheless, it is feasible to determine a line on which the center of force belongs. Such line is defined from the last observation Z k and has a slope determined by the mean of λ s .
[Z k(near) s , U s k(near) ] are used to estimate the unknown parameters in equation (4) for a particular attractive area s. The measurement and control input from which next ||U 2 k || 2 values start decreasing are labeled as [Z s k(switch) , U s k(switch) ]. The magnitude of U s k(switch) is taken as an estimation of to the term β of equation (4), such thatβ s = ||U s k(switch) || 2 . Additionally, it is assumedα s =β s , such that moving agents tend to remain on the attractive center of force when they arrive in it. Then, an iterative gradient descent is proposed to minimize the error between magnitudes ||U s k(near) || 2 and the proposed velocity field formulation of equation (4) based on the sparse space representation of the observed data Z k(near) .
Accordingly, the function to optimize is the mean square error between ||U s k(near) || 2 and the proposed velocity field function described in (4) with the fixed values of α =α s and β =β s . By assuming a total number of N measurements with their control inputs identified in a near attractive range of interaction for an area s, i.e., [Z k(near) s , U s k(near) ] with k from 1 to N , the function to optimize is shown in equation (14): Since G(r near ) is a differentiable function respecting the parameters σ and X 0 , a classical gradient descent algorithm is performed by taking the partial derivative of the function J(σ, X 0 ) respecting each of them. Both expressions are shown in equation (15): where r k = (Z k(near) − X 0 ), e k = αe − r 2 k σ 2 , ψ k = U k(near) + e k − β.  [40] Online (Sliding window + Top down) Data points series 2 distance between line and data points Signal's piecewise linear representation [41] Online (Slope change threshold) Data points series Distance between reference slopes Signal's piecewise linear representation [42] Batch (Bottom-Up) High frequency data points 2 distance between line and super-interval data Identification of events [43] Online As a moving agent is approaching an attractive center of force, the number N of measurements identified in a near range of interaction will increase as more vectors [Z s k(near) , U s k(near) ] are available. In other words, each time that N increases, new estimationsσ s and X 0,s made by gradient descent process are obtained. Supposing that a total number of Q estimations ofX 0 andσ have been obtained by the multiple computations of the gradient descent method, it is proposed to fuse all of them for a given segment s, i.e., [X 0,s,q ,σ s,q ] where q goes from 1 to Q, by performing a weighted average over the Q estimations such as shown in equation (16): [X 0,s,q , σ s,q ]w 1,q w 2,s,q , (16) where w 1,q is a weight related to the number of samples with which the gradient descent was executed in the iteration q. Each w 1,q is normalized respecting the maximum number of samples with which the gradient descent have been performed. w 2,s,q is a weight related to the error J s,q (β, α, σ, X 0 ) obtained on each iteration q at estimating the properties of the attractor associated to the segment s. w 2,s,q values are normalized respecting the lowest error obtained.
The pair of parameters [X 0,s(avg) ,σ s(avg) ] obtained by applying equation (16), is the final estimation of the velocity field parameters [X 0 ,σ] related to the effects of an attractive area based on the segment s. X 0,s(avg) represents the estimated location of the attractive center of force associated to based the segment s andσ s(avg) encodes information about the shape of its effect in the environment.
By replacing the vector of parameters' estimationŝ ξ s = [β s ,α s ,X 0,s(avg) ,σ s(avg) ] in equation (4), it is pos-sible to obtain an expression that explains the effect of an attractive area in a near range interactions, such that,ˆ G s near (r) = G near (ξ s ). Similarly, for a far range of interaction, it is possible to writeˆ G s f ar (r) =λ s . Consequently, a final estimation of attractive effects can be defined as: where r s(switch) represents the distance from which agents start decreasing their velocities at approaching the attractor and r s = ||Z k − X 0,s || 2 is the distance between an agent and its center of force. Estimated velocity fieldsˆ G s (r s ) can be used to rewrite equation (13) in terms of the proposed parametric function such as shown next: As explained before, the purpose of this paper is to estimate the velocity fields G s (r s ) generated by attractive areas in environments. From equation (17), it is possible to see that a bank of filters composed of the effects of attractive fields related to each segment s is obtained by applying the proposed methodology. From this viewpoint, each KF dynamical model A s can be seen as a letter that is learned on the fly as patterns in agents' motions are detected. Consequently, as multiple letters are observed and characterized, it is possible to build a vocabulary in terms of learned environment properties. In the next section, some results at modeling such properties in synthetic and real trajectories are shown and discussed.

Results
The proposed method was tested in two different scenarios: i) Synthetic data, in which an environment with different attractive areas is proposed and whose characteristics are inferred based on agents that move towards different goals. ii) Pedestrian dataset, where dynamics of people moving through an indoor place are analyzed and attractive points in the environment are identified.

Synthetic data
In order to validate the proposed method, a simulated scenario in which moving agents are motivated by different attractive zones is considered. Three radial attractors that influence moving agents are proposed as shown in Fig.5. It is proposed that agents interact with at least one attractor before they reach their final destination. In this sense, situations in which agents change dynamically their destinations (goals) are simulated and analyzed in an online way. This simulation assumes that agents always start moving from a random side of the environment such as shown in Fig.5. Noise from a uniform distribution U(−b, b) is considered in order to affect the motion of agents in directions x and y. The value of b is selected according to the speed that agents present each instant of time, such that it is adjusted to a specific signal-to-noise ratio SNR = || V X || 2 /b, where V X (t) is the velocity exhibited by an agent in a location X . Attractive areas' effects are simulated according to the formulation shown in equation (4) with β = −α.
The selected values of the parameters for each attractor are shown in the first column of table 2.
It was considered a total of 150 trajectories that start randomly from one side of the environment and whose final/intermediate(s) points of attraction are also selected at random. The proposed method was applied to the trajectories in order to recognize attractive effects in the environment.
By taking the estimations of attractive centers of force generated by agents that behave according to a near range of interaction explained in 3.1. It is possible to obtain a map with different locations of attractive points such as shown in Fig.6. As can been seen, similar centers of force can be clustered by using a classic k-means algorithm in order to identify attractive areas in the scene that combine information of similar attractors' estimations.

Clusters of attractors (SNR = 5)
Attractor 1 Attractor 2 Attractor 3 Estimation of centers of force Ground truth From Fig.6, it can be seen that each identified cluster corresponds to an attractive zone. Crosses are calculated by taking the average position of all the velocity fields that belong to a particular cluster. Similarly, the average of σ and β components of velocity fields is taken in order to characterize the properties of each merged attractor.
Attractors resulting from the clustering process can be seen as letters that conform a vocabulary that characterizes the environment. Accordingly, the parameters associated with each letter can be expressed as shown in equation (18): where m indexes each identified cluster composed by similar estimated fields that in turn are indexed as p m .ξ pm represents the estimated parametersξ s = [β s ,α s ,X 0,s(avg) ,σ s(avg) ] coming from a segment s and relabeled according to the clusters (letters) reached with the k-means algorithm.
In order to evaluate the algorithm performance, it is possible compare the parameters estimated for each merged attractor with the respective ground truth values. Accordingly, table 2 shows the values estimated at different SNRs for each attractor.  From table 2, it can be seen that estimations of centers of force locations are not affected drastically at the presence of noise. However, it is observed a significant change in the estimations β and σ when SNR is close to 1. Such behavior indicates that at low SNRs the main direction of trajectories is preserved but the magnitudes of their velocities are significantly affected.
In order to illustrate how the overall performance in the estimation ofξ s = [β s ,α s ,X 0,s(avg) ,σ s(avg) ] at different SNRs, it is proposed to take the following expression shown in equation (19): where ϕ τ = sum{ϑ τ }, ϑ τ = λ τ γ , γ = max({λ 1 , λ 2 , ..., λ T }), λ τ = sum{ τ }, τ = {ρ 1,τ , ρ 2,τ , ..., ρ M,τ }, ρ m,τ = |ξ m −ξ m,τ |, m and τ index the attractive zones and the different SNRs respectively. The total number of attractors and SNRs are represented with M and T . ξ m represents the ground truth of the parameters that define the attractor m.ξ m,k is the estimation of attractive parameters related to an attractor m at a specific SNR k. By taking the normalized error expressed in equation (19), it is possible to obtain the performance results shown in Fig.7 for different signal-to-noise ratios. Variances produced by estimations of the three attractive zones are plotted as error bars for each SNR case. From results obtained with simulated data, it is possible to see that the proposed approach recognizes and characterizes radial attractive fields with different intensities and shapes at several SNR values by looking at the motion of individuals. Additionally, the proposed method does not need a large number of data vectors and parameterizes areas according to a known function. This represents a an advantage in comparison with our previous approach [30] that needs trajectories all around the environment for estimating correctly the effects of force fields in environments. For validating our method on real data, it is proposed to analyze a dataset composed by pedestrians' trajectories in an indoor environment.

Pedestrian dataset
The dataset proposed by Yi in [46] was used to test our approach. The database is composed by 12,684 pedestrian trajectories in an indoor place where each individual is manually labeled from a one-hour crowd surveillance video. In their work, they identify 10 zones that act as source/destination points for pedestrians and it is manually labeled in Fig.8, as can be seen, an 11th zone is introduced as the center point of the scene that is hypothesized to be an attractor for some pedestrians that interact with it. Consequently, the plot shown in Fig.8 can be seen as a map of attractors in the scene. By using our approach, it is expected to identify those points in terms of their location and the effect they produce on moving pedestrians. Figure 8 Zones of interest in pedestrian database. 10 source/destination zones identified by [46] plus a center zone of interaction.

11
By grouping similar estimations of attractive centers of force generated by pedestrians that behave according to a near range of interaction, it is possible to obtain a map of the attractive zones' locations such as shown in Fig.9. Similar to the case of synthetic data, parameters that belong to the same attractive zone are averaged based on equation (18) to obtain the parametrization of each merged version of attractive fields in the scenario. Estimations of attractive zones' locations are depicted as red crosses on Fig.9.
In order to visualize the presence and effect of each attractive zone, it is proposed a map that is shown in Fig.10. Areas with null values (blue colors) represent the absence of attractive fields. Zones with larger values (red colors) represent the presence of attractors that where agents feel more attracted in terms of intensity. The shape of fields are visualized as the radius around each center of force (black cross) until the color map becomes totally blue. Consistently, the larger such radius is, the near range of interaction effect becomes broader, i.e., a larger period of deceleration is detected.  Results obtained in this database demonstrate that from the dynamics of moving agents it is possible to infer the locations and characteristics of attractive areas. Particularly, qualitative results can be seen by comparing our approximation of attractive centers of force shown in Fig.10 with the zones manually labeled by [46] and depicted in Fig.8. It can be seen that zones labeled as {C, A, I, B, G, J, H, E} in Fig.10 correspond respectively to the labels {1, 2, 3, 5, 6, 7, 8, 9, 10} in Fig.8.

Clusters of attractive areas
Since there is not a ground truth available to verify the intensity or shape of attractors associated to β and σ values respectively, the only comparison that can be done it is terms of centers of force localizations between Fig.8 and Fig.10 as proposed before. Figure 11 Characteristics of the environment. Areas that become relevant according to the context of the environment.

Object of interaction
Additionally, it was identified the area labeled with letter F corresponds to an effect of a queue that pedestrians follow through the video. Zones identified as K and D are related to pedestrians' interactions with the central object of the scene. Both, queue and object's effect are illustrated in Fig.11. According to that, it is demonstrated that the proposed methodology is capable of recognizing effects derived from contextual situations in the environment by looking at movements of dynamical agents through time.

Conclusions
A method for characterizing attractive forces in statical environments based on movements of agents is proposed. To do that, it is put forward a methodology based on the minimization of innovations from a Kalman filter based on a random walk model. Innovations from this model are used in order to the explain external effects that affect agents' motions. Information that encodes properties of the environment effects on agents is proposed to be added as a control input into the initial random walk formulation.
An incremental learning of environment properties is considered. Characteristics of attractive zones around observed agents are learned on the fly. A method for individuating attractive fields effect based on radial force hypothesis is proposed based on a quasilinear segmentation of the agents' dynamics. An iterative method that approximates velocity fields produced by attractive zones is proposed when only information about agents' dynamics is available.
Obtained maps can be used to perform further analysis by following a semantic approach where each characterized attractive area (letter) can be considered as part of a vocabulary, if activation sequences of attractive areas are detected with the proposed bank of filters, it would be possible to extract information about situations in an environment.
For future work, it is proposed to adopt a semantic representation of learned static areas properties, such that more complex interactions between agents and environments can be characterized by applying the built bank of filters based on attractive effects to new trajectories. For this approach, it is planned to using the innovations with their covariance matrices produced by the built bank of filters to characterize repulsive effects in environments.