ComparisonWithStateGraph2

Comparison with StateGraph2

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

An evolved, but non-standard conforming Modelica library, called "Modelica_StateGraph2", is available from https://github.com/HansOlsson/Modelica_StateGraph2. Find below a comparison with respect to Modelica.StateGraph. A third option, especially for modeling of discrete controllers, are the clocked state machines, which are available as built-in Modelica language elements, see Section 17 (State Machines) of the Modelica 3.4 specification.

The Modelica_StateGraph2 library (called StateGraph2 below) is based on the experience with the current Modelica.StateGraph library (called StateGraph1 below) and is a significantly further development of StateGraph1. Furthermore, it is heavily based on the article (Malmheden et. al. 2008), see Literature below, but uses a different implementation technique as described in this article. The StateGraph2 library has the following improvements with respect to the StateGraph1 library:

  • 3 Basic Components (Step, Transition, Parallel)
    All multiple versions of a component are combined in only one version (e.g., one step and not 4 step components). This is easier to understand and more convenient to use. The "Parallel" component is both used as "composite step" (so only one branch), as well as "parallel step" (so several execution branches).
     
  • Safer state machines
    It is no longer possible to construct a wrong state machine in the sense that properties of the graph are violated (e.g., two initial steps, or branching wrongly out of a parallel component). Contrary to StateGraph2, in StateGraph1 such wrong graphs do not lead to an error but to unexpected simulation results. Still, other desirable properties of a state machine, such as "no deadlock" or "lifeliness" or "every step reachable", are not (yet) guaranteed with the current StateGraph2.
     
  • Composite, autonomous, synchronized, preempted subgraphs
    Composite steps and parallel steps are described in a much better and more powerful way as in StateGraph1: Either by component "Parallel" or by inheriting from "PartialParallel". The first alternative has the advantage that it is simple to use (not necessary to construct a new class and instantiating this class, and easy variable access since no new hierarchy is constructed), the second alternative has the advantage that it introduces a Modelica hierarchy (useful for large subgraphs). In both cases, various options are possible, such as
    1. autonomous subgraphs (branches are executed in parallel autonomously),
    2. synchronized subgraphs (branches are executed in parallel and are synchronized before leaving the subgraph via the outPort),
    3. subgraphs with preemption and exception (a parallel step can be interrupted via the suspend ports and can continue execution via the resume ports).
    This is achieved by enabling/disabling the different ports.
     
  • No infinite looping:
    As in StateGraph1, there are two types of transitions: immediate transitions (during event iteration all immediate transitions fire until no transition condition is true anymore) and delayed transitions (a transition fires only after a delay). Contrary to StateGraph1, in StateGraph2 every loop must have at least one delayed transition. If this is not the case a translation error occurs which states that the model contains an algebraic loop between Booleans with the name "checkOneDelayedTransitionPerLoop".
         This property guarantees that an event iteration over a StateGraph2 converges after a finite number of iterations, provided the modeller does not introduce an unsafe construct in the actions associated with a StateGraph2 (e.g., "i = pre(i) + 1" in the equation section outside of a when-clause will give an event iteration that never stops).
         It is possible to switch off this feature, by setting parameter "loopCheck = false" in one transition of a loop, instead of using a "delayed transition" at this place (in cases where immediate transitions are important and the transition conditions are in a form that they cannot fire at the same time instant).

Literature

The Modelica_StateGraph2 library is described in detail in (Otter et. al. 2009, see below) and is additionally based on the following references:

André, C. (2003):
Semantics of S.S.M (Safe State Machine). I3S Laboratory, UMR 6070 University of Nice-Sophia Antipolis / CNRS.
 
Årzén K.-E. (2004):
JGrafchart User Manual. Version 1.5. Department of Automatic Control, Lund Institute of Technology, Lund, Sweden, Feb. 13, 2004.
 
Dressler I. (2004):
Code Generation From JGrafchart to Modelica. Master thesis, supervisor: Karl-Erik Årzén, Department of Automatic Control, Lund Institute of Technology, Lund, Sweden, March 30, 2004.
 
Elmqvist H., Mattsson S.E., Otter M. (2001):
Object-Oriented and Hybrid Modeling in Modelica. Journal Europeen des systemes automatises (JESA), Volume 35 - n. 1, 2001.
 
Harel, D. (1987):
A Visual Formalism for Complex Systems. Science of Computer Programming 8, 231-274. Department of Applied Mathematics, The Weizmann Institute of Science, Rehovot, Israel.
 
Malmheden M. (2007):
ModeGraph - A Mode-Automata-Based Modelica Library for Embedded Control. Master thesis, Department of Automatic Control, Lund University, Sweden.
 
Malmheden M., Elmqvist H., Mattsson S.E., Henrisson D., Otter M. (2008):
ModeGraph - A Modelica Library for Embedded Control based on Mode-Automata. Modelica'2008 Conference, March 3-4, 2008.
 
Maraninchi F., Rémond, Y. (2002):
Mode-Automata: A New Domain-Specific Construct for the Development of Safe Critical Systems.
 
Mosterman P., Otter M., Elmqvist H. (1998):
Modeling Petri Nets as Local Constraint Equations for Hybrid Systems using Modelica. SCSC'98, Reno, Nevada, USA, Society for Computer Simulation International, pp. 314-319, 1998.
 
Otter M., Malmheden M., Elmqvist H., Mattsson S.E., Johnsson C. (2009):
A New Formalism for Modeling of Reactive and Hybrid Systems. Modelica'2009 Conference, Como, Italy, Sept. 20-22, 2009.