0

For an agent based modelling I'm doing with mesa & mesa-geo I need a way, to select and manipulate the agents out of the model.py.

For example, if you take the Introductory Tutorial, each step you want a particular randomly picked percentage of all agents which have no money (self.wealth = 0) to receive one money.

Therefore you need to know from all agents the wealth, pick the ones with wealth zero, pick randomly an amount of them and set wealth = 1. But is there a way, to do this out of the model.py?

For my understanding, you can only get a list of the agents by model.grid.agents, but here you can't see there attributes and you can't change the attributes.

vvvvv
  • 25,404
  • 19
  • 49
  • 81

1 Answers1

0

At the end I found a solution. The keyword is object oriented programing. Here is a question which answers this one quite good. At the end I realised my problem with adding functions for finding the object by a attribute criteria and then changing the attributes of those. As I already mentioned, the list of attributes can be accessed in the model itself by self.space.agents or self.grid.agents.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – buhtz Apr 21 '22 at 08:35