"Plug-and-play" modularity means the ability to replace one module in a model with another, without having to specify how the module's inputs and outputs link up with the rest of the model. This requires that the modules to be swapped share the same interface to the rest of the model.
In Simile, a module is a submodel. There is a mechanism for replacing one submodel with another: simply open a separate window for the submodel, and use the File: Open command to load a new submodel. However, this by itself does not automatically remake all the links between variables in the submodel and those in the rest of the model.
In order to have plug-and-play modularity, we need to specify the interface between a submodel and the rest of the model. This means stating which variable in the submodel is linked to which variable in the main model, and the nature (dimensions, units) of the two variables. This specification is saved in a separate interface specification file, and can be loaded when we create a new submodel, in order to re-make all the linkages.
In: Contents >> Working with submodels
In this simple example, we make a model of the interaction between plant
growth and soil water. We use a submodel for each component. Note that
at this stage we do not actually need to use submodels: they merely serve
to show the main functional components of this model.
In: Contents >> Working with submodels >> Plug-and-play modularity
We first open up a separate window for the soil submodel by double-clicking on its boundary.
We now select the "Save as..." command from the submodel window's File menu (not the menu for the main model window).
In: Contents >> Working with submodels >> Plug-and-play modularity
We save the interface specification for the interface between the soil
water submodel and the rest of the model, using the "Save Interface"
command from the "Model" menu of the submodel window.
In: Contents >> Working with submodels >> Plug-and-play modularity
We clear the submodel, by selecting File: New from the submodel window's
menu.
In: Contents >> Working with submodels >> Plug-and-play modularity
We now load an alternative version of the submodel.
This new submodel also has a variable called "Soil water" (though in this case it is a Simile variable, not a compartment), and a flow called "transpiration". Note also that this submodel is structurally different from the first submodel: all that matters for plug-and-playability is that the two models have the same interfacing variables: the rest of their structure is irrelevant.
At this stage, the linkages are not re-made. The Soil submodel contains an unsatisfied input parameter "Plant biomass", while the main model contains an unsatisfied input parameter called "Soil water". These undefined elements are shown in red.
In: Contents >> Working with submodels >> Plug-and-play modularity
We select an interface specification file using the "Load interface"
command from the "Model" menu of the submodel window (again, not the main
model window).
Now, Simile automatically re-makes the linkages between the submodel and
the rest of the model.
Finally, we can close the submodel window, since it is not required any
more. We now have the new model!
In: Contents >> Working with submodels >> Plug-and-play modularity