Skip to content

Model multiple Agents #20

Answered by jofmi
Erlix322 asked this question in Q&A
Jun 9, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi @Erlix322, you are right that there is no example for this in the docs yet. You would have to define two agent classes (e.g. AgentType1 and AgentType2) and initiate a model for example as follows:

class MyModel(ap.Model):
    def setup(self):
        self.type1_agents = ap.AgentList(self, 10, AgentType1)
        self.type2_agents = ap.AgentList(self, 10, AgentType2)
        self.all_agents = self.type1_agents + self.type2_agents

You can then use these three lists to access either agents of just one type, or all agents together.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Erlix322
Comment options

Answer selected by jofmi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants