Skip to content

Collecting data from different types of agents (agenttype_reporters) #2804

Open
@rklymentiev

Description

@rklymentiev

Hi,

I am not sure if I am misunderstanding the usage of agenttype_reporters parameter in DataCollector() function, but I cannot make it work. For example, I was trying to implement it in the Money Model (https://mesa.readthedocs.io/latest/tutorials/2_collecting_data.html) by replacing

self.datacollector = mesa.DataCollector(
    model_reporters={"Gini": compute_gini}, 
    agent_reporters={"Wealth": "wealth"}
)

with

self.datacollector = mesa.DataCollector(
    model_reporters={"Gini": compute_gini}, 
    agenttype_reporters={MoneyAgent: {'Wealth': 'wealth'}}
)

In this case no errors are popping up, but at the end there are no Wealth data in the results. Running using batch_run():

params = {"width": 10, "height": 10, "n": range(5, 105, 5)}

results = mesa.batch_run(
    MoneyModel,
    parameters=params,
    iterations=5,
    max_steps=100,
    number_processes=1,
    data_collection_period=-1,
    display_progress=True,
)
results_df = pd.DataFrame(results)

Am I missing something? If I use both agent_reporters and agenttype_reporters at the same time, then only measures defined in agent_reporters are saved in the results. Mesa version 3.2.0

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions