Setting Up Import Links

You can use import links to bring data in from external Excel or CSV files. This greatly simplifies data organization, and also lets you have multiple datasets that can be used to run different scenarios, or to parametrize your model for different situations. There are two distinct ways to import data. The first brings in constants and graphical functions that directly change the corresponding model equations. The second brings in temporary changes to model variables for a run, or set of runs, that don't change any model equations. The two are discussed separately, but the rules for formatting the source data file, outlines in Creating Import and Export Files, are the same in both cases.

Note: You can specify import links of both types in a model, but they can't come from the same source.

Set Parameters - Bringing Data Directly into a Model

You can import constants and graphical functions to replace the values entered in your model equations. To do this, you need to create a link between the model and an Excel worksheet or a delimited text file and choose Set parameters for import behavior. The worksheet or file should contain the names of the model variables that you want to import data into, and the values that you want to import.

When you set up an import link, you can make the link dynamic, so that it's executed whenever the source file changes, or you can just have it import values in when you explicitly ask it to. You can also disable links without removing them, so that you don't need to set them up again.

If you don't make the link dynamic, you'll need to perform a manual import whenever you want to update the values in the model. You can also perform a manual import on automatic links, but it'll only have an effect when you've changed values in an open Excel worksheet and haven't saved them - otherwise the values will be imported automatically when the file changes.

You can create as many import links as you want per model, but each source can only be used once.

If you're using Excel files, you can set up export and import links to use the same or different Excel files. For example, you can import values from one file into your model, and then export model run values to a different file to retain the "before" and "after" values in separate files. Or, you can import from and export to different tabs in the same file, although with automated links this will trigger another import (because the file changes). Exporting to and importing from the same sheet (or same delimited file) will not work.

Note: Since the software performs an import when you set up a link, you must have created an import file with valid data formats before you set up the link (and for CSV and tab delimited files, you must have saved all changes to the file) in order to import its data.

To Set Up a Direct Import Link

  1. Open the model you want to set up an import link for.
  2. From the Edit menu, choose Import Data.

    The Import Data dialog box will open.

  3. Use the options in the dialog box to choose the file, the worksheet (if applicable), and whether or not to make the link dynamic.
  4. Click on the Set parameters radio button toward the bottom of the dialog (by default, Control variables is selected).
  5. You can add as many links as you want.
  6. When you're finished setting up the import links, click OK.

    The selected data will be imported into the model.

Note: When data are imported automatically, no warning or error messages are given. You should verify the validity of your import file by importing manually when you set up the link. This will give you information about the import.

Note: If your import source includes variables that are not constants or graphical functions, those variables will be ignored during the import process.

Control Variables - Temporarily Overriding Model Values

By selecting Control variables, rather than Set Parameters for the import behavior, you can import values that will temporarily override the value of a variable during simulation, but not make any changes to the equations. The data format for the file is the same, but you can specify any variable in the file, even variables that aren't constants. The value specified will be used in place of the computed value. For example, if the equation for x is y+1, and you've specified a value of 42 in the file, then x will be 42 no matter what value y takes on. If the variable is a graphical function, you can either specify a single value for it to take on, or a series of values to populate the graphical function. If you specify a series of values for a variable that's not a graphical function, only the first one will be used.

The steps for temporarily overriding values are also the same as those for changing constants directly, though the actions that trigger changes are slightly different. Temporary overrides are read at the beginning of each simulation, and only active import sources are used at all. So, whereas a direct import will stop changing if an import sheet is deactivated, a temporary change will just be dropped, reverting to the equation value. Because the files are all checked each time you start a simulation, you don't need to save changes in Excel files for them to be used (CSV files will still need to be saved).

To Control Variables with an Import Link

  1. Open the model you want to set up an import link for.
  2. From the Edit menu, choose Import Data.

    The Import Data dialog box will open.

  3. Use the options in the dialog box to choose the file, the worksheet (if applicable), and whether or not to make the link dynamic.
  4. Leave the default, Control variables, selected.
  5. You can add as many links as you want.
  6. When you're finished setting up the import links, click OK.

    The next time the model is run, selected data will be used to control variable values.

You can control variables of any type. If you control a stock, it will change the initial value. If you control other variables, it will set the value they take during the entire simulation.

Note: When you simulate, no warnings or errors will be shown. To see warnings and errors, click on the test button at the bottom of the panel.

Controlling Graphicals

Graphicals can be controlled in two ways. The value of the variable can be controlled directly, or the graphical function can be replaced with one specified in the file. The software looks at the number of values you've supplied. If you supply 1, it will control the variable. If you supply more than one, it will use the values as y points for the graphical. If you use explicit :x, :y formatting, it will control the graphical.

Array Considerations

You can import to arrays by following the formats described in Creating Import and Export Files. If you import to an array that's apply to all, using the set parameters option, but provide different values, the equations in the model will be changed to be not apply to all. If you do the opposite, supply a single value for a non apply to all equation, the equation will remain non apply to all, but all of the values will be changed to the one specified.

When controlling variables, the model equations are never changed, but all variables are treated element by element. You can, for example, set the value for a single element of an apply to all array in this fashion. If you specify the entire array (using no [] in the variable name), all elements will be changed regardless of whether it's an apply to all variable or not.