Creating paired agents

Because every population simulated in an ABM has to start from some point, a representative zero-population has to be created. This is relatively straight forward if each member of the population is created independently as the values of the memory variables can be drawn from appropriate distributions with a respecting covariance matrix of the variables. As our model includes partnerships between agents, also a possible partner needs to be documentend in the PID memory variable.

Our first approach was the application of a matching algorithm. Firstly, all agents were created using the AgentMaker with their age drawn from the according age distribution of the German population and afterwards – corresponding to the share of the agents in relationships – a part of the agent population was matched into partnerships according to their AGE and SEXOR. This approach worked pretty well, until one day we decided to go for an population with 1.000.000 agents. Until that day the greatest agent population has been 100.000 agents, for which our (very simple) matching algorithm took roundabout 60 minutes. 1.000.000 agents was too much and the algorithm crashed.

Besides the long computational time, we needed a new procedure for the creation of paired agents. A computationally much faster solution is the creation of the partner-agent by the agent itself. So, if a random number determines, that an agent should be in a relationship, the agent creates its own partner-agent with corresponding values in dependency to its own AGE and SEXOR. The problem that now arises is the occurence of an unbalanced age structure of the zero-population. Say, if a 25 year old agent draws its own partner, the probability will be high, that this partner will also be in his twenties. So, the probability for an age-group X needs to be seen as conditional on the probability that an agent from another agegroup Y is in a relationship and creates his own partner in age group X. In other words the age distribution needs to be corrected for the age distribution of the partners. Using Bayes’ Rule we can solve this problem analytically.




R-code can be found on the corresponding github-repository.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: