Modeling State-Based DEVS Models in CD++ Gastón Christen Alejandro Dobniewski Computer Science Department Universidad de Buenos Aires Planta Baja. Pabellón I. Ciudad Universitaria (1428) Buenos Aires. Argentina. Gabriel Wainer Dept. of Systems and Computer Engineering Carleton University 4456 Mackenzie Building 1125 Colonel By Drive Ottawa, ON. K1S 5B6. Canada. E-mail: gwainer@sce.carleton.ca Keywords: DEVS, DEVS Graphs, CD++. Abstract: We introduce the features of CD++, a toolkit for modeling and simulation based on the DEVS formalism. We show recent extensions that permit the users to write the models using state machines, and we show how to use it through application examples. The use of this formal ap- proach allowed developing safe and cost-effective simula- tions, reducing significantly the development times of simu- lation software. 1. INTRODUCTION In recent years, several efforts have been devoted to define new modeling paradigms, allowing improving the analysis of complex dynamic systems through simulation of these models. DEVS (Discrete Event systems Specifications) allows modular description of models that can be integrated using a hierarchical approach [1, 2]. We have built a toolkit with the goal of developing mod- els based on the DEVS formalism and simulating them. The core of the toolkit is the CD++ environment [3], which implements the DEVS theory. Here, we focus in the devel- opment process of simulated models using a graph-based definition of DEVS models. Graphical-only notations have some limitations in building complex systems [4]. There- fore, we permit the users to define intermediate functions in C++. Likewise, if the complexity of the models is such that graphical notations are not adequate, the models can be still defined using a standard representation in C++, thus permit- ting the integration of simple state-based specifications with more complex models defined in a programming language. 2. THE DEVS FORMALISM DEVS was originally defined in the '70s as a discrete-event modeling specification mechanism [1]. It was derived from systems theory, and it allows one to define hierarchical modular models that can be easily reused. A real system modeled with DEVS is described as a composite of sub- models, each of them being behavioral (atomic) or structural (coupled). Closure under coupling allows coupled models to be integrated to a model hierarchy. Each model is defined by a time base, inputs, states, out- puts, and functions to compute the next states and outputs. A DEVS atomic model is formally described by: M = < X, S, Y, δ int , δ ext , λ, ta > Each model is seen as having input (X) and output (Y) ports to communicate with other models. The input and output events determine the values to appear in those ports. The input external events are received in input ports, and the specification of the external transition function (δ int ) defines the behavior under such inputs. The internal transition func- tion (δ ext ) is activated after the lifetime of the present state has been consumed, which is defined by the time advance (ta) function. Its goal is to produce an internal event, which lead to a state change. The desired results are spread through output ports by the output function (λ), which executes before the internal transition. A DEVS coupled model is composed of several atomic or coupled submodels. They are formally defined as: CM = < X, Y, D, {M i }, {I i }, {Z ij } > Each model is seen as having input (X) and output (Y) ports to communicate with other models. Coupled models are defined as a set (D) of basic components (M i atomic or coupled), which are interconnected. The translation function (Z ij ) is in charge of converting the outputs of a model into inputs for the others. To do so, an index of influencees (I i ) is created for each model. This index defines that the outputs of the model M i are connected to inputs in the model M j , where j is an element of I i . The CD++ tool [3] allows defining models following these specifications. The tool is built as a hierarchy of mod- els, each of them related with a simulation entity. Atomic models can be programmed and incorporated onto a basic class hierarchy programmed in C++. New atomic models must be incorporated into this class hierarchy as subclasses of the Atomic Model class. Defining models in C++ allow the users to have great flexibility to define behavior. Nevertheless, a non- experienced user can have difficulties in defining models using this approach. Likewise, having a graphical specifica- tion enhances the interaction with customers during system specification [5]. Graph-based notations have the advantage of allowing the modeler to think about the problem in a more abstract way. Therefore, we have used an extended