System Dynamics Model Documentation Tool User Guide JAVA SDM-Doc is an analysis tool that creates HTML-based documentation and assessments of Vensim-based system dynamics models. Mark J. Bragen and Ignacio Martinez-Moyano September 2014 System Dynamics Model Documentation Tool User Guide — JAVA Page 2 of 32 Contents 1. Background on Transparency in Models and SDM-Doc .......................................................... 5 2. Installation................................................................................................................................. 6 3. Getting Started ........................................................................................................................ 10 3.1 File Menu Items ............................................................................................................. 10 3.2 Language Menu Items .................................................................................................... 15 3.3 Tools ............................................................................................................................... 17 3.4 Help Menu Items ............................................................................................................ 19 4. SDM-Doc Reports .................................................................................................................. 22 5. Output Files ............................................................................................................................. 30 6. Troubleshooting—When Things Go Wrong .......................................................................... 31 References ..................................................................................................................................... 32 System Dynamics Model Documentation Tool User Guide — JAVA Page 3 of 32 List of Figures Figure 1. Selection of Menu Items Needed to Arrive at the SDM-Doc Download Location........ 6 Figure 2. Overview Section with Documenting Tools Link Circled ............................................. 7 Figure 3. Documenting and Explaining Models with Link to SDM-Doc Download Page ........... 7 Figure 4. SDM-Doc Page with Download Link Circled................................................................ 8 Figure 5. Download Page Showing the Run, Save, Cancel Dialogue Box .................................... 9 Figure 6. SDM-Doc Tool/Java Version 1.0 Dialogue Box .......................................................... 10 Figure 7. SDM-Doc Tool/Java Version 1.0 Dialogue Box: File Pull-Down Menu .................... 10 Figure 8. Model Assessment Result Options Menu .................................................................... 11 Figure 9. Model Information Options .......................................................................................... 12 Figure 10. Variable Information and Warnings Options ............................................................. 13 Figure 11. Potential Omissions, Arrow Information, and Analyze Loops Options ..................... 14 Figure 12. Graph and Output Options.......................................................................................... 15 Figure 13. Register Language ...................................................................................................... 16 Figure 14. Language Translation File .......................................................................................... 16 Figure 15. File Selection Dialogue Box in Spanish ..................................................................... 17 Figure 16. Tools Options .............................................................................................................. 17 Figure 17. Tools Comment Cleaner Extracted Comments File .................................................... 18 Figure 18. Tools Comment Merged Vensim File ......................................................................... 18 Figure 19. Extracted Comments Word File .................................................................................. 19 Figure 20. Help Menu About and Feedback Options .................................................................. 19 Figure 21. About Dialogue Box with Disclaimer; Yes Button Circled ....................................... 20 Figure 22. SDM-Doc Feedback Form ......................................................................................... 21 Figure 23. Section 1: Model Assessment Section ........................................................................ 22 Figure 24. Section 2: Variable Types Section ............................................................................. 23 Figure 25. Section 3: Views Section ............................................................................................ 23 Figure 26. Section 4: Groups Section .......................................................................................... 23 Figure 27. Section 5: Modules Section ........................................................................................ 24 Figure 28. Section 6: Detailed Equation Descriptions for All Variables in the Model ............... 25 Figure 29. Section 7: Feedback Loop Information ...................................................................... 26 Figure 30. Section 9: Dimensionless Unit Variables ................................................................... 27 Figure 31. Section 8: Equations with Unit Errors or Warnings ................................................... 27 Figure 32. Section 10: Variable-View Relationships (Top) ........................................................ 28 Figure 33. Section 11: Variable-View Relationships (Bottom) ................................................... 29 Figure 34. Section 12: Input and Output Files’ Dates and Versions ........................................... 29 System Dynamics Model Documentation Tool User Guide — JAVA Page 4 of 32 1. Background on Transparency in Models and SDM-Doc1 The system dynamics modeling (SDM) approach champions model transparency and facilitates ease of communication about model elements. Transparency—the state or quality of being easily observed and comprehended—is an important attribute of useful models because it enables you to identify and understand the assumptions, relationships, and data used in models. Model transparency, therefore, is a central element in good modeling practice. SDM, like other types of models, embodies scientific theories about how the world works. Specifically, the SDM approach calls for the use of dynamic hypotheses as the basis for developing scientific models. Transparency in our models is akin to openness in our scientific research. One way to achieve transparency in our modeling efforts is through the use of thorough documentation processes. To help modelers increase the transparency of their models through enhanced documentation, scientists at Argonne National Laboratory, building on model documentation work by Oliva (2001), developed the System Dynamics Model Documentation Tool (SDM-Doc), a tool that enables modelers to create practical, efficient, HTML-based model documentation and provide customizable model assessments. Designed to provide documentation of models built with Vensim modeling software, and for ease of use, SDM-Doc is hosted at the System Dynamics Society webpage (www.systemdynamics.org). The tool provides for the quick generation of model documentation and assessment that can be produced concurrently with model development. Facilitating the generation of documentation and diagnostics of models—documenting and discovering “as you go”— makes it possible, as stated by Sterman, to “uncover errors that otherwise might not be detected until much later, preventing costly rework” (2000). The System Dynamics Review, the official journal of the System Dynamics Society, requires that all articles submitted have impeccable presentation of system dynamics models (formulation, validation, interpretation, etc.) and that all SD work be provided in an auditable format to allow a more streamlined review process. SDM-Doc is the perfect tool to meet this requirement. 1 Text taken from the Introduction section of Martinez-Moyano (2012). System Dynamics Model Documentation Tool User Guide — JAVA Page 5 of 32 2. Installation To download and install SDM-Doc, go to the System Dynamics Society webpage at www.systemdynamics.org. Here is a summary of the menu items to select in order to get to the location where you can download SDM-Doc: Home | Activities and Resources | Tools | Documenting Tools | Overview (Figure 1). Figure 1. Selection of Menu Items Needed to Arrive at the SDM-Doc Download Location System Dynamics Model Documentation Tool User Guide — JAVA Page 6 of 32 In the body of the Overview section, select Documenting tools (Figure 2). Figure 2. Overview Section with Documenting Tools Link Circled When you select Documenting tools, you will see the Documenting and Explaining Models page (Figure 3). In the second paragraph, select the here link (circled) to go to the SDM-Doc page where you can download the SDM-Doc tool. Figure 3. Documenting and Explaining Models with Link to SDM-Doc Download Page System Dynamics Model Documentation Tool User Guide — JAVA Page 7 of 32 Two versions of the SDM-Doc tool are available on the SDM-Doc page (Figure 4): the previously released C# version and the newly released Java version. Currently, the C# User Guide can be found with the “here” link. Figure 4. SDM-Doc Page with Download Link Circled System Dynamics Model Documentation Tool User Guide — JAVA Page 8 of 32 Once you select the link to download the Java version of the open-source SDM-Doc tool, you will have a choice to Run, Save, or Cancel the action (Figure 5). Since the Java version is distributed as a Zip file, clicking Run will open the file with your local Zip tool and allow the contents to be extracted to your local disk without making a local copy of the Zip file. Clicking Save will copy the Zip file to your local disk and then you will need to invoke your Zip tool on that file to extract the contents. You may extract the contents to the directory of your choice. The root directory of the distribution is named SDM-Docx.x where x.x specifies the version. No additional configuration is required to use the tool. Figure 5. Download Page Showing the Run, Save, Cancel Dialogue Box System Dynamics Model Documentation Tool User Guide — JAVA Page 9 of 32 3. Getting Started Once you have downloaded and extracted SDM-Doc, you are ready to begin. In the tool root directory there are two executable scripts to invoke SDM-Doc/Java. SDM-Doc.vbs is used on Windows computers and SDM-Doc.sh is used on Unix-based Systems. Double clicking the appropriate script will start execution of the tool. When you run the tool, you will see a dialogue box titled Sdm Doc Tool/Java Version 1.0 — English (United States) Figure 6. The field labeled Definition Input File asks you to type in the name of the input file to use. You can use the Browse button to select the input file. The following internet browsers have been tested for displaying SDM-Doc/Java results. Chrome Firefox Internet Explorer Figure 6. SDM-Doc Tool/Java Version 1.0 Dialogue Box The file browser applies a filter to display only regular files with the .mdl file extension, along with any directories. The tool will “remember” the directory from which a file was selected and use that as a starting point for the next Browse operation. 3.1 File Menu Items When you start SDM-Doc, you will have a File menu of Exit and Options (Figure 7). Figure 7. SDM-Doc Tool/Java Version 1.0 Dialogue Box: File Pull-Down Menu System Dynamics Model Documentation Tool User Guide — JAVA Page 10 of 32 Selecting Options will open a file of the SDM-Doc Model Assessment Result Options Menu (Figure 8). Figure 8. Model Assessment Result Options Menu With the Model Assessment Result Options menu item, you can select about 50 options to determine the types of results SDM-Doc will display in the generated HTML output file, grouped with the following buttons: Model Information — 19 options Variable Information — 5 options Warnings — 11 options Potential Omissions — 5 options Arrow Information — 3 options Analyze Loops — 4 options Graph & Output Options — 10 options You can use the buttons at the bottom of the options window to Save or Quit. System Dynamics Model Documentation Tool User Guide — JAVA Page 11 of 32 Menu Item: Options | Model Information The Model Information subsection identifies the total (Figure 9): Number of Variables Number of State Variables Number of Stocks Number of Feedback Loops – No IVV Number of Feedback Loops – With IVV Number of Causal Links Number of Macros Number of Equations Using Macros It also has options for: Variables with Source Information, Dimensionless Unit Variables, Variables without Predefined Min or Max Values, Function Sensitivity Parameters, and Data Lookup Tables Time Unit, Initial Time, Final Time, Reported Time Interval, and Time Step Model Is Fully Formulated Model Defined Groups Figure 9. Model Information Options System Dynamics Model Documentation Tool User Guide — JAVA Page 12 of 32 Menu Item: Options | Variable Information There are five Variable Information options (Figure 10): Description Meta Data Present in Views Used By Feedback Loops Menu Item: Options | Warnings The Warnings section has 12 options: Number of Undocumented Variables Equations with Embedded Data Equations with Unit Errors or Warnings Variables Not in Any View Nonmonotonic Lookup Functions Cascading Lookup Functions Non-Zero End Sloped Lookup Functions Equations with IF THEN ELSE Functions Equations with MIN or MAX Functions, Equations with STEP PULSE or Related Functions Ignore Embedded Constants of 0 or 1 Figure 10. Variable Information and Warnings Options System Dynamics Model Documentation Tool User Guide — JAVA Page 13 of 32 Menu Item: Options | Potential Omissions There are five options in the Potential Omissions section (Figure 11): Unused Variables Supplementary Variables Supplementary Variables Being Used Complex Variable Complex Stock Menu Item: Options | Arrow Information There are three Arrow Information options: Positive Polarity Causal Links Negative Polarity Causal Links Function-based Polarity Causal Links Figure 11. Potential Omissions, Arrow Information, and Analyze Loops Options System Dynamics Model Documentation Tool User Guide — JAVA Page 14 of 32 Menu Item: Options | Analyze Loops There are four Analyze Loop options: Analyze Loops Analyze Loops with IVV Loop Size Unlimited Loop Size Maximum Options: Graph and Output Options The Graph and Output Options section has fields to determine the visual representation of the output (Figure 12). The width, height, margins, font size, and view width of your screen can be customized or the defaults for each of those options can be used. In addition, you can select the threshold to be used for the Richardson’s Rule. You can also select the check boxes for Create Zip File With All Output Reports and Include MDL, if needed. Figure 12. Graph and Output Options Menu Item: Exit When you are ready to end your SDM-Doc session, select Exit from the File menu (Figure 7). 3.2 Language Menu Items Menu Item: Language | Register Language SDM-Doc supports internationalization. In this initial version, SDM-Doc can display results in English (United Sates), French, German, Italian, Japanese, Portuguese (Brazil), or Spanish (Figure 13). Provided with the tool is a Microsoft® Word template document that contains a list of the words and phrases displayed on input and output screens in table form. You can enter the translations of these words and phrases into the second column. The process of registering a new language can be initiated through the graphical user interface (GUI). The Word document is automatically reformatted as a Java Resource Bundle and it is stored with the other available languages. These resource bundle files can be shared with other users. System Dynamics Model Documentation Tool User Guide — JAVA Page 15 of 32 Simply place this file into the src\lang directory and this additional language will be available upon the next execution of the tool as it loads all available languages from this directory. Figure 13. Register Language If you select the Register Language option under Language, you will see a Language Registration dialogue box asking for the name of the Language Translation File (Figure 14). You can use the Browse button to go to the file you wish to use for the translation. Figure 14. Language Translation File You then select the language and country (if the translation is country-specific) from the list and click on the Register Language button to start the process (Figure 14). Note that the contents of the list box is the set of languages supported by the Java Locale class. Menu Item: Language | English (United States) If you select Language, English (United States) you can then use the Browse button to select your file. System Dynamics Model Documentation Tool User Guide — JAVA Page 16 of 32 Menu Item: Language | Spanish (Mexico) If you select Language, Spanish (Mexico), you will see the dialogue box messages translated into Spanish (Figure 15). You can then use the Explorar button to select your file. Figure 15. File Selection Dialogue Box in Spanish 3.3 Tools The Tools menu includes the Extract Comments and Merge Comments options (Figure 16). Using either the Vensim GUI or a text editor is not the most efficient way to edit comments in an MDL file. The SDM-Doc/Java tool provides the capability to extract the comments in the model file and write them to a Word file. The comments can be edited in Word and then loaded back into the model file. Figure 16. Tools Options Extract Comments in the Tools menu displays a window containing two fields in which the names of the model file and the Word file to which to write the comments (Figure 17). By default, when you select the model file, the tool with automatically fill in the name of the Word file replacing the “.mdl” extension with “.docx”. You can specify any filename for the Extracted Comments File. Note that if you specify the name of a file that already exists, a popup window will provide you the capability of not overwriting the file. By default the Word document will contain an alphabetically sorted list of variables . Checking the Group Variables By With/Without Comments checkbox will create two sections in the output document. The top of the document will contain an alphabetically sorted list of variables System Dynamics Model Documentation Tool User Guide — JAVA Page 17 of 32 with comments followed by an alphabetically sorted list of variables without comments. A sample of the Word document is shown in Figure 19. Figure 17. Tools Comment Cleaner Extracted Comments File Merge Comments Comments in the Tools menu displays a window containing three fields in which the names of the model file, the Word file with edited comments, and the file to which to write the merged model and comments file (Figure 18). By default, selecting the Vensim will auotmatically populate the two other filename fields with default values (“.docx” and “_Merged.mdl”. You will be warned if an existing output model file will be overwritten. Figure 18. Tools Comment Merged Vensim File Figure 19 contains a portion on the Extracted Comments Word file. There is a required format to this file. Three markers are inserted to delineate the start of a section for a variable and the beginning and end of its associated comment. The markers are: 1. _Variable_ 2. _CommentStart_ 3. _CommentEnd_ These markers must remain intact in order for the comments to be properly merged wit hthe model file. The variable names also must remain intact. Any changes to the variable name will result in an incorrect merge operation. System Dynamics Model Documentation Tool User Guide — JAVA Page 18 of 32 Figure 19. Extracted Comments Word File 3.4 Help Menu Items The Help menu includes About and Feedback options (Figure 20). Figure 20. Help Menu About and Feedback Options System Dynamics Model Documentation Tool User Guide — JAVA Page 19 of 32 Menu Item: Help | About Selecting the About option in the Help menu displays a window with the copyright notice, an open source license agreement, and a disclaimer (Figure 21). You must select the Yes button to proceed. Figure 21. About Dialogue Box with Disclaimer; Yes Button Circled System Dynamics Model Documentation Tool User Guide — JAVA Page 20 of 32 Menu Item: Help | Feedback Selecting the Feedback option in the Help menu displays a window with a feedback form for your use in communicating with the tool’s developers (Figure 22). Figure 22. SDM-Doc Feedback Form System Dynamics Model Documentation Tool User Guide — JAVA Page 21 of 32 4. SDM-Doc Reports Once you have provided an MDL file, SDM-Doc will produce an HTML file containing several reports based on the information requested on the Options Screen. The HTML report is highly hyperlinked to provide quick access to specific reports and external websites and files. 1. The Model Assessment section (Figure 23) shows results in three categories: Model Information, Warnings, and Potential Omissions. This section displays the summary information of your model. Figure 23. Section 1: Model Assessment Section The Quick Links at the top of the report provide quick access to a number of different points within the report from which the user can view results or serve as a starting point for System Dynamics Model Documentation Tool User Guide — JAVA Page 22 of 32 additional browsing of the report. Hyperlinks in Section 1 provide quick access to a list of individual equations and variables used in computing the summary statistics. 2. The Variable Types section (Figure 24) summarizes each type of variable in your model. Figure 24. Section 2: Variable Types Section 3. The Views section (Figure 25) summarizes the views in your model. Figure 25. Section 3: Views Section 4. The Groups section (Figure 26) summarizes each group in your model. Figure 26. Section 4: Groups Section 5. The Modules section (Figure 27) is an optional grouping mechanism beyond Views and Groups and it is created by prepending a non-zero length character sequence of any legal characters that can be part of a variable name followed by a terminating colon “:”. The use of the “:” in a variable name differentiates between subscript definitions and equations. These module identifiers are part of the variable name and simply provide an additional grouping identifier that can be used by the user. If no Module Identifiers appear in the model, then this section will not appear in the output report. System Dynamics Model Documentation Tool User Guide — JAVA Page 23 of 32 Figure 27. Section 5: Modules Section Sections 2, 3, and 4 are hyperlinked to provide quick access to detailed equation descriptions grouped by Type, View, or Group. 6. Section 5 is the largest section of the main HTML file (Figure 28). It contains the detailed equation descriptions mentioned above for all variables in the model. This section contains three (or four) columns: Module (optional), Group, Type, and Variable Name and Description. There is one row for each variable. The Group column contains the userspecified group in which the variable resides. The Type column includes a variable number (sequentially ordered using case-insensitive alphabetic sorting) and the variable type from the set provided in Section 2. Note that variables can be classified as multiple types. The last column provides the detailed description of the variable. This column is explained below the figure. The alphabet Quick Links provide direct access to the first variable in the list starting with the selected letter of the alphabet. Though they are displayed, no hyperlinks are provided for letters of the alphabet that do not appear as the first character of a variable name. System Dynamics Model Documentation Tool User Guide — JAVA Page 24 of 32 Figure 28. Section 6: Detailed Equation Descriptions for All Variables in the Model In the Variable Name and Description column, first the variable name is specified, followed by the specified units in red. The equation defining this variable is then presented. If the variable is a Level (Stock) variable, the INTEG function is converted into its integral form. The variables are hyperlinked to their detailed descriptions. The description is the comment provided by the modeler. Next, the list of views in which the variable is shown is displayed. These are hyperlinked to the View grouping report containing detailed descriptions for all variables in the view. The Used By list shows the variables that use this variable on the right side of its equation and it is hyperlinked to its detailed description. If a comment has been provided for that variable, it is displayed in green. Feedback loop information (Figure 28) is provided as follows: first, the number of feedback loops in which the variable appears is displayed, followed by the percentage of the total number of feedback loops in the model. Then loop information is broken down by polarity— positive polarity loop information display in blue, negative polarity loops display in red, and if the variable is contained in loops for which a polarity could not be determined, this information is displayed in black. Note that “0 entries will not be displayed” means all loops could be classified as either positive or negative. The first number displayed is the count in System Dynamics Model Documentation Tool User Guide — JAVA Page 25 of 32 the polarity group followed by the minimum and maximum lengths of those loops in square brackets. Figure 29. Section 7: Feedback Loop Information 7. Section 6 lists variables that include: a. Undocumented Variables b. Supplementary Variables c. Supplementary Variables Being Used d. Unused Variables e. Stock Variables f. Equations with Embedded Data g. Nonmonotonic Lookup Functions h. Non-Zero End Sloped Lookup Functions i. Cascading (Chained) Lookup Functions j. Variables with “STEP”, “PULSE”, or “Related Functions” k. Equations with “IF THEN ELSE” Functions l. Equations with “MIN” or “MAX” Functions m. Complex Variable Formulations (Richardson’s Rule = 3) n. Complex Stock Formulations o. State Variables p. Variables with Source Information q. Dimensionless Unit Variables (Figure 29) r. Function Sensitivity Parameters s. Data Lookup Tables t. Using Macros u. Variables Not in Any View v. Equations With Unit Errors or Warnings (Figure 30) w. Feedback Loops x. Macros y. Positive Polarity Causal Links z. Negative Polarity Causal Links aa. Unknown Polarity Causal Links System Dynamics Model Documentation Tool User Guide — JAVA Page 26 of 32 These lists can be reached by the selection of the hyperlinks provided in the main summary tables in Section 1. Figure 30. Section 9: Dimensionless Unit Variables Some samples of these lists are provided below: Figure 31. Section 8: Equations with Unit Errors or Warnings Variable-View relationships are represented graphically in the last two reports. “ViewVariable Profile” (Figure 32, top) shows the number and percentage of the total number of variables for each of the views. Since variables can be present in multiple views, the sum of numbers and percentages will not total the number of variables or 100%. Lastly, we see how individual variables are distributed among the views (Figure 33, Variable-View Relationships bottom). System Dynamics Model Documentation Tool User Guide — JAVA Page 27 of 32 Hyperlinks within these last two reports provide quick access to either specific variables or variables grouped by view based on the hyperlink selected. Figure 32. Section 10: Variable-View Relationships (Top) System Dynamics Model Documentation Tool User Guide — JAVA Page 28 of 32 Figure 33. Section 11: Variable-View Relationships (Bottom) The end of the HTML file identifies your input and output files’ dates and versions (Figure 34). Also included are hyperlinks to the tool webpage, the Decision and Information Sciences Division public webpage, and the Argonne National Laboratory public webpage. Figure 34. Section 12: Input and Output Files’ Dates and Versions System Dynamics Model Documentation Tool User Guide — JAVA Page 29 of 32 5. Output Files As the tool executes, several output files are generated. File and directory names are based on the name of the .mdl file containing the model. For a model saved in a file named ABC.mdl, the following files will be generated: 1. ABC_l.html where “l” is the selected language (i.e., ABC_English.html or ABC_Spanish.html). This is the file that contains the HTML report generated by the SDM-Doc. 2. ABC_l.zip where “l” is the selected language. This is a zip file containing all files generated by SDM-Doc. 3. A directory named ABC_DOC_GRAPH into which a number of files are written by SDM-Doc. Among them are the lookup table graphic .png files, language specific HTML and text files that list all loops discovered in the model subject to the Analyze Loop options, and a log file. The log file is especially useful in debugging any issues that may arise. System Dynamics Model Documentation Tool User Guide — JAVA Page 30 of 32 6. Troubleshooting—When Things Go Wrong The tool may, at times, have difficulty completing the analysis of a system dynamics model. These difficulties generally will arise from a corrupted .mdl file, a non-parsable equation, or a highly-connected model. The tool requires a correctly defined complete model or a model map as input. A corrupted .mdl file can cause the tool to be unable to correctly interpret the model due to missing or incorrect data. In most cases, the tool can detect the problem and report it in an appropriate manner. However, the tool can crash under some error conditions. The tool parses each equation as it performs its analysis of the model. Incorrect syntax is usually detected cleanly. However, language extensions not supported in the tool can cause a crash. The analysis of a model may appear to be stuck in the loop generation phase. While it is possible that the tool is stuck in a loop, it is more likely the case that the model is highly connected and, due to its size, the possible number of loops can be huge. The tool will attempt to enumerate each of these loops. The tool can easily handle tens of thousands of loops. But once we reach upwards of a million potential loops, progress is not visually recognizable through the GUI. When this situation is encountered, the loop analysis option should first be unchecked to verify what the issue is during loop analysis. Once this has been verified, loop analysis should be checked, but the maximum size of a loop should be set to a small number, such as five. Note that even with a size limit of five, a highly-connected model can still have hundreds of thousands of potential loops. The smallest allowable loop size is two. In the event that a model cannot be analyzed, use the “feedback” capability to report the problem and you will be contacted for additional details. System Dynamics Model Documentation Tool User Guide — JAVA Page 31 of 32 References Martinez-Moyano, IJ. (2012). "Documentation for model transparency." System Dynamics Review 28(2): 199-208. Oliva R. 2001. HTML model documentation utility v0.2. Available: http://iops.tamu.edu/faculty/ roliva/research/sd/ [9 May 2012]. Sterman JD. 2000. Business Dynamics: Systems Thinking and Modeling for a Complex World. Irwin McGraw-Hill: Boston, MA. System Dynamics Model Documentation Tool User Guide — JAVA Page 32 of 32