Archive

Posts Tagged ‘XMILE’

Generating Custom Reports Using XMILE

September 4th, 2013 No comments

XMILE is an open standard for describing system dynamics models in XML.  Version 10 of iThink and STELLA output their models in the XMILE format.  One of the advantages of XML is that it is a text-based format that can be easily queried and manipulated.  This post will show you how to use XMLStarlet, a free XML command line management tool available for Windows, Macintosh, and Linux, to easily extract information from a XMILE model.  It will also demonstrate how to modify the XML style sheet (XSLT) generated by XMLStarlet to create custom HTML reports.

Our goal is to create a report that lists the stocks, flows, and converters in the susceptible-infected-recovered (SIR) model of infection shown below (available by clicking here).  Each model variable will be listed with its own equation and sorted by name.

SIR

XMLStarlet uses the select command (sel) for making queries to an XML file and formatting the results.  We will use all of the following select command options:

-t (template): define a set of rules (below) to be applied to the XML file
-m “XPath query” (match): find and select a set of nodes in the XML file
-s <options> “XPath expression” (sort): sort selected nodes by XPath expression
-v “XPath expression” (value): output value of XPath expression
-o “text” (output): output the quoted text
-n (newline): start a new line in the output

Reporting Stock Names

Let’s start by outputting the names of the stocks in the model.  In a XMILE file, stocks are identified by the <stock> tag, which is nested inside the <xmile> and <model> tags:

<xmile …>
   <model>
      <stock name="Infected">
         <eqn>1</eqn>
      </stock>
   </model>
</xmile>

There is one <stock> tag for every stock in the model and each stock has, at a minimum, both a name (in the “name” attribute) and an initialization equation (in the <eqn> tag).  To get the names of all stocks in the model, we can build a template using these XMLStarlet command options:

sel –t -m “_:xmile/_:model/_:stock” -v “@name” -n

The “sel” chooses the select command and the –t begins the template (the set of rules used to extract and format information from the XML file).  The –n at the end puts each stock name on its own line.

The –m option defines the XML path to any stock from the root.  In this case, the –m option is selecting all the XML nodes named stock (i.e., <stock> tags) that are under any <model> tags in the <xmile> tag.  From the XMILE file, one might expect the XML path to be “xmile/model/stock,” but the tags in the XMILE file are in the XMILE namespace and XPath, which is being used for this query, requires namespaces to be explicitly specified.  Luckily, XMLStarlet, starting in version 1.5.0, allows us to use “_” for the name of the namespace used by the XML file, in this case the XMILE namespace.  Thus, every XMILE name in a query must be preceded by “_:”.

Finally, the –v option allows us to output the name of each node selected with -m (stocks, in this case).  The “@” tells XPath that “name” is an attribute, not a tag, i.e., it is of the form name=”…” rather than <name>…</name>.

To build a full command, we need to add the path to XML Starlet to the beginning and the name of the XML file being queried to the end:

XMLStarlet_path/xml <options above> SIR.stmx

The entire command without the path to XMLStarlet is:

xml sel -t -m “_:xmile/_:model/_:stock” -v “@name” -n SIR.stmx

This command produces the following output:

Infected
Susceptible
Recovered

Read more…

XMILE – An open standard for system dynamics models

July 19th, 2013 No comments

In June, isee systems and IBM sponsored a new technical committee in OASIS, a large standards organization. This committee is developing a new system dynamics modeling standard called XMILE. This blog post will answer some important questions about XMILE.

1. What is XMILE?

XMILE is an open XML protocol for the sharing, interoperability, and reuse of system dynamics models and simulations.

2. What’s the difference between XMILE and SMILE?

XMILE is the XML representation of a system dynamics model. SMILE is the underlying system dynamics language that is represented in XML using XMILE. In this way, it is very similar to the DYNAMO language originally used to create system dynamics models. SMILE could eventually be encoded using something other than XML.

3. How does XMILE benefit iThink and STELLA users?

There are several immediate benefits to iThink and STELLA users:

  • XML files can be reformatted and styled with XSLT files. There are programs available that generate reports directly from XML files.
  • Model files can be examined and edited in a text editor, facilitating searches and simple replaces.
  • Because XMILE is a text file format, proper versioning of model files, showing meaningful differences between revisions, can be done with version control software such as SVN and Git.
  • Because XMILE is textual, platform-neutral, and descriptive, rather than a binary representation of the implementation, it is more resilient to possible file corruption.
  • As the standard becomes more widely adopted additional benefits will include a broader market for models and the ability to share models with colleagues working in different modeling software packages.

4. How will the adoption of the XMILE standard benefit the field of system dynamics?

The benefits of this standard are:

  • System dynamics models can be re-used to show how different policies produce different outcomes in complex environments.
  • Models can be stored in cloud-based libraries, shared within and between organizations, and used to communicate different outcomes with common vocabulary.
  • Model components can be re-used and plugged into other simulations.
  • It will allow the creation of online repositories modeling many common business decisions.
  • It will increase acceptance and use of system dynamics as a discipline.
  • It will help ISVs make new tools that help businesses to develop and understand models and simulations.
  • It will enable vendors to develop standards-based applications for new markets such as mobile and social media.

5. What is the connection to Big Data?

XMILE opens up system dynamics models to a broader audience and for new uses, including embedding models within larger processes. System dynamics models provide a new way to analyze Big Data, especially when pulling live data streams into a running model to determine the impacts of our decisions in real time against future outcomes, to hopefully avoid unintended consequences of our actions. Note, however, that the presumption of Big Data, or the addition of Big Data, does not automatically lead to large, complicated models. You do not have to create giant models just because you have a lot of data. We’re aggregating the data and looking at it in a more homogenous way, so the models can still stay relatively understandable.

6. Can I adapt existing iThink and STELLA models to XMILE?

All of the isee systems products (version 10 and later) already use the XMILE standard in its draft form. As the standard evolves, isee systems products will be updated to meet the changing standard and your models will be translated forward so they remain XMILE-compatible

7. Do you plan to extend XMILE to include discrete event or agent-based simulations?

XMILE focuses on the language of classic system dynamics, rooted in DYNAMO. While we anticipate the language to expand to include both discrete simulation and agent-based modeling, version one of the XMILE specification is restricted to system dynamics modeling.

8. Could you show an example of how XMILE is used in a model?

XMILE is used to describe the model and is the format used for saving it. A model snippet is shown below with the XMILE that completely describes both its simulation and its drawing properties (in the display tag).

image

xmile

9. A big part of system dynamics is graphical, will XMILE include this part of models?

Yes, all graphical information is stored within the display tag, as shown in the earlier example.

10. Why would you want to store visual layout in Xmile? Why not separate structure from layout?

The structure is actually separate from the layout in the XML file. All visual information is embedded within display tags and can be ignored. XMILE defines three separate levels of compliance, with the lowest level being simulation information only (i.e., structure). A model does not need to include display information and any application is free to ignore it.

11. Will XMILE include data from running the model?

XMILE only represents the model structure, so no data is included.

12. Where can I get more information?

The OASIS technical committee for XMILE maintains a public record at https://www.oasis-open.org/committees/xmile/. This page is regularly updated with new information.

The draft standard can be found in these two documents:

http://www.iseesystems.com/community/support/SMILEv4.pdf http://www.iseesystems.com/community/support/XMILEv4.pdf

In addition, isee systems maintains a web page, http://www.iseesystems.com/community/support/XMILE.aspx, that will be updated periodically with new information about XMILE.

Categories: News & Announcements Tags: