Object Oriented Modeling and Con guration of Simulation Programs Herbert Praehofer
Systems Theory and Information Engineering Johannes Kepler University A-4040 Linz / Austria email:
[email protected]
Abstract This paper deals with the question of reusability in simulation modeling of large scale systems. It discusses dierent approaches known from software engineering, in particular object oriented techniques and domain modeling, to enhance software reusability. Based on these ideas and on systems theory based simulation modeling, an environment is presented which supports modeling of application domains, interactive con guration of simulation models and automatic simulation program generation.
1 Introduction and Motivation
Modeling and computer simulation of large scale systems, like transportation systems, trac systems manufacturing systems, large scale networks and others, usually requires taking into account a huge number of dierent alternatives and parameters in system realization. However, often the variations in design of one system to another are relatively small. But the models and knowledge acquired in one simulation project are only used in the next project to a minor extent. Simulation models often are built from scratch. An important issue in simulation modeling and programming, therefore, is to enhance model reusability. Model libraries provide basic building blocks for dierent types of application and have successfully been applied in several domains, like manufacturing systems, transport systems and others. However, model libraries only store and make reusable knowledge about basic components. They are not capable of codi ng information about how systems are composed, what favorite system architectures are, what kind of limitations in system realizations exist, etc. Systems theory based simulation modeling as well as object oriented software engineering have recog Work supported by Siemens AG Munich, Corporate Research and Development
nized the need to reuse knowledge acquired over several dierent projects. The multifacetted modeling and system design approach [Zeigler, 1984; Rozenblit and Huang, 1991] use systems theory based modeling concepts and AI techniques to represent a design domain in its dierent variations, decompositions, objectives, constraints, and requirements. Domain modeling [Batory et al., 1995; Batory and O'Malley, 1992; Holibaugh, 1993; Kang et al., 1991], as a new eort in software engineering, aims at enhancing software reusability with quite similar means, viz. by providing libraries of reusable building blocks and to formally model families of software designs in one particular domain. In this paper we deal with the question of reusability in simulation modeling. We discuss dierent approaches to reusability known from software engineering, we review the systems theory based approach to modular, hierarchical simulation modeling and show how they can work together to enhance simulation model reusability. Finally we present a modeling and simulation system based upon a C++-implementation of the modeling concepts which supports domain modeling, interactive con guration of simulation models and automatic simulation program generation. In the following, we rst give a survey of approaches to software reusability. Then we discuss system modeling concepts and show how the object oriented realization of system models in C++ supports the realization of reusable and parameterizable simulation building blocks. In the next section we show how domain models of simulation applications can be built based on the OMT object oriented modeling approach. Finally we present our environment to support domain modeling and simulation program generation.
2 Approaches to Reusability
Software component reusability is regarded to be the key factor to enhance eciency of software production. However, so far the problem seems not to be solved and is therefore a topic of intensive research. In the following we discuss dierent approaches which
have emerged to tackle software reusability.
2.1 Object oriented programming
Object oriented programming has been regarded as the solution for software reusability in the 80s. Based upon abstract data types and data encapsulation, it introduced polymorphism and inheritance and type hierarchies. An object class de nes an abstract function call interface which can be realized in several different ways in specialized classes through polymorphic operations. Polymorphism together with specialization hierarchies allows for specifying so-called \template" methods which de ne general behavioral patterns, with the possibility for delegating speci c tasks to \hook" methods which are polymorphic [Pree, 1994]. Depending on the hook class, the general template behavior can be varied. Design patterns [Gamma et al., 1995] and frameworks [Gamma, 1992] based on these concepts aim at providing general architectural principles in software design and reusable object libraries. However, the goal of object reusability has not been achieved to its fullest extent. It has been shown that building reusable libraries, where objects can be used and extended, are dicult to accomplish.
2.2 Generic programming
Another approach to achieve reusability is generic programming. It allows for de ning objects and algorithms for generic types from where concrete classes and algorithms are derived by determining a concrete type for the generic type parameter. Generic programming works intensively with functional parameterization, i.e., using functional parameters for parameterization of behavior. Generic programming in C++ [Stroustrup, 1991] is realized by template classes and template functions together with functional objects and has heavily and successfully been used in the de nition of the Standard Template Library [Musser and Stepanov, 1993]. Functional objects in C++ are classes with a function call operator de ned and are used more conveniently than function pointers for behavior parameterization.
2.3 Object oriented analysis, modeling, and design
Object oriented modeling and design techniques realize that complex engineering designs need object oriented concepts, most notably taxonomic knowledge representation schemes in the form of inheritance hierarchies. Rumbaugh [Rumbaugh et al., 1991], Booch [Booch, 1991], Wirfs-Brooks [Wirfs-Brooks et al., 1990] and others use graph-like representations of complex object oriented software which in particular show how objects are composed from smaller objects (has-a relation), what kind of interrelations between objects exist (association) and what kind of taxonomic
relations between object classes exist (is-a relation). This static object view forms a framework for a behavioral model in the form of various state transition diagrams and a functional model showing the data and event ow between objects of the system. Based on those representations an object oriented software engineering methodology is de ned which distinguishes several steps like system analysis or requirement analysis, system design, object design and implementation [Rumbaugh et al., 1991]. Object oriented analysis and design techniques are intended to address only single problems and their theme is not reusability in the rst place. However, object oriented requirement, speci cation and design models give good documentation of structure and variations of system components, so that they provide a good foundation for reuse in similar projects.
2.4 Domain modeling
In coparison to object oriented techniques, domain analysis and modeling [Batory et al., 1995; Batory and O'Malley, 1992; Holibaugh, 1993; Kang et al., 1991] are intended to encode domain requirement and design models for reusablility over a family of systems in one domain. Based mostly on object oriented modeling techniques, they recognize the necessity to enhance those techniques, in particular, they recognize the need to do requirement engineering, speci cation, and design for reusability. A domain model identi es the essential features, interfaces, components, variations and alternatives, abstractions, capabilities, limitations etc. of a family of systems in a domain. Domain modeling, which is a recent research eort, today is believed to be the key factor in developing an economic and scalable means for constructing families of related software systems. In domain modeling, two major approaches are identi ed, viz. integrative modeling and generative modeling [Batory et al., 1995]. Integrative modeling is a direct extension of object oriented modeling techniques and typically de ne an integrated set of submodels in the form of object decomposition/coupling and generalization/specialization hierarchies. They extend conventional object oriented schemes by the ability to represent optional objects, relationships, and states when specifying a target. Generative or reference architecture models are the second kind of domain models. They primarily deal with such issues like: identifying the fundamental programming abstractions in a domain, creating libraries of interoperable software components, de ning knowledge representation schemes for stating constraints on combinations of building blocks, and nding dierent types of coupling schemes [Batory et al., 1995]. A fundamental prerequisite of generative domain modeling therefore is a methodology for software component speci cation, a component programming methodology going
beyond object oriented techniques [Batory et al., 1995; Batory and O'Malley, 1992; van der Linden and Muller, 1995]. Based on system theory simulation modeling concepts, Zeigler [Zeigler, 1984] de ned a methodology for modeling in the large (termed multifacetted modeling) which recognizes the multiplicities of objectives and models in the modeling and simulation enterprise. This methodology regards a model as a means to embody knowledge of a real system, it concentrates on the organization of model bases for a domain, and, in that, shows strong resemblance to domain modeling eorts. The heart of the methodology is the System Entity Structure (SES) knowledge representation scheme which recognizes the need to represent decomposition and coupling as well as taxonomic knowledge. Based on multifacetted modeling, Rozenblit [Rozenblit and Huang, 1991] de ned a knowledge-based system design and simulation methodology which introduces knowledge representation schemes to de ne coupling and synthesis constraints, selection rules, and non-functional parameters. A heuristic, rule based pruning process has been realized to extract possible system con gurations satisfying stated requirements.
3 Modular, Hierarchical System Modeling
Modular, hierarchical system modeling [Zeigler, 1984; 1990; Pichler and Schwartzel, 1992] is an approach to complex dynamic system modeling where modular building blocks, i.e., system components with a well de ned interface in the form of input and output ports, are coupled in a hierarchical manner to form complex systems. In system modeling, one distinguishes between atomic or coupled models. While an atomic model speci es its internal structure in terms of its set of states and state transition functions, a coupled model's internal structure is speci ed by its components and coupling scheme, i.e., how ports are connected. System modeling means modeling complex systems by interface based object composition. Modularity allows for setting up bases of reusable building blocks which can be plugged into a system through their well de ned input and output interface. Modular hierarchical system modeling concepts have been applied in several domains, most notably hardware design and communication engineering. Zeigler [Zeigler, 1984; 1990] introduced modular hierarchical modeling for discrete event simulation. The DEVS-formalism is an application and computer implementation independent formalism for discrete event modeling and parallels the dierential equation speci ed and nite state automaton formalism. An atomic DEVS knows two types of events: (1) external events occur upon input events on the input interface and are handled by an external state transition function, (2)
internal events are time scheduled events, i.e., they occur when a certain time span determined by a time advance function elapses, and are handled by the internal state transition function. The abstract simulator concept for modular hierarchical DEVS [Zeigler, 1984] provides appropriate hierarchical simulation concepts. The DEVS-formalism and methodology have been extended in several ways. The extension to multiformalism modeling and simulation [Pichler and Schwartzel, 1992] allows combined discrete/continuous modeling and simulation and the integration of components speci ed in several dierent formalisms. This is accomplished by an abstract simulator [Praehofer et al., 1993] with a polymorphic simulation protocol taking care of the various needs in simulation of dierent model types. Another extension is to allow coupled models with state behavior [Thomas, 1993; Praehofer, 1996], i.e., a coupled model owns its own state transition function and, in that way, is able to dynamically change its component and coupling structure. This extension facilitates the realization of variable structure models [Zeigler and Praehofer, 1990].
3.1 Object oriented programming and system modeling contrasted
Zeigler [Zeigler, 1990] compares modular hierarchical system modeling and the object oriented paradigm. While both share various concepts they also show major dierences. System models as well as objects use the concept of internal states. However, objects are not dynamic systems in the sense of system theory which show dynamic, concurrent behavior speci ed over a time base. Nor are objects modular units in the above sense. In particular, objects lack an explicit output interface. The output interface is only given implicitly by the method calls to other objects. Therefore, an object has to have knowledge of the other objects with whom it communicates. In contrast to that, a system model only de nes an output port, the communication with other components is de ned independently on the higher coupled system level. Object oriented systems also are not hierarchical in the above sense. While polymorphic operations in system models are given by equal interface for dierent internal model structure and behavior, inheritance is not de ned for system models. However, as shown in [Zeigler, 1990] and [Praehofer, 1996], such extension are straight forward.
3.2 Object oriented realization of system models
The basis for the simulation program modeling and con guration system is given by the C++implementation of the DEVS-based modeling and simulation concepts. Exploiting C++, DEVS-based mod-
eling has been extended with object oriented and generic programming features. DEVS-based models, atomic as well as coupled, are de ned by C++-class de nitions which implement the model interface, set of states, and component systems by data de nitions and behavior and couplings by polymorphic methods. Generic template classes, which are parameterized by their values' data types, are provided for model input and output port de nitions. State and parameter values can be de ned by member variables of any data type; model components are declared as member variables of any model class or, preferably, as a pointer to a model class. In that way it is feasible to use the object oriented features of C++, viz. inheritance, polymorphism, and genericity for model realization. In the implementation, the realization of the model and the simulation protocol have been strictly separated. For each model type one simulator object is realized, which, however, all obey the same simulation protocol. In that way the integration of dierent model types, e.g., discrete event and continuous models, is supported.
3.3 Building generic model base libraries
To realize reusable component libraries in C++, black box models de ning an interface for a set of model realizations are implemented by separate classes. Different model realizations can be derived from the black box models by class inheritance. All models derived from a black box models are interchangeable in a simulation program since they obey the same interface. The multiformalism modeling approach also facilitates the use of dierent modeling formalisms, e.g. coupled or atomic, discrete or continuous, for dierent models derived from one black box class. Reusability of model library components can be further enhanced by employing generic programming features of C++. In a similar way as in the Standard Template Library, the model base components are de ned in a generic way and can be parameterized by template parameters and functional objects. In particular, generic library components can be parameterized in the following ways:
Actual types of input and output values can be xed by de nition of template parameters.
Variables with scalar values are used to determine model parameters, like capacity of queues, number of components in a coupled model, constant processing times etc.
Model components usually are de ned as pointers to black box models. Then, any model class derived from the black box class can be used as the actual component.
FMS
Server
SerialServer
Storage
Conveyors
ParallelServer
Control
SimpleServer
is-a has-a
Server
SelectFn Server
Random
association multiple
LeastRecently FirstSelFn SelFn
Exponential
Normal
Figure 1: OMT-model of ctitious manufacturing domain.
Functional object parameters are employed to parameterize the behavior of model components. For example, a functional object can be used for random number generation, or to implement various strategies for selection of a server model in a parallel bank of servers, or to implement various control strategies for selection of the next workpiece in a manufacturing cell.
4 OMT-Based Modeling of Simulation Domains
An object oriented model of a simulation domain is intended to represent the domain in all its variations and alternatives, abstractions levels, and with all the restrictions which apply. It should support the simulationist in the selection of a simulation model which represents a particular system design to be tested by simulation. Due to its popularity, we decided to follow the OMT method [Rumbaugh et al., 1991] to a large extend. We use the graphical representation introduced by OMT to show decomposition and inheritance hierarchies. For behavioral modeling we adapted the Statechart state diagram formalism also used in OMT for discrete event and combined discrete continuous modeling [Praehofer and Pree, 1993]. However, our approach also diers in several details from OMT and show much resemblance to the multifacetted modeling methodology. In particular, we support a hierarchical modeling approach and require modular model coupling. Reviewed in the sense of the object oriented C++realization of the simulation models, the OMT model of a simulation application is a meta-model of the C++ model de nitions. It represents the hierarchical structure of the simulation model and it represents the different variants for model components, i.e., the models which are derived from one black box class. Furthermore, the OMT model has to show the possible parameterization of the model components by template
parameters and functional objects. Figure 1 depicts such an OMT model of a ctitious manufacturing domain. It depicts the hierarical decomposition in the system and specialization hierarchies of the servers component. The model component are generic and can be parameterized by a type T de ning the type of workpiece to be processed. Functional objects are used to de ne the processing time of a SimpleServer as well as the selection criterion for a ParallelServer. The class hierarchies at the bottom de ne the dierent alternatives for these functional objects. Several design issues cannot be represented by an object oriented model. These are in particular: restrictions in the selections of components, compatibility of components, compatibility of template parameters and functional objects, etc. Similar to [Rozenblit and Huang, 1991; Batory et al., 1995], our object oriented model is augmented by a rule based approach for representation the of these various design rules.
5 Domain Modeling and Con guration System
Based on the C++-realization of DEVS-based modeling and simulation and on the OMT-based object oriented domain modeling concepts, an environment is realized which facilitates the representation of simulation application domains, the con guration of simulation models, and the automatic generation of C++ simulation code from those con gurations. Furthermore, the environment also serves as a framework for speci cation of experimental conditions, to support execution of simulation runs, and the administration of simulation results. Figure 2 shows the architecture of the modeling and simulation environment. Central in the environment is an object oriented database system which stores and manages the object oriented model of the domain, the dierent con gurations already derived from it in the form of hierarchical model structures, and the experimental conditions and the simulation results for the models. Beneath this database we identify the C++ layer. It contains all the C++ class de nitions of the generic libraries components, but also the executable simulation programs for the hierarchical model con gurations. A translation process is implemented which is capable to produce C++ source code from the hierarchical model con guration. Object oriented modeling as well as simulation program generation and simulation experimentation are supported by an interactive user interface. The environment supports users with dierent expertise: (1)
User Interface modelling
configuration
simulation
data analysis
Data Base oo model
hier. model
experiment
data
C++ Programs model libraries
simulation programs
Figure 2: Architecture of the domain modeling and con guration system. the simulationist can run simulation experiments for existing model con gurations and analyze the results, (2) the modeler con gures new systems designs based on the available domain knowledge, (3) the expert programmer is able to realize new model components and integrate them into the domain knowledge base. The system is currently realized using the GCC C++ compiler, the object oriented database system Poet, the portable user interface framework wxWindows and CLIPS as a rule-based forward chaining system.
6 Summary
In this paper we have shown how dierent approaches can be employed to achieve reusability in simulation programming. Object oriented and generic programming and modular hierarchical system modeling can cooperate successfully to implement reusable generic model libraries. Object oriented modeling techniques augmented with rule-based paradigms facilitate the representation of application domains. Based on these concepts, a software environment is realized which supports the con guration of simulation models and automatic generation of simulation programs.
References
[Batory and O'Malley, 1992] D. Batory and Sean O'Malley. The design and implementation of hierarchical software systems with reusable components. ACM Trans Software Eng and Methodology, 1992. [Batory et al., 1995] D. Batory, D. McAllester, L. Coglianese, and W. Tracz. Domain modeling in engineering computer-based systems. In 1995 Int. Workshop on Systems Eng of Computer-Based Systems, Tucson AZ, 1995. IEEE/CS Press. [Booch, 1991] G. Booch. Object Oriented Design with Applications. Benjamin Cummings, Redwood City, 1991.
[Gamma et al., 1995] E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns. AddisonWesley, Wokingham, 1995. [Gamma, 1992] E. Gamma. Objektorientierte Softwareentwicklung am Beispiel ET++. PhD thesis, University of Zurich, Zurich, Switzerland, 1992. [Holibaugh, 1993] R. Holibaugh. Object oriented domain analysis method (JODA). Technical report, Software Engineering Institute, Carnegie Mellon University, Pittsburgh, Pennsylvania, 1993. [Kang et al., 1991] K. Kang, S. Cohen, J. Hess, W. Nowak, and A. Peterson. Feature oriented domain analysis (FODA) feasibility study. Technical report, Software Engineering Institute, Carnegie Mellon University, Pittsburgh, Pennsylvania, 1991. [Musser and Stepanov, 1993] D. R. Musser and A. A. Stepanov. Algorithm oriented generic libraries. Technical report, Computer Science Department, Rensselear Polytechnical Institute, Troy, New York, 1993. [Pichler and Schwartzel, 1992] F. Pichler and H. Schwartzel, editors. CAST Methods in Modelling. Springer-Verlag, 1992. [Praehofer and Pree, 1993] H. Praehofer and D. Pree. Visual modeling of devs-based systems based on higraphs. In Winter Simulation Conference 1993 Systems, pages 595 { 603, Los Angeles CA, Dec. 1993. SCS Press. [Praehofer et al., 1993] H. Praehofer, F. Auernig, and G. Reisinger. An environment for DEVS-based multiformalims simulation in Common Lisp / CLOS. Discrete Event Dynamic Systems: Theory and Application, 3(2):119{149, 1993. [Praehofer, 1996] H. Praehofer. An environment for DEVS-based multiformalism modeling and simulation in C++. In Proc. of AI, Simulation and Planning in High-Autonomy Systems, Tucson AZ, March 1996. IEEE/CS Press. to appear. [Pree, 1994] W. Pree. Design Patterns for ObjectOriented Software Construction. Addison-Wesley, Wokingham, 1994. [Rozenblit and Huang, 1991] J. Rozenblit and Y.M. Huang. Rule-based generation of model structures in multifacetted modeling and system design. OSRA Journal of Computing, 3(4):330{344, 1991. [Rumbaugh et al., 1991] J. Rumbaugh, M. Blaha, W. Premerlani, F. Eddy, and W. Lorenson. Object Oriented Modeling and Design. Prentice Hall, Englewood Clis, 1991.
[Stroustrup, 1991] B. Stroustrup. The C++ Programming Language. Addison-Wesley, Wokingham, 1991. [Thomas, 1993] C. Thomas. Hierarchical objects nets - a methodology for graphical modeling of discrete event systems. In Winter Simulation Conference 1993, pages 650 { 656, Los Angeles CA, Dec. 1993. SCS Press. [van der Linden and Muller, 1995] F. van der Linden and J. K. Muller. Composing product families from resuable components. In 1995 Int. Workshop on Systems Eng of Computer-Based Systems, Tucson AZ, 1995. IEEE/CS Press. [Wirfs-Brooks et al., 1990] R. Wirfs-Brooks, B. Wilkerson, and L. Wiener. Designing Object-Oriented Software. Prentice Hall, Englewood Clis, 1990. [Zeigler and Praehofer, 1990] B. Zeigler and H. Praehofer. Systems theory challanges in the simulation of variable structure and intelligent systems. In EUROCAST '89, pages 41{51. Springer Lecture Notes on Computer Science 410, 1990. [Zeigler, 1984] B. P. Zeigler. Multifacetted Modelling and Discrete Event Simulation. Academic Press, London, 1984. [Zeigler, 1990] B. P. Zeigler. Object-Oriented Simulation with Hierarchical, Modular Models. Academic Press, London, 1990.