I'm building a model in AnyLogic where I need to assign a value to agents that corresponds to their age. These values must be based on the population age profile that I got from national statistics (# of people with 0 to 100 years-old).
So far, I've tried to used custom distribution with ranges to define ages and the corresponding number of observation, both loaded from a table. I added a condition to match simulation year to the year in the table (i.e. for each year in the simulation there will be a different age distribution in the table, reflecting an aging population).
It seems that AnyLogic check the condition to match the year just once and use the values found during all simulation time (i.e. it carries the age distribution of first years to all years). When I run the model for a single year, it correctly use the corresponding distribution for that year.
Table with number of observations for each age per year Custom Distribution settings
It seems that AnyLogic check the condition to match the year just once and use the values found during all simulation time
This is how it works, correct. You could instead create these distributions programmatically, one for each year:
Loop through each dbase row (using the Database query wizard) and create a custom distribution for each year entry.
Store them in a LinkedHashMap<Integer, CustomDistribution>
where the key is the year and the value the distribution for that year.
Then at runtime, you can simply call myLinkedHashMap.get(getYear())
to get the distribution for that year