Automatic code generation from high-level Petri-Nets for model driven systems engineering

https://doi.org/10.1016/j.jss.2005.12.022Get rights and content

Abstract

One of the main concepts of the model driven architecture framework proposed by the OMG is the transformation of platform independent models into either platform dependent ones or into implementations. The latter needs generators which automatically translate models into code of a chosen target programming language. Nowadays most models in systems engineering are created with the UML as standardized set of notations. However, the UML is still largely undefined from a semantical point of view. Automatic code generation from these models is thus only possible if further semantic definitions are provided. Since Petri-Nets are frequently utilized for these purposes, the automatic generation of code from Petri-Nets is an important topic.

Starting from this observation, this article gives an overview of different strategies to generate code from high-level Petri-Nets. One of these strategies is due to its characteristics investigated in more detail. Several improvements of the basic idea are introduced and also the impact of these enhancements in terms of efficient execution of generated code is illustrated with a benchmark.

Introduction

The development of almost every kind of technological system is nowadays based on models as abstractions of real-world and/or thought concepts. State of the art in systems modelling are multi-perspective approaches, where different kinds of models represent different views on a system. During the course of systems development such models are enriched with additional information and are thus transformed from more abstract into more concrete ones. In systems engineering the UML (Object Management Group (OMG), 2004) has become the lingua franca for object-oriented modelling in the last years. While object-oriented models traditionally serve as blueprints for manual systems implementation, the model driven architecture initiative of the OMG (OMG, 2003) promotes the usage of models throughout the entire development process. Starting from a so-called platform independent model (PIM), different kinds of transformations lead to platform specific models (PSMs). Such transformations might automatically generate, for instance, source code for different programming languages from a single PIM. Automatic code generation from object-oriented models is thus an important area of work in the context of model driven architecture.

Since the UML is the standard for object-oriented modelling, code generation from this set of notations seems to be a natural starting point for investigation. However, as the UML is still largely undefined from a semantical point of view, difficulties arise in such a scenario due to the ambiguity of models, which makes them not very well suited neither as a reliable communication basis nor the starting point for automatic code generation. In order to overcome these problems, a plethora of work exists to give (parts of) the UML a formal underpinning. As many of these approaches are based on Petri-Nets (see e.g. Baresi and Pezzè, 2001, Bernardi et al., 2002), automatic code generation from this formalism is a promising lead in the area of model driven architecture.

Code generation from Petri-Nets generally has a long tradition. However, unlike methods for the analysis and simulation of Petri-Nets, code generation is not yet considered a standard feature, and thus not implemented in modelling tools such as Design/CPN (Christensen et al., 1997), Renew (Kummer et al., 2004) and others. An extensive review of existing work in the area of automatic code generation from Petri-Nets is given in (Girault and Valk, 2003). Most of the approaches in this review focus on code generation from (extended) low-level Petri-Nets, e.g. for the generation of controllers (see for instance Uzam and Jones, 1998, Lee et al., 2004). Even though the review also lists approaches for code generation from high-level Petri-Nets, the work in this area is not based on object-oriented principles, and in consequence not applicable to more complex systems. A frequent use of approaches to automatic code generation from Petri-Nets is the validation of requirements in systems engineering. Since models are used in this context as blueprints for traditional systems development, aspects such as readability (and thus extensibility) as well as efficiency of generated code are not important and, therefore, usually not the focus of existing approaches to code generation. As a consequence of (i) models which are not structured in an object-oriented way and (ii) the problems arising from not well readable code for further systems development, some authors state that the final application ‘should not be the main goal of code generation [from Petri-Nets]’ (Girault and Valk, 2003, p. 434).

In contrast to this view, the motivation for the work presented in this article is to shed some light on Petri-Net based code generation from a different angle. In accordance to the ideas of model driven architecture, models are considered as a central means not only for the capturing and validation of requirements, but for the whole development process in systems engineering. As a direct consequence of this philosophy there are major differences between the goals of the code generation approach to be presented in the remainder of this article and the existing work as reviewed in (Girault and Valk, 2003). First of all, the approach to be introduced is based on a class of object-oriented Petri-Nets in order to be applicable also for complex systems. In addition, the work to be presented is intended to support the use of models throughout the entire systems development process and not only for validation purposes. A fundamental requirement to reach this goal is that automatically generated code closely resembles manually implemented code. In order to make a first step into this direction the subject of discourse in this article is the evaluation of different strategies for automatic code generation from Petri-Nets with the focus on their general applicability as well as the readability, extensibility and efficiency of generated code.

Starting from this perspective, the next section gives an overview of the theoretical possibilities for code generation from (high-level) Petri-Nets. An object-oriented class of Petri-Nets is introduced then together with a running example in section three. Different variants of simulation-based code generation as well as the results of a performance evaluation based on the introduced example are discussed afterwards. Finally, the last section concludes the article with a short summary and an outlook on future work.

Section snippets

Code generation from high-level Petri-Nets

Since Petri-Nets are mathematical objects there are different methods for their formal analysis. These methods can also be used as a basis for code generation and are thus a natural starting point for further investigations into this direction. The potential of (i) structural analysis, (ii) simulation and (iii) reachability graphs for automatic code generation from high-level Petri-Nets is thus described next. Afterwards, the applicability of approaches for code generation based on these

Object-oriented Pr/T-models

A running example is used throughout the article as a vehicle to demonstrate different methods for the improvement of readability and efficiency of code generated with simulation-based approaches. Since Petri-Nets are due to the absence of proper modularization capabilities often criticized as not being well suited for the modelling of complex systems, the example is given in an object-oriented Petri-Net dialect which overcomes these problems. However, even if the motivation for our work is the

Simulation-based code generation

This section describes different variants of simulation-based code generation with the calculation of primes as running example. Even if this example is given by an OOPr/T-Model, the code generation principles discussed in the following are largely independent of a specific class of high-level Petri-Nets, i.e. they apply to other kinds of Petri-Nets almost without any changes.

As already mentioned above, Java is the target programming language for code generation throughout this article.

Evaluation of automatic code generation

The calculation of primes used as a running example throughout this article is further used as a basis for the evaluation of the efficiency of simulation-based code generation and the above described enhancements. In detail, a manual reference implementation of the system is evaluated against different versions generated according to the above descriptions. Table 2 gives the absolute execution times as well as the relative efficiency with respect to the manual reference implementation for the

Conclusions and further perspectives

Due to the model driven architecture initiative of the OMG, automatic code generation is nowadays a topic of major interest. The main theme of this article is code generation from high-level Petri-Nets, which are often used for the semantic definition of UML notations. As a result of the characterization of different strategies for code generation from Petri-Nets, a hybrid approach was presented which combines the advantages of simulation-based generation principles and structural analysis. The

Acknowledgement

The author would like to thank Thomas George, Pascal von Hutten and Philipp Wojke for their contributions to the NEPTUN project.

References (21)

  • K. Arnold et al.

    The Java Programming Language

    (1996)
  • L. Baresi et al.

    Improving UML with Petri nets

  • S. Bernardi et al.

    From UML sequence diagrams and statecharts to analysable Petri net models

  • S. Christensen et al.

    Design/CPN—A computer tool for coloured Petri nets

  • H.J. Genrich et al.

    System modelling with high-level Petri nets

    Theoretical Computer Science

    (1981)
  • George, T., 1999. OOPr/T-modeller: a Tool for the modelling of object-oriented systems based on UML and Petri-Nets....
  • C. Girault et al.

    Petri-Nets for Systems Engineering

    (2003)
  • Kummer, O., Wienberg, F., Duvigneau, M., 2004. Renew—User Guide, Release 2.0....
  • K. Lautenbach

    Linear algebraic techniques for place/transition nets

  • G. Lee et al.

    Automatic generation of ladder diagram with control Petri Nets

    Journal of Intelligent Manufacturing

    (2004)
There are more references available in the full text version of this article.

Cited by (0)

View full text