An R6 class that implements a contact pattern in R
An R6 class that implements a contact pattern in R
get
.The external pointer pointing to the C++ RContact object.
attached
a logical value indicating whether the object has been attached to a population
new()
the constructor
Contact$new()
population
the population to attach to. An external pointer
contact()
Returns the contacts of the given agent
Contact$contact(time, agent)
time
the current time in the simulation, a number
agent
the agent whose contacts are requested. An external pointer
a list of external pointers pointing to the contacting agents
addAgent()
Add an agent to the contact pattern
Contact$addAgent(agent)
agent
the agent to be added. An external pointer
agent
the agent to be removed. An external pointer
build()
Build the contact pattern
Contact$build()
clone()
The objects of this class are cloneable with this method.
Contact$clone(deep = FALSE)
deep
Whether to make a deep clone.
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.