Submodels enable the reusing of parts of a model to perform specific operations inside other models. By using them, we can reduce the amount of work we have to put on when creating models that share similar functionalities. They are also an important tool for abstraction, hiding unnecessary details and making easier to reason about the model concept and its implementation. Conceptually, a submodel is a combination of functors exporting inputs and outputs to be bound externally, but, from the user point of view, a submodel is used just like any other ordinary functor.
Submodels are also first class citizen that can be transferred from one model to another. They can also be modified and updated at any time without breaking the model where they are being used. They can also depend on other submodels, as long as their definition do not form a cycle.
Basically, we have three different types of submodels in Dinamica EGO: system submodels, user submodels and local submodels. The different types of submodels are identified by different icon badges on the representation of the corresponding functors on the model.
System and user submodels are displayed in the “Submodels” tab while local submodels are shown in the “Local Submodels” tab of the Functor Library. Local submodels are only available when their associated model is opened.
In practice, users can only create local submodels. These local submodels can later be promoted to user submodels making them a definitive part of the user's tool set.
Local submodels are stored in a folder based on the model name. If the model containing the local submodel is named simulation model.egoml
, its local submodels will be stored in a subfolder called simulation model_egoml_Submodels
. Basically, the naming algorithm just replaces “.” with “_” and appends “_Submodels” to the file name. Using a unique submodel folder for each model guarantees that submodels from one model are completely independent from the submodels from any other model. Local submodels can also be defined in a folder called “Submodels” located in the same folder where the model file is located, and shared among all the models located in that folder. However, the folder is automatically converted into an unique submodel folder when the model is saved by the graphical interface.
User submodels are stored typically in the folder c:\<User>\Documents\Dinamica EGO 5\Submodels
.
Store submodels are stored typically in the folder c:\<User>\AppData\Local\Dinamica EGO 5\StoreSubmodels
.