STEM help / Editor skills

4.13.4 Linking STEM model inputs to the results of another model

Some modelling projects may demand a series of STEM models, where some key results of one model drive the inputs of another. In previous versions of STEM, the only way to achieve this linkage was:

  1. to output results tables from the first model
  2. to link key results into an appropriately formatted input workbook in Excel
  3. to link inputs for the second model from that input workbook,

taking care to perform each of these steps each time the first model had been run, before running the second.

Figure 1: Linking models via intermediate workbooks

Defining an external reference to a result of another model

Now you can link a model input directly to a result of another model through a new type of external reference. Suppose you have two models, model1.dtl and model2.dtl, and you want to link the deployment of a Resource called Eight-Channel Base Station in the second model to the number of installed units of a Resource called Base Station Site in the first:

  1. Load model2.dtl into the Editor and select Deployment from the icon menu for the Eight-Channel Base Station Resource. The Deployment dialog is displayed.
  2. Select the Sites field, and then select Links from the File menu on the main window. The External Links dialog is displayed.
  3. Click Add… to display the Define External Link dialog, and then enter model1.smr, or click Browse… in order to locate the appropriate directory.

Figure 2: Adding an external link to the results of another model

  1. Click OK to return to the External Links dialog, and then select the Paste button. The Select Result dialog is displayed.
  2. Select Resources in the Type list. The names of all the Resources in model1 are listed in the Element box, and the names of all the available Resource results are listed in the Result box.

Figure 3: Selecting an external reference to a STEM model result

  1. Select Base Station Site and Installed Units and then click OK. The appropriate external reference is pasted into the formula bar for the Sites input.
  2. Click the tick button or press <Enter> to commit the formula. The results data are retrieved in the form of an Interpolated Series.

Figure 4: Linking an input to a result from another STEM model

Note: If you prefer, you can enter the formula directly without using the External Links dialog. This may be quicker in some circumstances, e.g., if you want to reference a different element or result in the formula.

Updating an external reference to a result of another model

Once you have created an external link to another model, you can update the data at any time, as for any other external link:

  1. Select Links from the File menu on the main window. The External Links dialog is displayed.
  2. Select model1.smr in the list of Links and click Update. Any formulae that refer to this file are re-calculated, retrieving the latest data.

However, this procedure is not essential, because whenever you run model2, STEM will prompt you to update links to model1 if it has been run since the data was last retrieved, making the process of linking the two models completely automatic.

Figure 5: Linking models directly

Defining an external reference to an Excel named range

Although it is slightly out of context, this seems nonetheless an appropriate place to mention that the process of linking inputs to named ranges in Excel – see 6.3 Linking input data from Microsoft Excel spreadsheets – has been slightly simplified:

  1. Select Links from the File menu on the main window. The External Links dialog is displayed.
  2. Add a link to an Excel file, or select an existing one from the list of Links and click Paste. The Select Name is displayed, listing all the named ranges defined in the selected workbook.
  3. Select the required name from the list and click OK. The appropriate external reference is pasted into the current formula bar.

Figure 6: Selecting an external reference to an Excel workbook

Note: You can enter an unlisted name if you haven’t yet created the name to which you wish to refer in the workbook.

 

© Implied Logic Limited