Localizing Containers

In most models, element names are forced to be unique. In some cases, however, you may want to have more than one element with the same name. This requirement usually arises when you have a number of similar subsystems in your model.

For example, suppose that you have developed a subsystem (within a Container) that calculates the balance in a bank account as a function of the previous balance, interest rate, deposits and withdrawals. Each of these items would be represented by its own element in the Container. After creating these elements, you decide you would like to track ten other accounts.

In such a case, it would be convenient to create ten copies of the Container (one for each of the other ten accounts). If GoldSim allowed you to just make copies of the bank account Container, however, there would be confusion when you referred to an element by name (e.g., in an expression), since GoldSim would have no way of knowing which copy of the element you were referring to.

GoldSim’s solution to this problem is to allow you to localize portions of your model, such that any element names in the local region are hidden from elements outside of that region. A local region is referred to as a scope in GoldSim. Elements with the same name cannot exist within the same scope. Elements can, however, have the same name if they are located in different scopes. You change the scope of an element by localizing the Container in which it is located. Unless you specifically “expose” an element, the contents of a local Container can only be "seen" and hence referenced by other elements inside the Container.

The example model LocalizedContainer.gsm in the General Examples/Containers folder of your GoldSim directory (accessed by selecting File | Open Example... from the main menu) contains an example of the use of Localized Containers.

Learn more about: