You are here

Working with submodels : Plug-and-play modularity

Plug-and-play modularity using submodels

"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.

Demonstration of plug-and-play modularity

  • Step 1: Build a model with submodels
  • Step 2: Save one of the submodels as a separate model
  • Step 3: Save the interface specification
  • Step 4: Clear the submodel
  • Step 5: Load an alternative version of the submodel
  • Step 6: Load the interface specification file

In: Contents >> Working with submodels