Documentation > Utility Tasks

Geosimulation models, in the broad sense of simulation models in which the spatial configuration of agents plays a significant roles in the underlying processes (think e.g. of spatial interaction models), are generally tested for sensitivity on processes or agents parameters, but less frequently on the spatial configuration itself.
A recent paper proposed the generation of synthetic spatial configurations as a method to test the sensitivity of geosimulation models to the initial spatial configuration.
Some complementary work (paper) focused on similar generator at larger scales, namely generators for building configurations at the scale of the district.

More generally, the spatial data library developed by the OpenMOLE team integrates these kind of methods in a larger context, including for example synthetic spatial networks and perturbation of real data, but also spatial interaction models and urban dynamics models.

Some of the corresponding spatial generators are included in OpenMOLE as

where

with the specific parameters as factors for generator parameters:

A binary grid resembling a labyrinthine building organisation, obtained by percolating a grid network (see details in paper). It percolates a grid network until a fixed number of points on the boundaries of the world are linked through the giant cluster. The resulting network is transposed to a building configuration by assimilating each link to a street with a given width as a parameter.

with

with

## Content:

More generally, the spatial data library developed by the OpenMOLE team integrates these kind of methods in a larger context, including for example synthetic spatial networks and perturbation of real data, but also spatial interaction models and urban dynamics models.

Some of the corresponding spatial generators are included in OpenMOLE as

*Task*. In the current development version, only some grid generators are included, for a reason of types for output prototypes (synthetic networks are difficult to represent as simple types and to feed as inputs to models). All generators output the generated grids in a provided

`Val[Array[Array[Double]`

, along with the generation parameters for the generators taken as arguments.
## Random grid sampling ðŸ”—

A raster with random values:```
val myGrid = Val[Array[Array[Double]]]
val myDensity = Val[Double]
val myGenerator =
RandomSpatialSamplingTask(
grid = myGrid,
gridSize = 10,
density = myDensity
)
val myModel =
ScalaTask("println(myGrid.size)") set (
(inputs, outputs) += myGrid
)
DirectSampling(
sampling = myDensity in (0.0 to 1.0 by 0.1),
evaluation = myGenerator -- myModel
)
```

where

`worldSize`

is the width of the generated square grid,- the density parameter is optional and produces a binary grid of given density in average if provided,

## Blocks grid sampling ðŸ”—

A binary grid with random blocks (random size and position). With the same arguments as before, except the factors for the generator parameters:`blocksNumber`

is the number of blocks positioned, `blocksMinSize`

/`blocksMaxSize`

minimal/maximal (exchanged if needed) width/height of blocks, each being uniformly drawn for each block.
```
val myGrid = Val[Array[Array[Double]]]
val myBlocksNumber = Val[Int]
val myBlocksMinSize = Val[Int]
val myBlocksMaxSize = Val[Int]
val myGenerator =
BlocksGridSpatialSamplingTask(
grid = myGrid,
gridSize = 10,
number = myBlocksNumber,
minSize = myBlocksMinSize,
maxSize = myBlocksMaxSize
)
val myModel =
ScalaTask("println(myGrid.size)") set (
(inputs, outputs) += myGrid
)
DirectSampling(
sampling =
(myBlocksNumber in (10 to 15)) x
(myBlocksMinSize in (1 to 3)) x
(myBlocksMaxSize in RangeDomain[Int]("myBlocksMinSize + 3", "myBlocksMinSize + 5")),
evaluation = myGenerator -- myModel
)
```

## Thresholded exponential mixture sampling ðŸ”—

A binary grid created with an exponential mixture, with kernels of the form`exp(-r/r0)`

. A threshold parameter is applied to produce the binary grid.
```
val myGrid = Val[Array[Array[Double]]]
val myCenter = Val[Int]
val myRadius = Val[Double]
val myThreshold = Val[Double]
val myGenerator =
ExpMixtureThresholdSpatialSamplingTask(
grid = myGrid,
gridSize = 10,
center = myCenter,
radius = myRadius,
threshold = myThreshold
)
val myModel =
ScalaTask("println(myGrid.size)") set (
(inputs, outputs) += myGrid
)
DirectSampling(
sampling =
(myCenter in (1 to 20)) x
(myRadius in (1.0 to 20.0)) x
(myThreshold in (2.0 to 30.0)),
evaluation = myGenerator -- myModel
)
```

with the specific parameters as factors for generator parameters:

`center`

the number of kernels,`radius`

the range of kernels,`threshold`

the threshold to produce the binary grid.

## Percolated grid sampling ðŸ”—

**USE WITH CAUTION - SOME PARAMETER VALUES YIELD VERY LONG GENERATION RUNTIME**

A binary grid resembling a labyrinthine building organisation, obtained by percolating a grid network (see details in paper). It percolates a grid network until a fixed number of points on the boundaries of the world are linked through the giant cluster. The resulting network is transposed to a building configuration by assimilating each link to a street with a given width as a parameter.

```
val myGrid = Val[Array[Array[Double]]]
val myPercolation = Val[Double]
val myBordPoint = Val[Int]
val myLinkWidth = Val[Double]
val myGenerator =
PercolationGridSpatialSamplingTask(
grid = myGrid,
gridSize = 10,
percolation = myPercolation,
bordPoint = myBordPoint,
linkWidth = myLinkWidth)
val myModel =
ScalaTask("println(myGrid.size)") set (
(inputs, outputs) += myGrid
)
DirectSampling(
sampling =
(myPercolation in (0.1 to 1.0 by 0.1)) x
(myBordPoint in (1 to 30)) x
(myLinkWidth in (1.0 to 5.0)),
evaluation = myGenerator -- myModel
)
```

with

`percolation`

the percolation probability,`bordPoint`

the number of points on the bord of the grid to belong to the giant cluster,`linkWidth`

the width of the final streets.

## Reaction diffusion population grid sampling ðŸ”—

Urban morphogenesis model for population density introduced by (Raimbault, 2018).**USE WITH CAUTION - SOME PARAMETER VALUES YIELD VERY LONG GENERATION RUNTIME**

```
val myGrid = Val[Array[Array[Double]]]
val myGrowthRate = Val[Double]
val myGenerator =
ReactionDiffusionSpatialTask(
grid = myGrid,
gridSize = 10,
alpha = 10.0,
beta = 10.0,
nBeta = 10,
growthRate = myGrowthRate,
totalPopulation = 10)
val myModel =
ScalaTask("println(myGrid.size)") set (
(inputs, outputs) += myGrid
)
DirectSampling(
sampling =
(myGrowthRate in (1.0 to 10.0)),
evaluation = myGenerator -- myModel
)
```

with

`gridSize`

width of the square grid,`alpha`

strength of preferential attachment,`beta`

strength of diffusion,`nBeta`

number of times diffusion is operated at each time step,`growthRate`

number of population added at each step,`totalPopulation`

the final total population.

## OpenStreetMap buildings sampling ðŸ”—

*Currently being implemented*