Contact {ABM}R Documentation

An R6 class that implements a contact pattern in R

Description

An R6 class that implements a contact pattern in R

An R6 class that implements a contact pattern in R

Details

The main task of the class is to return the contacts of a given agent. Each object of this class is associated to a population. A population may have multiple contacts attached, e.g., a random mixing contact pattern and a network contact pattern.

This class must be subclassed in order to implement specific functionality. To subclass, we must implement three methods, namely contact, addAgent, and build. See more details in the documentation of each method.

. This method should be called from the C++ side. Users should not call this directly.

When an agent is added to a population, it is added to each of the contact patterns. When a contact pattern is added to a population, all agents in a population is added to the contact pattern, one by one.

Note that, immediately before the simulation is run, while reporting the states to the simulation object, the population will call the build method for each Contact object. Thus a contact object may choose to ignore adding agents before build is called, and handle all agents within the finalize method. However, the contact object must handle adding an agent after build is called.

When an agent leaves a population, it is removed from each of the contact patterns.

This method may also be called in event handlers to remove an agent

This method is called immediately before the simulation is run, when the attached population reports the states to the simulation object.

Thus this method can be considered as a callback function to notify the contact object the population state, such as its agents, states, events, and contact patterns are all initialized, so the contact pattern should finish initialization, for example, building the contact network.

This is needed because some contact patterns, such as a configuration- model contact network, cannot be built while adding agents one by one. It must be generated when all agents are present. This is unlike the Albert-Barabasi networkm which can be built while adding the agents.

Active bindings

get

.The external pointer pointing to the C++ RContact object.

attached

a logical value indicating whether the object has been attached to a population

Methods

Public methods


Method new()

the constructor

Usage
Contact$new()

Method attach()

attach to a population

Usage
Contact$attach(population)
Arguments
population

the population to attach to. An external pointer


Method contact()

Returns the contacts of the given agent

Usage
Contact$contact(time, agent)
Arguments
time

the current time in the simulation, a number

agent

the agent whose contacts are requested. An external pointer

Returns

a list of external pointers pointing to the contacting agents


Method addAgent()

Add an agent to the contact pattern

Usage
Contact$addAgent(agent)
Arguments
agent

the agent to be added. An external pointer


Method remove()

Remove an agent from the contact pattern

Usage
Contact$remove(agent)
Arguments
agent

the agent to be removed. An external pointer


Method build()

Build the contact pattern

Usage
Contact$build()

Method clone()

The objects of this class are cloneable with this method.

Usage
Contact$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


[Package ABM version 0.4.1 Index]