proposal.tex 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. %**************************************************************************
  2. %*
  3. %* Paper: ``INSTRUCTIONS FOR AUTHORS OF LATEX DOCUMENTS''
  4. %*
  5. %* Publication: 2019 Winter Simulation Conference Author Kit
  6. %*
  7. %* Filename: wsc19paper.tex
  8. %*
  9. %* Date: February 15, 2019
  10. %*
  11. %* Word Processing System: TeXnicCenter and MiKTeX
  12. %*
  13. %*
  14. %* All files need the following
  15. %\input{wsc19style.tex} % download from author kit. Style files for wsc formatting. Don't remove this line - required for generating the final paper!
  16. \documentclass{wscpaperproc}
  17. \usepackage{latexsym}
  18. %\usepackage{caption}
  19. \usepackage{graphicx}
  20. \usepackage{mathptmx}
  21. %
  22. %****************************************************************************
  23. % AUTHOR: You may want to use some of these packages. (Optional)
  24. \usepackage{amsmath}
  25. \usepackage{amsfonts}
  26. \usepackage{amssymb}
  27. \usepackage{amsbsy}
  28. \usepackage{amsthm}
  29. %****************************************************************************
  30. %
  31. %****************************************************************************
  32. % AUTHOR: If you do not wish to use hyperlinks, then just comment
  33. % out the hyperref usepackage commands below.
  34. %% This version of the command is used if you use pdflatex. In this case you
  35. %% cannot use ps or eps files for graphics, but pdf, jpeg, png etc are fine.
  36. \usepackage[pdftex,colorlinks=true,urlcolor=blue,citecolor=black,anchorcolor=black,linkcolor=black]{hyperref}
  37. %% The next versions of the hyperref command are used if you adopt the
  38. %% outdated latex-dvips-ps2pdf route in generating your pdf file. In
  39. %% this case you can use ps or eps files for graphics, but not pdf, jpeg, png etc.
  40. %% However, the final pdf file should embed all fonts required which means that you have to use file
  41. %% formats which can embed fonts. Please note that the final PDF file will not be generated on your computer!
  42. %% If you are using WinEdt or PCTeX, then use the following. If you are using
  43. %% Y&Y TeX then replace "dvips" with "dvipsone"
  44. %%\usepackage[dvips,colorlinks=true,urlcolor=blue,citecolor=black,%
  45. %% anchorcolor=black,linkcolor=black]{hyperref}
  46. %****************************************************************************
  47. \usepackage{subcaption}
  48. %
  49. %****************************************************************************
  50. %*
  51. %* AUTHOR: YOUR CALL! Document-specific macros can come here.
  52. %*
  53. %****************************************************************************
  54. % If you use theoremes
  55. \newtheoremstyle{wsc}% hnamei
  56. {3pt}% hSpace abovei
  57. {3pt}% hSpace belowi
  58. {}% hBody fonti
  59. {}% hIndent amounti1
  60. {\bf}% hTheorem head fontbf
  61. {}% hPunctuation after theorem headi
  62. {.5em}% hSpace after theorem headi2
  63. {}% hTheorem head spec (can be left empty, meaning `normal')i
  64. \theoremstyle{wsc}
  65. \newtheorem{theorem}{Theorem}
  66. \renewcommand{\thetheorem}{\arabic{theorem}}
  67. \newtheorem{corollary}[theorem]{Corollary}
  68. \renewcommand{\thecorollary}{\arabic{corollary}}
  69. \newtheorem{definition}{Definition}
  70. \renewcommand{\thedefinition}{\arabic{definition}}
  71. % comments
  72. \newcommand{\boxedtext}[2]{\colorbox{#1}{\scriptsize\bfseries\textsf{#2}}}
  73. \newcommand{\nota}[3]{
  74. \boxedtext{#2}{#1}
  75. {$\blacktriangleright${#3}$\blacktriangleleft$}
  76. }
  77. \newcommand\source[1]{\nota{Source}{green}{#1}}
  78. \newcommand\todo[1]{\nota{TODO}{magenta}{#1}}
  79. \newcommand\placeholder[1]{\textless\textless#1\textgreater\textgreater}
  80. %#########################################################
  81. %*
  82. %* The Document.
  83. %*
  84. \begin{document}
  85. %***************************************************************************
  86. % AUTHOR: AUTHOR NAMES GO HERE
  87. % FORMAT AUTHORS NAMES Like: Author1, Author2 and Author3 (last names)
  88. %
  89. % You need to change the author listing below!
  90. % Please list ALL authors using last name only, separate by a comma except
  91. % for the last author, separate with "and"
  92. %
  93. \WSCpagesetup{Van Mierlo and Vangheluwe}
  94. % AUTHOR: Enter the title, all letters in upper case
  95. \title{THE FUNDAMENTALS OF DOMAIN-SPECIFIC SIMULATION LANGUAGE ENGINEERING}
  96. % AUTHOR: Enter the authors of the article, see end of the example document for further examples
  97. \author{Simon Van Mierlo\\
  98. \vspace{12pt}
  99. Hans Vangheluwe \\
  100. Department of Mathematics and Computer Science \\
  101. University of Antwerp - Flanders Make vzw \\
  102. Middelheimlaan 1 \\
  103. Antwerp, BELGIUM
  104. }
  105. \maketitle
  106. \section*{ABSTRACT}
  107. %\todo{This can only be 150 words long.} \\
  108. Simulationists use a plethora of modelling languages.
  109. General-purpose languages such as C extended with simulation constructs give the user access to abstractions
  110. for general-purpose computation and modularization.
  111. The learning curve for experts in domains that are far from programming is steep however.
  112. Languages such as Modelica, and DEVS allow for a more intuitive definition of models,
  113. often through visual notations and with libraries of reusable components for various domains.
  114. The semantics of these languages is fixed. While libraries can be created,
  115. it is not possible to adapt the language's syntax and semantics to suit the needs of a particular domain.
  116. Modelling Language Engineering allows one to explicitly model all aspects --in particular, syntax and semantics--
  117. of a modelling and simulation language and to subsequently synthesize visual modelling interfaces, simulators,
  118. and debuggers.
  119. This is demonstrated by means of a simple railway network language using AToMPM, a (meta)modelling tool.
  120. \section{INTRODUCTION}
  121. \label{sec:intro}
  122. This tutorial introduces the fundamentals of language engineering for creating domain-specific simulation languages.
  123. \subsection{Why Domain-Specific Language for Simulation?}
  124. The complexity of the systems we develop is continuously increasing.
  125. To overcome this complexity, the designers of the system can employ simulation techniques, building virtual prototypes if the system that allow for the quick evaluation of candidates.
  126. The structure and behaviour of these prototypes are expressed in \emph{models} of the system: abstractions that specify a particular view on, or a part of the system.
  127. Such models are implemented in a \emph{modelling language}, often a general-purpose programming language such as C or Java.
  128. This may lead to certain issues.
  129. The domain expert, on the other hand, has deep knowledge of the problem domain, but only a limited understanding of computer programs.
  130. This can result in communication problems, such as the programmer making false assumptions about the domain, or the domain expert to gloss over details when explaining the problem to the programmer.
  131. Furthermore, the domain experts will finally receive a software component that they don't fully understand, making it difficult for them to validate and modify if necessary.
  132. There is a conceptual gap in effect between the two domains, hindering productivity.
  133. Model-Driven Engineering (MDE)~\cite{MandS} tries to bridge this gap, by shifting the level of specification from computing concepts (the ``how'') to conceptual models or abstractions in the problem domain (the ``what'').
  134. Domain-Specific Modelling (DSM)~\cite{Kelly2008} in particular makes it possible to specify these models in a Domain-Specific Modelling Language (DSML), using concepts and notations of a specific domain.
  135. The goal is to enable domain experts to develop, understand, and verify models more easily, without having to use concepts outside of their own domain.
  136. It allows the use of a custom visual syntax, which is closer to the problem domain, and therefore more intuitive.
  137. Models created in such DSMLs are used, among others, for simulation, (formal) analysis, documentation, and code synthesis for different platforms.
  138. There is, however, still a need for a language engineer to create the DSML, which includes defining its syntax, and providing the mapping between the problem domain and the solution domain.
  139. \begin{figure}
  140. \includegraphics[width=\textwidth]{figure1.pdf}
  141. \caption{Terminology}
  142. \label{fig:terminology}
  143. \end{figure}
  144. This tutorial introduces language engineering for domain-specific simulation languages.
  145. A DSML is fully defined~\cite{Kleppe} by:
  146. \begin{enumerate}
  147. \item Its \textbf{abstract syntax}, defining the DSML constructs and their allowed combinations.
  148. This information is typically captured in a metamodel.
  149. \item Its \textbf{concrete syntax}, specifying the visual representation of the different constructs.
  150. This visual representation can either be graphical (using icons), or textual.
  151. \item Its \textbf{semantics}, defining the meaning of models created in the domain~\cite{SemanticsOfSemantics}.
  152. This encompasses both the \textbf{semantic domain} (\textit{what} is its meaning), and the \textbf{semantic mapping} (\textit{how} to give it meaning).
  153. \end{enumerate}
  154. For example, $1 + 2$ and $(+~1~2)$ can both be seen as textual concrete syntax (\textit{i.e.}, a visualization) for the abstract syntax concept ``addition of 1 and 2'' (\textit{i.e.}, what construct it is).
  155. The semantic domain of this operation is the set of natural numbers (\textit{i.e.}, what it evaluates to), with the semantic mapping being the execution of the operation (\textit{i.e.}, how it is evaluated).
  156. Therefore, the semantics, or ``meaning'', of $1 + 2$ is $3$.
  157. This definition of terminology can be seen in Fig.~\ref{fig:terminology}.
  158. Each aspect of a formalism is modelled explicitly, as well as relations between different formalisms.
  159. \subsection{Multi-Paradigm Modelling}
  160. Multi-Paradigm Modelling (MPM)~\cite{Mosterman_MPM} aims to support the modelling of complex systems by combining three different directions of research:
  161. \begin{itemize}
  162. \item \emph{Meta-Modelling}, which is the process of modelling formalisms.
  163. \item \emph{Model Abstraction}, concerned with the relationship between models at different levels of abstraction.
  164. \item \emph{Multi-Formalism Modelling}, concerned with the coupling of and transformation between models described in different formalisms.
  165. \item \emph{Process Modelling}, allowing to describe system development workflows.
  166. \end{itemize}
  167. This allows developers to model every aspect of interest explicitly, using the most appropriate formalism(s), at the most appropriate level(s) of abstraction, with processes explicitly modelled.
  168. In many cases, an appropriate formalism (with respect to some properties such as the expressiveness, tool support, and other pragmatics such as the knowledge the development team has of the language) is readily available.
  169. Examples include Matlab/Simulink for specifying the dynamics of system using a block-diagram abstraction, Modelica for modelling the physics of systems in an acausal way, and DEVS for discrete-event systems such as queuing systems.
  170. In other cases, such a language is not readily available and one has to be created to serve for a specific domain, or to solve a specific problem.
  171. Within MPM, meta-modelling allows a language engineer to efficiently build such languages and generate domain-specific modelling environments; by specifying the semantics, languages are given a meaning.
  172. \subsection{Example: Railway Simulation}
  173. The tutorial uses an example from the railway domain as an application of the presented techniques.
  174. When designing railway networks, domain experts create the network by connecting railway building blocks, such as:
  175. \begin{itemize}
  176. \item \emph{Stations}, where people can get on an off the trains.
  177. \item \emph{Track Segments}, connecting other track segments to each other, as well as to stations.
  178. \item \emph{Straights}, a special type of track that has exactly one incoming segment and one outgoing segment.
  179. \item \emph{Turnouts}, a special type of track that splits into two other tracks.
  180. \item \emph{Junctions}, a special type of track that merges two other tracks.
  181. \item \emph{Lights}, controlling whether or not a train can enter the next track segment.
  182. \end{itemize}
  183. Such models might be subject to evaluation trough virtual experiment (simulation) to see whether some performance metric is optimal.
  184. For example, one could ask the question what the optimal track length is, given a specific railway network.
  185. The track length influences the total cost of the system: very long tracks mean less infrastructure has to be built (since there are less lights to put next to the tracks), but it also means that trains might have to wait very long before they are admitted to enter the next track, potentially causing delays.
  186. \begin{figure}
  187. \centering
  188. \includegraphics[width=0.5\textwidth]{problem.pdf}
  189. \caption{The optimal track length problem illustrated.}
  190. \label{fig:problem}
  191. \end{figure}
  192. To answer such questions, the models are typically encoded in an appropriate modelling language, where such answers can be easily given.
  193. The optimal track length problem is illustrated in Figure~\ref{fig:problem}.
  194. Domain experts might be more comfortable with such visual models, instead of a simulation language that is specifying \emph{how} to run the simulation.
  195. This can improve understandability, both for expressing the problem correctly, and for interpreting the results of simulation.
  196. \section{WHAT IS A DOMAIN-SPECIFIC MODELLING LANGUAGE?}
  197. A domain-specific modelling language is a modelling language, tailored to a specific domain.
  198. The concept of domain-specificity is relative: a language such as HTML/CSS can be viewed as domain-specific, since it is tailored to the specification of the structure and layout of webpages.
  199. However, these languages are very general, and can specify solutions in many domains.
  200. The explanations that follow can be applied to modelling languages in general, regardless of whether they are viewed as domain-specific or not.
  201. In the following subsections, we explain the building blocks of domain-specific languages.
  202. \subsection{Syntax}
  203. A syntax defines whether elements are valid in a specified language or not.
  204. It does not, however, concern itself with what the constructs mean.
  205. With syntax only, it would be possible to specify whether a construct is valid, but it might have invalid semantics.
  206. A simple, textual example is the expression $\frac{1}{0}$.
  207. It is perfectly valid to write this, as it follows all structural rules: a fraction symbol separates two recursively parsed expressions.
  208. However, its semantics is undefined, since it is a division by zero.
  209. \subsubsection{Abstract Syntax}
  210. The abstract syntax of a language specifies its constructs and their allowed combinations, and can be compared to grammars specifying parsing rules.
  211. Such definitions are captured in a metamodel, which itself is again a model of the metametamodel~\cite{MattersOfMetamodelling}.
  212. Most commonly, the metametamodel is similar to UML Class Diagrams, as is also the case in our case study.
  213. The metametamodel used in the examples makes it possible to define classes, associations between classes (with incoming and outgoing multiplicities), and attributes.
  214. While the abstract syntax reasons about the allowable constructs, it does not state anything about how they are presented to the user.
  215. In this way, it is distinct from textual grammars, as they already offer the keywords to use~\cite{Kleppe}.
  216. It merely states the concepts that are usable in the domain.
  217. % TODO: Explain a bit more maybe.
  218. \subsubsection{Concrete Syntax}
  219. The concrete syntax of a model specifies how elements from the abstract syntax are visually represented.
  220. The relation between abstract and concrete syntax elements is also modelled: each representable abstract syntax concept has exactly one concrete syntax construct, and vice versa.
  221. As such, the mapping between abstract and concrete syntax needs to be a bijective function.
  222. This does not, however, limit the number of distinct concrete syntax definitions, as long as each combination of concrete and abstract syntax has a bijective mapping.
  223. The definition of the concrete syntax is a determining factor in the usability of the DSML~\cite{Usability}.
  224. Multiple types of concrete syntaxes exist, though the main distinction is between \textbf{textual} and \textbf{graphical} languages.
  225. Both have their advantages and disadvantages: textual languages are more similar to programming languages, making it easier for programmers to start using the DSML.
  226. On the other hand, visual languages can represent the problem domain better, due to the use of standardized symbols, despite them being generally less efficient~\cite{TextualVsGraphical}.
  227. An overview of different types of graphical languages is given in~\cite{VisualLanguages}.
  228. Different tools have different options for concrete syntax, depending on the expected target audience of the tool.
  229. For example, standard parsers always use a textual language, as their target audience consists of computer programmers who specify a system in (textual) code.
  230. While the possibilities with textual languages are rather restricted, graphical languages have an almost infinite number of possibilities.
  231. In~\cite{PhysicsOfNotation}, several ``rules'' are identified for handling this large number of possibilities.
  232. As indicated beforehand, a single model can have different concrete syntax representations, so it is possible for one to be textual, and another to be graphical.
  233. \subsection{Semantics}
  234. For a domain-specific language to be called a formalism~\cite{Giese_SummaryMPM}, it requires a semantic definition.
  235. Since the syntax only defines what a valid model looks like, we need to give a meaning to the models.
  236. Even though models might be syntactically valid, their meaning might be useless or even invalid.
  237. It is possible for humans to come up with intuitive semantics for the visual notations used (\textit{e.g.}, an arrow between two states means that the state changes from the source to the destination if a certain condition is satisfied).
  238. There is, however, a need to make the semantics explicit for two main reasons:
  239. \begin{enumerate}
  240. \item Computers cannot use intuition, and therefore there needs to be some operation defined to convey the meaning to the machine level.
  241. \item Intuition might only take us that far, and can cause some subtle differences in border cases.
  242. Having semantics explicitly defined makes different interpretations impossible, as there will always be a ``reference implementation''.
  243. \end{enumerate}
  244. Semantics consists of two parts: the domain it maps to, and the mapping itself.
  245. While many categories of semantic mapping exist, as presented in~\cite{SurveySemantics}, we only focus on the two main categories relevant to our case study:
  246. \begin{enumerate}
  247. \item \textbf{Translational semantics}, where the semantic mapping translates the model from one formalism to another, while maintaining an equivalent model with respect to the properties under study.
  248. The target formalism has semantics (again, either translational or operational), meaning that the semantics is ``transferred'' to the original model.
  249. \item \textbf{Operational semantics}, where the semantic mapping effectively executes, or simulates, the model being mapped.
  250. Operational semantics can be implemented with an external simulator, or through model transformations that simulate the model by modifying its state.
  251. The advantage of in-place model transformations is that semantics are also defined completely in the problem domain, making it suitable for use by domain experts.
  252. For our case study, this means implementing a simulator using model transformations.
  253. \end{enumerate}
  254. Both the semantic domain and the possible semantic mappings (operational and translational) will be covered in the next subsections.
  255. \subsubsection{Semantic Domain}
  256. The semantic domain is the target of the semantic mapping.
  257. As such, the semantic mapping will map every valid language instance to a (not necessarily unique) instance of the semantic domain.
  258. Many semantic domains exist, as basically every language with semantics of its own can act as a semantic domain.
  259. The choice of semantic domain depends on which properties need to be conserved.
  260. For example, \textsf{DEVS}~\cite{CDEVS} can be used for simulation, \textsf{Petri nets}~\cite{PetriNets} for verification, \textsf{Statecharts}~\cite{Statecharts} for code synthesis, and \textsf{Causal Block Diagrams}~\cite{CBD} for continuous systems using differential equations.
  261. A single model might even have different semantic domains, each targeted at a specific goal.
  262. For the example simulation language developed during the tutorial, we will use \textsf{DEVS} as the semantic domain; we want to run several simulations to analyze the optimal track length, which requires to look at the overall cost of the system using the throughput of the track by regarding it as a queueing system.
  263. \textsf{DEVS} is a popular formalism for modelling complex dynamic systems using a discrete-event abstraction.
  264. Atomic DEVS models are the behavioural atomic blocks of a DEVS model.
  265. Their structure is described by:
  266. \begin{gather*}
  267. AM = \langle X, Y, S, q_{init}, \delta_{int}, \delta_{ext}, \lambda, ta\rangle \\
  268. \begin{aligned}
  269. &X &\textit{set of input events} \\
  270. &Y &\textit{set of output events} \\
  271. &S &\textit{set of sequential states} \\
  272. &q_{init} \in Q &\textit{initial total state} \\
  273. & Q = \{(s, e) | s \in S, 0 \leq e \leq ta(s)\}\hspace{-1cm} &\textit{set of total states} \\
  274. &\delta_{int} : S \to S &\textit{internal transition function} \\
  275. &\delta_{ext} : Q \times X \to S &\textit{external transition function} \\
  276. &\lambda : S \to Y \cup \{\phi\} &\textit{output function} \\
  277. &ta : S \to \mathbb{R}^+_{0,+\infty} &\textit{time advance}
  278. \end{aligned}
  279. \end{gather*}
  280. Simulating an atomic DEVS model results in a (discrete-event) trace of output events.
  281. This allows a modeller to check the behaviour of the system by, for example, computing some performance metric.
  282. Coupled DEVS models as the structuring concept of DEVS.
  283. Their structure is described by:
  284. \begin{gather*}
  285. CM = \langle X_{\textit{self}}, Y_{\textit{self}}, D, MS, IS, ZS, \textit{select} \rangle \\
  286. \begin{aligned}
  287. &X_{\textit{self}} &\textit{set of input events} \\
  288. &Y_{\textit{self}} &\textit{set of output events} \\
  289. &D &\textit{set of model instance labels} \\
  290. &MS = \{AM_i | i \in D\} &\textit{set of submodels} \\
  291. &IS = \{I_i | i \in D \cup \{\textit{self}\}\} \hspace{-0.2cm}&\textit{topology} \\
  292. &I_i = 2^{D \cup \{\textit{self}\} \setminus \{i\}} &\textit{set of influencees' labels} \\
  293. &ZS = \{Z_{i,j} | i \in D \cup \{\textit{self}\}, j \in I_i\}\hspace{-1.5cm} &\textit{translation} \\
  294. &Z_{\textit{self},j} : X_\textit{self} \to X_j &\textit{input-to-input translation} \\
  295. &Z_{i,j} : Y_i \to X_j &\textit{output-to-input translation} \\
  296. &Z_{i,\textit{self}} : Y_i \to Y_\textit{self} &\textit{output-to-output translation} \\
  297. &\textit{select} : 2^D \to D &\textit{select function}
  298. \end{aligned}
  299. \end{gather*}
  300. DEVS is closed under coupling, so models can be nested up to arbitrary depth.
  301. The semantics of DEVS, a discrete-event formalism are well known~\cite{CDEVS} and implemented in a number of tools such as PythonPDEVS~\cite{DistributedPythonPDEVS}.
  302. In the tutorial, we will use DEVS as the semantic domain for our railway language to evaluate its behaviour by looking at it as a queuing network and extracting throughput information from the different scenarios.
  303. \subsubsection{Translational Semantics}
  304. With translational semantics, the source model is translated to a target model, expressed in a different formalism, which has its own semantic definition.
  305. The (partial) semantics of the source model then correspond to the semantics of the target model.
  306. As the rule uses both concepts of the problem domain and the target domain (\textsf{DEVS} in our case), the modeller should be familiar with both domains.
  307. % TODO: explain some more here maybe.
  308. \subsubsection{Operational Semantics}
  309. A formalism is operationalized by defining a simulator for that formalism.
  310. This simulator can be modelled as a model transformation that executes the model by continuously updating its state (effectively defining a ``stepping'' function).
  311. The next state of the model is computed from the current state, the information captured in the model (such as state transitions and conditions), and the current state of the environment.
  312. Contrary to translational semantics, the source model of operational semantics is often augmented with runtime information.
  313. This requires the creation of both a ``design formalism'' and a ``runtime formalism''.
  314. In our case study, for example, the runtime formalism is equivalent to the design formalism augmented with information on the current state and the simulated time, as well as a list of inputs from the environment.
  315. % TODO: explain some more here maybe.
  316. \subsubsection{Terminology}
  317. The difference between a \emph{language} and a \emph{formalism} is not always clear.
  318. To scope our work, we define the vocabulary that we use:
  319. \begin{itemize}
  320. \item A \emph{language} is the set of abstract syntax models. No meaning is given to these models.
  321. \item A \emph{concrete language} comprises both the abstract syntax and a concrete syntax mapping function. Obviously, a single language may have several concrete languages associated with it.
  322. \item A \emph{formalism} consists of a language, a semantic domain and a semantic mapping function giving meaning to model in the language.
  323. \item A \emph{concrete formalism} comprises a formalism together with a concrete syntax mapping function.
  324. \end{itemize}
  325. Whenever we use the term \emph{domain-specific language} in this tutorial, we assume it is a \emph{concrete formalism}; this ensures that the commonly known term \emph{DSL} is used.
  326. \section{HOW IS A DOMAIN-SPECIFIC LANGUAGE CREATED?}
  327. Now that we explained how a DSL is built up of syntax and semantics, we show technology with which it is possible to define these building blocks.
  328. By defining a DSL, a language engineer has the intention of building a \emph{tool} that allows users of the language to build models, check whether they are valid instances of the model, simulate them, debug them, \ldots
  329. To efficiently do this, metamodelling environments offer a framework within which the syntax can be described in a metamodel, and the semantics using model transformation.
  330. This section explains how to create a new DSL, both its syntax and its semantics.
  331. We use the metamodelling environment AToMPM~\cite{AToMPM} to demonstrate these language engineering techniques.
  332. The presented techniques are general enough to apply them in other metamodelling environments with similar capabilities as AToMPM.
  333. \subsection{Generating a Syntax-Directed Modelling Environment}
  334. \begin{figure}
  335. \centering
  336. \includegraphics[width=\textwidth]{example_model.png}
  337. \caption{Example model in the domain-specific editing environment for the railway language.}
  338. \label{fig:example_model}
  339. \end{figure}
  340. The idea behind a domain-specific language is generating a domain-specific editing environment.
  341. This environment is a tool, used by domain experts, that helps them to define models that are valid according to the rules defined in the language.
  342. One way of achieving this is offering a free-hand editor (such as a text editor), equipped with parsers, syntax checkers, and compilers configured for the language.
  343. These work in a similar way to integrated development environments, such as Eclipse.
  344. They offer freedom with respect to the editing of the syntax, but, as a downside, one can only confirm the model is correct with respect to the language definition after a manual ``check'' is performed.
  345. Another way of achieving this is through a so-called \emph{syntax-directed modelling environment}.
  346. These environments are specifically configured to the modelling language and have a model of its syntax that is continuously checked.
  347. This allows for the environment to only allow operations on the model that lead to a syntactically valid model.
  348. This constrains the user more, but since the language is tailored to a specific domain, the domain's constraints can be encoded in this way and improve the efficiency of users.
  349. Often, such environments are graphical; they offer the user a set of domain-specific icons and links in a toolbar that can be placed on a canvas.
  350. For domain experts, this often coincides with their intuition, especially for technical drawings in the electrical, mechanical, \ldots domains.
  351. We focus in this tutorial on generating syntax-directed graphical modelling environments.
  352. An example, for the railway language, is shown in Figure~\ref{fig:example_model}.
  353. It consists of a toolbar, listing the valid language element that the user of the language can instantiate.
  354. For the railway language, this includes the notions of straights, junctions, turnouts, stations, lights, and trains.
  355. On the canvas, the modeller can instantiate the graphical representation of these elements.
  356. In the example, a railway network is built consisting of a number of segments that connect stations.
  357. \begin{figure}
  358. \centering
  359. \begin{subfigure}[t]{0.55\textwidth}
  360. \centering
  361. \includegraphics[width=\textwidth]{train_metamodel.png}
  362. \caption{The metamodel of the railway language.}
  363. \label{fig:train_metamodel}
  364. \end{subfigure}
  365. \hfill
  366. \begin{subfigure}[t]{0.42\textwidth}
  367. \centering
  368. \includegraphics[width=\textwidth]{train_concretesyntax.png}
  369. \caption{The icon definition of the railway language.}
  370. \label{fig:train_concretesyntax}
  371. \end{subfigure}
  372. \caption{The syntax definition of the railway language.}
  373. \label{fig:railway_syntax}
  374. \end{figure}
  375. To obtain such a modelling environment, we need to specify the syntax of the language in a metamodel, shown in Figure~\ref{fig:railway_syntax}, and a definition of the icons, shown in Figure~\ref{fig:train_concretesyntax}.
  376. The metamodel defines the language constructs of the railway language.
  377. It also lists the allowed associations between abstract syntax elements (\emph{e.g.}, a train cannot be connected to a light, but a segment can be connected to a train).
  378. While we don't yet give semantics to our language, we already limit the set of valid models (\textit{i.e.}, for which semantics need to be defined).
  379. By preventing ambiguous situations in the abstract syntax, we do not need to take them into account in the semantic definition, as they represent invalid configurations.
  380. This language definition, together with the concrete syntax definition, is used by AToMPM
  381. to generate a domain-specific syntax-directed modelling environment, which means that only valid instances can be created.
  382. For example, if the abstract syntax model specifies that a segment can only be connected to one light, trying to connect that segment to a second light will result in an error.
  383. This maximally constrains the modeller and ensures the models are (syntactically) correct by construction.
  384. A possible concrete syntax for the railway language, shown in Figure~\ref{fig:train_concretesyntax}, assigns an icon to each langauge element.
  385. Each of the constructs shown in the concrete syntax model corresponds to the abstract syntax element with the same name.
  386. Every construct receives a visual representation that tries to be as close as possible to the mental model of the domain experts using the language.
  387. In case of standardized icons or symbols, it would be trivial to define a new concrete syntax model.
  388. Once we have defined the concrete and abstract syntax of the language, we can generate a graphical modelling environment, shown in Figure~\ref{fig:example_model}.
  389. \subsection{Modelling the Operational Semantics}
  390. \begin{figure}
  391. \includegraphics[width=\textwidth]{operational_rule.png}
  392. \caption{Example rule of the operational semantics.}
  393. \label{fig:operational_rule}
  394. \end{figure}
  395. The operational semantics of a language define a simulator for that language, which defines a number of simulation \emph{steps} that a model has to go through.
  396. It allows to obtain a simulation trace from any valid model in the language.
  397. The operational semantics are commonly expressed using model transformations, which are often called the heart and soul of Model-Driven Engineering~\cite{Transformations}.
  398. A model transformation is defined using a set of transformation rules, and a schedule.
  399. A rule consists of a Left-Hand Side (LHS) pattern (transformation pre-condition), Right-Hand Side (RHS) pattern (transformation post-condition), and possible Negative Application Condition (NAC) patterns (patterns which, if found, stop rule application).
  400. The rule is applicable on a graph (the host graph), if each element in the LHS can be matched in the model, without being able to match any of the NAC patterns.
  401. When applying a rule, the elements matched by the LHS are replaced by elements of the RHS in the host graph.
  402. Elements of the LHS that don't appear in the RHS are removed, and elements of the RHS that don't appear in the LHS are created.
  403. Elements can be labelled in order to correctly link elements from the LHS and RHS.
  404. A schedule determines the order in which transformation rules are applied.
  405. For our purpose, we use MoTiF~\cite{MoTiF}, which defines a set of basic building blocks for transformation rule scheduling.
  406. We limit ourself to three types of rules: the \textit{ARule} (apply a rule once), the \textit{FRule} (apply a rule for all matches simultaneously), and the \textit{CRule} (for nesting transformation schedules).
  407. An example rule of the operational semantics of the railway formalism is shown in Figure~\ref{fig:operational_rule}.
  408. The left-hand side of the rule tries to find two connected tracks, where a train is currently on one of the tracks.
  409. In the right-hand side of the rule, the train is moved to the next track.
  410. This rule would appear in a schedule, that implements the complete semantics of the language.
  411. The schedule operationalizes a railway network by switching lights to red when a train enters a track, and to green again when the train leaves the track.
  412. It then moves trains along the network according to which station they want to go to, and how they want to get there (their schedule).
  413. It makes sure to check that no trains will collide by entering a track at the same time (in particular also when two trains want to enter a junction).
  414. These operational semantics ``bring the system to life'' and allows for users to quickly assess the behaviour of the system by visually inspecting the trace.
  415. The simulator can, moreover, compute metrics while the simulation is running, for analysis.
  416. \subsection{DEVS as a Semantic Domain for Simulation}
  417. DEVS~\cite{CDEVS} can be used to build queuing systems, and analyze their behaviour.
  418. For the railway system language, a particular analysis might look at the railway network as a queuing system, by looking at the tracks as connected nodes with a specific capacity; trains travel between these nodes from a start to end destination.
  419. In between, they might have to wait for red lights, causing a delay in their arrival.
  420. To analyze such properties, we could make use of the operational semantics of the language, encoding the appropriate behaviour.
  421. But sometimes, it might be easier to map to a language that already has capabilities (both syntactically and semantically) for analyzing such properties.
  422. That allows us to reuse existing infrastructure, avoiding the overhead of having to reimplement it.
  423. %\begin{figure}
  424. % \includegraphics[width=\textwidth]{denotational_rule.png}
  425. % \caption{Example rule of the translational semantics.}
  426. % \label{fig:denotational_rule}
  427. %\end{figure}
  428. \begin{figure}
  429. \includegraphics[width=\textwidth]{devs_overview.pdf}
  430. \caption{Result of mapping a railway model to DEVS.}
  431. \label{fig:railway_devs_example}
  432. \end{figure}
  433. As with operational semantics, we make use of model transformations for realizing this mapping.
  434. The basic idea of the mapping is to take each building block of the model (in our case, segments, trains, and lights) and map them onto building blocks of a model in the target language.
  435. The result of mapping a particular railway segment, modelled in our domain-specific language, to DEVS, is shown in Figure~\ref{fig:railway_devs_example}.
  436. The queuing system consists of a generator, that generates trains according to some distribution.
  437. The trains then flow through the network of segments (represented by atomic DEVS models) until they reach the collector (or end station).
  438. Along the way, a train will travel through a track by trying to accelerate (at some predefined maximum acceleration) to its preferred speed.
  439. When the train is close to the next segment, a query will be sent to the next segment, for checking whether or not the segment can be entered (\emph{i.e.}, its light is green).
  440. If the light is red, the train will start to slow down, potentially stopping altogether.
  441. Once the light becomes green, a message will be sent, signifying that the train can continue.
  442. \begin{figure}
  443. \centering
  444. \includegraphics[width=0.5\textwidth]{simulation_results.png}
  445. \caption{Analyzing the results of simulation.}
  446. \label{fig:simulation_results}
  447. \end{figure}
  448. While the simulation is running, multiple metrics are collected, such as the average speed of trains, the average time it takes them to traverse the complete railway network, the average time spent in one segment, etc.
  449. Such metrics can be used to calculate a cost metric.
  450. In our example, cost is calculated by looking at the average time it takes trains to pass through the complete railway network, as well as the track length.
  451. These two properties are in conflict: as tracks become longer, the cost goes down, but the travel time will go up as trains will frequently be waiting for a red light.
  452. Looking at the simulation results, shown in Figure~\ref{fig:simulation_results}, there is a mimimum at a segment length of around 200 meter: the simulations were run for a complete tack length of 10 kilometers, and the local minimum is at around 50 track segments.
  453. By mapping the model onto a language with known semantics, we can perform analysis of certain behavioural properties by reusing the semantics and the tooling (in particular, simulators) of that formalism.
  454. %\section{RELATED WORK}
  455. % TODO: is this actually necessary?
  456. \section{CONCLUSION}
  457. In this tutorial, we presented the use of domain-specific modelling languages for simulation.
  458. We motivated the use of such languages in specific domains to improve understanding and to improve the efficiency of domain experts in defining their models, instead of having to use general-purpose languages.
  459. We presented the different aspects of a domain-specific modelling language:
  460. \begin{enumerate}
  461. \item abstract syntax to define the allowable constructs;
  462. \item concrete syntax to define the visual representation of abstract syntax constructs;
  463. \item semantic domain to define the domain in which the semantics is expressed;
  464. \item semantic mapping to define the mapping to a model in the semantic domain that defines the (partial) semantics of the domain-specific model.
  465. \end{enumerate}
  466. Each of these aspects was explained and applied to our case study: modelling the behaviour of a nuclear power plant controller and its subcomponents.
  467. The behaviour of the nuclear power plant interface is defined using both operational semantics (``simulation'') and translational semantics (``mapping'').
  468. A generative approach is used, in order to limit the development overhead.
  469. % Reducing font size (to 9pt) for References & Author Biagraphies
  470. \footnotesize
  471. % Please don't exchange the bibliographystyle style
  472. \bibliographystyle{wsc}
  473. % AUTHOR: Include your bib file here
  474. \bibliography{bibliography}
  475. \section*{AUTHOR BIOGRAPHIES}
  476. \noindent {\bf SIMON VAN MIERLO} is a post-doctoral researcher at the University of Antwerp (Belgium). He is a member of the modeling, Simulation and Design (MSDL) research lab. For his PhD thesis, he developed debugging techniques for modeling and simulation formalisms by explicitly modeling their executor's control flow using Statecharts. He is the main developer and maintainer of SCCD, a hybrid formalism that combines Statecharts with class diagrams. His e-mail address is \email{simon.vanmierlo@uantwerpen.be}. \\
  477. \noindent {\bf HANS VANGHELUWE} is a Professor at the University of Antwerp - Flanders Make (Belgium)
  478. %, an Adjunct Professor at McGill University (Canada) and an Adjunct Professor at the National University of Defense Technology (NUDT) in Changsha, China.
  479. He heads the modeling, Simulation and Design (MSDL) research lab. In a variety of projects, often with industrial partners, he develops and applies the model-based theory and techniques of Multi-Paradigm modeling (MPM).
  480. %His current interests are in domain-specific modeling and simulation, including the development of graphical user interfaces for multiple platforms. To model such reactive systems, he advocates the use of Statecharts to describe their behaviour.
  481. His e-mail address is \email{hans.vangheluwe@uantwerpen.be}. \\
  482. \end{document}