| Agent {ABM} | R Documentation |
R6 class that represent an agent
Description
The key task of an agent is to maintain events, and handle them in the chronological order. Agents also maintain their states, which is a list of values. The events, when handled, operate on the state of the agent (or other agents).
Details
During the simulation the agent with the earliest event in the simulation is picked out, unscheduled, then its earliest event is handled, which potentially causes the state change of the agent (or another agent in the simulation). The state change is then logged by loggers that recognize the state change.
An agent itself cannot handle the event. Instead, it has to be added to a simulation (or a population that itself is added to a simulation).
Note that specifying death.time is equivalent to call the
$setDeathTime method.
Check if the state of the agent matches a given state
At the time of death, the agent is removed from the simulation. Calling it multiple times causes the agent to die at the earliest time.
Active bindings
stateGet/set the state of the agent
idGet the agent ID
getGet the external pointer for the agent
Methods
Public methods
Method new()
Usage
Agent$new(agent = NULL, death.time = NA)
Arguments
agentcan be either an external pointer to an agent such as one returned by newAgent, or a list representing the initial state for creating a new agent, or NULL (an empty state)
death.timethe time of death for the agent, a numeric value
Method match()
Usage
Agent$match(rule)
Arguments
rulethe state to match, a list
Returns
a logical value Schedule an event
Method schedule()
Usage
Agent$schedule(event)
Arguments
eventan object of the R6 class Event, or an external pointer returned by newEvent
Returns
the agent itself (invisible) Unschedule an event
Method unschedule()
Usage
Agent$unschedule(event)
Arguments
eventan object of the R6 class Event, or an external pointer returned by newEvent
Returns
the agent itself (invisible) leave the population that the agent is in
Method leave()
Usage
Agent$leave()
Returns
the agent itself set the time of death for the agent
Method setDeathTime()
Usage
Agent$setDeathTime(time)
Arguments
timethe time of death, a numeric value
Returns
the agent itself (invisible)
Method clone()
The objects of this class are cloneable with this method.
Usage
Agent$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.