Version 9.1.2 introduces the oft-requested ability to run models from the command line outside of iThink or STELLA (Windows only). This feature opens up a number of possibilities for users who need to automate their modeling tasks. For example, you could use the command line to automatically run a model multiple times, start a model from a script, or create a shortcut that opens and runs a model when you double-click on the icon.
I have set up a simple example that illustrates how you could run an iThink model multiple times to skirt the 32,767 time step limit that advanced users sometimes run up against. The model itself does nothing extraordinary, it simply increments the value of a Stock by one at each time step. What makes it worth noticing is that it runs 32,000 iterations three times to mimic a 96,000 step run.
This example will open and run the model file named multiple_run.itm, import data at the beginning of each run, and export data at the end of each run. You can double-click on the “Start batch runs” shortcut to kick things off or you can use the batch file that is provided. Note that you may have to edit these start files to make them work on your computer
Command Line Syntax
"c:\program files\isee systems\iThink 9.1.2\iThink.exe" -rn 3 multiple_run.itm
The command line above was entered into the “Target” field of the “Start batch runs” Properties dialog. Note the “Start in” field is intentionally left blank so that the shortcut will run the model from the current directory. If you move the shortcut file to a different directory, you’ll need to enter that directory into this field.
The identical command line syntax is used in the supplied batch file named “go.bat” and can be edited using Notepad.
Sample Model and Spreadsheet
The sample model uses a table to report the value of the Stock at the end of each run so that it can be exported to the “multiple_run_data.xls” Excel file. In Excel, I linked the exported value of the Stock to an “Import” worksheet. This way, one run hands off the final data to start the subsequent run like runners in a relay race passing a baton. Note the initial Stock value will need to be reset in Excel before starting a new batch of runs.
Running the sample command line puts iThink into a macro mode. It opens just as if you double-clicked its icon and manually started the runs yourself. Sit back and watch the model open, and let the model run three times on its own. Try to leave the process alone while it executes, I did find that if the runs were interrupted the Excel file could sometimes lose its formatting.
For an experiment you could add “-nq” to the command so that the model stays open after running. After adding the new parameter your command would look like this:
"c:\program files\isee systems\iThink 9.1.2\iThink.exe" -rn 3 -nq multiple_run.itm
There are many more command options available. View the full list here and experiment with other parameters.
Another advantage to running from the command line is that you can start and run a model from inside Excel. Not only can you run the model this way, but you can take advantage of all the parameters.
Create a shortcut as described in the post and save it. In Excel, pick a cell and select Insert hyperlink. Browse to and select the shortcut and then click OK. It’s that easy!!