• No results found

Chapter 5 OPEN-SOURCE DATA ASSIMILATION FRAMEWORK SOFT-

6.3 Data Assimilation Preparation

The objective of this tutorial is to build data assimilation system from this road system and use Bootstrap particle filter algorithm to improve the prediction of the model. As introduced in Section 5.2, our software successfully decouples the development of a data assimilation system since the interface and connection between SMC algorithm and simulation model have already been taken care of. As a result, developers only need to implement SMC algorithm as a subclass of

AbstractParticleSystem and simulation system as a subclass of AbstractSpatialTemporal- System separately. Specifically, in this tutorial, we will use Bootstrap particle filter and road system model to demonstrate the process.

Figure 6.5. BootstrapFilter

6.3.1 Bootstrap Particle Filter

As previously mentioned in Section 5.2.2, in the SMC package, Bootstrap filter is already imple-

mented. Bootstrap filter algorithm is created as BootstrapFilter class which extends Abstract-

ParticleSystem. As is shown in Figure 6.5,BootstrapFilter is aggregated by PriorSampling,

LikelihoodWeightandSystematicResampling classes. BootstrapFilter, as is introduced in 5.7, only needs to define its own constructor method by creating instances of these classes since other

methods in AbstractParticleSystem has defined the general procedure of SMC algorithm. The

three strategy classes are forced to implement the abstract methods defined by the corresponding su-

per classes. PriorSampling implements the abstract sampling method by callingtransitionModel

function defined in StateInterface for each particle. LikelihoodWeight implements the abstract

updateUnnormalizedWeight method to calculate the weight of each particle. The current weight

is the multiplication of the previous weight and the posterior density of the particle. Systemati-

cResampling implements the abstractresampling method using systematic resampling algorithm introduced in [70]. The source code of these three classes is listed in Appendix A.

In this way, a Bootstrap particle system is completely defined and can be easily used for data assimilation. If another SMC algorithm is proposed, researchers can follow the steps to develop their specific strategy classes of sampling, weight updating and resampling. And a new particle system can be constructed by combing them effortless.

6.3.2 Spatial Temporal System

With data assimilation algorithm available, We only need to take care of the simulation model.

We starts by creating a subclass of AbstractSpatialTemporalSystem, namedDEVSRoadSys-

tem, and develop it as a wrapper class to wrap up the road system model (keep a reference to the

road system). This class, which extends AbstractSpatialTemporalSystem class, is forced to

implement the abstract methods defined in it. As mentioned in 5.2.3, this includes clone, run-

Simulation, getSensorObservation and runSimulationWithNoise method. The signatures of these methods are listed in table 6.1.

And the class diagram and source code of these methods are shown in Figure 6.6. TheroadSys-

tem variable is an instance of RoadSystemclass, which is a wrapper class for road system model.

As is shown in the figure, the implementation of all these methods will use this wrapper to complete the task, which is explained in detail as follows.

clone method accepts no parameter and return a deep copy of the wrapper class. It is manda- tory because SMC methods requires that all particles can be duplicated and clone method is the way of duplicate objects in Java. If some components of a system model are not cloneable or ed- itable, the model should provide equivalent method to generate a duplicate copy. Specifically, in

RoadSystem uses a copy constructor to duplicate the simulation system. We will further explain why a copy constructor is used in Section 6.4.

Table 6.1. Abstract Methods to be Implemented

Name Parameters Return Type

runSimulation int stepLength AbstractSpatialTemporalSystem

runSimulationWithRandomNoise int stepLength AbstractSpatialTemporalSystem

getSensorObservation AbstractSpace Space AbstractMeasurement

Figure 6.6. DEVSRoadSystem Class

runSimulation method accepts an integer value as parameter, and return the next state of the

system of type AbstractSpatialTemporalSystem. This method is delegated by SystemState

class to run as transition function of a system state. Therefore, the method is designed to run the

simulation system by the given amount of time. Specifically, it uses run method to advance the

road system model from current time by the “timeStep”.

runSimulationWithRandomNoise method has the same parameter and return value defined. It is delegated to run as transitionModel function by SystemState class, which run the simulation system with random noise added. This method is designed to fulfill the requirement of stochasticity for SMC algorithms. Since the road system model is a deterministic model, this method has to be implemented explicitly with artificial random noise. The random noise should be added to the system state to be estimated or the measurement from the system state. Specifically, it first call

run method to run simulation and then add random noise by calling addNoise method.

getSensorObservation method accepts an AbstractSpace variableand return an Abstract- Measurement object. It is delegated to retrieve the sensor observation data from a running

will eventually be used to update the weight. For any system model, a measurement class ex-

tending AbstractMeasurement is required to be created and weightUpdate method is forced to

implement in order to deal with the sensor data from this specific system. Specifically, DEVS-

RoadSystemMeasurement is created to encapsulate the sensor data obtained from road system.

It also implements updateWeight method based on the data, of which the source code is listed in

Appendix A.

To summarize the process, two classes, one extends AbstractSpatialTemporalSystem and

one extends AbstractMeasurement, have to be created and the abstract methods are meant

to be implemented. For the example of road system model, we create DEVSRoadSystem class

to wrap up the model and DEVSRoadSystemMeasurement class to encapsulate sensor data.

Then DEVSRoadSystem is ready to be integrated with Bootstrap particle system and perform

data assimilation if all the methods from RoadSystem are successfully implemented.