<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>An NMF solution to the Train Benchmark Case at the TTC 2015</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Georg Hinkel</string-name>
          <email>hinkel@fzi.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Lucia Happe</string-name>
          <email>lucia.kapova@kit.edu</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Forschungszentrum Informatik (FZI)</institution>
          ,
          <addr-line>Haid-und-Neu-Straße 10-14, Karlsruhe</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Karlsruhe Institute of Technology (KIT)</institution>
          ,
          <addr-line>Am Fasanengarten 5, Karlsruhe</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2015</year>
      </pub-date>
      <abstract>
        <p>Model validation in model-driven development gains in importance as the systems grow in size and complexity. In this situation an efficiency of validation execution and an immediate feedback whether a recent manual edit operation broke a validation rule is desirable. To increase efficiency, incremental model validation tries to minimize the proportions of the model that have to be rechecked by reusing previous validation results. As a benchmark for efficiency of validation tools, the Train Benchmark Case at the Transformation Tool Contest 2015 was created. In this paper, we present a solution using NMF Expressions, a tool for incremental evaluation of arbitrary expressions on the .NET platform.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>In this paper, we evaluate the efficiency of incremental validation with NMF Expressions. The rest
of this paper is structured as follows: Section 2 gives a very short introduction to NMF Expressions and
Section 3 explains our solution. Finally Section 5 summarizes the paper.
2</p>
    </sec>
    <sec id="sec-2">
      <title>NMF Expressions</title>
      <p>The goal of NMF Expressions is to give developers an automated tool at hand providing them with
advantages of incremental evaluation for arbitrary expressions. Unlike many other approaches, our approach
works implicitly, so developers only have to specify their expressions and NMF Expressions takes care
of how to turn this into an algorithm that will evaluate the expression in an incremental fashion. On the
other hand, the traditional batch mode specification is still available so that NMF Expressions yields a
choice whether to run a given expression incrementally or in batch mode.</p>
      <p>In the incremental mode, the approach creates a dynamic dependency graph from a given expression
and observes changes. These changes originate from elementary update notifications and are propagated
through the dependency graph. Operating on the .NET platform, NMF Expressions uses the industry
standard INotifyPropertyChanged and INotifyCollectionChanged interfaces to record elementary changes.
These are also required by a lot of other tools including the modern UI libraries on the .NET platform.
As a consequence of the theoretical foundation using monads, the dependency graph contains specialized
nodes for optimized incrementalization of queries.</p>
      <p>While NMF Expressions works with arbitrary model representations implementing the interfaces for
elementary change propagation, we use the model representation of NMF. That is, we transformed the
given Ecore metamodel of the railway domain into an NMeta metamodel and generated model
representation code. NMF thus offers us a deserialization mechanism to load the resulting models as objects into
memory.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Solution with NMF Expressions</title>
      <p>The intended usage of NMF Expressions in incremental mode is that users would modify the model
in some editor through a sequence of change operations, each of which providing elementary change
notifications. Then, NMF Expressions would use the elementary change notifications and combine them
to provide immediate feedback whether the most recent model manipulation has caused some validation
rule to fail for some model elements. Currently, NMF Expressions always minimizes the model elements
that it has to look at, even at the cost of high memory usage. However, in the Train Benchmark, the only
model manipulations we can see are the repair operations, so for us the benchmark does not really reflect
the situation for which we have designed NMF Expressions.</p>
      <p>In incremental mode, NMF Expressions creates a cache for the selected expressions and maintains
this cache. This maintenance happens automatically as NMF Expressions adds computational effort to the
(in-memory) online model manipulation. In this case solution, we created expressions for the validation
patterns so NMF Expressions caches the invalid elements continuously. However, this means that the
phases drawn from the case description get blurred. In particular, the check phases get meaningless as the
updated results are always available and could be used for immediate feedback, while more computational
effort is put to the model manipulation such as the modify operations.</p>
      <p>Because NMF Expressions allows to use the same specification both in a classic batch manner as
also incrementally, our solution can also be configured to run in batch mode without any changes to the
Georg Hinkel and Lucia Happe</p>
      <sec id="sec-3-1">
        <title>PosLength</title>
      </sec>
      <sec id="sec-3-2">
        <title>SwitchSensor</title>
      </sec>
      <sec id="sec-3-3">
        <title>SwitchSet</title>
      </sec>
      <sec id="sec-3-4">
        <title>RouteSensor SemaphoreNeighbor</title>
        <p>patterns. When executed in batch mode, NMF Expressions simply forwards the call to the LINQ to
objects implementation. Besides a negligible runtime compilation effort, this utilizes the highly optimized
platform LINQ implementation.</p>
        <p>The patterns are enumerable expressions where developers can choose at runtime whether the
pattern should be executed in batch mode or whether NMF Expressions should register for elementary
change notifications to keep a cache of the result up to date. To specify patterns, we created a small
method Fix that captures them.
The easiest implementation for the Fix function repairing any validation error as soon as they occur
would be the one presented in Listing 1. In Line 2, we tell NMF Expressions that we want to obtain
incremental updates for the given pattern. Line 3 repairs all occurences existing so far and Lines 4-8
handle new pattern matches. For the benchmark, we adopted the Fix function to account for the benchmark
phases. In particular, the implemented version takes a third parameter to allow us to sort matches. Since
these sort keys offer little insight, we omit them in the pattern presentation.</p>
        <p>In the following we will present the solution to the tasks, following the structure of the case
description, though with omitted sort keys.</p>
        <p>Please note that the parameter names such as pattern or action are optional, we only included them
for better understandability.</p>
        <p>The solutions to SwitchSet, RouteSensor and SemaphoreNeighbor use the query syntax of C#. This
syntax is translated to the method chaining syntax by mapping the query keywords like from or where to
method calls of NMF Expressions. Such query expressions are commonality on the .NET platform and
thus easy to write and understand by most developers.</p>
        <p>Note that the order in which the statements occur does make a difference. In particular, e.g. lines 2 and
3 of the SwitchSet solution could logically be interchanged but cause a slightly different implementation.
NMF Expressions currently does not optimize the query for performance.</p>
        <p>In the solution for SemaphoreNeighbor we can observe that NMF Expressions is not able to inverse
directed references. We argue that such inversion is always limited to a particular scope, which is unclear
from the context. If the context was clear, the reference should have been navigable in both directions in
the metamodel. As this is not the case, we have to cross join the two respective routes and filter them on
the semaphores.
4</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Evaluation</title>
      <p>
        To evaluate our solution, we ran it in comparison to the reference implementations in Java and
EMFIncQuery [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. The measurements were taken on a system with an Intel i5-4300U processor in a system
equipped with 12GB RAM running on Windows 8.1 Pro, .NET 4.5 and Java 1.8 update 45. The results
for recheck and repair are shown in Figure 1. The SemaphoreNeighbor ran out of memory for larger
models. A discussion is omitted for space limitations.
      </p>
      <p>In all four presented queries, both versions are up to multiple magnitudes faster than the plain Java
solution. In medium-sized models, the incremental version also beats EMF-IncQuery, in the SwitchSet
pattern it is even faster on the larger models.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Summary</title>
      <p>In this paper, we presented an NMF solution to the Train Benchmark case at the TTC 2015.</p>
      <p>The queries and repair transformations demonstrate why we have sticked to the C# language. We
think that it is very hard to get a more concise textual solution for this case. At the same time, developers
get the full tool support from e.g. Visual Studio and the query syntax that we use is used by thousands of
developers already and widely understood.</p>
      <p>The performance figures shows that the incremental version of our solution outperforms the batch
mode execution of the same solution in all cases. At the same time, our solution yields a batch mode
execution in cases where only a single analysis run is needed. This version outperforms the classic Java
solution in several orders of magnitude. On the other hand, for large models our incremental solution
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
T0.00.11 ●
1
10000
)1000
sm100
(e 10
im 1
T
PosLength, Function: repair+recheck
SwitchSensor, Function: repair+recheck
1 2 4 8 16 32 64 128 256 512 1024</p>
      <p>Size
Tool ● EMFIncQuery Java NMF(Batch) NMF(Incremental)
4 8 16 32 64 128 256 512 1024</p>
      <p>Size</p>
      <p>Tool ● EMFIncQuery Java NMF(Batch) NMF(Incremental)
SwitchSet, Function: repair+recheck
RouteSensor, Function: repair+recheck
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
2 4 8 16 32 64 128 256 512 1024</p>
      <p>Size
Tool ● EMFIncQuery Java NMF(Batch) NMF(Incremental)
1 4 8 16 32 64 128 256 512 1024</p>
      <p>Size
Tool ● EMFIncQuery Java NMF(Batch) NMF(Incremental)
cannot keep up with the EMF-IncQuery solution, except for one pattern where the NMF solution is
slightly faster.</p>
      <p>The biggest advantage of our solution is that it gives both a batch mode solution and an incremental
solution our of the same pattern specifications. Thus, the same analysis code can be used in the case
setting where incrementality is a clear advantage, or in a batch mode, e.g. when memory is a sparse
resource or the analysis results are only required once.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>G.</given-names>
            <surname>Szárnyas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Semeráth</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Ráth</surname>
          </string-name>
          , and
          <string-name>
            <given-names>D.</given-names>
            <surname>Varró</surname>
          </string-name>
          , “
          <article-title>The TTC 2015 Train Benchmark Case for Incremental Model Validation,” in 8th Transformation Tool Contest (TTC</article-title>
          <year>2015</year>
          ),
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>M.</given-names>
            <surname>Staron</surname>
          </string-name>
          , “
          <article-title>Adopting model driven software development in industry-a case study at two companies</article-title>
          ,
          <source>” in Model Driven Engineering Languages and Systems</source>
          , Springer,
          <year>2006</year>
          , pp.
          <fpage>57</fpage>
          -
          <lpage>72</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>P.</given-names>
            <surname>Mohagheghi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Gilani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Stefanescu</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M. A.</given-names>
            <surname>Fernandez</surname>
          </string-name>
          , “
          <article-title>An empirical study of the state of the practice and acceptance of model-driven engineering in four industrial cases,” Empirical Software Engineering</article-title>
          , vol.
          <volume>18</volume>
          , no.
          <issue>1</issue>
          , pp.
          <fpage>89</fpage>
          -
          <lpage>116</lpage>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>L. A.</given-names>
            <surname>Meyerovich</surname>
          </string-name>
          and
          <string-name>
            <given-names>A. S.</given-names>
            <surname>Rabkin</surname>
          </string-name>
          , “
          <article-title>Empirical analysis of programming language adoption,” in Proceedings of the 2013 ACM SIGPLAN international conference on Object oriented programming systems languages &amp; applications</article-title>
          , ACM,
          <year>2013</year>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>18</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>G.</given-names>
            <surname>Bergmann</surname>
          </string-name>
          , Á. Horváth,
          <string-name>
            <given-names>I.</given-names>
            <surname>Ráth</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Varró</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Balogh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            <surname>Balogh</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Ökrös</surname>
          </string-name>
          , “
          <article-title>Incremental evaluation of model queries over emf models</article-title>
          ,
          <source>” in Model Driven Engineering Languages and Systems</source>
          , Springer,
          <year>2010</year>
          , pp.
          <fpage>76</fpage>
          -
          <lpage>90</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>