agent_manager | R Documentation |
A class that abstracts the management of aggregations of agent classes. Each village should have an instance of a agent_manager to interface the agents inside.
add_agent()
Adds a single agent to the manager.
get_average_age()
Returns the average age, in years, of all the agents.
get_living_agents()
Gets a list of all the agents that are currently alive.
get_states()
Returns a data.frame consisting of all of the managed agents.
get_agent()
Retrieves a particular agent from the manager.
get_agent_index()
Retrieves the index of a agent.
initialize()
Creates a new manager instance.
load()
Loads a csv file defining a population of agents and places them in the manager.
remove_agent()
Removes a agent from the manager
Creates a new agent manager instance.
agents
A list of agents objects that the agent manager manages.
agent_class
A class describing agents. This is usually the default villager supplied 'agent' class
new()
agent_manager$new(agent_class = villager::agent)
agent_class
The class that's being used to represent agents being managed Given the identifier of a agent, sort through all of the managed agents and return it if it exists.
get_agent()
Return the R6 instance of a agent with identifier 'agent_identifier'.
agent_manager$get_agent(agent_identifier)
agent_identifier
The identifier of the requested agent.
An R6 agent object Returns a list of all the agents that are currently alive.
get_living_agents()
agent_manager$get_living_agents()
A list of living agents Adds a agent to the manager.
add_agent()
agent_manager$add_agent(...)
...
One or more agents
None Removes a agent from the manager
remove_agent()
agent_manager$remove_agent(agent_identifier)
agent_identifier
The identifier of the agent being removed
None Returns a data.frame of agents
get_states()
agent_manager$get_states()
Each row of the data.frame represents a agent object
A single data.frame of all agents Returns the index of a agent in the internal agent list
get_agent_index()
agent_manager$get_agent_index(agent_identifier)
agent_identifier
The identifier of the agent being located
The index in the list, or R's default return value Connects two agents together as mates
connect_agents()
agent_manager$connect_agents(agent_a, agent_b)
agent_a
A agent that will be connected to agent_b
agent_b
A agent that will be connected to agent_a Returns the total number of agents that are alive
get_living_population()
agent_manager$get_living_population()
The number of living agents Returns the average age, in years, of all of the agents
get_average_age()
agent_manager$get_average_age()
This is an example of the kind of logic that the manager might handle. In this case, the manager is performing calculations about its aggregation (agents). Note that the 364 days needs to work better
The average age in years Takes all of the agents in the manager and reconstructs the children
add_children()
agent_manager$add_children()
This is typically called when loading agents from disk for the first time. When children are created during the simulation, the family connections are made through the agent class and added to the manager via add_agent.
None Loads agents from disk.
load()
agent_manager$load(file_name)
file_name
The location of the file holding the agents.
Populates the agent manager with a set of agents defined in a csv file.
None
clone()
The objects of this class are cloneable with this method.
agent_manager$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.