ModelConfig

The ModelConfig object is the common interface used to set up simulation experiments.

It allows to specify four categories of experiment configurations:

  1. Model configuration
  2. Node Configuration
  3. Edge Configuration
  4. Initial Status

Every diffusion model has its own parameters (as defined in its reference page).

Model Configuration

Model configuration involves the instantiation of both the mandatory and optional parameters of the chosen diffusion model.

Model parameters can be setted as in the following example:

import ndlib.models.ModelConfig as mc

# Model Configuration
config = mc.Configuration()
config.add_model_parameter("beta", 0.15)

The only model parameter common to all the diffusive approaches is fraction_infected that allows to specify the ratio of infected nodes at the beginning of the simulation.

Node Configuration

Node configuration involves the instantiation of both the mandatory and optional parameters attached to individual nodes.

Node parameters can be set as in the following example:

import ndlib.models.ModelConfig as mc

# Model Configuration
config = mc.Configuration()

threshold = 0.25
for i in g.nodes():
    config.add_node_configuration("threshold", i, threshold)

Edge Configuration

Edge configuration involves the instantiation of both the mandatory and optional parameters attached to individual edges.

Edge parameters can be set as in the following example:

import ndlib.models.ModelConfig as mc

# Model Configuration
config = mc.Configuration()

threshold = 0.25
for i in g.nodes():
    config.add_edge_configuration("threshold", i, threshold)

Status Configuration

Status configuration allows to specify explicitly the status of a set of nodes at the beginning of the simulation.

Node statuses can be set as in the following example:

import ndlib.models.ModelConfig as mc

# Model Configuration
config = mc.Configuration()

infected_nodes = [0, 1, 2, 3, 4, 5]
config.add_model_initial_configuration("Infected", infected_nodes)

Explicit status specification takes priority over the percentage specification expressed via model definition (e.g. fraction_infected).

Only the statuses implemented by the chosen model can be used to specify initial configurations of nodes.