Creating generic population model objects for different cities using cloned containers


Overview: This example illustrates an efficient way to model multiple objects of the same type or class without having to manually reimplement identical model logic and mathematics. In this case we're modeling population growth in three different cities. The population growth model has the following inputs: starting population, annual growth rate and growth rate variability (including an auto-correlation input). The values of the inputs may be different for each city, but the population growth dynamics are modeled in the same way.

Cloned Containers and Exposed Outputs: In GoldSim, it is easy to replicate model logic within a Container by simply cloning the Container as many times as needed. When you clone a Container, you are notified that the Container must be localized in order to avoid naming conflicts. The names of Elements inside of the clones will be the same. Any output inside of a localized Container that you wish to reference outside of it must be 'exposed' on the Container.

Inputs to Cloned Containers: Since clones are exact replicates of each other, if you were to hard-code a numerical value as an input, this numerical value would be replicated between the cloned models. To get around this, we instead reference the names of vector Data Elements (in the 'Inputs' Container) that store different numerical input values for the different cities.

If you go into any one of the city Containers, you will see that there is a non-cloned Data Element called 'Object_ID' that stores the numerical index corresponding to the city. Inside of cloned Containers, a model input can be referenced using the name of the input followed by 'Object_ID' inside of square brackets. For example, the initial population input for an Integrator can be specified as 'start_population[Object_ID]'. The value of 'Object_ID' is different for each city and thus references a different population value in 'start_population'.


Making Better Decisions In An Uncertain World