Simulation framework
This is an overview of the concept of the GeoStoch library. In particular an overview of the simulation framework is given, followed by the explanation of the basic ideas behind the framework.
Motivation
Various programs exist that deal with the simulation of specific spatial stochastic models. However, combining these models is not easy and usually requires greater effort (e.g. the simulation of a Vornoi tessellation of a Poisson hard core point process). It is easy to see that thereby extensions often require code refacturing. Furthermore most implementations depend on the dimension of the simulated model. So, to generate a sample of a model in a higher dimension a new program has to be developed or at least changes are necessary. The simulation framework of the GeoStoch library helps to overcome these problems.
Overview of the simulation framework
The framework for the simulation of random geometric models consists of several parts whose dependencies are shown in the Figure below. The basis of the simulation framework is the simulation of real-valued random variables.
Fundamental principles
- Interfaces: All models are designed as interfaces and only interfaces are referred to within implementations (as far as possible). This helps to make the implementation as independent as possible from concrete implementations. Example: The change of a Poisson Voronoi tessellation to a Poisson Delaunay tessellation in the program can be done without making any further changes.
- Use of the decorator pattern: One common problem with the simulation of models is to handle the combinatorial complexity. Example: In a nested tessellation, the initial tessellation and the component tessellation can be chosen arbitrarily and independently of each other. Furthermore, the concept of nesting tessellations does not depend on the concrete tessellations. Thus, instead of implementing a PoissonLinePoissonLineTessellation, a PoissonLinePoissonVoronoiTessellation, and so on, it is sufficient, to have one single IteratedTessellation which can be combined with an arbitrary initial and component tessellation. For this purpose, the concept of interfaces is also essential. The implementation of IteratedTessellation simply asks the simulation of the initial tessellation to generate a realization and then asks the simulation of the component tessellation to generate a realization within each cell of the initial tessellation. Obviously, this is possible independently of the types of tessellations. Furthermore, several IteratedTessellation objects can be nested to produce deeper nested tessellations.
- Naming conventions: In order to make the framework easier to use, each model interface has a method realise() that generates a sample of the model. Classes which simulate real-valued random variables also have such a method.
Real-valued random variables
Real-valued random variables are necessary for several purposes, e.g. many implementations of simulations of stochastic-geometric models rely on the generation of real-valued random variables. A concrete real-valued random variable implements the interface RandomVariable. With the method realise(), a new realization of the random variable can be obtained. The methods getInfimum() and getSupremum() return the lower and upper bounds, respectively, of the range of the random variable. Since an implementation of a deterministic random variable is provided by the class Deterministic, real-valued random variables can also act as double variables. This yields a maximum of flexibility.
The implementations of the concrete classes for real-valued random variables are based on the Java class java.util.Random. To be independent of this class and its pseudo-random number generator and to allow the usage of other pseudo-random number generators, the (custom) subclass Random of the mentioned class has been introduced. This class provides a method to set an custom pseudo-random number generator (of type Generator). The generator StreamGenerator, which provides this interface, reads the random numbers from a stream. So, in case another generator should be used or the Java pseudo-random number generator proves bad, it can easily be replaced. For this reason, the classes Random and java.util.Random should only be used for the implementation of the classes Uniform and Gaussian. The implementation of all other classes, such as Discrete, must be based only on other random variables (i.e. objects with type RandomVariable, e.g. Uniform).
Basic Data Structures
The interfaces of the whole framework are independent of the dimension. Therefore, the basic data structure, such as the utility classes DoubleBox, which represents a hyper cuboid, and ConvexPolytope, which stands for a convex polytope, as well as the class RandomSet have to be implemented for arbitrary dimensions, since they are used in the interfaces. Furthermore, the result of the simulation of a model is an object of the class RandomSet, which is bounded by a DoubleBox, containing RandomSetElement objects. These elements are deterministic geometric objects, such as points (class Point), lines (class Line), and so on. A RandomSet itself is also a RandomSetElement, so iterated tessellations, e.g., can be represented as trees, where each level contains the cells of one iteration level. The methods of RandomSet are common container methods.
Note that there exist classes which represent basic geometric objects, such as lines, line segments, convex polygons, and so on and algorithms for, e.g., the union and intersection of such objects.
Summary
The simulation framework, a keypart of the GeoStoch library, is a sophisticated tool for the simulation of spatial stochastic models, such as random point processes, random tessellations and their typical cells. The framework contains the construction bricks which only have to be combined for the simulation of concrete models. The consequent use of interfacesenables the reusability of the code. The application of the decorator pattern allows classes that are a combination of other classes as general as possible and ensures that arbitrary combinations are possible.
The GeoStoch library can easily be adapted to the different needs in various projects. For example in all our projects (c.f. the project list) the GeoStoch library is used for simulation, estimation, and other purposes.