scieee AI-readable full text Open interactive document viewer

A Java Simulator for Basic Transition P Systems

Nepomuceno Chamorro, Isabel de los Ángeles

Abstract

In this paper, a software tool (called SimCM, from Spanish Sim- ulador de Computaci¶on con Membranas) for handling P systems is presented. The program can simulate basic transition P Systems where dissolution of membranes and priority rules are allowed. This is a ¯rst step to cross the border between simulations and distributed implementations that capture the parallelism existing in this model.

Full text

A Java Simulator for Basic Transition P Systems Isabel A. NEPOMUCENO-CHAMORRO Research Group on Natural Computing Department of Computer Science and Artificial Intelligence University of Sevilla Avda. Reina Mercedes s/n, 41012 Sevilla, Spain E-mail: [email protected] Abstract. In this paper, a software tool (called SimCM, from Spanish Simulador de Computaci´on con Membranas) for handling P systems is presented. The program can simulate basic transition P Systems where dissolution of membranes and priority rules are allowed. This is a first step to cross the border between simulations and distributed implementations that capture the parallelism existing in this model. 1 Introduction Membrane computing is a recent area of Natural Computing, a topic where much work has been done but still much remains to be done. There are some applications which have been developed in imperative languages, like C++, or in declaratives languages, as Prolog, working in the frame of P systems. The present paper describes a software application, SimCm, carried out in an imperative and object-oriented language – Java. We choose Java because it is a scalable and distributed language. Working with Java is the first step to cross the border between simulations and a distributed implementation able to capture the parallelism existing in the membrane computing area. This tool is a friendly application which allows us to follow the evolution of a P system easily and in a visual way. This program can be used to move close the P system theory to the biologist and all the people who wants to learn and understand how this model works. 2 A Look Inside the Application This application is a variation of the Model-View-Controller (MVC), an architecture model of software development used in interactive systems where the user interfaces are changeable. It is also composed of several different components: in the first one, Model, functional qualities and type abstract data are found; the second component, View, is responsible for showing the results to the user through a graphical interface; the third component, Controller, is in charge of the requests made by the user. In the creation of the SimCM 309 Figure 1: Subsystems of the software. Figure 2: Subsystem I. program, the View and Controller components are joined into a single component. The following picture represents the hierarchical structure and the relations between the different Java classes designed and used for the application. These classes are distributed in two subsystems: •Subsystem I: it includes the simulator engine, that is, all the functional qualities of the basic transition P systems, and type abstract data. This subsystem is formed by the following Java packages: NAryTree (implementing the tree types to represent the membrane structure and the computation tree), List,Membrane,Multiset,Rules, and Simulator. •Subsystem II: it includes all the classes related to the Guide User Interface (GUI) that interacts with the user and is formed by the Java packages: Interface,DataUSer, ParseRule,Serialization, and HelpHtml. The two subsystems interact with each other and produce a computation that has been implemented with instance objects of the Observer and Observable Java classes. The instance objects of the Observer Java class should be notified when the state of an 310 Figure 3: Subsystem II. observable object is modified. The Observable objects are any objects whose state can be of interest for any other object (observer). However, the communication between the execution threads of the program can be more difficult than that between the observer and observable. Threads used for common objects, so that a thread can give an object to another, can be designed in such a way that the objects can be manipulated independently by both sides at the same time. This is the classic example of the thread communication in the producer/consumer problem: one thread, called producer, produces a result that another thread, the consumer, uses or consumes the result, no matter what the result is. For example, in the program the user can select the Guided mode of execution. In this mode, the user selects with the mouse by clicking on the configuration node in the GUI; this node is a product the GUI offers to the simulator in order that the simulator continues running from this node; the simulator engine consumes this object. In order to control this communication, the Java class Pipeline has been created, including push() and pull() functions (synchronized access methods), in order to maintain the integrity of the shared objects. In the following subsections we describe some programming details of this two subsystems. 2.1 Engine of Simulator The engine is built upon two fundamental pillars: the first one is the simulator that includes the algorithms to simulate the processes and computations produced inside a membrane system; it also contains the functional qualities of the system, with the task of starting the initial configuration of the P system and constructing the initial configuration of the associated computation tree; the second one includes all the type abstract data in order to support the membrane structure and its content (multisets of objects and rules), and contains the type data necessary for the creation and storage of the applicability multisets. The two relevant classes of the engine are Simulator.java and CreateBagAplicabil311 ity.java. The class CreateBagAplicability.java has the task to create the applicability multiset of rules, MAp(Ci), that must be computed for each configuration. Briefly, the algorithm to obtain MAp(Ci) works as follows: for each membrane, the rules are iterated in such a way that in each iteration a distinct rule is pivotal and for each rule its maximum applicability number is calculated according to the multiset associated with the membrane and the other rules are analyzed according to those that can be maximally applied or not (in this way the parallelism of the application rules is simulated, and the distinct possibilities of applying rules for each membrane is obtained); finally, this process continues over each of these possibilities and one obtains the applicable multiset of rules. The main class is Simulator.java which extends the Thread Java class. In this way an instance of this class can create a context of the system task and execute it through a call to start method, stop the execution of the associated thread of the task without destroying it, and execute the run method that starts the simulation algorithm. This class constructs the computation tree associated with the loaded P system: it starts with the initial configuration, computes its applicable multisets of rules and obtains its next configurations; this process is repeated for each configuration until it reaches the final state or a depth level previously established by the user. It must be understood that the efficiency of Simulator class is based on a sound implementation of the data structures, and on the iteration algorithm of these structures. In the construction of the computation tree, the membrane structure associated with each configuration is stored on the hard disk in order to unburden the RAM and not to overload the computer. Finally, Simulator.java is controlled by the user in such a way that he/she can re-do the process of the computation tree construction in one step or step by step. This step by step possibility implies a more exhaustive communication with the guide user interface than simply generating the events. 2.2 Guide User Interface The GUI is the part of the program allowing the user to interact with the application. The GUI is included in the Subsystem II with the management-reception of events generated between the user and the Simulator engine. The Swing Java package is used in the construction of this GUI (a independent platform library of classes used to develop GUI’s). This package includes the AWT1package (Abstract Windows Toolkit) and extends its capabilities. The AWT package was the first library class offered in Java. Among the classes that form the GUI, the most important are GraficaArbolConfig.java and GraficaArbolMu.java, with the task of allow a visual representation of the computation tree and the membrane structure (they both extend the JPanel Java class). 3 Sightseeing of the Application Essentially, this software tool allows us to handle transition P systems by means of three basic operations: •Create an initial membrane system; the simulator includes a debug mode in order to avoid some user errors. •Load and Save previously defined membrane systems. 1The AWT is part of the Java Foundation Classes (JFC), the standard API for providing graphical user interfaces (GUIs) for Java programs. 312 Figure 4: The main screen of the program. •Carry out a simulation of the P system evolution. This simulation can be made in three different ways: until a given maximal level, level by level, and guided. The guide user interface (GUI) of the application (Figure 4) uses classes of the Java Swing2package and the Integrated Development Environment (IDE) used is Forte3. The main screen is divided into four basic panels: •Computation tree: this panel shows the tree of configurations after the simulation is finished or during its development. •Current cell: initially, this panel contains a sketch in tree form of the membrane system to be studied (the program represents the membrane systems as tree structures). Once the simulation is finished or when it is in development, this panel will represent the state of the membrane system according to the configuration chosen by the user in the computation tree panel. In order to select the configuration, a simple click on the chosen node in the tree of the computation panel is needed. •Rules: in this panel the rules associated with each membrane are shown. •Applicable rules: this panel shows the applicability multiset associated with the configuration selected by the user in the computation tree. In the menu bar several actions are found; among them, we mention: 1. Load and save P systems. 2. Create P systems. To do this, an initial membrane system must be created by selecting the insertion of new structures. In this case one must click Create and next New in the menu and the skin appear in the current cell panel. New elements such 2Swing is form to the Java Foundation Classes (JFC). This is a set of Java class libraries provided as part of Java 2 Platform, Standard Edition (J2SE), to support building graphics user interface (GUI). 3Forte for Java v.3.0 Copyright Sun Microsystems 313 Figure 5: Insertion form. as other membranes, rules and objects can be added. There is a form that has been created to help the user in the insertion (Figure 5). The program parses the input to avoid mistakes (for example, when the user introduces new membranes, he/she must indicate the father tag and if this tag does not exist, the program will advise the user that the action is not allowed). Also, when introducing the multiset of objects, the program parses the lexical alphabet and multiplicity. Finally, when the user introduces new rules, if the rules are associated with non-existent membrane tags or if there are lexical errors in the multisets or non-existent greater priority rule tags, the program warns the user about the mistake. 3. Start the evolution of the P System. There are three modes of simulation: the first one is Until Max Depth Level, in which the simulation engine runs and does not show the final result until it either reaches the stop configuration or it hits the max level given by the user. The second mode is Level by Level, in which the simulation engine runs and shows the results as they are computed step by step in the computation tree. The third mode is Guided, in which with each new level the user has to select the corresponding node according to the configuration the user wants to continue computing, and then click Next step in the menu or toolbar. 4. Erase computation tree – in order to clean panels and memory, to work with a new P system. In the toolbar several actions are found. The most important is the fact that the user can use the text box to set the boundary mark, in order to set the desired depth of the tree of configurations. By default, the mark is set at four levels. In this way, in the case that the stop configuration does not exist, the program will finalize the simulation of the P system when the tree of configurations reaches the mark indicated in the text box. 314 4 Future Work There are three different ways to continue our work: to develop the tools in order to handle another kind of P systems (with active membranes, symport/antiport systems, ...) and to add the possibility of changing the representation of membrane structure (Venn-like diagrams); then, a Java applet running in a browser to use the application in a remote machine can be designed; and finally, to implement a distributed P system in Java RMI or using the standard CORBA4. In this way we could use the tools of distributed computing to capture the idea of maximal parallelism present in this model. In this way the future software would be very similar to the way the P systems compute. In such a new design it will be necessary to study and understand several problems related with the distributed computations and its differences to the parallel computing. References [1] G. Ciobanu, D. Paraschiv, Membrane Software. A P System Simulator, Pre-Proceedings of Workshop on Membrane Computing, Curtea de Arges, Romania, August 2001, Technical Report 17/01 of Research Group on Mathematical Linguistics, Rovira i Virgili University, Tarragona, Spain, 2001, 45–50, and Fundamenta Informaticae, 49, 1-3 (2002), 61–66. [2] A. Cord´on-Franco, M.A. Guri´errez-Naranjo, M.J. P´erez-Jim´enez, F. Sancho-Caparrini, A Prolog Simulator for Deterministic P Systems with Active Membranes, Rovira i Virgili Univ., Tech. Rep. No. 26, M. Cavaliere, C. Martin-Vide, Gh. P˘aun (Eds.), Brainstorming Week on Membrane Computing, Tarragona, Feb 5-11 2003, 141–154. [3] E. Gamma, R. Helm, R. Johnson, J. Vlissides, Design Patterns. Elements of Reusable Object-Oriented Software. Addison-Wesley. [4] I.A. Nepomuceno-Chamorro, Simulaciones de P Systemas en Java, aplicaci´on SimCM. CCIA Universidad de Sevilla Secci´on III, N 3, 2003, 1–115. [5] Gh. P˘aun, Membrane Computing. An Introduction. Springer-Verlag, 2002. [6] M.J. P´erez-Jim´enez, F. Sancho-Caparrini, Computaci´on celular con membranas: Un modelo no convencional. Kronos, 2002. 4Common Object Request Broker Architecture 315