Skip to contents

Agent-based model class

Agent-based model class

Details

Represents an agent-based model with specified parameters and agents.

Methods

initialize(parameters = DEFAULT_PARAMETERS, agents)

Creates a new AgentBasedModel with the given parameters and agents.

parameters

A ModelParameters object specifying the model parameters. Defaults to DEFAULT_PARAMETERS.

agents

A list of agent instances for the model.

get_parameters()

Returns the ModelParameters instance for this model.

Methods


Method new()

Create a new AgentBasedModel instance.

Usage

AgentBasedModel$new(parameters = DEFAULT_PARAMETERS, agents = NULL)

Arguments

parameters

A ModelParameters object specifying the model parameters. Defaults to DEFAULT_PARAMETERS.

agents

A list of agent instances for the model.


Method sync_network()

Synchronize agent and network fields

Usage

AgentBasedModel$sync_network(
  direction = c("to_graph", "from_graph", "neighbors_only")
)

Arguments

direction

"to_graph", "from_graph", or "neighbors_only"


Method get_agent()

Get the agent associated with a given ID or name

Usage

AgentBasedModel$get_agent(key)

Arguments

key

Integer index or character name


Method get_network()

Return the igraph network (after syncing from agents)

Usage

AgentBasedModel$get_network()


Method get_parameters()

Get the of model parameters

Usage

AgentBasedModel$get_parameters()


Method set_parameters()

Set multiple model parameters

Usage

AgentBasedModel$set_parameters(params)

Arguments

params

Named list of parameters to set


Method set_parameter()

Set a single model parameter

Usage

AgentBasedModel$set_parameter(key, value)

Arguments

key

Parameter name

value

Parameter value


Method get_parameter()

Get a single model parameter

Usage

AgentBasedModel$get_parameter(key)

Arguments

key

Parameter name


Method clone()

The objects of this class are cloneable with this method.

Usage

AgentBasedModel$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.