<!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 T TC 2020 roundtrip engineering case</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Georg Hinkel</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Am Rathaus 4b</institution>
          ,
          <addr-line>65207 Wiesbaden</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2021</year>
      </pub-date>
      <abstract>
        <p>This paper presents a solution to the Roundtrip Engineering case at the Transformation Tool Contest (TTC) 2020. I demonstrate how synchronization blocks can be easily used to specify the relationships in a bidirectional manner. Through a superimposition concept, the migrations can concentrate on those parts of the metamodel that have actually changed. The performance results on the provided model shows that the solution has a very good performance on the provided input models, although these are very small.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Model Migration</kwd>
        <kwd>Roundtrip</kwd>
        <kwd>BX</kwd>
        <kwd>Transformation</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>The first condition is a direct translation of the original
PutGet law. Meanwhile, the second line is a bit weaker
than the original GetPut because the global state may
have changed. In particular, we allow the Put function
to change the global state.</p>
      <p>A (single-valued) synchronization block  is an
octuple (, , , , Φ −  , Φ − , , ) that declares a
synchronization action given a pair (, ) ∈ Φ −  :
 ∼=  of corresponding elements in a base
isomorphism Φ −  . For each such a tuple in states (, ),
the synchronization block specifies that the elements
( (, ),  ↗ (, )) ∈  ×  gained by the lenses
 and  are isomorphic with regard to Φ − .</p>
      <p>A schematic overview of a synchronization block is
depicted in Figure 1. The usage of lenses allows these
declarations to be enforced automatically and in both
directions. The engine simply computes the value that
the right selector should have and enforces it using the
Put operation. Similarly, a multi-valued synchronization
block is a synchronization block where the lenses  and
 are typed with collections of  and , for example
 :  ˓→ * and  :  ˓→ * where stars denote
Kleene closures.</p>
      <p>
        Synchronization blocks have been implemented in
NMF Synchronizations, an internal DSL hosted by C#
[
        <xref ref-type="bibr" rid="ref2 ref4">4, 2</xref>
        ]. For the incrementalization, it uses the extensible
incrementalization system NMF Expressions [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. This
DSL is able to lift the specification of a model
transformation/synchronization in three orthogonal dimensions:
• Direction: A client may choose between
transformation from left to right, right to left or in
check-only mode
• Change Propagation: A client may choose
whether changes to the input model should be
propagated to the output model, also vice versa
or not at all
• Synchronization: A client may execute the
transformation in synchronization mode between
a left and a right model. In that case, the engine
ifnds diferences between the models and
handles them according to the given strategy (only
add missing elements to either side, also delete
superfluous elements on the other or full duplex
synchronization)
      </p>
    </sec>
    <sec id="sec-2">
      <title>3. Solution</title>
      <p>Our solution consists of two parts: At first, I describe the
solutions to all four of the scenarios using vanilla NMF
Synchronizations, that is, using explicit coding.
Afterwards, I explain the necessary steps to turn this into a
generic solution.</p>
      <p>Φ−</p>
      <p>The idea of synchronization blocks is to specify the
semantic overlap between two metamodels, not their
difference. For scenario 1, this overlap consists of the name,
which is still the same, and the overlap that the age can
be computed from the year of birth or vice versa. This is
depicted in Listing 1.</p>
      <p>In particular, both aspects of the semantic overlap can
be specified with just one line of code each. Here, the
calculation of the age from the year of birth (and vice
versa which NMF is able to automatically infer) is very
simple because the inversion of a subtraction is already
built into NMF. However, NMF also allows to specify a
custom conversion operation and an appropriate lens
to put back the value, in case a metamodel evolution
requires more sophisticated adaptions.</p>
      <p>As a very simple example, such a conversion is used
in scenario 3, because the coalescing operator is not
reversible in NMF by default. The implementation of the
custom conversion is shown in Listing 2.
3.2. Generic solution
The biggest problem that I see with the specific solution
is that the identical parts of the metamodel have to be
specified over and over again. While of course not a
problem for very small metamodels such as the ones in
the benchmark, this can become a problem once the idea
is applied to big metamodels with hundreds of classes as
variable and put the migrated Person model element. for the diference between null values and empty strings
one has to create a separate synchronization rule for each rules to house the generated synchronization blocks. For
metaclass and a synchronization block for every feature. this, we simply iterate over the classes of the metamodel</p>
      <p>The code for generating such synchronization blocks and check whether there is a corresponding class in the
for single-valued attributes and references is depicted in
new metamodel.</p>
      <p>Listing 4. For brevity, we do not handle inheritance,
multivalued attributes or references and only check whether
an attribute or reference with the same name exists and
whether the lower bound is the same (in order to account
in scenario 3).</p>
      <p>foreach (var oldClass in oldModel.Descendants().OfType&lt;</p>
      <p>IClass&gt;()) {
var newClass = newModel.Descendants().OfType&lt;IClass&gt;().</p>
      <p>FirstOrDefault(c =&gt; c.Name == oldClass.Name);
if (newClass != null) {
var oldMapping = oldClass.GetExtension&lt;MappedType&gt;();
var newMapping = newClass.GetExtension&lt;MappedType&gt;();
if (oldMapping?.SystemType != null &amp;&amp; newMapping?.</p>
      <p>SystemType != null) {
var rule = (SynchronizationRuleBase)Activator.</p>
      <p>CreateInstance(typeof(MigrationRule&lt;,&gt;).</p>
      <p>MakeGenericType(oldMapping.SystemType,
newMapping.SystemType));
yield return rule;
}
}
}</p>
      <p>Listing 5: Generating synchronization rules
What we need to do is to generate synchronization</p>
      <p>Scenario
Scenario1Backward
Scenario1Forward
Scenario2Backward
Scenario2Forward
Scenario3Backward
Scenario3Forward
Scenario4Backward
Scenario4Forward</p>
      <p>1000</p>
      <p>Repetitions
1
10
100</p>
      <p>With these two artifacts, we get a model
synchronization that automatically synchronizes all classes and fea- Figure 2: Performance results for running the
Transformatures that have not changed (meaning that a feature with tion step of the solution multiple times.
the same name exists), but we still need to specify the
semantic overlap that is contained in diferent attributes
such as the corespondence between age and year of birth. 5. Conclusion</p>
      <p>To do that, we use the superimposition concept that
is available in NMF Synchronizations, depicted in List- I think that the NMF solution highlights the advantages
ing 6. That is, we inherit from our new migration class model transformations based on synchronization blocks
that spawns the synchronization rules to synchronize can ofer in terms of flexibility. A single specification of
the unchanged bits and then superimpose this rule by consistency relationships between the evolution steps
a more detailed rule that inherits the synchronization of a metamodel sufices to transform instances forwards
of unchanged attributes and references (line 5) and add and backwards. Boilerplate rules can be calculated
authe synchronization of the age with the year of birth by tomatically while the essential diferences between two
subtracting from 2020. evolution steps (the actual migration) is specified
manually with the full flexibility.
4. Evaluation One may think that the generic solution and the
reflection it performs must lead to a slow solution. However,
this is not true because NMF uses the .NET expression
compiler under the hood to compile the expressions that
are built through reflection. Therefore, the reflection
only afects the initialization of such a transformation,
the runtime is completely identical.</p>
      <p>I ran performance measurements of the solution on a Intel
Core i7-8550U CPU on a system with 8GB RAM running
Windows 10. The results are depicted in Figure 2. The
ifgure shows the required time to synchronize the model
changes forward and backward. The sufix indicates the
direction that is executed first, i.e. Scenario1Backward
means that the V2 version of scenario 1 is migrated back
to V1 and then migrated to V2 again, Scenario1Forward
means that the V1 version of scenario 1 is migrated to
V2 and back to V1 again.</p>
      <p>As the figure shows, the solution is generally very
fast. If the synchronization is only called once, the
effects of just-in-time compilation and assembly loading
cause an average of little more than 10ms but if the
synchronization is repeated often, the runtime anneals to
roughly 10ns per iteration. However, the input model
size is also trivially small and therefore, the results are
hardly meaningful. A thourough performance evaluation
would require larger models that the benchmark did not
provide.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>L.</given-names>
            <surname>Beurer-Kellner</surname>
          </string-name>
          , J. von Pilgrim, T. Kehrer,
          <article-title>RoundTrip Migration of Object-Oriented Data Model Instances</article-title>
          , http://www.transformation-tool-contest.eu/ 2020_roundtrip.pdf ,
          <year>2020</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>G.</given-names>
            <surname>Hinkel</surname>
          </string-name>
          , E. Burger,
          <article-title>Change Propagation and Bidirectionality in Internal Transformation DSLs</article-title>
          , Software &amp; Systems
          <string-name>
            <surname>Modeling</surname>
          </string-name>
          (
          <year>2017</year>
          ). URL: http://rdcu. be/u9PT. doi:
          <volume>10</volume>
          .1007/s10270-017-0617-6.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>J. N.</given-names>
            <surname>Foster</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. B.</given-names>
            <surname>Greenwald</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. T.</given-names>
            <surname>Moore</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B. C.</given-names>
            <surname>Pierce</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Schmitt</surname>
          </string-name>
          ,
          <article-title>Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem</article-title>
          ,
          <source>ACM Transactions on Programming Languages and Systems (TOPLAS) 29</source>
          (
          <year>2007</year>
          ). URL: http://doi.acm.
          <source>org/10</source>
          .1145/1232420.1232424. doi:
          <volume>10</volume>
          . 1145/1232420.1232424.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>G.</given-names>
            <surname>Hinkel</surname>
          </string-name>
          ,
          <article-title>Change Propagation in an Internal Model Transformation Language</article-title>
          , in: D.
          <string-name>
            <surname>Kolovos</surname>
          </string-name>
          , M. Wimmer (Eds.),
          <source>Theory and Practice of Model Transformations: 8th International Conference, ICMT</source>
          <year>2015</year>
          ,
          <article-title>Held as Part of STAF 2015, L'Aquila</article-title>
          , Italy,
          <source>July 20-21</source>
          ,
          <year>2015</year>
          . Proceedings, Springer International Publishing, Cham,
          <year>2015</year>
          , pp.
          <fpage>3</fpage>
          -
          <lpage>17</lpage>
          . URL: http: //dx.doi.org/10.1007/978-3-
          <fpage>319</fpage>
          -21155-
          <issue>8</issue>
          _1. doi:
          <volume>10</volume>
          . 1007/978-3-
          <fpage>319</fpage>
          -21155-
          <issue>8</issue>
          _
          <fpage>1</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>G.</given-names>
            <surname>Hinkel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Heinrich</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Reussner</surname>
          </string-name>
          ,
          <article-title>An extensible approach to implicit incremental model analyses, Software</article-title>
          &amp; Systems
          <string-name>
            <surname>Modeling</surname>
          </string-name>
          (
          <year>2019</year>
          ). URL: https:// doi.org/10.1007/s10270-019-00719-y. doi:
          <volume>10</volume>
          .1007/ s10270-019-00719-y.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>G.</given-names>
            <surname>Hinkel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Goldschmidt</surname>
          </string-name>
          , E. Burger,
          <string-name>
            <given-names>R.</given-names>
            <surname>Reussner</surname>
          </string-name>
          ,
          <article-title>Using Internal Domain-Specific Languages to Inherit Tool Support and Modularity for Model Transformations</article-title>
          , Software &amp; Systems
          <string-name>
            <surname>Modeling</surname>
          </string-name>
          (
          <year>2017</year>
          )
          <fpage>1</fpage>
          -
          <lpage>27</lpage>
          . URL: http://rdcu.be/oTED. doi:
          <volume>10</volume>
          . 1007/s10270-017-0578-9.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>