-
Notifications
You must be signed in to change notification settings - Fork 10
Logger
A simulation object maintains a list of logger, which observes the state changes of an agent. At the specified times in a run, the values of the logger are reported and recorded in a data.frame object, where the columns represent variables, and rows represent the observation at each time point given to each run. Each logger has a name, which becomes the the column name in the data.frame.
newCounter = function(name, from, to=NULL, initial=0)
- name: the name of the counter, must be a length-1 character vector
- from: a list specifying state of the agent, or a character or numeric value that is equivalent to list(from). please see the details section
- to: a list (can be NULL) specifying the state of the agent after the state change, or a character or numeric value that is equivalent to list(from). please see the details section
- initial: the initial value of the counter. Default to 0.
an external pointer that can be passed to the Simulation class' addLogger method.
If the argument to=NULL
, then the counter counts the transitions from from
to to
. Otherwise, it counts the number of agents in a state that matches the state
argument. Specifically, if the agent jumps to state
, then the count increases by 1. If the agents jumps away from state
, then the count decreases by 1.
newStateLogger = function(name, agent, state.name)
- name: the name of the logger. A length-1 character vector
- agent: the agent whose state will be logged. An external pointer
- state.name: the state name of the state of the agent to be logged. A character vector of length 1.
If a state changed happened to any agent, the specified state of the agent given by the agent
argument will be logged. If
state.name==NULL
, then the state of the agent who just changed is logged.
The agent must be an external pointer. To use an R6 object, we need to use its active field $get
to get the external pointer.
The state to be logged must have a numeric value.