AgentDataCollector

BPTK API Documentation for the AgentDataCollector class
Keywords

agent-based modeling, abm, data collection, bptk, bptk-py, python, business prototyping

AgentDataCollector

AgentDataCollector Constructor

AgentDataCollector()

A DataCollector that keeps the properties of every individual agent in every timestep, rather than only the aggregate statistics per agent type and state.

Use it when the question is about the spread rather than the average: which agents ran out of stock, how unequal the outcome was, what an individual trajectory looked like. It costs memory proportional to agents times timesteps, so the default DataCollector remains the right choice for large populations.

Hand it to the model like any other collector:

from BPTK_Py import Model, AgentDataCollector, SimultaneousScheduler

model = Model(
    starttime=1, stoptime=60, dt=1, name="Customer Acquisition",
    scheduler=SimultaneousScheduler(),
    data_collector=AgentDataCollector(),
)

AgentDataCollector.collect_agent_statistics

collect_agent_statistics(time, agents)

Called by the scheduler once per timestep. Records every agent’s properties for that timestep.

  • Parameters

    • time – Float. The timestep being recorded.

    • agents – List. The agents to record.

AgentDataCollector.get_agent_stats

get_agent_stats()

Returns everything collected so far.

  • Returns

    A dictionary of the collected agent data, keyed by timestep.

AgentDataCollector.plot_agent_stats

plot_agent_stats(agent_ids=[], properties=[], title=‘Base’, agent_type=’’)

Plots the recorded properties of individual agents over time.

  • Parameters

    • agent_ids – List (Default=[]). The agents to plot. Empty means every agent.

    • properties – List (Default=[]). The properties to plot. Empty means every property.

    • title – String (Default=‘Base’). The plot title.

    • agent_type – String (Default=’’). Restrict the plot to one agent type. Empty means every type.