Using Network Generators

Network Generator Classes

Network Generator UML Class Diagram

Recycling of Network Configurations

Often, especially for sensitivity analysis, simulations are conducted many times and only one or a few parameters are changed meaning the networks stays constant. Then, especially for resource consuming network builders it is a good idea to generate the network once and store it. MoRe provides suitable features:

Typically, the GRAPHML file is also produced by MoRe using MoreIoUtilities#outputGraph()

For details, see JavaDoc of MGeoRsRestoreNetworkBuilder. The test class MGeoRsRestoreNetworkBuilderTest contains a complete example.

The builder implements MoreGeoNetworkBuilder in order to substitute such network builders. However, it can also be used to restore networks for agents that are not geographically rooted.

Adding and Removal of Edges

Network generators that support addition and removal of edges extend MoreNetworkEdgeModifier. Implementations often depend on the target system like Repast Simphony (MGeoRsNetworkEdgeModifier). Example: MBaselineDhhRadiusNetworkBuilder extends MGeoRsNetworkService, which uses a MGeoRsNetworkEdgeModifier.

Often, the method addAndLinkNode needs to specified by the network generator by themselves since the way a node is linked a network is not general (e.g. MBaselineDhhRadiusNetworkBuilder). The MoreNetworkEdgeModifier can be used in these implementations.

NetworkService classes usually combine the MoreNetworkBuilder and the MoreNetworkModifier interfaces.

There is an interface MoreGeoNetworkEdgeModifier for edge modifiers that support geographies. However, the user needs to take care to assign such a MoreNetworkEdgeModifier to the network generator that shall support geographies.

The component approach in network generation and manipulation is much more flexible than encapsulating all network operations within the network object. It allows using e.g. different edge modifiers as ones that have geography support only in certain contexts, for instance initialisation or for certain model configurations.

Homophily-based Distance Depending Forest Fire Network Service

The MGeoRsHomophilyDistanceFfNetworkService seeks to incorporate important features for ABM:

  1. Milieu-specific degree distributions
  2. Milieu-specific distance distributions
  3. Milieu-specific milieu composition preferences
  4. Focus on modularity

Algorithm

HDFF Network Generator

Apart from the milieu composition preferences, degree and distance distributions, the algorithm considers two important parameters that allow to control the resulting networks modularity quite well:

MNetBuildHdffPa#PROB_FORWARD
While exploring an ambassador's neighbours this probability determines the likelihood that the focal agent is linked from ambassador's outgoing links.
MNetBuildHdffPa#PROB_BACKWARD
While exploring an ambassador's neighbours this probability determines the likelihood that the focal agent is linked from ambassador's incoming links. This seems especially important for relations of social influence.

Two more parameters are important to adjust the precision for milieu composition and distance distribution (Note that the sum of both has to be 1.0):

MNetBuildHdffPa#DIM_WEIGHTS_MILIEU
Determines the weight for milieu composition preferences when calculating a link's probability. The higher the value the more accurate milieu composition preferences can be fulfilled.
MNetBuildHdffPa#DIM_WEIGHTS_GEO
Determines the weight for distance related link probability when calculating a link's probability. The higher the value the more accurate distance distributions can be fulfilled.

See MGeoRsHomophilyDistanceFfNetworkService for a list of all relevant parameters.

Creating Hexagon Shapefiles

Hexagon shapefiles are required to determine distances between agents. Since the size of hexagons depends on the simulation region and desired performance, often according hexagon shapefiles need to be created anew (and the filename assigned to parameter MNetBuildHdffPa#HEXAGON_SHAPEFILE.

NOTE: The hexagon shapefile must cover all agent positions and should not be much larger since it is used to calculated the area's diameter which is used to initialised the distance distributions!

There are two ways to produce appropriate hexagon shapefiles:

Using a python script

The python scripts are available at . There is one for squared model areas and one for arbitrary model regions using a raster file as input (or a shapefile to use subsequently in the process).

Manually in QGIS [[1]] Download and install QuantumGIS
  1. Download and install the python plugin mmqgis
  2. Settings > Project Properties > Select "WTS 84 / UTM zone 32N"
  3. Choose plugins > mmqgis > create > Create Grid Layer
  4. Select Hexagon (polygon) at the bottom
  5. Adapt and use these values (here for a 1km x 1km area with 200m wide hexagons; note that the hexagon shapefile's boundary exceeds the actual area in order to cover the entire region.):
    Left X -150
    Width 1300
    Bottom Y -150
    Height 1200
    H Spacing 200
    V Spacing auto
  6. Make sure that the shapefile defines the correct CRS by inspecting the *.prj file (usually the plugin does not assign a CRS). If not, right-click on the layer in QGIS and save as a new file. You can choose the CRS in the "Save vector layer as..." dialog.

Implementing Network Builders

There are several ways to implement network generators that comply with the various MoRe interfaces:

  • The most easy way is to extends the MNetworkService class which implements both MoreNetworkBuilder and MoreNetworkService. See MCompleteNetworkGenerator for the simplest example.
  • To implement the MoreGeoNetworkBuilder one might extend MGeoRsNetworkService. In order to use common network generation code for the standard network builder and e.g. the RS geography version one could source out such code, as was done in MSmallWorldBetaModelNetworkGenerator.
  • In case you prefer to extends the standard network builder to implement the RS geogrpahy version, you could use the MGeoRsNetworkService as a component and add forwarding methods to this component.

    To specify a general network generator as RS and/or geography network generator it is normally sufficient to

  • assign a MoreGeoNetworkEdgeModifier instead of a MoreNetworkEdgeModifier
  • implement MoreGeoNetworkService or extend MGeoRsNetworkService and copy & paste the special network generator code (since JAVA does not allow multiple inheritance).

    Network Builders should have at least two constructors:

  • One with only MoreEdgeFactory as parameter
  • One with MoreEdgeFactory and String as name as parameter