Search code examples
anylogic

Creating ResourcePool using Agent Population and reading from Database in Anylogic


I am trying to generate resourcepool agents with parameters read from the database. So first thing I did I connected the Database with my resourcepool agent population, see image

enter image description here

enter image description here

Next in resourcepool (Team) block, I added the new units to my population teammembers

enter image description here

But since, I am adding new populations to my custom population the generated resourcepool agents just adds to the population. All I need is to use the five agents read from database with their parameters in the resourcepool. How to do this?

I found a temporary solution, I used an event function to set the parameters of the population after they are generated. But still, I want to generate the parameter values at the model creation time.

enter image description here


Solution

  • ResourcePools work like that: you typically only define the number of resources.

    To assign them specific param values directly, use the "on new unit" code as below. It is called for each new unit created.

    So if you have an initial pool size of 5, add a little counter variable to keep track of which unit you already assigned param values:

    enter image description here