A Web-Based P Systems Simulator and Its Parallelization

12
A Web-Based P Systems Simulator and Its Parallelization Cosmin Bonchi¸ s 1 , Gabriel Ciobanu 1,3 , Cornel Izba¸ sa 1 , and Dana Petcu 1,2 1 Research Institute “e-Austria” Timi¸ soara, Romania 2 Western University of Timi¸ soara, Department of Computer Science 3 Romanian Academy, Institute of Computer Science, Ia¸ si Abstract. In this paper we present WebPS, an open-source web-enabled simulator for P systems, and a P accelerator for parallelization of the ex- isting sequential simulators. The simulator is based on CLIPS, and it is already available as a web application. The P accelerator is used to parallelize the existing sequential simulators of the P systems. We ex- emplify this tool by using a simple CLIPS simulator. The speedup and the efficiency of the resulting parallel implementation are surprisingly close to the ideal ones. Combining these two ingredients, we get a com- plex and ready-to-use parallel simulator for P systems; no installation are required, no previous knowledge of operating systems, parallel pro- gramming or specific software. 1 Introduction Transition P systems and deterministic P systems with active membranes (see [7]) are simulated in various programming languages, and some of them are used to solve NP-complete problems as SAT, Subset Sum, Knapsack, and parti- tion problems. P systems with active membranes, input membrane and external output are simulated in CLIPS, and used to solve NP-complete problems (see [8]). New variants of these simulators provide symport-antiport rules, and cat- alysts. A previous simulator written in Visual C++ for P systems with active membranes and catalytic P systems is presented in [2]. It provides a graphical simulator, interactive definition, visualization of a defined membrane system, a scalable graphical representation of the computation, and step-by-step observa- tions of the membrane system behaviour. A parallel and cluster implementation for transition P systems in C++ and MPI is presented in [2]. The rules are im- plemented as threads. At the initialization phase, one thread is created for each rule. Since each rule is modelled as a separate thread, it should have the ability to decide its own applicability in a particular round. In order to detect if the P system halts, each membrane must inform the other membranes about its inac- tivity. It can do so by sending messages to others, and by using a termination detection algorithm. We present here a new simulator, and its main feature is given by the avail- ability as a Web application. This aspect is actually emphasized by its name: WebPS. As any Web application, WebPS does not require an installation. It can C.S. Calude et al. (Eds.): UC 2005, LNCS 3699, pp. 58–69, 2005. c Springer-Verlag Berlin Heidelberg 2005

Transcript of A Web-Based P Systems Simulator and Its Parallelization

A Web-Based P Systems Simulator

and Its Parallelization

Cosmin Bonchis1 Gabriel Ciobanu13 Cornel Izbasa1 and Dana Petcu12

1 Research Institute ldquoe-Austriardquo Timisoara Romania2 Western University of Timisoara Department of Computer Science

3 Romanian Academy Institute of Computer Science Iasi

Abstract In this paper we present WebPS an open-source web-enabledsimulator for P systems and a P accelerator for parallelization of the ex-isting sequential simulators The simulator is based on CLIPS and itis already available as a web application The P accelerator is used toparallelize the existing sequential simulators of the P systems We ex-emplify this tool by using a simple CLIPS simulator The speedup andthe efficiency of the resulting parallel implementation are surprisinglyclose to the ideal ones Combining these two ingredients we get a com-plex and ready-to-use parallel simulator for P systems no installationare required no previous knowledge of operating systems parallel pro-gramming or specific software

1 Introduction

Transition P systems and deterministic P systems with active membranes (see[7]) are simulated in various programming languages and some of them areused to solve NP-complete problems as SAT Subset Sum Knapsack and parti-tion problems P systems with active membranes input membrane and externaloutput are simulated in CLIPS and used to solve NP-complete problems (see[8]) New variants of these simulators provide symport-antiport rules and cat-alysts A previous simulator written in Visual C++ for P systems with activemembranes and catalytic P systems is presented in [2] It provides a graphicalsimulator interactive definition visualization of a defined membrane system ascalable graphical representation of the computation and step-by-step observa-tions of the membrane system behaviour A parallel and cluster implementationfor transition P systems in C++ and MPI is presented in [2] The rules are im-plemented as threads At the initialization phase one thread is created for eachrule Since each rule is modelled as a separate thread it should have the abilityto decide its own applicability in a particular round In order to detect if the Psystem halts each membrane must inform the other membranes about its inac-tivity It can do so by sending messages to others and by using a terminationdetection algorithm

We present here a new simulator and its main feature is given by the avail-ability as a Web application This aspect is actually emphasized by its nameWebPS As any Web application WebPS does not require an installation It can

CS Calude et al (Eds) UC 2005 LNCS 3699 pp 58ndash69 2005ccopy Springer-Verlag Berlin Heidelberg 2005

A Web-Based P Systems Simulator and Its Parallelization 59

be used from any machine anywhere in the world without any previous prepa-ration A simple and easy to use interface allows the user to supply an XMLinput both as text and a file A friendly way of describing P systems is given byan interactive JavaScript-based P system designer The interface provides a highdegree of (re)usability during the development and simulation of the P systemsThe initial screen offers an example and the user may find useful documentationabout the XML schema the rules and the query language The query languagehelps the user to select the output of the simulation

This simulator is based on CLIPS The previous CLIPS implementationsrepresent P systems rules by CLIPS facts we get a significantly faster execu-tion by using CLIPS rules to implement P systems rules In [8] the P systemdata are inserted directly into code and so they cannot be easily modified asopposed to our implementation where a P system is an input data providinga lot of flexibility P systems as input data are described by XML documentsthis fact provides a standard method to access information making it easierto use modify transmit and display XML is readable and understandable itexpresses metadata easily in a portable format just because many applicationscan process XML on many existent platforms Moreover by using XML it be-comes easy to define new features and properties of P systems XML allowsan automated document validation restricting wrong input data and warningthe user before execution with respect to the possible errors in their P systemsdescription From a user point of view all these features facilitate an efficientdescription and reconfiguration of the P systems

The simulator is open-source actually free software as it is being offered athttppsystemsieatro under the GNU General Public License This allowsanyone to contribute with enhancements and error corrections to the code andpossibly develop new interfaces for the C and CLIPS level APIs These interfacescan be local (graphical or command-line) or yet other Web-based ones

Section 2 presents the WebPS structure and argue what are its advantagesover the previous P simulators Several new and interesting examples imple-mented in the WebPS system are described in Section 3 In Section 4 we discusson the parallelization of sequential simulators and present Jess as a starting toolin building a wrapper for parallel systems Then we describe our P accelerator asa parallel version of Jess able to work on homogeneous clusters of workstationsWe provide some implementation details and measure the efficiency of our Paccelerator by applying it to a simple CLIPS simulator solving a difficult prob-lem We present the results of our experiments showing a significant reductionof the running time Conclusion further work and references end the paper

2 WebPS Software Architecture

The software structure of the simulator has three distinct levels The inner levelis the CLIPS level This level integrates part of the knowledge about the theo-retical description of P systems the result being a library of CLIPS functionsmeta-rules and templates Since CLIPS is easily embeddable in C (as its name rdquoCLanguage Integrated Production Systemrdquo suggests) we can control the CLIPS

60 C Bonchis et al

level from a C program and we include some example to illustrate how this isdone The C level is strengthened by introducing a C library for modelling andsimulating P systems based on the CLIPS library The Web application level of-fers a user-friendly interface to the simulator and can become after the additionof debugging and visualization features a powerful P system development tool

21 CLIPS Level

This is the core level of the simulator We address here some crucial issuesnamely how we implement in a sequential context the maximally parallel andnondeterministic execution of P systems

Maximally Parallel Execution The maximally parallel execution require-ment relies on constraining our simulation cycle to the following distinct steps

1 React step where the activated reaction rules are sequentially executed2 Spawn step where the new objects created by rules inside their membranes

are asserted as object facts they become visible for a future React step3 Communication step where the objects injected or ejected by communi-

cation rules in different membranes are asserted as objects facts4 Divide step it handles possible divisions processes of membranes5 Dissolve step it handles dissolving processes of membranes

By constantly recording the state of the P system after each React Spawn andCommunication steps we can get a trace of an execution

Nondeterministic Execution CLIPS uses RETE algorithm to process rulesRETE is a very efficient mechanism for solving many-to-many matching prob-lem [5] The nondeterministic execution requirement is fulfilled by the CLIPSrandom mechanism We have looked closely at the random strategy and wefound it makes the same choice for the same configurations in different execu-tions By calling the random function of CLIPS the random mechanism usesthe random number generator The failure is related to the improper seeding ofthe random number generator We have corrected this error and properly seedthe random number generator by using devurandom the entropy gatheringdevice on GNULinux systems This aspect can be also useful for other CLIPSimplementations possibly affected by the same failure

Data Representation An important choice regarding an implementation isgiven by data representation We decide to represent P system objects and mem-brane structure as CLIPS facts (with set-fact-duplication option of CLIPS set toon) and the P systems reaction rules as CLIPS rules This contrasts the previ-ous implementations which have represented reaction rules as CLIPS facts whiletheir choice might allow general meta-rules for execution we get a flexible andefficient framework by representing reaction rules as CLIPS rules The efficiencyis gained by making direct use of the CLIPS pattern-matching mechanism andrule activation capabilities This choice is also confirmed by the efficiency of the

A Web-Based P Systems Simulator and Its Parallelization 61

dissolve and divide operations which imply a lot of moving and copying Ini-tially we think to represent membranes as modules but later we see that thisrepresentation decreases the efficiency and flexibility of the whole system

It is useful to note that the simulator supports divide promotersinhibitorsand symportantiport rules for membranes For example the P system transitionrule a+brarrc+d(2)+e(0) with priority 11 from membrane 1 is converted into thefollowing CLIPS rule

(defrule MAIN1_a+b-gtc+d[2]+e[0]

(declare (salience 11))

(do (what react))

(or (parent-child (parent 1) (child 2))

(parent-child (parent 2) (child 1)))

(or (parent-child (parent 1) (child 0))

(parent-child (parent 0) (child 1)))

a-0 lt- (obj (name a) (membrane 1))

b-1 lt- (obj (name b) (membrane 1))

=gt

(assert (newobj (name c) (membrane 1)))

(assert (inject (name d) (membrane 2)))

(assert (inject (name e) (membrane 0)))

(retract a-0) (retract b-1))

The membrane structure is reflected by the parent-child facts An object a ofmembrane 1 is represented as a CLIPS fact on line 8 (obj (name a) (membrane1)) While the reactants a and b are consumed the new objects c d and e arecreated during the Spawn and Communication steps respectively The rulepriorities are mapped directly to CLIPS rules salience values and therefore arerestricted to integer values in the interval [-10000 10000]

22 C Level

In the C level we use CLIPS API although we plan to develop a complete librarythat encapsulates the C-CLIPS interface namely a C library which wraps nicelyaround the CLIPS one

We represent a P system using XML and we define an XML schema forthis kind of document A special library is developed to handle XML parsingof the input for the CLIPS part of the simulator In the following example wedescribe a P system using our XML schema This example system presents a Psystem for multiplication of the number of a objects in membrane 1 with thenumber of b objects in membrane 0 the result being the number of d objectsin membrane 0

ltxml version=10gt

ltpsystemgt

ltmembrane name=0gt

ltobject name=b count=3 gt

ltrule body=b+v-gte+v+d priority=1 gt

ltrule body=e+u-gtb+u+d priority=1 gt

ltrule body=v-gtu(1) gt

62 C Bonchis et al

ltrule body=u-gtv(1) gt

ltmembrane name=1gt

ltobject name=a count=4 gt

ltobject name=v count=1 gt

ltrule body=a+v-gtv(0) gt

ltrule body=a+u-gtu(0) gt

ltmembranegt

ltmembranegt

ltquery text=count of (objects from 0 where (objects d)) gt

ltpsystemgt

23 Web Level

The Web level of the simulator allows to choose between a user-friendly P systemdesigner written in JavaScript and a traditional HTML input form transmittingan XML description by uploading a file or by editing Aside from the XML Psystem description editing the user can specify a number of executions of the Psystem Our JavaScript P system Designer aims to facilitate the description ofthe P system without requiring the user to write XML but generating it basedon the userrsquos interaction with a dynamic interface

PHP script

CGI program(C)

CLIPS library LibCGI PSminusXML C library

JavaScriptP system Designer

HTML input formfor XML

After the user introduces a XML description it is transmitted to a PHPscript which does some further processing and sent then to a CGI programwritten in C The C program uses a specific P system XML library called PS-XML as well as LibCGI and CLIPS library in order to simulate the evolutionof the P system Finally it returns the results to the user It is possible to selectvarious information provided as results and in order to help the user to selectthe desired information we define a query language called PsQL

PsQL (P systems Query Language) We define PsQL as an SQL-like lan-guage for querying the state of a P system We developed a CLIPS library forparsing and interpreting this language At the Web level the queries can be in-cluded in the XML input these queries are activated after the execution of the

A Web-Based P Systems Simulator and Its Parallelization 63

specified P system If it does not exist any query the P system is simulated butno output is generated At the CLIPS level it is possible to specify queries forthe P system in a dynamic manner not just before starting the simulation Atthe syntactic level PsQL is a Lisp-like language and it is supported by a smallCLIPS library of list-handling functions

The Backus-Naur description of PsQL is presented in the following lines

ltquerygt = ltexpressiongt |

ltcount-querygt |

ltmembranes-querygt |

ltobjects-querygt

ltcount-querygt = ( count-of ltobjects-querygt |

ltmembranes-querygt )

ltobjects-querygt = ( objects-from ltmembranes-specgt

[ where ltwhere-specgt ] )

ltmembranes-querygt = ( membranes-from ltmembranes-specgt

[ where ltwhere-specgt ] )

The full description is available at httptwikiieatrotwikibinviewInstitutPSystemsQueryLanguage We plan to extend PsQL with tracefacilities having queries on the possible traces during an execution represents astep towards an automated verification of the P systems

3 Examples

The first example is a P system that computes the multiplication of two naturalnumbers The following figure describes graphically the P system

bm

b+v e+v+d gt v u(1)e+u b+u+d gt u v(1)

an

a+v v(0)a+u u(0)

v

0

1

As inputs we consider the number of a objects in membrane 1 and thenumber of b objects in membrane 0 The result is given by the number of dobjects in membrane 0

This P system differs from other similar ones by that it does not have expo-nential space complexity and does not require active membranes As a particularcase it would be quite easy to compute n2 by just placing the same number nof a and b objects in its membranes

Another interesting feature is that it may continue computing the multipli-cation after reaching a certain result Thus if initially there are m b objects and

64 C Bonchis et al

n a objects the system evolves and reaches a state with n middotm d objects in mem-brane 0 If the user wish to continue in order to compute (n+k) middotm it is enoughto inject k a objects in membrane 1 at the current state and the computationcan go on Therefore this example emphasizes a certain degree of re-usability

Recursive Sum The P system described in the next picture computes therecursive sum

sumni=1 ki

a a(0) a a(0) a a(0)

k2

k1

kn

1 2

aa

0

n

a

The numbers of a objects in the membranes 1n are the addition argumentsand the result of the computation is the number of a objects in membrane 0The PsQL query to determine this result is (count of (objects from 0))

While this example is rather trivial it illustrates the expressiveness of thequery language (PsQL) Using PsQL queries it is not necessary to apply therules and execute the specified P system Given the initial multiset the samerecursive sum is obtained by using the following query (count of (objectsfrom (membranes from 0)))

Dot Product of Two Vectors Combining the previous two examples we cancompute the dot (scalar) product x middot y of two vectors x y isin N

m where m isin NLet us denote the components of the vectors by xi and yi respectively thesecomponents are given by the number of b and a in the membranes labelled by 2iand 2i+1 respectively Then xmiddoty is given by the number of d objects obtained inmembrane 0 after the P system halts This P system is described graphically as

gt u u(2k+2)e+u b+u+d(0)

yk+1

a+v v(2k+1)a+u u(2k+1)

2k+2

a v

b+v e+v+d(0) gt v v(2k+2)

xk+1b

2k+1

b+v e+v+d(0)

y1

a+v v(1)a+u u(1)

a v

2

x1b

e+u

1

gt v gt u b+u+d(0)

v(2)u(2)

0

where k = 0 m minus 1 The PsQL query for retrieving the result is (count of(objects from 0))

A Web-Based P Systems Simulator and Its Parallelization 65

4 On Parallelization of Sequential Simulators

There will always be a need for exploiting parallelism in computing such thatmany difficult problems can be executed on parallel architectures There is also aneed to free the programmers from thinking about the parallelization of existingsequential programs Automatic parallelization of code has been an active re-search topic in scientific computing for some decades For a long period of timethe kind of attempts achieve little of the potential benefit of parallel computingRecent contributions improve the performance and efficient parallel codes havebeen created automatically to solve problems in various fields

We refer to the sequential simulators of the P systems particularly to thoseimplemented in CLIPS [8] These sequential simulators have both didactic andscientific values However the P systems are inherently parallel and in manyvariants they also exhibit an intrinsic non-determinism hard to be captured bysequential computers By simulating parallelism and nondeterminism on a se-quential machine one can lose the real power of parallelism and attractiveness ofP system computing Therefore the simulations on multiple processors representa particularly interesting subject Currently the only known parallel and clusterimplementation for P systems is presented in [2] using C++ and MPI41 Jess Java Expert System ShellJess is the abbreviation for Java Expert System Shell it is a rule-based program-ming environment for Java platforms it is available at httpherzbergcasandiagovjess More information about Jess can be found in [6] Jess usesthe RETE algorithm [5] for rules an efficient mechanism for solving the difficultmany-to-many matching problem Our strategy is to build a parallel productionsystems with a high degree of flexibility namely to construct a wrapper for theparallel system which allows cooperation between its instances From this pointof view Jess has been considered mainly due to its flexibility (communication viasockets ability to create Java objects and call Java methods) and its compatibil-ity with the C Language Interface Production System CLIPS CLIPS is availableat httpwwwghgnetclipsCLIPShtml where it is presented as a tool forbuilding expert systems Jess is also selected because of its active developmentand support tight interaction with Java programs and expressiveness

The Jess rule language includes elements not present in many other produc-tion systems such as arbitrary combinations of Boolean conjunctions and dis-junctions Its scripting language is powerful enough to generate full applicationsentirely within the Jess system Jess is also a powerful Java scripting environ-ment from which one can create Java objects and call Java methods withoutcompiling any Java code The core Jess language is fully compatible with CLIPS(Jess scripts are valid CLIPS scripts and vice-versa) Jess adds many features toCLIPS including backwards chaining working memory queries and the abilityto manipulate and directly reason about Java objects

We think to consider existing implementations and improve them by usingmultiple computing units leading to faster P system simulators than the cur-rent available ones The proposed architecture for a such system is based on an

66 C Bonchis et al

accelerator actually a wrapper allowing the cooperation between several in-stances of a program running on different computers in order to speedup thecurrent P system simulators

We intend to apply our P accelerators to WebPS As a first step we considera simpler CLIPS simulator [8] The set of rules and the configurations in eachstep of the evolution are expressed as facts in a knowledge base We first showthat a splitting technique of the membranes in several Java threads runningembedded Jess can lead to a faster simulation Then we use the P accelerator tofurther speedup the simulation

42 P Accelerators

Having in mind the parallel evolutions of its membranes based on different ruleswe build a parallel distributed memory version of a production system based ontask parallelism The target architecture is a homogeneous cluster of worksta-tions Building a Jess application based on socket communication facilities isconsidered to be difficult and can distract the user from its main aim Thereforea middleware is needed We adopt a modular scheme composed by Jess instancesConnectors and Messengers

A first component of the P accelerator is called Connector and consists of aJava code Each Jess instance has one corresponding Connector A Jess instance(acting as a client) contacts its Connector (acting as a server) via a socket Assoon as such a connection is established the Connector interprets the Jess specialincoming requests for communications and controls other Jess instances (namelysend or receive information launch or kill other instances) An information intransit is a string containing a command written in Jess language

Another component of the P accelerator is represented by the MessengersEach Messenger is associated with one Connector and its purpose is to exe-cute the commands received by Connector and to communicate with variousMessengers associated with the other Jess instances We add new commands toJess assuring a valid message passing interface More details about the set ofcommands and some other aspects related to P accelerators can be found in [4]

43 Implementation Details

A Connector uses the standard Java ServerSockets methods The current Mes-senger is written in Java and JPVM a Java implementation of Parallel VirtualMachine selected due to its ability to dynamically create and destroy tasks auseful ability when simulating the division and dissolution of membranes JPVMis available at httpwwwcsvirginiaedusimajf2jjpvmhtml Adopting aPVM variant the user is absolved of the duties to nominate the hosts were theJess instances are running as well as to treat sequentially the incoming messages(as in the case of a socket connection) or to check the status of the machineson which the Jess instances are running

Regarding CLIPS we should mention that a production system consists ina working memory a set of rules and an inference engine The working memoryis a global database of data representing the system state A rule is a condition-action pair The inference engine is based on a three-phase cyclic execution model

A Web-Based P Systems Simulator and Its Parallelization 67

of condition evaluations (matching) conflict-resolution and action firing Firingcan add delete or modify elements in the working memory An instantiationis a rule with a set of working memory elements In a sequential environmentconflict-resolution selects for firing a certain instantiation from the set of all in-stantiations In a parallel environment multiple instantiations can be selectedfor firing simultaneously Considering a high degree of parallelism the time per-formance can be improved44 Experiments

The computational power of a P system can be used not for solving small prob-lems for which we have already faster algorithms but for large and difficultproblems The main goal of our experiments is to measure the efficiency of Paccelerator in a cluster environment when it is applied to a particular problemOur experiments use the P system with active membrane described in [8] tosolve the validity problem given a Boolean formula in conjunctive normal formto determine whether or not it is a tautology If we consider the problem inputin the form andm

i=1 orki

j=1 xij where xij isin X1 Xn X1 Xn the P systemsolves the NP-complete problem of validity in 5n + 2m + 4 steps The numberof membranes increases by division from only three initial membranes to 2n + 2membranes at the end of computation This example is also of interest for parallelsimulation using dynamic task creation Different membranes can be distributedon different machines of a cluster They can evolve independently accordingly tothe evolution rules Send-in and Send-out rules request message exchanges

Based on the fact that CLIPS code is fully compatible with Jess we haverepeated the experiments reported in [8] We concentrate our attention to themost consuming part of the simulation namely after the final division when wehave already 2n + 2 membranes The number of rules to be fired is similar tothose from the classical production systems benchmarks The following tablespecifies the number of rules to be fired in the case of checking the validity of aBoolean expression with m = n

m times n Membranes Rules fired Time for Reaching Total time ofafter the last firing those the final simulationdivision rules configuration

2 times 2 6 335 1 s 1 s 2 s3 times 3 10 779 13 s 3 s 16 s4 times 4 18 1835 428 s 6 s 434 s5 times 5 34 49 s

The evaluation of time is measured on one PC of a cluster used in our testsThe cluster is composed of four PCs at 15GHz and 256Mb RAM connected viaa Myrinet switch ensuring communication at 2Gbs

We describe now how the P accelerator is working in order to assure thedistribution of the membranes and the communication between rules The Paccelerator can be activated by a user in a simple way Each Jess instancesreads the simulator rules the facts (the membrane rules to be applied) themembrane structure and their contents Each membrane is owned by a Jess

68 C Bonchis et al

instance An instance can own none one or several membranes Rules are firedby an instance only if they are associated to an owned membrane Each instancehas copies of the other instance membranes A change in the content of thefather membrane can lead to a change in the children membrane The sourcesand destinations used in the send and receive commands are related to theirmembrane owners The send and receive rules are activated only if the involvedsources and destinations have different owners

45 Running Time

It is easy to note a significant reduction of the running time even when weuse the P accelerator running on one machine of the cluster (ie Jess instancesare running on the same machine) In the following table the shorter time isunderlined for each number of Jess instances working concurrently The lowesttime depends on the dimension of the problem It seems that for a m times mproblem the lowest time is given by m Jess instances

Membranes 1 instance 2 instances 3 instances 4 instances6 1 s 1 s 3 s 3 s10 13 s 5 s 5 s 10 s18 428 s 45 s 25 s 33 s34 Memout 1054 s 325 s 200 s

Further reduction of the simulation time is expected when our P accelerator isrunning on several machines These expectations are confirmed by our tests Thespeedup Sp and the efficiency Ep of the parallel implementation are registeredin the following table the values being close to the ideal ones It is easy toremark a normal increasing of the speedup with the number of rules to be firedIt is expected to obtain even better results for larger dimension of the validityproblem

MembranesInstances Machines 6 10 18 341 1 1 s 13 s 428 s Memory out2 1 1 s 5 s 45 s 1054 s

2 1 s 3 s 23 s 528 sS2 1 17 19 2E2 051 065 095 099

3 1 3 s 5 s 25 s 325 s3 3 s 2 s 10 s 126 sS3 1 25 25 26E3 033 083 083 087

4 1 3 s 10 s 33 s 200 s4 2 s 3 s 9 s 52 sS4 15 33 37 38E4 037 082 091 096

A Web-Based P Systems Simulator and Its Parallelization 69

5 Conclusion and Further Work

We present a new simulator of the P systems It is efficient flexible and does notrequire any previous knowledge or expertise in computers Since the simulatorhas some novel and interesting features related to efficiency ease of use andgenerality it can become a useful tool for the community both theoretically andpractically Being GPL licensed we expect it is eligible to become a simulatorbenchmark reference The simulator is available at httppsystemsieatro

We intend to make the simulator available as a web service Moreover con-tinuing the commitment to standards compliance we will strive for SBML com-patibility for our specification language Further improvements are related tobetter debugging and visualization capabilities (including a flexible fine andcoarse-grained tracer) developing a library of macros and methodologies usingthe principles of modularity extensibility and structured design from softwareengineering introducing rules for the development of macros for P systems

In this paper we also present an automatic parallelization tool of the existingsequential simulators of the P systems We use a splitting technique of mem-branes in several Java threads and then we develop a P accelerator enabling thecooperation of many Jess instances running in a cluster environment to speedupa P simulator The P accelerator will be further developed to include facilities formembrane dissolution and division Further extensions are under investigation

References

1 G Ciobanu ldquoDistributed algorithms over communicating membrane systemsrdquoBioSystems vol70 123ndash133 Elsevier 2003

2 G Ciobanu W Guo ldquoP Systems Running on a Cluster of Computersrdquo in GhPaunet al (Eds) Proceedings 4th Workshop on Membrane Computing LNCS 2933123ndash139 Springer 2004

3 G Ciobanu D Paraschiv ldquoMembrane Software A P System Simulatorrdquo Funda-menta Informaticae vol49 no1-3 61ndash66 2002

4 G Ciobanu D Petcu ldquoP accelerators Parallelization of sequential simulatorsrdquo inMAGutierrez-Naranjo GhPaun MJPerez-Jimenez (Eds) Cellular Computingcomplexity aspects ESF PESC Exploratory Workshop Fenix Editora Sevilla 177-186 2005

5 CL Forgy ldquoRETE A Fast Algorithm for the Many PatternMany Object PatternMatch Problemrdquo Artificial Intelligence vol19 17ndash37 1982

6 E Friedman-Hill Jess in Action Rule-Based Systems in Java Manning Publica-tions 2003

7 Gh Paun Membrane Computing An Introduction Springer 20028 MJ Perez-Jimenez FJ Romero-Campero ldquoA CLIPS Simulator for Recognizer P

Systems with Active Membranesrdquo Proceedings 2nd Brainstorming Week on Mem-brane Computing University of Sevilla Tech Rep 012004 387-413 2004

A Web-Based P Systems Simulator and Its Parallelization 59

be used from any machine anywhere in the world without any previous prepa-ration A simple and easy to use interface allows the user to supply an XMLinput both as text and a file A friendly way of describing P systems is given byan interactive JavaScript-based P system designer The interface provides a highdegree of (re)usability during the development and simulation of the P systemsThe initial screen offers an example and the user may find useful documentationabout the XML schema the rules and the query language The query languagehelps the user to select the output of the simulation

This simulator is based on CLIPS The previous CLIPS implementationsrepresent P systems rules by CLIPS facts we get a significantly faster execu-tion by using CLIPS rules to implement P systems rules In [8] the P systemdata are inserted directly into code and so they cannot be easily modified asopposed to our implementation where a P system is an input data providinga lot of flexibility P systems as input data are described by XML documentsthis fact provides a standard method to access information making it easierto use modify transmit and display XML is readable and understandable itexpresses metadata easily in a portable format just because many applicationscan process XML on many existent platforms Moreover by using XML it be-comes easy to define new features and properties of P systems XML allowsan automated document validation restricting wrong input data and warningthe user before execution with respect to the possible errors in their P systemsdescription From a user point of view all these features facilitate an efficientdescription and reconfiguration of the P systems

The simulator is open-source actually free software as it is being offered athttppsystemsieatro under the GNU General Public License This allowsanyone to contribute with enhancements and error corrections to the code andpossibly develop new interfaces for the C and CLIPS level APIs These interfacescan be local (graphical or command-line) or yet other Web-based ones

Section 2 presents the WebPS structure and argue what are its advantagesover the previous P simulators Several new and interesting examples imple-mented in the WebPS system are described in Section 3 In Section 4 we discusson the parallelization of sequential simulators and present Jess as a starting toolin building a wrapper for parallel systems Then we describe our P accelerator asa parallel version of Jess able to work on homogeneous clusters of workstationsWe provide some implementation details and measure the efficiency of our Paccelerator by applying it to a simple CLIPS simulator solving a difficult prob-lem We present the results of our experiments showing a significant reductionof the running time Conclusion further work and references end the paper

2 WebPS Software Architecture

The software structure of the simulator has three distinct levels The inner levelis the CLIPS level This level integrates part of the knowledge about the theo-retical description of P systems the result being a library of CLIPS functionsmeta-rules and templates Since CLIPS is easily embeddable in C (as its name rdquoCLanguage Integrated Production Systemrdquo suggests) we can control the CLIPS

60 C Bonchis et al

level from a C program and we include some example to illustrate how this isdone The C level is strengthened by introducing a C library for modelling andsimulating P systems based on the CLIPS library The Web application level of-fers a user-friendly interface to the simulator and can become after the additionof debugging and visualization features a powerful P system development tool

21 CLIPS Level

This is the core level of the simulator We address here some crucial issuesnamely how we implement in a sequential context the maximally parallel andnondeterministic execution of P systems

Maximally Parallel Execution The maximally parallel execution require-ment relies on constraining our simulation cycle to the following distinct steps

1 React step where the activated reaction rules are sequentially executed2 Spawn step where the new objects created by rules inside their membranes

are asserted as object facts they become visible for a future React step3 Communication step where the objects injected or ejected by communi-

cation rules in different membranes are asserted as objects facts4 Divide step it handles possible divisions processes of membranes5 Dissolve step it handles dissolving processes of membranes

By constantly recording the state of the P system after each React Spawn andCommunication steps we can get a trace of an execution

Nondeterministic Execution CLIPS uses RETE algorithm to process rulesRETE is a very efficient mechanism for solving many-to-many matching prob-lem [5] The nondeterministic execution requirement is fulfilled by the CLIPSrandom mechanism We have looked closely at the random strategy and wefound it makes the same choice for the same configurations in different execu-tions By calling the random function of CLIPS the random mechanism usesthe random number generator The failure is related to the improper seeding ofthe random number generator We have corrected this error and properly seedthe random number generator by using devurandom the entropy gatheringdevice on GNULinux systems This aspect can be also useful for other CLIPSimplementations possibly affected by the same failure

Data Representation An important choice regarding an implementation isgiven by data representation We decide to represent P system objects and mem-brane structure as CLIPS facts (with set-fact-duplication option of CLIPS set toon) and the P systems reaction rules as CLIPS rules This contrasts the previ-ous implementations which have represented reaction rules as CLIPS facts whiletheir choice might allow general meta-rules for execution we get a flexible andefficient framework by representing reaction rules as CLIPS rules The efficiencyis gained by making direct use of the CLIPS pattern-matching mechanism andrule activation capabilities This choice is also confirmed by the efficiency of the

A Web-Based P Systems Simulator and Its Parallelization 61

dissolve and divide operations which imply a lot of moving and copying Ini-tially we think to represent membranes as modules but later we see that thisrepresentation decreases the efficiency and flexibility of the whole system

It is useful to note that the simulator supports divide promotersinhibitorsand symportantiport rules for membranes For example the P system transitionrule a+brarrc+d(2)+e(0) with priority 11 from membrane 1 is converted into thefollowing CLIPS rule

(defrule MAIN1_a+b-gtc+d[2]+e[0]

(declare (salience 11))

(do (what react))

(or (parent-child (parent 1) (child 2))

(parent-child (parent 2) (child 1)))

(or (parent-child (parent 1) (child 0))

(parent-child (parent 0) (child 1)))

a-0 lt- (obj (name a) (membrane 1))

b-1 lt- (obj (name b) (membrane 1))

=gt

(assert (newobj (name c) (membrane 1)))

(assert (inject (name d) (membrane 2)))

(assert (inject (name e) (membrane 0)))

(retract a-0) (retract b-1))

The membrane structure is reflected by the parent-child facts An object a ofmembrane 1 is represented as a CLIPS fact on line 8 (obj (name a) (membrane1)) While the reactants a and b are consumed the new objects c d and e arecreated during the Spawn and Communication steps respectively The rulepriorities are mapped directly to CLIPS rules salience values and therefore arerestricted to integer values in the interval [-10000 10000]

22 C Level

In the C level we use CLIPS API although we plan to develop a complete librarythat encapsulates the C-CLIPS interface namely a C library which wraps nicelyaround the CLIPS one

We represent a P system using XML and we define an XML schema forthis kind of document A special library is developed to handle XML parsingof the input for the CLIPS part of the simulator In the following example wedescribe a P system using our XML schema This example system presents a Psystem for multiplication of the number of a objects in membrane 1 with thenumber of b objects in membrane 0 the result being the number of d objectsin membrane 0

ltxml version=10gt

ltpsystemgt

ltmembrane name=0gt

ltobject name=b count=3 gt

ltrule body=b+v-gte+v+d priority=1 gt

ltrule body=e+u-gtb+u+d priority=1 gt

ltrule body=v-gtu(1) gt

62 C Bonchis et al

ltrule body=u-gtv(1) gt

ltmembrane name=1gt

ltobject name=a count=4 gt

ltobject name=v count=1 gt

ltrule body=a+v-gtv(0) gt

ltrule body=a+u-gtu(0) gt

ltmembranegt

ltmembranegt

ltquery text=count of (objects from 0 where (objects d)) gt

ltpsystemgt

23 Web Level

The Web level of the simulator allows to choose between a user-friendly P systemdesigner written in JavaScript and a traditional HTML input form transmittingan XML description by uploading a file or by editing Aside from the XML Psystem description editing the user can specify a number of executions of the Psystem Our JavaScript P system Designer aims to facilitate the description ofthe P system without requiring the user to write XML but generating it basedon the userrsquos interaction with a dynamic interface

PHP script

CGI program(C)

CLIPS library LibCGI PSminusXML C library

JavaScriptP system Designer

HTML input formfor XML

After the user introduces a XML description it is transmitted to a PHPscript which does some further processing and sent then to a CGI programwritten in C The C program uses a specific P system XML library called PS-XML as well as LibCGI and CLIPS library in order to simulate the evolutionof the P system Finally it returns the results to the user It is possible to selectvarious information provided as results and in order to help the user to selectthe desired information we define a query language called PsQL

PsQL (P systems Query Language) We define PsQL as an SQL-like lan-guage for querying the state of a P system We developed a CLIPS library forparsing and interpreting this language At the Web level the queries can be in-cluded in the XML input these queries are activated after the execution of the

A Web-Based P Systems Simulator and Its Parallelization 63

specified P system If it does not exist any query the P system is simulated butno output is generated At the CLIPS level it is possible to specify queries forthe P system in a dynamic manner not just before starting the simulation Atthe syntactic level PsQL is a Lisp-like language and it is supported by a smallCLIPS library of list-handling functions

The Backus-Naur description of PsQL is presented in the following lines

ltquerygt = ltexpressiongt |

ltcount-querygt |

ltmembranes-querygt |

ltobjects-querygt

ltcount-querygt = ( count-of ltobjects-querygt |

ltmembranes-querygt )

ltobjects-querygt = ( objects-from ltmembranes-specgt

[ where ltwhere-specgt ] )

ltmembranes-querygt = ( membranes-from ltmembranes-specgt

[ where ltwhere-specgt ] )

The full description is available at httptwikiieatrotwikibinviewInstitutPSystemsQueryLanguage We plan to extend PsQL with tracefacilities having queries on the possible traces during an execution represents astep towards an automated verification of the P systems

3 Examples

The first example is a P system that computes the multiplication of two naturalnumbers The following figure describes graphically the P system

bm

b+v e+v+d gt v u(1)e+u b+u+d gt u v(1)

an

a+v v(0)a+u u(0)

v

0

1

As inputs we consider the number of a objects in membrane 1 and thenumber of b objects in membrane 0 The result is given by the number of dobjects in membrane 0

This P system differs from other similar ones by that it does not have expo-nential space complexity and does not require active membranes As a particularcase it would be quite easy to compute n2 by just placing the same number nof a and b objects in its membranes

Another interesting feature is that it may continue computing the multipli-cation after reaching a certain result Thus if initially there are m b objects and

64 C Bonchis et al

n a objects the system evolves and reaches a state with n middotm d objects in mem-brane 0 If the user wish to continue in order to compute (n+k) middotm it is enoughto inject k a objects in membrane 1 at the current state and the computationcan go on Therefore this example emphasizes a certain degree of re-usability

Recursive Sum The P system described in the next picture computes therecursive sum

sumni=1 ki

a a(0) a a(0) a a(0)

k2

k1

kn

1 2

aa

0

n

a

The numbers of a objects in the membranes 1n are the addition argumentsand the result of the computation is the number of a objects in membrane 0The PsQL query to determine this result is (count of (objects from 0))

While this example is rather trivial it illustrates the expressiveness of thequery language (PsQL) Using PsQL queries it is not necessary to apply therules and execute the specified P system Given the initial multiset the samerecursive sum is obtained by using the following query (count of (objectsfrom (membranes from 0)))

Dot Product of Two Vectors Combining the previous two examples we cancompute the dot (scalar) product x middot y of two vectors x y isin N

m where m isin NLet us denote the components of the vectors by xi and yi respectively thesecomponents are given by the number of b and a in the membranes labelled by 2iand 2i+1 respectively Then xmiddoty is given by the number of d objects obtained inmembrane 0 after the P system halts This P system is described graphically as

gt u u(2k+2)e+u b+u+d(0)

yk+1

a+v v(2k+1)a+u u(2k+1)

2k+2

a v

b+v e+v+d(0) gt v v(2k+2)

xk+1b

2k+1

b+v e+v+d(0)

y1

a+v v(1)a+u u(1)

a v

2

x1b

e+u

1

gt v gt u b+u+d(0)

v(2)u(2)

0

where k = 0 m minus 1 The PsQL query for retrieving the result is (count of(objects from 0))

A Web-Based P Systems Simulator and Its Parallelization 65

4 On Parallelization of Sequential Simulators

There will always be a need for exploiting parallelism in computing such thatmany difficult problems can be executed on parallel architectures There is also aneed to free the programmers from thinking about the parallelization of existingsequential programs Automatic parallelization of code has been an active re-search topic in scientific computing for some decades For a long period of timethe kind of attempts achieve little of the potential benefit of parallel computingRecent contributions improve the performance and efficient parallel codes havebeen created automatically to solve problems in various fields

We refer to the sequential simulators of the P systems particularly to thoseimplemented in CLIPS [8] These sequential simulators have both didactic andscientific values However the P systems are inherently parallel and in manyvariants they also exhibit an intrinsic non-determinism hard to be captured bysequential computers By simulating parallelism and nondeterminism on a se-quential machine one can lose the real power of parallelism and attractiveness ofP system computing Therefore the simulations on multiple processors representa particularly interesting subject Currently the only known parallel and clusterimplementation for P systems is presented in [2] using C++ and MPI41 Jess Java Expert System ShellJess is the abbreviation for Java Expert System Shell it is a rule-based program-ming environment for Java platforms it is available at httpherzbergcasandiagovjess More information about Jess can be found in [6] Jess usesthe RETE algorithm [5] for rules an efficient mechanism for solving the difficultmany-to-many matching problem Our strategy is to build a parallel productionsystems with a high degree of flexibility namely to construct a wrapper for theparallel system which allows cooperation between its instances From this pointof view Jess has been considered mainly due to its flexibility (communication viasockets ability to create Java objects and call Java methods) and its compatibil-ity with the C Language Interface Production System CLIPS CLIPS is availableat httpwwwghgnetclipsCLIPShtml where it is presented as a tool forbuilding expert systems Jess is also selected because of its active developmentand support tight interaction with Java programs and expressiveness

The Jess rule language includes elements not present in many other produc-tion systems such as arbitrary combinations of Boolean conjunctions and dis-junctions Its scripting language is powerful enough to generate full applicationsentirely within the Jess system Jess is also a powerful Java scripting environ-ment from which one can create Java objects and call Java methods withoutcompiling any Java code The core Jess language is fully compatible with CLIPS(Jess scripts are valid CLIPS scripts and vice-versa) Jess adds many features toCLIPS including backwards chaining working memory queries and the abilityto manipulate and directly reason about Java objects

We think to consider existing implementations and improve them by usingmultiple computing units leading to faster P system simulators than the cur-rent available ones The proposed architecture for a such system is based on an

66 C Bonchis et al

accelerator actually a wrapper allowing the cooperation between several in-stances of a program running on different computers in order to speedup thecurrent P system simulators

We intend to apply our P accelerators to WebPS As a first step we considera simpler CLIPS simulator [8] The set of rules and the configurations in eachstep of the evolution are expressed as facts in a knowledge base We first showthat a splitting technique of the membranes in several Java threads runningembedded Jess can lead to a faster simulation Then we use the P accelerator tofurther speedup the simulation

42 P Accelerators

Having in mind the parallel evolutions of its membranes based on different ruleswe build a parallel distributed memory version of a production system based ontask parallelism The target architecture is a homogeneous cluster of worksta-tions Building a Jess application based on socket communication facilities isconsidered to be difficult and can distract the user from its main aim Thereforea middleware is needed We adopt a modular scheme composed by Jess instancesConnectors and Messengers

A first component of the P accelerator is called Connector and consists of aJava code Each Jess instance has one corresponding Connector A Jess instance(acting as a client) contacts its Connector (acting as a server) via a socket Assoon as such a connection is established the Connector interprets the Jess specialincoming requests for communications and controls other Jess instances (namelysend or receive information launch or kill other instances) An information intransit is a string containing a command written in Jess language

Another component of the P accelerator is represented by the MessengersEach Messenger is associated with one Connector and its purpose is to exe-cute the commands received by Connector and to communicate with variousMessengers associated with the other Jess instances We add new commands toJess assuring a valid message passing interface More details about the set ofcommands and some other aspects related to P accelerators can be found in [4]

43 Implementation Details

A Connector uses the standard Java ServerSockets methods The current Mes-senger is written in Java and JPVM a Java implementation of Parallel VirtualMachine selected due to its ability to dynamically create and destroy tasks auseful ability when simulating the division and dissolution of membranes JPVMis available at httpwwwcsvirginiaedusimajf2jjpvmhtml Adopting aPVM variant the user is absolved of the duties to nominate the hosts were theJess instances are running as well as to treat sequentially the incoming messages(as in the case of a socket connection) or to check the status of the machineson which the Jess instances are running

Regarding CLIPS we should mention that a production system consists ina working memory a set of rules and an inference engine The working memoryis a global database of data representing the system state A rule is a condition-action pair The inference engine is based on a three-phase cyclic execution model

A Web-Based P Systems Simulator and Its Parallelization 67

of condition evaluations (matching) conflict-resolution and action firing Firingcan add delete or modify elements in the working memory An instantiationis a rule with a set of working memory elements In a sequential environmentconflict-resolution selects for firing a certain instantiation from the set of all in-stantiations In a parallel environment multiple instantiations can be selectedfor firing simultaneously Considering a high degree of parallelism the time per-formance can be improved44 Experiments

The computational power of a P system can be used not for solving small prob-lems for which we have already faster algorithms but for large and difficultproblems The main goal of our experiments is to measure the efficiency of Paccelerator in a cluster environment when it is applied to a particular problemOur experiments use the P system with active membrane described in [8] tosolve the validity problem given a Boolean formula in conjunctive normal formto determine whether or not it is a tautology If we consider the problem inputin the form andm

i=1 orki

j=1 xij where xij isin X1 Xn X1 Xn the P systemsolves the NP-complete problem of validity in 5n + 2m + 4 steps The numberof membranes increases by division from only three initial membranes to 2n + 2membranes at the end of computation This example is also of interest for parallelsimulation using dynamic task creation Different membranes can be distributedon different machines of a cluster They can evolve independently accordingly tothe evolution rules Send-in and Send-out rules request message exchanges

Based on the fact that CLIPS code is fully compatible with Jess we haverepeated the experiments reported in [8] We concentrate our attention to themost consuming part of the simulation namely after the final division when wehave already 2n + 2 membranes The number of rules to be fired is similar tothose from the classical production systems benchmarks The following tablespecifies the number of rules to be fired in the case of checking the validity of aBoolean expression with m = n

m times n Membranes Rules fired Time for Reaching Total time ofafter the last firing those the final simulationdivision rules configuration

2 times 2 6 335 1 s 1 s 2 s3 times 3 10 779 13 s 3 s 16 s4 times 4 18 1835 428 s 6 s 434 s5 times 5 34 49 s

The evaluation of time is measured on one PC of a cluster used in our testsThe cluster is composed of four PCs at 15GHz and 256Mb RAM connected viaa Myrinet switch ensuring communication at 2Gbs

We describe now how the P accelerator is working in order to assure thedistribution of the membranes and the communication between rules The Paccelerator can be activated by a user in a simple way Each Jess instancesreads the simulator rules the facts (the membrane rules to be applied) themembrane structure and their contents Each membrane is owned by a Jess

68 C Bonchis et al

instance An instance can own none one or several membranes Rules are firedby an instance only if they are associated to an owned membrane Each instancehas copies of the other instance membranes A change in the content of thefather membrane can lead to a change in the children membrane The sourcesand destinations used in the send and receive commands are related to theirmembrane owners The send and receive rules are activated only if the involvedsources and destinations have different owners

45 Running Time

It is easy to note a significant reduction of the running time even when weuse the P accelerator running on one machine of the cluster (ie Jess instancesare running on the same machine) In the following table the shorter time isunderlined for each number of Jess instances working concurrently The lowesttime depends on the dimension of the problem It seems that for a m times mproblem the lowest time is given by m Jess instances

Membranes 1 instance 2 instances 3 instances 4 instances6 1 s 1 s 3 s 3 s10 13 s 5 s 5 s 10 s18 428 s 45 s 25 s 33 s34 Memout 1054 s 325 s 200 s

Further reduction of the simulation time is expected when our P accelerator isrunning on several machines These expectations are confirmed by our tests Thespeedup Sp and the efficiency Ep of the parallel implementation are registeredin the following table the values being close to the ideal ones It is easy toremark a normal increasing of the speedup with the number of rules to be firedIt is expected to obtain even better results for larger dimension of the validityproblem

MembranesInstances Machines 6 10 18 341 1 1 s 13 s 428 s Memory out2 1 1 s 5 s 45 s 1054 s

2 1 s 3 s 23 s 528 sS2 1 17 19 2E2 051 065 095 099

3 1 3 s 5 s 25 s 325 s3 3 s 2 s 10 s 126 sS3 1 25 25 26E3 033 083 083 087

4 1 3 s 10 s 33 s 200 s4 2 s 3 s 9 s 52 sS4 15 33 37 38E4 037 082 091 096

A Web-Based P Systems Simulator and Its Parallelization 69

5 Conclusion and Further Work

We present a new simulator of the P systems It is efficient flexible and does notrequire any previous knowledge or expertise in computers Since the simulatorhas some novel and interesting features related to efficiency ease of use andgenerality it can become a useful tool for the community both theoretically andpractically Being GPL licensed we expect it is eligible to become a simulatorbenchmark reference The simulator is available at httppsystemsieatro

We intend to make the simulator available as a web service Moreover con-tinuing the commitment to standards compliance we will strive for SBML com-patibility for our specification language Further improvements are related tobetter debugging and visualization capabilities (including a flexible fine andcoarse-grained tracer) developing a library of macros and methodologies usingthe principles of modularity extensibility and structured design from softwareengineering introducing rules for the development of macros for P systems

In this paper we also present an automatic parallelization tool of the existingsequential simulators of the P systems We use a splitting technique of mem-branes in several Java threads and then we develop a P accelerator enabling thecooperation of many Jess instances running in a cluster environment to speedupa P simulator The P accelerator will be further developed to include facilities formembrane dissolution and division Further extensions are under investigation

References

1 G Ciobanu ldquoDistributed algorithms over communicating membrane systemsrdquoBioSystems vol70 123ndash133 Elsevier 2003

2 G Ciobanu W Guo ldquoP Systems Running on a Cluster of Computersrdquo in GhPaunet al (Eds) Proceedings 4th Workshop on Membrane Computing LNCS 2933123ndash139 Springer 2004

3 G Ciobanu D Paraschiv ldquoMembrane Software A P System Simulatorrdquo Funda-menta Informaticae vol49 no1-3 61ndash66 2002

4 G Ciobanu D Petcu ldquoP accelerators Parallelization of sequential simulatorsrdquo inMAGutierrez-Naranjo GhPaun MJPerez-Jimenez (Eds) Cellular Computingcomplexity aspects ESF PESC Exploratory Workshop Fenix Editora Sevilla 177-186 2005

5 CL Forgy ldquoRETE A Fast Algorithm for the Many PatternMany Object PatternMatch Problemrdquo Artificial Intelligence vol19 17ndash37 1982

6 E Friedman-Hill Jess in Action Rule-Based Systems in Java Manning Publica-tions 2003

7 Gh Paun Membrane Computing An Introduction Springer 20028 MJ Perez-Jimenez FJ Romero-Campero ldquoA CLIPS Simulator for Recognizer P

Systems with Active Membranesrdquo Proceedings 2nd Brainstorming Week on Mem-brane Computing University of Sevilla Tech Rep 012004 387-413 2004

60 C Bonchis et al

level from a C program and we include some example to illustrate how this isdone The C level is strengthened by introducing a C library for modelling andsimulating P systems based on the CLIPS library The Web application level of-fers a user-friendly interface to the simulator and can become after the additionof debugging and visualization features a powerful P system development tool

21 CLIPS Level

This is the core level of the simulator We address here some crucial issuesnamely how we implement in a sequential context the maximally parallel andnondeterministic execution of P systems

Maximally Parallel Execution The maximally parallel execution require-ment relies on constraining our simulation cycle to the following distinct steps

1 React step where the activated reaction rules are sequentially executed2 Spawn step where the new objects created by rules inside their membranes

are asserted as object facts they become visible for a future React step3 Communication step where the objects injected or ejected by communi-

cation rules in different membranes are asserted as objects facts4 Divide step it handles possible divisions processes of membranes5 Dissolve step it handles dissolving processes of membranes

By constantly recording the state of the P system after each React Spawn andCommunication steps we can get a trace of an execution

Nondeterministic Execution CLIPS uses RETE algorithm to process rulesRETE is a very efficient mechanism for solving many-to-many matching prob-lem [5] The nondeterministic execution requirement is fulfilled by the CLIPSrandom mechanism We have looked closely at the random strategy and wefound it makes the same choice for the same configurations in different execu-tions By calling the random function of CLIPS the random mechanism usesthe random number generator The failure is related to the improper seeding ofthe random number generator We have corrected this error and properly seedthe random number generator by using devurandom the entropy gatheringdevice on GNULinux systems This aspect can be also useful for other CLIPSimplementations possibly affected by the same failure

Data Representation An important choice regarding an implementation isgiven by data representation We decide to represent P system objects and mem-brane structure as CLIPS facts (with set-fact-duplication option of CLIPS set toon) and the P systems reaction rules as CLIPS rules This contrasts the previ-ous implementations which have represented reaction rules as CLIPS facts whiletheir choice might allow general meta-rules for execution we get a flexible andefficient framework by representing reaction rules as CLIPS rules The efficiencyis gained by making direct use of the CLIPS pattern-matching mechanism andrule activation capabilities This choice is also confirmed by the efficiency of the

A Web-Based P Systems Simulator and Its Parallelization 61

dissolve and divide operations which imply a lot of moving and copying Ini-tially we think to represent membranes as modules but later we see that thisrepresentation decreases the efficiency and flexibility of the whole system

It is useful to note that the simulator supports divide promotersinhibitorsand symportantiport rules for membranes For example the P system transitionrule a+brarrc+d(2)+e(0) with priority 11 from membrane 1 is converted into thefollowing CLIPS rule

(defrule MAIN1_a+b-gtc+d[2]+e[0]

(declare (salience 11))

(do (what react))

(or (parent-child (parent 1) (child 2))

(parent-child (parent 2) (child 1)))

(or (parent-child (parent 1) (child 0))

(parent-child (parent 0) (child 1)))

a-0 lt- (obj (name a) (membrane 1))

b-1 lt- (obj (name b) (membrane 1))

=gt

(assert (newobj (name c) (membrane 1)))

(assert (inject (name d) (membrane 2)))

(assert (inject (name e) (membrane 0)))

(retract a-0) (retract b-1))

The membrane structure is reflected by the parent-child facts An object a ofmembrane 1 is represented as a CLIPS fact on line 8 (obj (name a) (membrane1)) While the reactants a and b are consumed the new objects c d and e arecreated during the Spawn and Communication steps respectively The rulepriorities are mapped directly to CLIPS rules salience values and therefore arerestricted to integer values in the interval [-10000 10000]

22 C Level

In the C level we use CLIPS API although we plan to develop a complete librarythat encapsulates the C-CLIPS interface namely a C library which wraps nicelyaround the CLIPS one

We represent a P system using XML and we define an XML schema forthis kind of document A special library is developed to handle XML parsingof the input for the CLIPS part of the simulator In the following example wedescribe a P system using our XML schema This example system presents a Psystem for multiplication of the number of a objects in membrane 1 with thenumber of b objects in membrane 0 the result being the number of d objectsin membrane 0

ltxml version=10gt

ltpsystemgt

ltmembrane name=0gt

ltobject name=b count=3 gt

ltrule body=b+v-gte+v+d priority=1 gt

ltrule body=e+u-gtb+u+d priority=1 gt

ltrule body=v-gtu(1) gt

62 C Bonchis et al

ltrule body=u-gtv(1) gt

ltmembrane name=1gt

ltobject name=a count=4 gt

ltobject name=v count=1 gt

ltrule body=a+v-gtv(0) gt

ltrule body=a+u-gtu(0) gt

ltmembranegt

ltmembranegt

ltquery text=count of (objects from 0 where (objects d)) gt

ltpsystemgt

23 Web Level

The Web level of the simulator allows to choose between a user-friendly P systemdesigner written in JavaScript and a traditional HTML input form transmittingan XML description by uploading a file or by editing Aside from the XML Psystem description editing the user can specify a number of executions of the Psystem Our JavaScript P system Designer aims to facilitate the description ofthe P system without requiring the user to write XML but generating it basedon the userrsquos interaction with a dynamic interface

PHP script

CGI program(C)

CLIPS library LibCGI PSminusXML C library

JavaScriptP system Designer

HTML input formfor XML

After the user introduces a XML description it is transmitted to a PHPscript which does some further processing and sent then to a CGI programwritten in C The C program uses a specific P system XML library called PS-XML as well as LibCGI and CLIPS library in order to simulate the evolutionof the P system Finally it returns the results to the user It is possible to selectvarious information provided as results and in order to help the user to selectthe desired information we define a query language called PsQL

PsQL (P systems Query Language) We define PsQL as an SQL-like lan-guage for querying the state of a P system We developed a CLIPS library forparsing and interpreting this language At the Web level the queries can be in-cluded in the XML input these queries are activated after the execution of the

A Web-Based P Systems Simulator and Its Parallelization 63

specified P system If it does not exist any query the P system is simulated butno output is generated At the CLIPS level it is possible to specify queries forthe P system in a dynamic manner not just before starting the simulation Atthe syntactic level PsQL is a Lisp-like language and it is supported by a smallCLIPS library of list-handling functions

The Backus-Naur description of PsQL is presented in the following lines

ltquerygt = ltexpressiongt |

ltcount-querygt |

ltmembranes-querygt |

ltobjects-querygt

ltcount-querygt = ( count-of ltobjects-querygt |

ltmembranes-querygt )

ltobjects-querygt = ( objects-from ltmembranes-specgt

[ where ltwhere-specgt ] )

ltmembranes-querygt = ( membranes-from ltmembranes-specgt

[ where ltwhere-specgt ] )

The full description is available at httptwikiieatrotwikibinviewInstitutPSystemsQueryLanguage We plan to extend PsQL with tracefacilities having queries on the possible traces during an execution represents astep towards an automated verification of the P systems

3 Examples

The first example is a P system that computes the multiplication of two naturalnumbers The following figure describes graphically the P system

bm

b+v e+v+d gt v u(1)e+u b+u+d gt u v(1)

an

a+v v(0)a+u u(0)

v

0

1

As inputs we consider the number of a objects in membrane 1 and thenumber of b objects in membrane 0 The result is given by the number of dobjects in membrane 0

This P system differs from other similar ones by that it does not have expo-nential space complexity and does not require active membranes As a particularcase it would be quite easy to compute n2 by just placing the same number nof a and b objects in its membranes

Another interesting feature is that it may continue computing the multipli-cation after reaching a certain result Thus if initially there are m b objects and

64 C Bonchis et al

n a objects the system evolves and reaches a state with n middotm d objects in mem-brane 0 If the user wish to continue in order to compute (n+k) middotm it is enoughto inject k a objects in membrane 1 at the current state and the computationcan go on Therefore this example emphasizes a certain degree of re-usability

Recursive Sum The P system described in the next picture computes therecursive sum

sumni=1 ki

a a(0) a a(0) a a(0)

k2

k1

kn

1 2

aa

0

n

a

The numbers of a objects in the membranes 1n are the addition argumentsand the result of the computation is the number of a objects in membrane 0The PsQL query to determine this result is (count of (objects from 0))

While this example is rather trivial it illustrates the expressiveness of thequery language (PsQL) Using PsQL queries it is not necessary to apply therules and execute the specified P system Given the initial multiset the samerecursive sum is obtained by using the following query (count of (objectsfrom (membranes from 0)))

Dot Product of Two Vectors Combining the previous two examples we cancompute the dot (scalar) product x middot y of two vectors x y isin N

m where m isin NLet us denote the components of the vectors by xi and yi respectively thesecomponents are given by the number of b and a in the membranes labelled by 2iand 2i+1 respectively Then xmiddoty is given by the number of d objects obtained inmembrane 0 after the P system halts This P system is described graphically as

gt u u(2k+2)e+u b+u+d(0)

yk+1

a+v v(2k+1)a+u u(2k+1)

2k+2

a v

b+v e+v+d(0) gt v v(2k+2)

xk+1b

2k+1

b+v e+v+d(0)

y1

a+v v(1)a+u u(1)

a v

2

x1b

e+u

1

gt v gt u b+u+d(0)

v(2)u(2)

0

where k = 0 m minus 1 The PsQL query for retrieving the result is (count of(objects from 0))

A Web-Based P Systems Simulator and Its Parallelization 65

4 On Parallelization of Sequential Simulators

There will always be a need for exploiting parallelism in computing such thatmany difficult problems can be executed on parallel architectures There is also aneed to free the programmers from thinking about the parallelization of existingsequential programs Automatic parallelization of code has been an active re-search topic in scientific computing for some decades For a long period of timethe kind of attempts achieve little of the potential benefit of parallel computingRecent contributions improve the performance and efficient parallel codes havebeen created automatically to solve problems in various fields

We refer to the sequential simulators of the P systems particularly to thoseimplemented in CLIPS [8] These sequential simulators have both didactic andscientific values However the P systems are inherently parallel and in manyvariants they also exhibit an intrinsic non-determinism hard to be captured bysequential computers By simulating parallelism and nondeterminism on a se-quential machine one can lose the real power of parallelism and attractiveness ofP system computing Therefore the simulations on multiple processors representa particularly interesting subject Currently the only known parallel and clusterimplementation for P systems is presented in [2] using C++ and MPI41 Jess Java Expert System ShellJess is the abbreviation for Java Expert System Shell it is a rule-based program-ming environment for Java platforms it is available at httpherzbergcasandiagovjess More information about Jess can be found in [6] Jess usesthe RETE algorithm [5] for rules an efficient mechanism for solving the difficultmany-to-many matching problem Our strategy is to build a parallel productionsystems with a high degree of flexibility namely to construct a wrapper for theparallel system which allows cooperation between its instances From this pointof view Jess has been considered mainly due to its flexibility (communication viasockets ability to create Java objects and call Java methods) and its compatibil-ity with the C Language Interface Production System CLIPS CLIPS is availableat httpwwwghgnetclipsCLIPShtml where it is presented as a tool forbuilding expert systems Jess is also selected because of its active developmentand support tight interaction with Java programs and expressiveness

The Jess rule language includes elements not present in many other produc-tion systems such as arbitrary combinations of Boolean conjunctions and dis-junctions Its scripting language is powerful enough to generate full applicationsentirely within the Jess system Jess is also a powerful Java scripting environ-ment from which one can create Java objects and call Java methods withoutcompiling any Java code The core Jess language is fully compatible with CLIPS(Jess scripts are valid CLIPS scripts and vice-versa) Jess adds many features toCLIPS including backwards chaining working memory queries and the abilityto manipulate and directly reason about Java objects

We think to consider existing implementations and improve them by usingmultiple computing units leading to faster P system simulators than the cur-rent available ones The proposed architecture for a such system is based on an

66 C Bonchis et al

accelerator actually a wrapper allowing the cooperation between several in-stances of a program running on different computers in order to speedup thecurrent P system simulators

We intend to apply our P accelerators to WebPS As a first step we considera simpler CLIPS simulator [8] The set of rules and the configurations in eachstep of the evolution are expressed as facts in a knowledge base We first showthat a splitting technique of the membranes in several Java threads runningembedded Jess can lead to a faster simulation Then we use the P accelerator tofurther speedup the simulation

42 P Accelerators

Having in mind the parallel evolutions of its membranes based on different ruleswe build a parallel distributed memory version of a production system based ontask parallelism The target architecture is a homogeneous cluster of worksta-tions Building a Jess application based on socket communication facilities isconsidered to be difficult and can distract the user from its main aim Thereforea middleware is needed We adopt a modular scheme composed by Jess instancesConnectors and Messengers

A first component of the P accelerator is called Connector and consists of aJava code Each Jess instance has one corresponding Connector A Jess instance(acting as a client) contacts its Connector (acting as a server) via a socket Assoon as such a connection is established the Connector interprets the Jess specialincoming requests for communications and controls other Jess instances (namelysend or receive information launch or kill other instances) An information intransit is a string containing a command written in Jess language

Another component of the P accelerator is represented by the MessengersEach Messenger is associated with one Connector and its purpose is to exe-cute the commands received by Connector and to communicate with variousMessengers associated with the other Jess instances We add new commands toJess assuring a valid message passing interface More details about the set ofcommands and some other aspects related to P accelerators can be found in [4]

43 Implementation Details

A Connector uses the standard Java ServerSockets methods The current Mes-senger is written in Java and JPVM a Java implementation of Parallel VirtualMachine selected due to its ability to dynamically create and destroy tasks auseful ability when simulating the division and dissolution of membranes JPVMis available at httpwwwcsvirginiaedusimajf2jjpvmhtml Adopting aPVM variant the user is absolved of the duties to nominate the hosts were theJess instances are running as well as to treat sequentially the incoming messages(as in the case of a socket connection) or to check the status of the machineson which the Jess instances are running

Regarding CLIPS we should mention that a production system consists ina working memory a set of rules and an inference engine The working memoryis a global database of data representing the system state A rule is a condition-action pair The inference engine is based on a three-phase cyclic execution model

A Web-Based P Systems Simulator and Its Parallelization 67

of condition evaluations (matching) conflict-resolution and action firing Firingcan add delete or modify elements in the working memory An instantiationis a rule with a set of working memory elements In a sequential environmentconflict-resolution selects for firing a certain instantiation from the set of all in-stantiations In a parallel environment multiple instantiations can be selectedfor firing simultaneously Considering a high degree of parallelism the time per-formance can be improved44 Experiments

The computational power of a P system can be used not for solving small prob-lems for which we have already faster algorithms but for large and difficultproblems The main goal of our experiments is to measure the efficiency of Paccelerator in a cluster environment when it is applied to a particular problemOur experiments use the P system with active membrane described in [8] tosolve the validity problem given a Boolean formula in conjunctive normal formto determine whether or not it is a tautology If we consider the problem inputin the form andm

i=1 orki

j=1 xij where xij isin X1 Xn X1 Xn the P systemsolves the NP-complete problem of validity in 5n + 2m + 4 steps The numberof membranes increases by division from only three initial membranes to 2n + 2membranes at the end of computation This example is also of interest for parallelsimulation using dynamic task creation Different membranes can be distributedon different machines of a cluster They can evolve independently accordingly tothe evolution rules Send-in and Send-out rules request message exchanges

Based on the fact that CLIPS code is fully compatible with Jess we haverepeated the experiments reported in [8] We concentrate our attention to themost consuming part of the simulation namely after the final division when wehave already 2n + 2 membranes The number of rules to be fired is similar tothose from the classical production systems benchmarks The following tablespecifies the number of rules to be fired in the case of checking the validity of aBoolean expression with m = n

m times n Membranes Rules fired Time for Reaching Total time ofafter the last firing those the final simulationdivision rules configuration

2 times 2 6 335 1 s 1 s 2 s3 times 3 10 779 13 s 3 s 16 s4 times 4 18 1835 428 s 6 s 434 s5 times 5 34 49 s

The evaluation of time is measured on one PC of a cluster used in our testsThe cluster is composed of four PCs at 15GHz and 256Mb RAM connected viaa Myrinet switch ensuring communication at 2Gbs

We describe now how the P accelerator is working in order to assure thedistribution of the membranes and the communication between rules The Paccelerator can be activated by a user in a simple way Each Jess instancesreads the simulator rules the facts (the membrane rules to be applied) themembrane structure and their contents Each membrane is owned by a Jess

68 C Bonchis et al

instance An instance can own none one or several membranes Rules are firedby an instance only if they are associated to an owned membrane Each instancehas copies of the other instance membranes A change in the content of thefather membrane can lead to a change in the children membrane The sourcesand destinations used in the send and receive commands are related to theirmembrane owners The send and receive rules are activated only if the involvedsources and destinations have different owners

45 Running Time

It is easy to note a significant reduction of the running time even when weuse the P accelerator running on one machine of the cluster (ie Jess instancesare running on the same machine) In the following table the shorter time isunderlined for each number of Jess instances working concurrently The lowesttime depends on the dimension of the problem It seems that for a m times mproblem the lowest time is given by m Jess instances

Membranes 1 instance 2 instances 3 instances 4 instances6 1 s 1 s 3 s 3 s10 13 s 5 s 5 s 10 s18 428 s 45 s 25 s 33 s34 Memout 1054 s 325 s 200 s

Further reduction of the simulation time is expected when our P accelerator isrunning on several machines These expectations are confirmed by our tests Thespeedup Sp and the efficiency Ep of the parallel implementation are registeredin the following table the values being close to the ideal ones It is easy toremark a normal increasing of the speedup with the number of rules to be firedIt is expected to obtain even better results for larger dimension of the validityproblem

MembranesInstances Machines 6 10 18 341 1 1 s 13 s 428 s Memory out2 1 1 s 5 s 45 s 1054 s

2 1 s 3 s 23 s 528 sS2 1 17 19 2E2 051 065 095 099

3 1 3 s 5 s 25 s 325 s3 3 s 2 s 10 s 126 sS3 1 25 25 26E3 033 083 083 087

4 1 3 s 10 s 33 s 200 s4 2 s 3 s 9 s 52 sS4 15 33 37 38E4 037 082 091 096

A Web-Based P Systems Simulator and Its Parallelization 69

5 Conclusion and Further Work

We present a new simulator of the P systems It is efficient flexible and does notrequire any previous knowledge or expertise in computers Since the simulatorhas some novel and interesting features related to efficiency ease of use andgenerality it can become a useful tool for the community both theoretically andpractically Being GPL licensed we expect it is eligible to become a simulatorbenchmark reference The simulator is available at httppsystemsieatro

We intend to make the simulator available as a web service Moreover con-tinuing the commitment to standards compliance we will strive for SBML com-patibility for our specification language Further improvements are related tobetter debugging and visualization capabilities (including a flexible fine andcoarse-grained tracer) developing a library of macros and methodologies usingthe principles of modularity extensibility and structured design from softwareengineering introducing rules for the development of macros for P systems

In this paper we also present an automatic parallelization tool of the existingsequential simulators of the P systems We use a splitting technique of mem-branes in several Java threads and then we develop a P accelerator enabling thecooperation of many Jess instances running in a cluster environment to speedupa P simulator The P accelerator will be further developed to include facilities formembrane dissolution and division Further extensions are under investigation

References

1 G Ciobanu ldquoDistributed algorithms over communicating membrane systemsrdquoBioSystems vol70 123ndash133 Elsevier 2003

2 G Ciobanu W Guo ldquoP Systems Running on a Cluster of Computersrdquo in GhPaunet al (Eds) Proceedings 4th Workshop on Membrane Computing LNCS 2933123ndash139 Springer 2004

3 G Ciobanu D Paraschiv ldquoMembrane Software A P System Simulatorrdquo Funda-menta Informaticae vol49 no1-3 61ndash66 2002

4 G Ciobanu D Petcu ldquoP accelerators Parallelization of sequential simulatorsrdquo inMAGutierrez-Naranjo GhPaun MJPerez-Jimenez (Eds) Cellular Computingcomplexity aspects ESF PESC Exploratory Workshop Fenix Editora Sevilla 177-186 2005

5 CL Forgy ldquoRETE A Fast Algorithm for the Many PatternMany Object PatternMatch Problemrdquo Artificial Intelligence vol19 17ndash37 1982

6 E Friedman-Hill Jess in Action Rule-Based Systems in Java Manning Publica-tions 2003

7 Gh Paun Membrane Computing An Introduction Springer 20028 MJ Perez-Jimenez FJ Romero-Campero ldquoA CLIPS Simulator for Recognizer P

Systems with Active Membranesrdquo Proceedings 2nd Brainstorming Week on Mem-brane Computing University of Sevilla Tech Rep 012004 387-413 2004

A Web-Based P Systems Simulator and Its Parallelization 61

dissolve and divide operations which imply a lot of moving and copying Ini-tially we think to represent membranes as modules but later we see that thisrepresentation decreases the efficiency and flexibility of the whole system

It is useful to note that the simulator supports divide promotersinhibitorsand symportantiport rules for membranes For example the P system transitionrule a+brarrc+d(2)+e(0) with priority 11 from membrane 1 is converted into thefollowing CLIPS rule

(defrule MAIN1_a+b-gtc+d[2]+e[0]

(declare (salience 11))

(do (what react))

(or (parent-child (parent 1) (child 2))

(parent-child (parent 2) (child 1)))

(or (parent-child (parent 1) (child 0))

(parent-child (parent 0) (child 1)))

a-0 lt- (obj (name a) (membrane 1))

b-1 lt- (obj (name b) (membrane 1))

=gt

(assert (newobj (name c) (membrane 1)))

(assert (inject (name d) (membrane 2)))

(assert (inject (name e) (membrane 0)))

(retract a-0) (retract b-1))

The membrane structure is reflected by the parent-child facts An object a ofmembrane 1 is represented as a CLIPS fact on line 8 (obj (name a) (membrane1)) While the reactants a and b are consumed the new objects c d and e arecreated during the Spawn and Communication steps respectively The rulepriorities are mapped directly to CLIPS rules salience values and therefore arerestricted to integer values in the interval [-10000 10000]

22 C Level

In the C level we use CLIPS API although we plan to develop a complete librarythat encapsulates the C-CLIPS interface namely a C library which wraps nicelyaround the CLIPS one

We represent a P system using XML and we define an XML schema forthis kind of document A special library is developed to handle XML parsingof the input for the CLIPS part of the simulator In the following example wedescribe a P system using our XML schema This example system presents a Psystem for multiplication of the number of a objects in membrane 1 with thenumber of b objects in membrane 0 the result being the number of d objectsin membrane 0

ltxml version=10gt

ltpsystemgt

ltmembrane name=0gt

ltobject name=b count=3 gt

ltrule body=b+v-gte+v+d priority=1 gt

ltrule body=e+u-gtb+u+d priority=1 gt

ltrule body=v-gtu(1) gt

62 C Bonchis et al

ltrule body=u-gtv(1) gt

ltmembrane name=1gt

ltobject name=a count=4 gt

ltobject name=v count=1 gt

ltrule body=a+v-gtv(0) gt

ltrule body=a+u-gtu(0) gt

ltmembranegt

ltmembranegt

ltquery text=count of (objects from 0 where (objects d)) gt

ltpsystemgt

23 Web Level

The Web level of the simulator allows to choose between a user-friendly P systemdesigner written in JavaScript and a traditional HTML input form transmittingan XML description by uploading a file or by editing Aside from the XML Psystem description editing the user can specify a number of executions of the Psystem Our JavaScript P system Designer aims to facilitate the description ofthe P system without requiring the user to write XML but generating it basedon the userrsquos interaction with a dynamic interface

PHP script

CGI program(C)

CLIPS library LibCGI PSminusXML C library

JavaScriptP system Designer

HTML input formfor XML

After the user introduces a XML description it is transmitted to a PHPscript which does some further processing and sent then to a CGI programwritten in C The C program uses a specific P system XML library called PS-XML as well as LibCGI and CLIPS library in order to simulate the evolutionof the P system Finally it returns the results to the user It is possible to selectvarious information provided as results and in order to help the user to selectthe desired information we define a query language called PsQL

PsQL (P systems Query Language) We define PsQL as an SQL-like lan-guage for querying the state of a P system We developed a CLIPS library forparsing and interpreting this language At the Web level the queries can be in-cluded in the XML input these queries are activated after the execution of the

A Web-Based P Systems Simulator and Its Parallelization 63

specified P system If it does not exist any query the P system is simulated butno output is generated At the CLIPS level it is possible to specify queries forthe P system in a dynamic manner not just before starting the simulation Atthe syntactic level PsQL is a Lisp-like language and it is supported by a smallCLIPS library of list-handling functions

The Backus-Naur description of PsQL is presented in the following lines

ltquerygt = ltexpressiongt |

ltcount-querygt |

ltmembranes-querygt |

ltobjects-querygt

ltcount-querygt = ( count-of ltobjects-querygt |

ltmembranes-querygt )

ltobjects-querygt = ( objects-from ltmembranes-specgt

[ where ltwhere-specgt ] )

ltmembranes-querygt = ( membranes-from ltmembranes-specgt

[ where ltwhere-specgt ] )

The full description is available at httptwikiieatrotwikibinviewInstitutPSystemsQueryLanguage We plan to extend PsQL with tracefacilities having queries on the possible traces during an execution represents astep towards an automated verification of the P systems

3 Examples

The first example is a P system that computes the multiplication of two naturalnumbers The following figure describes graphically the P system

bm

b+v e+v+d gt v u(1)e+u b+u+d gt u v(1)

an

a+v v(0)a+u u(0)

v

0

1

As inputs we consider the number of a objects in membrane 1 and thenumber of b objects in membrane 0 The result is given by the number of dobjects in membrane 0

This P system differs from other similar ones by that it does not have expo-nential space complexity and does not require active membranes As a particularcase it would be quite easy to compute n2 by just placing the same number nof a and b objects in its membranes

Another interesting feature is that it may continue computing the multipli-cation after reaching a certain result Thus if initially there are m b objects and

64 C Bonchis et al

n a objects the system evolves and reaches a state with n middotm d objects in mem-brane 0 If the user wish to continue in order to compute (n+k) middotm it is enoughto inject k a objects in membrane 1 at the current state and the computationcan go on Therefore this example emphasizes a certain degree of re-usability

Recursive Sum The P system described in the next picture computes therecursive sum

sumni=1 ki

a a(0) a a(0) a a(0)

k2

k1

kn

1 2

aa

0

n

a

The numbers of a objects in the membranes 1n are the addition argumentsand the result of the computation is the number of a objects in membrane 0The PsQL query to determine this result is (count of (objects from 0))

While this example is rather trivial it illustrates the expressiveness of thequery language (PsQL) Using PsQL queries it is not necessary to apply therules and execute the specified P system Given the initial multiset the samerecursive sum is obtained by using the following query (count of (objectsfrom (membranes from 0)))

Dot Product of Two Vectors Combining the previous two examples we cancompute the dot (scalar) product x middot y of two vectors x y isin N

m where m isin NLet us denote the components of the vectors by xi and yi respectively thesecomponents are given by the number of b and a in the membranes labelled by 2iand 2i+1 respectively Then xmiddoty is given by the number of d objects obtained inmembrane 0 after the P system halts This P system is described graphically as

gt u u(2k+2)e+u b+u+d(0)

yk+1

a+v v(2k+1)a+u u(2k+1)

2k+2

a v

b+v e+v+d(0) gt v v(2k+2)

xk+1b

2k+1

b+v e+v+d(0)

y1

a+v v(1)a+u u(1)

a v

2

x1b

e+u

1

gt v gt u b+u+d(0)

v(2)u(2)

0

where k = 0 m minus 1 The PsQL query for retrieving the result is (count of(objects from 0))

A Web-Based P Systems Simulator and Its Parallelization 65

4 On Parallelization of Sequential Simulators

There will always be a need for exploiting parallelism in computing such thatmany difficult problems can be executed on parallel architectures There is also aneed to free the programmers from thinking about the parallelization of existingsequential programs Automatic parallelization of code has been an active re-search topic in scientific computing for some decades For a long period of timethe kind of attempts achieve little of the potential benefit of parallel computingRecent contributions improve the performance and efficient parallel codes havebeen created automatically to solve problems in various fields

We refer to the sequential simulators of the P systems particularly to thoseimplemented in CLIPS [8] These sequential simulators have both didactic andscientific values However the P systems are inherently parallel and in manyvariants they also exhibit an intrinsic non-determinism hard to be captured bysequential computers By simulating parallelism and nondeterminism on a se-quential machine one can lose the real power of parallelism and attractiveness ofP system computing Therefore the simulations on multiple processors representa particularly interesting subject Currently the only known parallel and clusterimplementation for P systems is presented in [2] using C++ and MPI41 Jess Java Expert System ShellJess is the abbreviation for Java Expert System Shell it is a rule-based program-ming environment for Java platforms it is available at httpherzbergcasandiagovjess More information about Jess can be found in [6] Jess usesthe RETE algorithm [5] for rules an efficient mechanism for solving the difficultmany-to-many matching problem Our strategy is to build a parallel productionsystems with a high degree of flexibility namely to construct a wrapper for theparallel system which allows cooperation between its instances From this pointof view Jess has been considered mainly due to its flexibility (communication viasockets ability to create Java objects and call Java methods) and its compatibil-ity with the C Language Interface Production System CLIPS CLIPS is availableat httpwwwghgnetclipsCLIPShtml where it is presented as a tool forbuilding expert systems Jess is also selected because of its active developmentand support tight interaction with Java programs and expressiveness

The Jess rule language includes elements not present in many other produc-tion systems such as arbitrary combinations of Boolean conjunctions and dis-junctions Its scripting language is powerful enough to generate full applicationsentirely within the Jess system Jess is also a powerful Java scripting environ-ment from which one can create Java objects and call Java methods withoutcompiling any Java code The core Jess language is fully compatible with CLIPS(Jess scripts are valid CLIPS scripts and vice-versa) Jess adds many features toCLIPS including backwards chaining working memory queries and the abilityto manipulate and directly reason about Java objects

We think to consider existing implementations and improve them by usingmultiple computing units leading to faster P system simulators than the cur-rent available ones The proposed architecture for a such system is based on an

66 C Bonchis et al

accelerator actually a wrapper allowing the cooperation between several in-stances of a program running on different computers in order to speedup thecurrent P system simulators

We intend to apply our P accelerators to WebPS As a first step we considera simpler CLIPS simulator [8] The set of rules and the configurations in eachstep of the evolution are expressed as facts in a knowledge base We first showthat a splitting technique of the membranes in several Java threads runningembedded Jess can lead to a faster simulation Then we use the P accelerator tofurther speedup the simulation

42 P Accelerators

Having in mind the parallel evolutions of its membranes based on different ruleswe build a parallel distributed memory version of a production system based ontask parallelism The target architecture is a homogeneous cluster of worksta-tions Building a Jess application based on socket communication facilities isconsidered to be difficult and can distract the user from its main aim Thereforea middleware is needed We adopt a modular scheme composed by Jess instancesConnectors and Messengers

A first component of the P accelerator is called Connector and consists of aJava code Each Jess instance has one corresponding Connector A Jess instance(acting as a client) contacts its Connector (acting as a server) via a socket Assoon as such a connection is established the Connector interprets the Jess specialincoming requests for communications and controls other Jess instances (namelysend or receive information launch or kill other instances) An information intransit is a string containing a command written in Jess language

Another component of the P accelerator is represented by the MessengersEach Messenger is associated with one Connector and its purpose is to exe-cute the commands received by Connector and to communicate with variousMessengers associated with the other Jess instances We add new commands toJess assuring a valid message passing interface More details about the set ofcommands and some other aspects related to P accelerators can be found in [4]

43 Implementation Details

A Connector uses the standard Java ServerSockets methods The current Mes-senger is written in Java and JPVM a Java implementation of Parallel VirtualMachine selected due to its ability to dynamically create and destroy tasks auseful ability when simulating the division and dissolution of membranes JPVMis available at httpwwwcsvirginiaedusimajf2jjpvmhtml Adopting aPVM variant the user is absolved of the duties to nominate the hosts were theJess instances are running as well as to treat sequentially the incoming messages(as in the case of a socket connection) or to check the status of the machineson which the Jess instances are running

Regarding CLIPS we should mention that a production system consists ina working memory a set of rules and an inference engine The working memoryis a global database of data representing the system state A rule is a condition-action pair The inference engine is based on a three-phase cyclic execution model

A Web-Based P Systems Simulator and Its Parallelization 67

of condition evaluations (matching) conflict-resolution and action firing Firingcan add delete or modify elements in the working memory An instantiationis a rule with a set of working memory elements In a sequential environmentconflict-resolution selects for firing a certain instantiation from the set of all in-stantiations In a parallel environment multiple instantiations can be selectedfor firing simultaneously Considering a high degree of parallelism the time per-formance can be improved44 Experiments

The computational power of a P system can be used not for solving small prob-lems for which we have already faster algorithms but for large and difficultproblems The main goal of our experiments is to measure the efficiency of Paccelerator in a cluster environment when it is applied to a particular problemOur experiments use the P system with active membrane described in [8] tosolve the validity problem given a Boolean formula in conjunctive normal formto determine whether or not it is a tautology If we consider the problem inputin the form andm

i=1 orki

j=1 xij where xij isin X1 Xn X1 Xn the P systemsolves the NP-complete problem of validity in 5n + 2m + 4 steps The numberof membranes increases by division from only three initial membranes to 2n + 2membranes at the end of computation This example is also of interest for parallelsimulation using dynamic task creation Different membranes can be distributedon different machines of a cluster They can evolve independently accordingly tothe evolution rules Send-in and Send-out rules request message exchanges

Based on the fact that CLIPS code is fully compatible with Jess we haverepeated the experiments reported in [8] We concentrate our attention to themost consuming part of the simulation namely after the final division when wehave already 2n + 2 membranes The number of rules to be fired is similar tothose from the classical production systems benchmarks The following tablespecifies the number of rules to be fired in the case of checking the validity of aBoolean expression with m = n

m times n Membranes Rules fired Time for Reaching Total time ofafter the last firing those the final simulationdivision rules configuration

2 times 2 6 335 1 s 1 s 2 s3 times 3 10 779 13 s 3 s 16 s4 times 4 18 1835 428 s 6 s 434 s5 times 5 34 49 s

The evaluation of time is measured on one PC of a cluster used in our testsThe cluster is composed of four PCs at 15GHz and 256Mb RAM connected viaa Myrinet switch ensuring communication at 2Gbs

We describe now how the P accelerator is working in order to assure thedistribution of the membranes and the communication between rules The Paccelerator can be activated by a user in a simple way Each Jess instancesreads the simulator rules the facts (the membrane rules to be applied) themembrane structure and their contents Each membrane is owned by a Jess

68 C Bonchis et al

instance An instance can own none one or several membranes Rules are firedby an instance only if they are associated to an owned membrane Each instancehas copies of the other instance membranes A change in the content of thefather membrane can lead to a change in the children membrane The sourcesand destinations used in the send and receive commands are related to theirmembrane owners The send and receive rules are activated only if the involvedsources and destinations have different owners

45 Running Time

It is easy to note a significant reduction of the running time even when weuse the P accelerator running on one machine of the cluster (ie Jess instancesare running on the same machine) In the following table the shorter time isunderlined for each number of Jess instances working concurrently The lowesttime depends on the dimension of the problem It seems that for a m times mproblem the lowest time is given by m Jess instances

Membranes 1 instance 2 instances 3 instances 4 instances6 1 s 1 s 3 s 3 s10 13 s 5 s 5 s 10 s18 428 s 45 s 25 s 33 s34 Memout 1054 s 325 s 200 s

Further reduction of the simulation time is expected when our P accelerator isrunning on several machines These expectations are confirmed by our tests Thespeedup Sp and the efficiency Ep of the parallel implementation are registeredin the following table the values being close to the ideal ones It is easy toremark a normal increasing of the speedup with the number of rules to be firedIt is expected to obtain even better results for larger dimension of the validityproblem

MembranesInstances Machines 6 10 18 341 1 1 s 13 s 428 s Memory out2 1 1 s 5 s 45 s 1054 s

2 1 s 3 s 23 s 528 sS2 1 17 19 2E2 051 065 095 099

3 1 3 s 5 s 25 s 325 s3 3 s 2 s 10 s 126 sS3 1 25 25 26E3 033 083 083 087

4 1 3 s 10 s 33 s 200 s4 2 s 3 s 9 s 52 sS4 15 33 37 38E4 037 082 091 096

A Web-Based P Systems Simulator and Its Parallelization 69

5 Conclusion and Further Work

We present a new simulator of the P systems It is efficient flexible and does notrequire any previous knowledge or expertise in computers Since the simulatorhas some novel and interesting features related to efficiency ease of use andgenerality it can become a useful tool for the community both theoretically andpractically Being GPL licensed we expect it is eligible to become a simulatorbenchmark reference The simulator is available at httppsystemsieatro

We intend to make the simulator available as a web service Moreover con-tinuing the commitment to standards compliance we will strive for SBML com-patibility for our specification language Further improvements are related tobetter debugging and visualization capabilities (including a flexible fine andcoarse-grained tracer) developing a library of macros and methodologies usingthe principles of modularity extensibility and structured design from softwareengineering introducing rules for the development of macros for P systems

In this paper we also present an automatic parallelization tool of the existingsequential simulators of the P systems We use a splitting technique of mem-branes in several Java threads and then we develop a P accelerator enabling thecooperation of many Jess instances running in a cluster environment to speedupa P simulator The P accelerator will be further developed to include facilities formembrane dissolution and division Further extensions are under investigation

References

1 G Ciobanu ldquoDistributed algorithms over communicating membrane systemsrdquoBioSystems vol70 123ndash133 Elsevier 2003

2 G Ciobanu W Guo ldquoP Systems Running on a Cluster of Computersrdquo in GhPaunet al (Eds) Proceedings 4th Workshop on Membrane Computing LNCS 2933123ndash139 Springer 2004

3 G Ciobanu D Paraschiv ldquoMembrane Software A P System Simulatorrdquo Funda-menta Informaticae vol49 no1-3 61ndash66 2002

4 G Ciobanu D Petcu ldquoP accelerators Parallelization of sequential simulatorsrdquo inMAGutierrez-Naranjo GhPaun MJPerez-Jimenez (Eds) Cellular Computingcomplexity aspects ESF PESC Exploratory Workshop Fenix Editora Sevilla 177-186 2005

5 CL Forgy ldquoRETE A Fast Algorithm for the Many PatternMany Object PatternMatch Problemrdquo Artificial Intelligence vol19 17ndash37 1982

6 E Friedman-Hill Jess in Action Rule-Based Systems in Java Manning Publica-tions 2003

7 Gh Paun Membrane Computing An Introduction Springer 20028 MJ Perez-Jimenez FJ Romero-Campero ldquoA CLIPS Simulator for Recognizer P

Systems with Active Membranesrdquo Proceedings 2nd Brainstorming Week on Mem-brane Computing University of Sevilla Tech Rep 012004 387-413 2004

62 C Bonchis et al

ltrule body=u-gtv(1) gt

ltmembrane name=1gt

ltobject name=a count=4 gt

ltobject name=v count=1 gt

ltrule body=a+v-gtv(0) gt

ltrule body=a+u-gtu(0) gt

ltmembranegt

ltmembranegt

ltquery text=count of (objects from 0 where (objects d)) gt

ltpsystemgt

23 Web Level

The Web level of the simulator allows to choose between a user-friendly P systemdesigner written in JavaScript and a traditional HTML input form transmittingan XML description by uploading a file or by editing Aside from the XML Psystem description editing the user can specify a number of executions of the Psystem Our JavaScript P system Designer aims to facilitate the description ofthe P system without requiring the user to write XML but generating it basedon the userrsquos interaction with a dynamic interface

PHP script

CGI program(C)

CLIPS library LibCGI PSminusXML C library

JavaScriptP system Designer

HTML input formfor XML

After the user introduces a XML description it is transmitted to a PHPscript which does some further processing and sent then to a CGI programwritten in C The C program uses a specific P system XML library called PS-XML as well as LibCGI and CLIPS library in order to simulate the evolutionof the P system Finally it returns the results to the user It is possible to selectvarious information provided as results and in order to help the user to selectthe desired information we define a query language called PsQL

PsQL (P systems Query Language) We define PsQL as an SQL-like lan-guage for querying the state of a P system We developed a CLIPS library forparsing and interpreting this language At the Web level the queries can be in-cluded in the XML input these queries are activated after the execution of the

A Web-Based P Systems Simulator and Its Parallelization 63

specified P system If it does not exist any query the P system is simulated butno output is generated At the CLIPS level it is possible to specify queries forthe P system in a dynamic manner not just before starting the simulation Atthe syntactic level PsQL is a Lisp-like language and it is supported by a smallCLIPS library of list-handling functions

The Backus-Naur description of PsQL is presented in the following lines

ltquerygt = ltexpressiongt |

ltcount-querygt |

ltmembranes-querygt |

ltobjects-querygt

ltcount-querygt = ( count-of ltobjects-querygt |

ltmembranes-querygt )

ltobjects-querygt = ( objects-from ltmembranes-specgt

[ where ltwhere-specgt ] )

ltmembranes-querygt = ( membranes-from ltmembranes-specgt

[ where ltwhere-specgt ] )

The full description is available at httptwikiieatrotwikibinviewInstitutPSystemsQueryLanguage We plan to extend PsQL with tracefacilities having queries on the possible traces during an execution represents astep towards an automated verification of the P systems

3 Examples

The first example is a P system that computes the multiplication of two naturalnumbers The following figure describes graphically the P system

bm

b+v e+v+d gt v u(1)e+u b+u+d gt u v(1)

an

a+v v(0)a+u u(0)

v

0

1

As inputs we consider the number of a objects in membrane 1 and thenumber of b objects in membrane 0 The result is given by the number of dobjects in membrane 0

This P system differs from other similar ones by that it does not have expo-nential space complexity and does not require active membranes As a particularcase it would be quite easy to compute n2 by just placing the same number nof a and b objects in its membranes

Another interesting feature is that it may continue computing the multipli-cation after reaching a certain result Thus if initially there are m b objects and

64 C Bonchis et al

n a objects the system evolves and reaches a state with n middotm d objects in mem-brane 0 If the user wish to continue in order to compute (n+k) middotm it is enoughto inject k a objects in membrane 1 at the current state and the computationcan go on Therefore this example emphasizes a certain degree of re-usability

Recursive Sum The P system described in the next picture computes therecursive sum

sumni=1 ki

a a(0) a a(0) a a(0)

k2

k1

kn

1 2

aa

0

n

a

The numbers of a objects in the membranes 1n are the addition argumentsand the result of the computation is the number of a objects in membrane 0The PsQL query to determine this result is (count of (objects from 0))

While this example is rather trivial it illustrates the expressiveness of thequery language (PsQL) Using PsQL queries it is not necessary to apply therules and execute the specified P system Given the initial multiset the samerecursive sum is obtained by using the following query (count of (objectsfrom (membranes from 0)))

Dot Product of Two Vectors Combining the previous two examples we cancompute the dot (scalar) product x middot y of two vectors x y isin N

m where m isin NLet us denote the components of the vectors by xi and yi respectively thesecomponents are given by the number of b and a in the membranes labelled by 2iand 2i+1 respectively Then xmiddoty is given by the number of d objects obtained inmembrane 0 after the P system halts This P system is described graphically as

gt u u(2k+2)e+u b+u+d(0)

yk+1

a+v v(2k+1)a+u u(2k+1)

2k+2

a v

b+v e+v+d(0) gt v v(2k+2)

xk+1b

2k+1

b+v e+v+d(0)

y1

a+v v(1)a+u u(1)

a v

2

x1b

e+u

1

gt v gt u b+u+d(0)

v(2)u(2)

0

where k = 0 m minus 1 The PsQL query for retrieving the result is (count of(objects from 0))

A Web-Based P Systems Simulator and Its Parallelization 65

4 On Parallelization of Sequential Simulators

There will always be a need for exploiting parallelism in computing such thatmany difficult problems can be executed on parallel architectures There is also aneed to free the programmers from thinking about the parallelization of existingsequential programs Automatic parallelization of code has been an active re-search topic in scientific computing for some decades For a long period of timethe kind of attempts achieve little of the potential benefit of parallel computingRecent contributions improve the performance and efficient parallel codes havebeen created automatically to solve problems in various fields

We refer to the sequential simulators of the P systems particularly to thoseimplemented in CLIPS [8] These sequential simulators have both didactic andscientific values However the P systems are inherently parallel and in manyvariants they also exhibit an intrinsic non-determinism hard to be captured bysequential computers By simulating parallelism and nondeterminism on a se-quential machine one can lose the real power of parallelism and attractiveness ofP system computing Therefore the simulations on multiple processors representa particularly interesting subject Currently the only known parallel and clusterimplementation for P systems is presented in [2] using C++ and MPI41 Jess Java Expert System ShellJess is the abbreviation for Java Expert System Shell it is a rule-based program-ming environment for Java platforms it is available at httpherzbergcasandiagovjess More information about Jess can be found in [6] Jess usesthe RETE algorithm [5] for rules an efficient mechanism for solving the difficultmany-to-many matching problem Our strategy is to build a parallel productionsystems with a high degree of flexibility namely to construct a wrapper for theparallel system which allows cooperation between its instances From this pointof view Jess has been considered mainly due to its flexibility (communication viasockets ability to create Java objects and call Java methods) and its compatibil-ity with the C Language Interface Production System CLIPS CLIPS is availableat httpwwwghgnetclipsCLIPShtml where it is presented as a tool forbuilding expert systems Jess is also selected because of its active developmentand support tight interaction with Java programs and expressiveness

The Jess rule language includes elements not present in many other produc-tion systems such as arbitrary combinations of Boolean conjunctions and dis-junctions Its scripting language is powerful enough to generate full applicationsentirely within the Jess system Jess is also a powerful Java scripting environ-ment from which one can create Java objects and call Java methods withoutcompiling any Java code The core Jess language is fully compatible with CLIPS(Jess scripts are valid CLIPS scripts and vice-versa) Jess adds many features toCLIPS including backwards chaining working memory queries and the abilityto manipulate and directly reason about Java objects

We think to consider existing implementations and improve them by usingmultiple computing units leading to faster P system simulators than the cur-rent available ones The proposed architecture for a such system is based on an

66 C Bonchis et al

accelerator actually a wrapper allowing the cooperation between several in-stances of a program running on different computers in order to speedup thecurrent P system simulators

We intend to apply our P accelerators to WebPS As a first step we considera simpler CLIPS simulator [8] The set of rules and the configurations in eachstep of the evolution are expressed as facts in a knowledge base We first showthat a splitting technique of the membranes in several Java threads runningembedded Jess can lead to a faster simulation Then we use the P accelerator tofurther speedup the simulation

42 P Accelerators

Having in mind the parallel evolutions of its membranes based on different ruleswe build a parallel distributed memory version of a production system based ontask parallelism The target architecture is a homogeneous cluster of worksta-tions Building a Jess application based on socket communication facilities isconsidered to be difficult and can distract the user from its main aim Thereforea middleware is needed We adopt a modular scheme composed by Jess instancesConnectors and Messengers

A first component of the P accelerator is called Connector and consists of aJava code Each Jess instance has one corresponding Connector A Jess instance(acting as a client) contacts its Connector (acting as a server) via a socket Assoon as such a connection is established the Connector interprets the Jess specialincoming requests for communications and controls other Jess instances (namelysend or receive information launch or kill other instances) An information intransit is a string containing a command written in Jess language

Another component of the P accelerator is represented by the MessengersEach Messenger is associated with one Connector and its purpose is to exe-cute the commands received by Connector and to communicate with variousMessengers associated with the other Jess instances We add new commands toJess assuring a valid message passing interface More details about the set ofcommands and some other aspects related to P accelerators can be found in [4]

43 Implementation Details

A Connector uses the standard Java ServerSockets methods The current Mes-senger is written in Java and JPVM a Java implementation of Parallel VirtualMachine selected due to its ability to dynamically create and destroy tasks auseful ability when simulating the division and dissolution of membranes JPVMis available at httpwwwcsvirginiaedusimajf2jjpvmhtml Adopting aPVM variant the user is absolved of the duties to nominate the hosts were theJess instances are running as well as to treat sequentially the incoming messages(as in the case of a socket connection) or to check the status of the machineson which the Jess instances are running

Regarding CLIPS we should mention that a production system consists ina working memory a set of rules and an inference engine The working memoryis a global database of data representing the system state A rule is a condition-action pair The inference engine is based on a three-phase cyclic execution model

A Web-Based P Systems Simulator and Its Parallelization 67

of condition evaluations (matching) conflict-resolution and action firing Firingcan add delete or modify elements in the working memory An instantiationis a rule with a set of working memory elements In a sequential environmentconflict-resolution selects for firing a certain instantiation from the set of all in-stantiations In a parallel environment multiple instantiations can be selectedfor firing simultaneously Considering a high degree of parallelism the time per-formance can be improved44 Experiments

The computational power of a P system can be used not for solving small prob-lems for which we have already faster algorithms but for large and difficultproblems The main goal of our experiments is to measure the efficiency of Paccelerator in a cluster environment when it is applied to a particular problemOur experiments use the P system with active membrane described in [8] tosolve the validity problem given a Boolean formula in conjunctive normal formto determine whether or not it is a tautology If we consider the problem inputin the form andm

i=1 orki

j=1 xij where xij isin X1 Xn X1 Xn the P systemsolves the NP-complete problem of validity in 5n + 2m + 4 steps The numberof membranes increases by division from only three initial membranes to 2n + 2membranes at the end of computation This example is also of interest for parallelsimulation using dynamic task creation Different membranes can be distributedon different machines of a cluster They can evolve independently accordingly tothe evolution rules Send-in and Send-out rules request message exchanges

Based on the fact that CLIPS code is fully compatible with Jess we haverepeated the experiments reported in [8] We concentrate our attention to themost consuming part of the simulation namely after the final division when wehave already 2n + 2 membranes The number of rules to be fired is similar tothose from the classical production systems benchmarks The following tablespecifies the number of rules to be fired in the case of checking the validity of aBoolean expression with m = n

m times n Membranes Rules fired Time for Reaching Total time ofafter the last firing those the final simulationdivision rules configuration

2 times 2 6 335 1 s 1 s 2 s3 times 3 10 779 13 s 3 s 16 s4 times 4 18 1835 428 s 6 s 434 s5 times 5 34 49 s

The evaluation of time is measured on one PC of a cluster used in our testsThe cluster is composed of four PCs at 15GHz and 256Mb RAM connected viaa Myrinet switch ensuring communication at 2Gbs

We describe now how the P accelerator is working in order to assure thedistribution of the membranes and the communication between rules The Paccelerator can be activated by a user in a simple way Each Jess instancesreads the simulator rules the facts (the membrane rules to be applied) themembrane structure and their contents Each membrane is owned by a Jess

68 C Bonchis et al

instance An instance can own none one or several membranes Rules are firedby an instance only if they are associated to an owned membrane Each instancehas copies of the other instance membranes A change in the content of thefather membrane can lead to a change in the children membrane The sourcesand destinations used in the send and receive commands are related to theirmembrane owners The send and receive rules are activated only if the involvedsources and destinations have different owners

45 Running Time

It is easy to note a significant reduction of the running time even when weuse the P accelerator running on one machine of the cluster (ie Jess instancesare running on the same machine) In the following table the shorter time isunderlined for each number of Jess instances working concurrently The lowesttime depends on the dimension of the problem It seems that for a m times mproblem the lowest time is given by m Jess instances

Membranes 1 instance 2 instances 3 instances 4 instances6 1 s 1 s 3 s 3 s10 13 s 5 s 5 s 10 s18 428 s 45 s 25 s 33 s34 Memout 1054 s 325 s 200 s

Further reduction of the simulation time is expected when our P accelerator isrunning on several machines These expectations are confirmed by our tests Thespeedup Sp and the efficiency Ep of the parallel implementation are registeredin the following table the values being close to the ideal ones It is easy toremark a normal increasing of the speedup with the number of rules to be firedIt is expected to obtain even better results for larger dimension of the validityproblem

MembranesInstances Machines 6 10 18 341 1 1 s 13 s 428 s Memory out2 1 1 s 5 s 45 s 1054 s

2 1 s 3 s 23 s 528 sS2 1 17 19 2E2 051 065 095 099

3 1 3 s 5 s 25 s 325 s3 3 s 2 s 10 s 126 sS3 1 25 25 26E3 033 083 083 087

4 1 3 s 10 s 33 s 200 s4 2 s 3 s 9 s 52 sS4 15 33 37 38E4 037 082 091 096

A Web-Based P Systems Simulator and Its Parallelization 69

5 Conclusion and Further Work

We present a new simulator of the P systems It is efficient flexible and does notrequire any previous knowledge or expertise in computers Since the simulatorhas some novel and interesting features related to efficiency ease of use andgenerality it can become a useful tool for the community both theoretically andpractically Being GPL licensed we expect it is eligible to become a simulatorbenchmark reference The simulator is available at httppsystemsieatro

We intend to make the simulator available as a web service Moreover con-tinuing the commitment to standards compliance we will strive for SBML com-patibility for our specification language Further improvements are related tobetter debugging and visualization capabilities (including a flexible fine andcoarse-grained tracer) developing a library of macros and methodologies usingthe principles of modularity extensibility and structured design from softwareengineering introducing rules for the development of macros for P systems

In this paper we also present an automatic parallelization tool of the existingsequential simulators of the P systems We use a splitting technique of mem-branes in several Java threads and then we develop a P accelerator enabling thecooperation of many Jess instances running in a cluster environment to speedupa P simulator The P accelerator will be further developed to include facilities formembrane dissolution and division Further extensions are under investigation

References

1 G Ciobanu ldquoDistributed algorithms over communicating membrane systemsrdquoBioSystems vol70 123ndash133 Elsevier 2003

2 G Ciobanu W Guo ldquoP Systems Running on a Cluster of Computersrdquo in GhPaunet al (Eds) Proceedings 4th Workshop on Membrane Computing LNCS 2933123ndash139 Springer 2004

3 G Ciobanu D Paraschiv ldquoMembrane Software A P System Simulatorrdquo Funda-menta Informaticae vol49 no1-3 61ndash66 2002

4 G Ciobanu D Petcu ldquoP accelerators Parallelization of sequential simulatorsrdquo inMAGutierrez-Naranjo GhPaun MJPerez-Jimenez (Eds) Cellular Computingcomplexity aspects ESF PESC Exploratory Workshop Fenix Editora Sevilla 177-186 2005

5 CL Forgy ldquoRETE A Fast Algorithm for the Many PatternMany Object PatternMatch Problemrdquo Artificial Intelligence vol19 17ndash37 1982

6 E Friedman-Hill Jess in Action Rule-Based Systems in Java Manning Publica-tions 2003

7 Gh Paun Membrane Computing An Introduction Springer 20028 MJ Perez-Jimenez FJ Romero-Campero ldquoA CLIPS Simulator for Recognizer P

Systems with Active Membranesrdquo Proceedings 2nd Brainstorming Week on Mem-brane Computing University of Sevilla Tech Rep 012004 387-413 2004

A Web-Based P Systems Simulator and Its Parallelization 63

specified P system If it does not exist any query the P system is simulated butno output is generated At the CLIPS level it is possible to specify queries forthe P system in a dynamic manner not just before starting the simulation Atthe syntactic level PsQL is a Lisp-like language and it is supported by a smallCLIPS library of list-handling functions

The Backus-Naur description of PsQL is presented in the following lines

ltquerygt = ltexpressiongt |

ltcount-querygt |

ltmembranes-querygt |

ltobjects-querygt

ltcount-querygt = ( count-of ltobjects-querygt |

ltmembranes-querygt )

ltobjects-querygt = ( objects-from ltmembranes-specgt

[ where ltwhere-specgt ] )

ltmembranes-querygt = ( membranes-from ltmembranes-specgt

[ where ltwhere-specgt ] )

The full description is available at httptwikiieatrotwikibinviewInstitutPSystemsQueryLanguage We plan to extend PsQL with tracefacilities having queries on the possible traces during an execution represents astep towards an automated verification of the P systems

3 Examples

The first example is a P system that computes the multiplication of two naturalnumbers The following figure describes graphically the P system

bm

b+v e+v+d gt v u(1)e+u b+u+d gt u v(1)

an

a+v v(0)a+u u(0)

v

0

1

As inputs we consider the number of a objects in membrane 1 and thenumber of b objects in membrane 0 The result is given by the number of dobjects in membrane 0

This P system differs from other similar ones by that it does not have expo-nential space complexity and does not require active membranes As a particularcase it would be quite easy to compute n2 by just placing the same number nof a and b objects in its membranes

Another interesting feature is that it may continue computing the multipli-cation after reaching a certain result Thus if initially there are m b objects and

64 C Bonchis et al

n a objects the system evolves and reaches a state with n middotm d objects in mem-brane 0 If the user wish to continue in order to compute (n+k) middotm it is enoughto inject k a objects in membrane 1 at the current state and the computationcan go on Therefore this example emphasizes a certain degree of re-usability

Recursive Sum The P system described in the next picture computes therecursive sum

sumni=1 ki

a a(0) a a(0) a a(0)

k2

k1

kn

1 2

aa

0

n

a

The numbers of a objects in the membranes 1n are the addition argumentsand the result of the computation is the number of a objects in membrane 0The PsQL query to determine this result is (count of (objects from 0))

While this example is rather trivial it illustrates the expressiveness of thequery language (PsQL) Using PsQL queries it is not necessary to apply therules and execute the specified P system Given the initial multiset the samerecursive sum is obtained by using the following query (count of (objectsfrom (membranes from 0)))

Dot Product of Two Vectors Combining the previous two examples we cancompute the dot (scalar) product x middot y of two vectors x y isin N

m where m isin NLet us denote the components of the vectors by xi and yi respectively thesecomponents are given by the number of b and a in the membranes labelled by 2iand 2i+1 respectively Then xmiddoty is given by the number of d objects obtained inmembrane 0 after the P system halts This P system is described graphically as

gt u u(2k+2)e+u b+u+d(0)

yk+1

a+v v(2k+1)a+u u(2k+1)

2k+2

a v

b+v e+v+d(0) gt v v(2k+2)

xk+1b

2k+1

b+v e+v+d(0)

y1

a+v v(1)a+u u(1)

a v

2

x1b

e+u

1

gt v gt u b+u+d(0)

v(2)u(2)

0

where k = 0 m minus 1 The PsQL query for retrieving the result is (count of(objects from 0))

A Web-Based P Systems Simulator and Its Parallelization 65

4 On Parallelization of Sequential Simulators

There will always be a need for exploiting parallelism in computing such thatmany difficult problems can be executed on parallel architectures There is also aneed to free the programmers from thinking about the parallelization of existingsequential programs Automatic parallelization of code has been an active re-search topic in scientific computing for some decades For a long period of timethe kind of attempts achieve little of the potential benefit of parallel computingRecent contributions improve the performance and efficient parallel codes havebeen created automatically to solve problems in various fields

We refer to the sequential simulators of the P systems particularly to thoseimplemented in CLIPS [8] These sequential simulators have both didactic andscientific values However the P systems are inherently parallel and in manyvariants they also exhibit an intrinsic non-determinism hard to be captured bysequential computers By simulating parallelism and nondeterminism on a se-quential machine one can lose the real power of parallelism and attractiveness ofP system computing Therefore the simulations on multiple processors representa particularly interesting subject Currently the only known parallel and clusterimplementation for P systems is presented in [2] using C++ and MPI41 Jess Java Expert System ShellJess is the abbreviation for Java Expert System Shell it is a rule-based program-ming environment for Java platforms it is available at httpherzbergcasandiagovjess More information about Jess can be found in [6] Jess usesthe RETE algorithm [5] for rules an efficient mechanism for solving the difficultmany-to-many matching problem Our strategy is to build a parallel productionsystems with a high degree of flexibility namely to construct a wrapper for theparallel system which allows cooperation between its instances From this pointof view Jess has been considered mainly due to its flexibility (communication viasockets ability to create Java objects and call Java methods) and its compatibil-ity with the C Language Interface Production System CLIPS CLIPS is availableat httpwwwghgnetclipsCLIPShtml where it is presented as a tool forbuilding expert systems Jess is also selected because of its active developmentand support tight interaction with Java programs and expressiveness

The Jess rule language includes elements not present in many other produc-tion systems such as arbitrary combinations of Boolean conjunctions and dis-junctions Its scripting language is powerful enough to generate full applicationsentirely within the Jess system Jess is also a powerful Java scripting environ-ment from which one can create Java objects and call Java methods withoutcompiling any Java code The core Jess language is fully compatible with CLIPS(Jess scripts are valid CLIPS scripts and vice-versa) Jess adds many features toCLIPS including backwards chaining working memory queries and the abilityto manipulate and directly reason about Java objects

We think to consider existing implementations and improve them by usingmultiple computing units leading to faster P system simulators than the cur-rent available ones The proposed architecture for a such system is based on an

66 C Bonchis et al

accelerator actually a wrapper allowing the cooperation between several in-stances of a program running on different computers in order to speedup thecurrent P system simulators

We intend to apply our P accelerators to WebPS As a first step we considera simpler CLIPS simulator [8] The set of rules and the configurations in eachstep of the evolution are expressed as facts in a knowledge base We first showthat a splitting technique of the membranes in several Java threads runningembedded Jess can lead to a faster simulation Then we use the P accelerator tofurther speedup the simulation

42 P Accelerators

Having in mind the parallel evolutions of its membranes based on different ruleswe build a parallel distributed memory version of a production system based ontask parallelism The target architecture is a homogeneous cluster of worksta-tions Building a Jess application based on socket communication facilities isconsidered to be difficult and can distract the user from its main aim Thereforea middleware is needed We adopt a modular scheme composed by Jess instancesConnectors and Messengers

A first component of the P accelerator is called Connector and consists of aJava code Each Jess instance has one corresponding Connector A Jess instance(acting as a client) contacts its Connector (acting as a server) via a socket Assoon as such a connection is established the Connector interprets the Jess specialincoming requests for communications and controls other Jess instances (namelysend or receive information launch or kill other instances) An information intransit is a string containing a command written in Jess language

Another component of the P accelerator is represented by the MessengersEach Messenger is associated with one Connector and its purpose is to exe-cute the commands received by Connector and to communicate with variousMessengers associated with the other Jess instances We add new commands toJess assuring a valid message passing interface More details about the set ofcommands and some other aspects related to P accelerators can be found in [4]

43 Implementation Details

A Connector uses the standard Java ServerSockets methods The current Mes-senger is written in Java and JPVM a Java implementation of Parallel VirtualMachine selected due to its ability to dynamically create and destroy tasks auseful ability when simulating the division and dissolution of membranes JPVMis available at httpwwwcsvirginiaedusimajf2jjpvmhtml Adopting aPVM variant the user is absolved of the duties to nominate the hosts were theJess instances are running as well as to treat sequentially the incoming messages(as in the case of a socket connection) or to check the status of the machineson which the Jess instances are running

Regarding CLIPS we should mention that a production system consists ina working memory a set of rules and an inference engine The working memoryis a global database of data representing the system state A rule is a condition-action pair The inference engine is based on a three-phase cyclic execution model

A Web-Based P Systems Simulator and Its Parallelization 67

of condition evaluations (matching) conflict-resolution and action firing Firingcan add delete or modify elements in the working memory An instantiationis a rule with a set of working memory elements In a sequential environmentconflict-resolution selects for firing a certain instantiation from the set of all in-stantiations In a parallel environment multiple instantiations can be selectedfor firing simultaneously Considering a high degree of parallelism the time per-formance can be improved44 Experiments

The computational power of a P system can be used not for solving small prob-lems for which we have already faster algorithms but for large and difficultproblems The main goal of our experiments is to measure the efficiency of Paccelerator in a cluster environment when it is applied to a particular problemOur experiments use the P system with active membrane described in [8] tosolve the validity problem given a Boolean formula in conjunctive normal formto determine whether or not it is a tautology If we consider the problem inputin the form andm

i=1 orki

j=1 xij where xij isin X1 Xn X1 Xn the P systemsolves the NP-complete problem of validity in 5n + 2m + 4 steps The numberof membranes increases by division from only three initial membranes to 2n + 2membranes at the end of computation This example is also of interest for parallelsimulation using dynamic task creation Different membranes can be distributedon different machines of a cluster They can evolve independently accordingly tothe evolution rules Send-in and Send-out rules request message exchanges

Based on the fact that CLIPS code is fully compatible with Jess we haverepeated the experiments reported in [8] We concentrate our attention to themost consuming part of the simulation namely after the final division when wehave already 2n + 2 membranes The number of rules to be fired is similar tothose from the classical production systems benchmarks The following tablespecifies the number of rules to be fired in the case of checking the validity of aBoolean expression with m = n

m times n Membranes Rules fired Time for Reaching Total time ofafter the last firing those the final simulationdivision rules configuration

2 times 2 6 335 1 s 1 s 2 s3 times 3 10 779 13 s 3 s 16 s4 times 4 18 1835 428 s 6 s 434 s5 times 5 34 49 s

The evaluation of time is measured on one PC of a cluster used in our testsThe cluster is composed of four PCs at 15GHz and 256Mb RAM connected viaa Myrinet switch ensuring communication at 2Gbs

We describe now how the P accelerator is working in order to assure thedistribution of the membranes and the communication between rules The Paccelerator can be activated by a user in a simple way Each Jess instancesreads the simulator rules the facts (the membrane rules to be applied) themembrane structure and their contents Each membrane is owned by a Jess

68 C Bonchis et al

instance An instance can own none one or several membranes Rules are firedby an instance only if they are associated to an owned membrane Each instancehas copies of the other instance membranes A change in the content of thefather membrane can lead to a change in the children membrane The sourcesand destinations used in the send and receive commands are related to theirmembrane owners The send and receive rules are activated only if the involvedsources and destinations have different owners

45 Running Time

It is easy to note a significant reduction of the running time even when weuse the P accelerator running on one machine of the cluster (ie Jess instancesare running on the same machine) In the following table the shorter time isunderlined for each number of Jess instances working concurrently The lowesttime depends on the dimension of the problem It seems that for a m times mproblem the lowest time is given by m Jess instances

Membranes 1 instance 2 instances 3 instances 4 instances6 1 s 1 s 3 s 3 s10 13 s 5 s 5 s 10 s18 428 s 45 s 25 s 33 s34 Memout 1054 s 325 s 200 s

Further reduction of the simulation time is expected when our P accelerator isrunning on several machines These expectations are confirmed by our tests Thespeedup Sp and the efficiency Ep of the parallel implementation are registeredin the following table the values being close to the ideal ones It is easy toremark a normal increasing of the speedup with the number of rules to be firedIt is expected to obtain even better results for larger dimension of the validityproblem

MembranesInstances Machines 6 10 18 341 1 1 s 13 s 428 s Memory out2 1 1 s 5 s 45 s 1054 s

2 1 s 3 s 23 s 528 sS2 1 17 19 2E2 051 065 095 099

3 1 3 s 5 s 25 s 325 s3 3 s 2 s 10 s 126 sS3 1 25 25 26E3 033 083 083 087

4 1 3 s 10 s 33 s 200 s4 2 s 3 s 9 s 52 sS4 15 33 37 38E4 037 082 091 096

A Web-Based P Systems Simulator and Its Parallelization 69

5 Conclusion and Further Work

We present a new simulator of the P systems It is efficient flexible and does notrequire any previous knowledge or expertise in computers Since the simulatorhas some novel and interesting features related to efficiency ease of use andgenerality it can become a useful tool for the community both theoretically andpractically Being GPL licensed we expect it is eligible to become a simulatorbenchmark reference The simulator is available at httppsystemsieatro

We intend to make the simulator available as a web service Moreover con-tinuing the commitment to standards compliance we will strive for SBML com-patibility for our specification language Further improvements are related tobetter debugging and visualization capabilities (including a flexible fine andcoarse-grained tracer) developing a library of macros and methodologies usingthe principles of modularity extensibility and structured design from softwareengineering introducing rules for the development of macros for P systems

In this paper we also present an automatic parallelization tool of the existingsequential simulators of the P systems We use a splitting technique of mem-branes in several Java threads and then we develop a P accelerator enabling thecooperation of many Jess instances running in a cluster environment to speedupa P simulator The P accelerator will be further developed to include facilities formembrane dissolution and division Further extensions are under investigation

References

1 G Ciobanu ldquoDistributed algorithms over communicating membrane systemsrdquoBioSystems vol70 123ndash133 Elsevier 2003

2 G Ciobanu W Guo ldquoP Systems Running on a Cluster of Computersrdquo in GhPaunet al (Eds) Proceedings 4th Workshop on Membrane Computing LNCS 2933123ndash139 Springer 2004

3 G Ciobanu D Paraschiv ldquoMembrane Software A P System Simulatorrdquo Funda-menta Informaticae vol49 no1-3 61ndash66 2002

4 G Ciobanu D Petcu ldquoP accelerators Parallelization of sequential simulatorsrdquo inMAGutierrez-Naranjo GhPaun MJPerez-Jimenez (Eds) Cellular Computingcomplexity aspects ESF PESC Exploratory Workshop Fenix Editora Sevilla 177-186 2005

5 CL Forgy ldquoRETE A Fast Algorithm for the Many PatternMany Object PatternMatch Problemrdquo Artificial Intelligence vol19 17ndash37 1982

6 E Friedman-Hill Jess in Action Rule-Based Systems in Java Manning Publica-tions 2003

7 Gh Paun Membrane Computing An Introduction Springer 20028 MJ Perez-Jimenez FJ Romero-Campero ldquoA CLIPS Simulator for Recognizer P

Systems with Active Membranesrdquo Proceedings 2nd Brainstorming Week on Mem-brane Computing University of Sevilla Tech Rep 012004 387-413 2004

64 C Bonchis et al

n a objects the system evolves and reaches a state with n middotm d objects in mem-brane 0 If the user wish to continue in order to compute (n+k) middotm it is enoughto inject k a objects in membrane 1 at the current state and the computationcan go on Therefore this example emphasizes a certain degree of re-usability

Recursive Sum The P system described in the next picture computes therecursive sum

sumni=1 ki

a a(0) a a(0) a a(0)

k2

k1

kn

1 2

aa

0

n

a

The numbers of a objects in the membranes 1n are the addition argumentsand the result of the computation is the number of a objects in membrane 0The PsQL query to determine this result is (count of (objects from 0))

While this example is rather trivial it illustrates the expressiveness of thequery language (PsQL) Using PsQL queries it is not necessary to apply therules and execute the specified P system Given the initial multiset the samerecursive sum is obtained by using the following query (count of (objectsfrom (membranes from 0)))

Dot Product of Two Vectors Combining the previous two examples we cancompute the dot (scalar) product x middot y of two vectors x y isin N

m where m isin NLet us denote the components of the vectors by xi and yi respectively thesecomponents are given by the number of b and a in the membranes labelled by 2iand 2i+1 respectively Then xmiddoty is given by the number of d objects obtained inmembrane 0 after the P system halts This P system is described graphically as

gt u u(2k+2)e+u b+u+d(0)

yk+1

a+v v(2k+1)a+u u(2k+1)

2k+2

a v

b+v e+v+d(0) gt v v(2k+2)

xk+1b

2k+1

b+v e+v+d(0)

y1

a+v v(1)a+u u(1)

a v

2

x1b

e+u

1

gt v gt u b+u+d(0)

v(2)u(2)

0

where k = 0 m minus 1 The PsQL query for retrieving the result is (count of(objects from 0))

A Web-Based P Systems Simulator and Its Parallelization 65

4 On Parallelization of Sequential Simulators

There will always be a need for exploiting parallelism in computing such thatmany difficult problems can be executed on parallel architectures There is also aneed to free the programmers from thinking about the parallelization of existingsequential programs Automatic parallelization of code has been an active re-search topic in scientific computing for some decades For a long period of timethe kind of attempts achieve little of the potential benefit of parallel computingRecent contributions improve the performance and efficient parallel codes havebeen created automatically to solve problems in various fields

We refer to the sequential simulators of the P systems particularly to thoseimplemented in CLIPS [8] These sequential simulators have both didactic andscientific values However the P systems are inherently parallel and in manyvariants they also exhibit an intrinsic non-determinism hard to be captured bysequential computers By simulating parallelism and nondeterminism on a se-quential machine one can lose the real power of parallelism and attractiveness ofP system computing Therefore the simulations on multiple processors representa particularly interesting subject Currently the only known parallel and clusterimplementation for P systems is presented in [2] using C++ and MPI41 Jess Java Expert System ShellJess is the abbreviation for Java Expert System Shell it is a rule-based program-ming environment for Java platforms it is available at httpherzbergcasandiagovjess More information about Jess can be found in [6] Jess usesthe RETE algorithm [5] for rules an efficient mechanism for solving the difficultmany-to-many matching problem Our strategy is to build a parallel productionsystems with a high degree of flexibility namely to construct a wrapper for theparallel system which allows cooperation between its instances From this pointof view Jess has been considered mainly due to its flexibility (communication viasockets ability to create Java objects and call Java methods) and its compatibil-ity with the C Language Interface Production System CLIPS CLIPS is availableat httpwwwghgnetclipsCLIPShtml where it is presented as a tool forbuilding expert systems Jess is also selected because of its active developmentand support tight interaction with Java programs and expressiveness

The Jess rule language includes elements not present in many other produc-tion systems such as arbitrary combinations of Boolean conjunctions and dis-junctions Its scripting language is powerful enough to generate full applicationsentirely within the Jess system Jess is also a powerful Java scripting environ-ment from which one can create Java objects and call Java methods withoutcompiling any Java code The core Jess language is fully compatible with CLIPS(Jess scripts are valid CLIPS scripts and vice-versa) Jess adds many features toCLIPS including backwards chaining working memory queries and the abilityto manipulate and directly reason about Java objects

We think to consider existing implementations and improve them by usingmultiple computing units leading to faster P system simulators than the cur-rent available ones The proposed architecture for a such system is based on an

66 C Bonchis et al

accelerator actually a wrapper allowing the cooperation between several in-stances of a program running on different computers in order to speedup thecurrent P system simulators

We intend to apply our P accelerators to WebPS As a first step we considera simpler CLIPS simulator [8] The set of rules and the configurations in eachstep of the evolution are expressed as facts in a knowledge base We first showthat a splitting technique of the membranes in several Java threads runningembedded Jess can lead to a faster simulation Then we use the P accelerator tofurther speedup the simulation

42 P Accelerators

Having in mind the parallel evolutions of its membranes based on different ruleswe build a parallel distributed memory version of a production system based ontask parallelism The target architecture is a homogeneous cluster of worksta-tions Building a Jess application based on socket communication facilities isconsidered to be difficult and can distract the user from its main aim Thereforea middleware is needed We adopt a modular scheme composed by Jess instancesConnectors and Messengers

A first component of the P accelerator is called Connector and consists of aJava code Each Jess instance has one corresponding Connector A Jess instance(acting as a client) contacts its Connector (acting as a server) via a socket Assoon as such a connection is established the Connector interprets the Jess specialincoming requests for communications and controls other Jess instances (namelysend or receive information launch or kill other instances) An information intransit is a string containing a command written in Jess language

Another component of the P accelerator is represented by the MessengersEach Messenger is associated with one Connector and its purpose is to exe-cute the commands received by Connector and to communicate with variousMessengers associated with the other Jess instances We add new commands toJess assuring a valid message passing interface More details about the set ofcommands and some other aspects related to P accelerators can be found in [4]

43 Implementation Details

A Connector uses the standard Java ServerSockets methods The current Mes-senger is written in Java and JPVM a Java implementation of Parallel VirtualMachine selected due to its ability to dynamically create and destroy tasks auseful ability when simulating the division and dissolution of membranes JPVMis available at httpwwwcsvirginiaedusimajf2jjpvmhtml Adopting aPVM variant the user is absolved of the duties to nominate the hosts were theJess instances are running as well as to treat sequentially the incoming messages(as in the case of a socket connection) or to check the status of the machineson which the Jess instances are running

Regarding CLIPS we should mention that a production system consists ina working memory a set of rules and an inference engine The working memoryis a global database of data representing the system state A rule is a condition-action pair The inference engine is based on a three-phase cyclic execution model

A Web-Based P Systems Simulator and Its Parallelization 67

of condition evaluations (matching) conflict-resolution and action firing Firingcan add delete or modify elements in the working memory An instantiationis a rule with a set of working memory elements In a sequential environmentconflict-resolution selects for firing a certain instantiation from the set of all in-stantiations In a parallel environment multiple instantiations can be selectedfor firing simultaneously Considering a high degree of parallelism the time per-formance can be improved44 Experiments

The computational power of a P system can be used not for solving small prob-lems for which we have already faster algorithms but for large and difficultproblems The main goal of our experiments is to measure the efficiency of Paccelerator in a cluster environment when it is applied to a particular problemOur experiments use the P system with active membrane described in [8] tosolve the validity problem given a Boolean formula in conjunctive normal formto determine whether or not it is a tautology If we consider the problem inputin the form andm

i=1 orki

j=1 xij where xij isin X1 Xn X1 Xn the P systemsolves the NP-complete problem of validity in 5n + 2m + 4 steps The numberof membranes increases by division from only three initial membranes to 2n + 2membranes at the end of computation This example is also of interest for parallelsimulation using dynamic task creation Different membranes can be distributedon different machines of a cluster They can evolve independently accordingly tothe evolution rules Send-in and Send-out rules request message exchanges

Based on the fact that CLIPS code is fully compatible with Jess we haverepeated the experiments reported in [8] We concentrate our attention to themost consuming part of the simulation namely after the final division when wehave already 2n + 2 membranes The number of rules to be fired is similar tothose from the classical production systems benchmarks The following tablespecifies the number of rules to be fired in the case of checking the validity of aBoolean expression with m = n

m times n Membranes Rules fired Time for Reaching Total time ofafter the last firing those the final simulationdivision rules configuration

2 times 2 6 335 1 s 1 s 2 s3 times 3 10 779 13 s 3 s 16 s4 times 4 18 1835 428 s 6 s 434 s5 times 5 34 49 s

The evaluation of time is measured on one PC of a cluster used in our testsThe cluster is composed of four PCs at 15GHz and 256Mb RAM connected viaa Myrinet switch ensuring communication at 2Gbs

We describe now how the P accelerator is working in order to assure thedistribution of the membranes and the communication between rules The Paccelerator can be activated by a user in a simple way Each Jess instancesreads the simulator rules the facts (the membrane rules to be applied) themembrane structure and their contents Each membrane is owned by a Jess

68 C Bonchis et al

instance An instance can own none one or several membranes Rules are firedby an instance only if they are associated to an owned membrane Each instancehas copies of the other instance membranes A change in the content of thefather membrane can lead to a change in the children membrane The sourcesand destinations used in the send and receive commands are related to theirmembrane owners The send and receive rules are activated only if the involvedsources and destinations have different owners

45 Running Time

It is easy to note a significant reduction of the running time even when weuse the P accelerator running on one machine of the cluster (ie Jess instancesare running on the same machine) In the following table the shorter time isunderlined for each number of Jess instances working concurrently The lowesttime depends on the dimension of the problem It seems that for a m times mproblem the lowest time is given by m Jess instances

Membranes 1 instance 2 instances 3 instances 4 instances6 1 s 1 s 3 s 3 s10 13 s 5 s 5 s 10 s18 428 s 45 s 25 s 33 s34 Memout 1054 s 325 s 200 s

Further reduction of the simulation time is expected when our P accelerator isrunning on several machines These expectations are confirmed by our tests Thespeedup Sp and the efficiency Ep of the parallel implementation are registeredin the following table the values being close to the ideal ones It is easy toremark a normal increasing of the speedup with the number of rules to be firedIt is expected to obtain even better results for larger dimension of the validityproblem

MembranesInstances Machines 6 10 18 341 1 1 s 13 s 428 s Memory out2 1 1 s 5 s 45 s 1054 s

2 1 s 3 s 23 s 528 sS2 1 17 19 2E2 051 065 095 099

3 1 3 s 5 s 25 s 325 s3 3 s 2 s 10 s 126 sS3 1 25 25 26E3 033 083 083 087

4 1 3 s 10 s 33 s 200 s4 2 s 3 s 9 s 52 sS4 15 33 37 38E4 037 082 091 096

A Web-Based P Systems Simulator and Its Parallelization 69

5 Conclusion and Further Work

We present a new simulator of the P systems It is efficient flexible and does notrequire any previous knowledge or expertise in computers Since the simulatorhas some novel and interesting features related to efficiency ease of use andgenerality it can become a useful tool for the community both theoretically andpractically Being GPL licensed we expect it is eligible to become a simulatorbenchmark reference The simulator is available at httppsystemsieatro

We intend to make the simulator available as a web service Moreover con-tinuing the commitment to standards compliance we will strive for SBML com-patibility for our specification language Further improvements are related tobetter debugging and visualization capabilities (including a flexible fine andcoarse-grained tracer) developing a library of macros and methodologies usingthe principles of modularity extensibility and structured design from softwareengineering introducing rules for the development of macros for P systems

In this paper we also present an automatic parallelization tool of the existingsequential simulators of the P systems We use a splitting technique of mem-branes in several Java threads and then we develop a P accelerator enabling thecooperation of many Jess instances running in a cluster environment to speedupa P simulator The P accelerator will be further developed to include facilities formembrane dissolution and division Further extensions are under investigation

References

1 G Ciobanu ldquoDistributed algorithms over communicating membrane systemsrdquoBioSystems vol70 123ndash133 Elsevier 2003

2 G Ciobanu W Guo ldquoP Systems Running on a Cluster of Computersrdquo in GhPaunet al (Eds) Proceedings 4th Workshop on Membrane Computing LNCS 2933123ndash139 Springer 2004

3 G Ciobanu D Paraschiv ldquoMembrane Software A P System Simulatorrdquo Funda-menta Informaticae vol49 no1-3 61ndash66 2002

4 G Ciobanu D Petcu ldquoP accelerators Parallelization of sequential simulatorsrdquo inMAGutierrez-Naranjo GhPaun MJPerez-Jimenez (Eds) Cellular Computingcomplexity aspects ESF PESC Exploratory Workshop Fenix Editora Sevilla 177-186 2005

5 CL Forgy ldquoRETE A Fast Algorithm for the Many PatternMany Object PatternMatch Problemrdquo Artificial Intelligence vol19 17ndash37 1982

6 E Friedman-Hill Jess in Action Rule-Based Systems in Java Manning Publica-tions 2003

7 Gh Paun Membrane Computing An Introduction Springer 20028 MJ Perez-Jimenez FJ Romero-Campero ldquoA CLIPS Simulator for Recognizer P

Systems with Active Membranesrdquo Proceedings 2nd Brainstorming Week on Mem-brane Computing University of Sevilla Tech Rep 012004 387-413 2004

A Web-Based P Systems Simulator and Its Parallelization 65

4 On Parallelization of Sequential Simulators

There will always be a need for exploiting parallelism in computing such thatmany difficult problems can be executed on parallel architectures There is also aneed to free the programmers from thinking about the parallelization of existingsequential programs Automatic parallelization of code has been an active re-search topic in scientific computing for some decades For a long period of timethe kind of attempts achieve little of the potential benefit of parallel computingRecent contributions improve the performance and efficient parallel codes havebeen created automatically to solve problems in various fields

We refer to the sequential simulators of the P systems particularly to thoseimplemented in CLIPS [8] These sequential simulators have both didactic andscientific values However the P systems are inherently parallel and in manyvariants they also exhibit an intrinsic non-determinism hard to be captured bysequential computers By simulating parallelism and nondeterminism on a se-quential machine one can lose the real power of parallelism and attractiveness ofP system computing Therefore the simulations on multiple processors representa particularly interesting subject Currently the only known parallel and clusterimplementation for P systems is presented in [2] using C++ and MPI41 Jess Java Expert System ShellJess is the abbreviation for Java Expert System Shell it is a rule-based program-ming environment for Java platforms it is available at httpherzbergcasandiagovjess More information about Jess can be found in [6] Jess usesthe RETE algorithm [5] for rules an efficient mechanism for solving the difficultmany-to-many matching problem Our strategy is to build a parallel productionsystems with a high degree of flexibility namely to construct a wrapper for theparallel system which allows cooperation between its instances From this pointof view Jess has been considered mainly due to its flexibility (communication viasockets ability to create Java objects and call Java methods) and its compatibil-ity with the C Language Interface Production System CLIPS CLIPS is availableat httpwwwghgnetclipsCLIPShtml where it is presented as a tool forbuilding expert systems Jess is also selected because of its active developmentand support tight interaction with Java programs and expressiveness

The Jess rule language includes elements not present in many other produc-tion systems such as arbitrary combinations of Boolean conjunctions and dis-junctions Its scripting language is powerful enough to generate full applicationsentirely within the Jess system Jess is also a powerful Java scripting environ-ment from which one can create Java objects and call Java methods withoutcompiling any Java code The core Jess language is fully compatible with CLIPS(Jess scripts are valid CLIPS scripts and vice-versa) Jess adds many features toCLIPS including backwards chaining working memory queries and the abilityto manipulate and directly reason about Java objects

We think to consider existing implementations and improve them by usingmultiple computing units leading to faster P system simulators than the cur-rent available ones The proposed architecture for a such system is based on an

66 C Bonchis et al

accelerator actually a wrapper allowing the cooperation between several in-stances of a program running on different computers in order to speedup thecurrent P system simulators

We intend to apply our P accelerators to WebPS As a first step we considera simpler CLIPS simulator [8] The set of rules and the configurations in eachstep of the evolution are expressed as facts in a knowledge base We first showthat a splitting technique of the membranes in several Java threads runningembedded Jess can lead to a faster simulation Then we use the P accelerator tofurther speedup the simulation

42 P Accelerators

Having in mind the parallel evolutions of its membranes based on different ruleswe build a parallel distributed memory version of a production system based ontask parallelism The target architecture is a homogeneous cluster of worksta-tions Building a Jess application based on socket communication facilities isconsidered to be difficult and can distract the user from its main aim Thereforea middleware is needed We adopt a modular scheme composed by Jess instancesConnectors and Messengers

A first component of the P accelerator is called Connector and consists of aJava code Each Jess instance has one corresponding Connector A Jess instance(acting as a client) contacts its Connector (acting as a server) via a socket Assoon as such a connection is established the Connector interprets the Jess specialincoming requests for communications and controls other Jess instances (namelysend or receive information launch or kill other instances) An information intransit is a string containing a command written in Jess language

Another component of the P accelerator is represented by the MessengersEach Messenger is associated with one Connector and its purpose is to exe-cute the commands received by Connector and to communicate with variousMessengers associated with the other Jess instances We add new commands toJess assuring a valid message passing interface More details about the set ofcommands and some other aspects related to P accelerators can be found in [4]

43 Implementation Details

A Connector uses the standard Java ServerSockets methods The current Mes-senger is written in Java and JPVM a Java implementation of Parallel VirtualMachine selected due to its ability to dynamically create and destroy tasks auseful ability when simulating the division and dissolution of membranes JPVMis available at httpwwwcsvirginiaedusimajf2jjpvmhtml Adopting aPVM variant the user is absolved of the duties to nominate the hosts were theJess instances are running as well as to treat sequentially the incoming messages(as in the case of a socket connection) or to check the status of the machineson which the Jess instances are running

Regarding CLIPS we should mention that a production system consists ina working memory a set of rules and an inference engine The working memoryis a global database of data representing the system state A rule is a condition-action pair The inference engine is based on a three-phase cyclic execution model

A Web-Based P Systems Simulator and Its Parallelization 67

of condition evaluations (matching) conflict-resolution and action firing Firingcan add delete or modify elements in the working memory An instantiationis a rule with a set of working memory elements In a sequential environmentconflict-resolution selects for firing a certain instantiation from the set of all in-stantiations In a parallel environment multiple instantiations can be selectedfor firing simultaneously Considering a high degree of parallelism the time per-formance can be improved44 Experiments

The computational power of a P system can be used not for solving small prob-lems for which we have already faster algorithms but for large and difficultproblems The main goal of our experiments is to measure the efficiency of Paccelerator in a cluster environment when it is applied to a particular problemOur experiments use the P system with active membrane described in [8] tosolve the validity problem given a Boolean formula in conjunctive normal formto determine whether or not it is a tautology If we consider the problem inputin the form andm

i=1 orki

j=1 xij where xij isin X1 Xn X1 Xn the P systemsolves the NP-complete problem of validity in 5n + 2m + 4 steps The numberof membranes increases by division from only three initial membranes to 2n + 2membranes at the end of computation This example is also of interest for parallelsimulation using dynamic task creation Different membranes can be distributedon different machines of a cluster They can evolve independently accordingly tothe evolution rules Send-in and Send-out rules request message exchanges

Based on the fact that CLIPS code is fully compatible with Jess we haverepeated the experiments reported in [8] We concentrate our attention to themost consuming part of the simulation namely after the final division when wehave already 2n + 2 membranes The number of rules to be fired is similar tothose from the classical production systems benchmarks The following tablespecifies the number of rules to be fired in the case of checking the validity of aBoolean expression with m = n

m times n Membranes Rules fired Time for Reaching Total time ofafter the last firing those the final simulationdivision rules configuration

2 times 2 6 335 1 s 1 s 2 s3 times 3 10 779 13 s 3 s 16 s4 times 4 18 1835 428 s 6 s 434 s5 times 5 34 49 s

The evaluation of time is measured on one PC of a cluster used in our testsThe cluster is composed of four PCs at 15GHz and 256Mb RAM connected viaa Myrinet switch ensuring communication at 2Gbs

We describe now how the P accelerator is working in order to assure thedistribution of the membranes and the communication between rules The Paccelerator can be activated by a user in a simple way Each Jess instancesreads the simulator rules the facts (the membrane rules to be applied) themembrane structure and their contents Each membrane is owned by a Jess

68 C Bonchis et al

instance An instance can own none one or several membranes Rules are firedby an instance only if they are associated to an owned membrane Each instancehas copies of the other instance membranes A change in the content of thefather membrane can lead to a change in the children membrane The sourcesand destinations used in the send and receive commands are related to theirmembrane owners The send and receive rules are activated only if the involvedsources and destinations have different owners

45 Running Time

It is easy to note a significant reduction of the running time even when weuse the P accelerator running on one machine of the cluster (ie Jess instancesare running on the same machine) In the following table the shorter time isunderlined for each number of Jess instances working concurrently The lowesttime depends on the dimension of the problem It seems that for a m times mproblem the lowest time is given by m Jess instances

Membranes 1 instance 2 instances 3 instances 4 instances6 1 s 1 s 3 s 3 s10 13 s 5 s 5 s 10 s18 428 s 45 s 25 s 33 s34 Memout 1054 s 325 s 200 s

Further reduction of the simulation time is expected when our P accelerator isrunning on several machines These expectations are confirmed by our tests Thespeedup Sp and the efficiency Ep of the parallel implementation are registeredin the following table the values being close to the ideal ones It is easy toremark a normal increasing of the speedup with the number of rules to be firedIt is expected to obtain even better results for larger dimension of the validityproblem

MembranesInstances Machines 6 10 18 341 1 1 s 13 s 428 s Memory out2 1 1 s 5 s 45 s 1054 s

2 1 s 3 s 23 s 528 sS2 1 17 19 2E2 051 065 095 099

3 1 3 s 5 s 25 s 325 s3 3 s 2 s 10 s 126 sS3 1 25 25 26E3 033 083 083 087

4 1 3 s 10 s 33 s 200 s4 2 s 3 s 9 s 52 sS4 15 33 37 38E4 037 082 091 096

A Web-Based P Systems Simulator and Its Parallelization 69

5 Conclusion and Further Work

We present a new simulator of the P systems It is efficient flexible and does notrequire any previous knowledge or expertise in computers Since the simulatorhas some novel and interesting features related to efficiency ease of use andgenerality it can become a useful tool for the community both theoretically andpractically Being GPL licensed we expect it is eligible to become a simulatorbenchmark reference The simulator is available at httppsystemsieatro

We intend to make the simulator available as a web service Moreover con-tinuing the commitment to standards compliance we will strive for SBML com-patibility for our specification language Further improvements are related tobetter debugging and visualization capabilities (including a flexible fine andcoarse-grained tracer) developing a library of macros and methodologies usingthe principles of modularity extensibility and structured design from softwareengineering introducing rules for the development of macros for P systems

In this paper we also present an automatic parallelization tool of the existingsequential simulators of the P systems We use a splitting technique of mem-branes in several Java threads and then we develop a P accelerator enabling thecooperation of many Jess instances running in a cluster environment to speedupa P simulator The P accelerator will be further developed to include facilities formembrane dissolution and division Further extensions are under investigation

References

1 G Ciobanu ldquoDistributed algorithms over communicating membrane systemsrdquoBioSystems vol70 123ndash133 Elsevier 2003

2 G Ciobanu W Guo ldquoP Systems Running on a Cluster of Computersrdquo in GhPaunet al (Eds) Proceedings 4th Workshop on Membrane Computing LNCS 2933123ndash139 Springer 2004

3 G Ciobanu D Paraschiv ldquoMembrane Software A P System Simulatorrdquo Funda-menta Informaticae vol49 no1-3 61ndash66 2002

4 G Ciobanu D Petcu ldquoP accelerators Parallelization of sequential simulatorsrdquo inMAGutierrez-Naranjo GhPaun MJPerez-Jimenez (Eds) Cellular Computingcomplexity aspects ESF PESC Exploratory Workshop Fenix Editora Sevilla 177-186 2005

5 CL Forgy ldquoRETE A Fast Algorithm for the Many PatternMany Object PatternMatch Problemrdquo Artificial Intelligence vol19 17ndash37 1982

6 E Friedman-Hill Jess in Action Rule-Based Systems in Java Manning Publica-tions 2003

7 Gh Paun Membrane Computing An Introduction Springer 20028 MJ Perez-Jimenez FJ Romero-Campero ldquoA CLIPS Simulator for Recognizer P

Systems with Active Membranesrdquo Proceedings 2nd Brainstorming Week on Mem-brane Computing University of Sevilla Tech Rep 012004 387-413 2004

66 C Bonchis et al

accelerator actually a wrapper allowing the cooperation between several in-stances of a program running on different computers in order to speedup thecurrent P system simulators

We intend to apply our P accelerators to WebPS As a first step we considera simpler CLIPS simulator [8] The set of rules and the configurations in eachstep of the evolution are expressed as facts in a knowledge base We first showthat a splitting technique of the membranes in several Java threads runningembedded Jess can lead to a faster simulation Then we use the P accelerator tofurther speedup the simulation

42 P Accelerators

Having in mind the parallel evolutions of its membranes based on different ruleswe build a parallel distributed memory version of a production system based ontask parallelism The target architecture is a homogeneous cluster of worksta-tions Building a Jess application based on socket communication facilities isconsidered to be difficult and can distract the user from its main aim Thereforea middleware is needed We adopt a modular scheme composed by Jess instancesConnectors and Messengers

A first component of the P accelerator is called Connector and consists of aJava code Each Jess instance has one corresponding Connector A Jess instance(acting as a client) contacts its Connector (acting as a server) via a socket Assoon as such a connection is established the Connector interprets the Jess specialincoming requests for communications and controls other Jess instances (namelysend or receive information launch or kill other instances) An information intransit is a string containing a command written in Jess language

Another component of the P accelerator is represented by the MessengersEach Messenger is associated with one Connector and its purpose is to exe-cute the commands received by Connector and to communicate with variousMessengers associated with the other Jess instances We add new commands toJess assuring a valid message passing interface More details about the set ofcommands and some other aspects related to P accelerators can be found in [4]

43 Implementation Details

A Connector uses the standard Java ServerSockets methods The current Mes-senger is written in Java and JPVM a Java implementation of Parallel VirtualMachine selected due to its ability to dynamically create and destroy tasks auseful ability when simulating the division and dissolution of membranes JPVMis available at httpwwwcsvirginiaedusimajf2jjpvmhtml Adopting aPVM variant the user is absolved of the duties to nominate the hosts were theJess instances are running as well as to treat sequentially the incoming messages(as in the case of a socket connection) or to check the status of the machineson which the Jess instances are running

Regarding CLIPS we should mention that a production system consists ina working memory a set of rules and an inference engine The working memoryis a global database of data representing the system state A rule is a condition-action pair The inference engine is based on a three-phase cyclic execution model

A Web-Based P Systems Simulator and Its Parallelization 67

of condition evaluations (matching) conflict-resolution and action firing Firingcan add delete or modify elements in the working memory An instantiationis a rule with a set of working memory elements In a sequential environmentconflict-resolution selects for firing a certain instantiation from the set of all in-stantiations In a parallel environment multiple instantiations can be selectedfor firing simultaneously Considering a high degree of parallelism the time per-formance can be improved44 Experiments

The computational power of a P system can be used not for solving small prob-lems for which we have already faster algorithms but for large and difficultproblems The main goal of our experiments is to measure the efficiency of Paccelerator in a cluster environment when it is applied to a particular problemOur experiments use the P system with active membrane described in [8] tosolve the validity problem given a Boolean formula in conjunctive normal formto determine whether or not it is a tautology If we consider the problem inputin the form andm

i=1 orki

j=1 xij where xij isin X1 Xn X1 Xn the P systemsolves the NP-complete problem of validity in 5n + 2m + 4 steps The numberof membranes increases by division from only three initial membranes to 2n + 2membranes at the end of computation This example is also of interest for parallelsimulation using dynamic task creation Different membranes can be distributedon different machines of a cluster They can evolve independently accordingly tothe evolution rules Send-in and Send-out rules request message exchanges

Based on the fact that CLIPS code is fully compatible with Jess we haverepeated the experiments reported in [8] We concentrate our attention to themost consuming part of the simulation namely after the final division when wehave already 2n + 2 membranes The number of rules to be fired is similar tothose from the classical production systems benchmarks The following tablespecifies the number of rules to be fired in the case of checking the validity of aBoolean expression with m = n

m times n Membranes Rules fired Time for Reaching Total time ofafter the last firing those the final simulationdivision rules configuration

2 times 2 6 335 1 s 1 s 2 s3 times 3 10 779 13 s 3 s 16 s4 times 4 18 1835 428 s 6 s 434 s5 times 5 34 49 s

The evaluation of time is measured on one PC of a cluster used in our testsThe cluster is composed of four PCs at 15GHz and 256Mb RAM connected viaa Myrinet switch ensuring communication at 2Gbs

We describe now how the P accelerator is working in order to assure thedistribution of the membranes and the communication between rules The Paccelerator can be activated by a user in a simple way Each Jess instancesreads the simulator rules the facts (the membrane rules to be applied) themembrane structure and their contents Each membrane is owned by a Jess

68 C Bonchis et al

instance An instance can own none one or several membranes Rules are firedby an instance only if they are associated to an owned membrane Each instancehas copies of the other instance membranes A change in the content of thefather membrane can lead to a change in the children membrane The sourcesand destinations used in the send and receive commands are related to theirmembrane owners The send and receive rules are activated only if the involvedsources and destinations have different owners

45 Running Time

It is easy to note a significant reduction of the running time even when weuse the P accelerator running on one machine of the cluster (ie Jess instancesare running on the same machine) In the following table the shorter time isunderlined for each number of Jess instances working concurrently The lowesttime depends on the dimension of the problem It seems that for a m times mproblem the lowest time is given by m Jess instances

Membranes 1 instance 2 instances 3 instances 4 instances6 1 s 1 s 3 s 3 s10 13 s 5 s 5 s 10 s18 428 s 45 s 25 s 33 s34 Memout 1054 s 325 s 200 s

Further reduction of the simulation time is expected when our P accelerator isrunning on several machines These expectations are confirmed by our tests Thespeedup Sp and the efficiency Ep of the parallel implementation are registeredin the following table the values being close to the ideal ones It is easy toremark a normal increasing of the speedup with the number of rules to be firedIt is expected to obtain even better results for larger dimension of the validityproblem

MembranesInstances Machines 6 10 18 341 1 1 s 13 s 428 s Memory out2 1 1 s 5 s 45 s 1054 s

2 1 s 3 s 23 s 528 sS2 1 17 19 2E2 051 065 095 099

3 1 3 s 5 s 25 s 325 s3 3 s 2 s 10 s 126 sS3 1 25 25 26E3 033 083 083 087

4 1 3 s 10 s 33 s 200 s4 2 s 3 s 9 s 52 sS4 15 33 37 38E4 037 082 091 096

A Web-Based P Systems Simulator and Its Parallelization 69

5 Conclusion and Further Work

We present a new simulator of the P systems It is efficient flexible and does notrequire any previous knowledge or expertise in computers Since the simulatorhas some novel and interesting features related to efficiency ease of use andgenerality it can become a useful tool for the community both theoretically andpractically Being GPL licensed we expect it is eligible to become a simulatorbenchmark reference The simulator is available at httppsystemsieatro

We intend to make the simulator available as a web service Moreover con-tinuing the commitment to standards compliance we will strive for SBML com-patibility for our specification language Further improvements are related tobetter debugging and visualization capabilities (including a flexible fine andcoarse-grained tracer) developing a library of macros and methodologies usingthe principles of modularity extensibility and structured design from softwareengineering introducing rules for the development of macros for P systems

In this paper we also present an automatic parallelization tool of the existingsequential simulators of the P systems We use a splitting technique of mem-branes in several Java threads and then we develop a P accelerator enabling thecooperation of many Jess instances running in a cluster environment to speedupa P simulator The P accelerator will be further developed to include facilities formembrane dissolution and division Further extensions are under investigation

References

1 G Ciobanu ldquoDistributed algorithms over communicating membrane systemsrdquoBioSystems vol70 123ndash133 Elsevier 2003

2 G Ciobanu W Guo ldquoP Systems Running on a Cluster of Computersrdquo in GhPaunet al (Eds) Proceedings 4th Workshop on Membrane Computing LNCS 2933123ndash139 Springer 2004

3 G Ciobanu D Paraschiv ldquoMembrane Software A P System Simulatorrdquo Funda-menta Informaticae vol49 no1-3 61ndash66 2002

4 G Ciobanu D Petcu ldquoP accelerators Parallelization of sequential simulatorsrdquo inMAGutierrez-Naranjo GhPaun MJPerez-Jimenez (Eds) Cellular Computingcomplexity aspects ESF PESC Exploratory Workshop Fenix Editora Sevilla 177-186 2005

5 CL Forgy ldquoRETE A Fast Algorithm for the Many PatternMany Object PatternMatch Problemrdquo Artificial Intelligence vol19 17ndash37 1982

6 E Friedman-Hill Jess in Action Rule-Based Systems in Java Manning Publica-tions 2003

7 Gh Paun Membrane Computing An Introduction Springer 20028 MJ Perez-Jimenez FJ Romero-Campero ldquoA CLIPS Simulator for Recognizer P

Systems with Active Membranesrdquo Proceedings 2nd Brainstorming Week on Mem-brane Computing University of Sevilla Tech Rep 012004 387-413 2004

A Web-Based P Systems Simulator and Its Parallelization 67

of condition evaluations (matching) conflict-resolution and action firing Firingcan add delete or modify elements in the working memory An instantiationis a rule with a set of working memory elements In a sequential environmentconflict-resolution selects for firing a certain instantiation from the set of all in-stantiations In a parallel environment multiple instantiations can be selectedfor firing simultaneously Considering a high degree of parallelism the time per-formance can be improved44 Experiments

The computational power of a P system can be used not for solving small prob-lems for which we have already faster algorithms but for large and difficultproblems The main goal of our experiments is to measure the efficiency of Paccelerator in a cluster environment when it is applied to a particular problemOur experiments use the P system with active membrane described in [8] tosolve the validity problem given a Boolean formula in conjunctive normal formto determine whether or not it is a tautology If we consider the problem inputin the form andm

i=1 orki

j=1 xij where xij isin X1 Xn X1 Xn the P systemsolves the NP-complete problem of validity in 5n + 2m + 4 steps The numberof membranes increases by division from only three initial membranes to 2n + 2membranes at the end of computation This example is also of interest for parallelsimulation using dynamic task creation Different membranes can be distributedon different machines of a cluster They can evolve independently accordingly tothe evolution rules Send-in and Send-out rules request message exchanges

Based on the fact that CLIPS code is fully compatible with Jess we haverepeated the experiments reported in [8] We concentrate our attention to themost consuming part of the simulation namely after the final division when wehave already 2n + 2 membranes The number of rules to be fired is similar tothose from the classical production systems benchmarks The following tablespecifies the number of rules to be fired in the case of checking the validity of aBoolean expression with m = n

m times n Membranes Rules fired Time for Reaching Total time ofafter the last firing those the final simulationdivision rules configuration

2 times 2 6 335 1 s 1 s 2 s3 times 3 10 779 13 s 3 s 16 s4 times 4 18 1835 428 s 6 s 434 s5 times 5 34 49 s

The evaluation of time is measured on one PC of a cluster used in our testsThe cluster is composed of four PCs at 15GHz and 256Mb RAM connected viaa Myrinet switch ensuring communication at 2Gbs

We describe now how the P accelerator is working in order to assure thedistribution of the membranes and the communication between rules The Paccelerator can be activated by a user in a simple way Each Jess instancesreads the simulator rules the facts (the membrane rules to be applied) themembrane structure and their contents Each membrane is owned by a Jess

68 C Bonchis et al

instance An instance can own none one or several membranes Rules are firedby an instance only if they are associated to an owned membrane Each instancehas copies of the other instance membranes A change in the content of thefather membrane can lead to a change in the children membrane The sourcesand destinations used in the send and receive commands are related to theirmembrane owners The send and receive rules are activated only if the involvedsources and destinations have different owners

45 Running Time

It is easy to note a significant reduction of the running time even when weuse the P accelerator running on one machine of the cluster (ie Jess instancesare running on the same machine) In the following table the shorter time isunderlined for each number of Jess instances working concurrently The lowesttime depends on the dimension of the problem It seems that for a m times mproblem the lowest time is given by m Jess instances

Membranes 1 instance 2 instances 3 instances 4 instances6 1 s 1 s 3 s 3 s10 13 s 5 s 5 s 10 s18 428 s 45 s 25 s 33 s34 Memout 1054 s 325 s 200 s

Further reduction of the simulation time is expected when our P accelerator isrunning on several machines These expectations are confirmed by our tests Thespeedup Sp and the efficiency Ep of the parallel implementation are registeredin the following table the values being close to the ideal ones It is easy toremark a normal increasing of the speedup with the number of rules to be firedIt is expected to obtain even better results for larger dimension of the validityproblem

MembranesInstances Machines 6 10 18 341 1 1 s 13 s 428 s Memory out2 1 1 s 5 s 45 s 1054 s

2 1 s 3 s 23 s 528 sS2 1 17 19 2E2 051 065 095 099

3 1 3 s 5 s 25 s 325 s3 3 s 2 s 10 s 126 sS3 1 25 25 26E3 033 083 083 087

4 1 3 s 10 s 33 s 200 s4 2 s 3 s 9 s 52 sS4 15 33 37 38E4 037 082 091 096

A Web-Based P Systems Simulator and Its Parallelization 69

5 Conclusion and Further Work

We present a new simulator of the P systems It is efficient flexible and does notrequire any previous knowledge or expertise in computers Since the simulatorhas some novel and interesting features related to efficiency ease of use andgenerality it can become a useful tool for the community both theoretically andpractically Being GPL licensed we expect it is eligible to become a simulatorbenchmark reference The simulator is available at httppsystemsieatro

We intend to make the simulator available as a web service Moreover con-tinuing the commitment to standards compliance we will strive for SBML com-patibility for our specification language Further improvements are related tobetter debugging and visualization capabilities (including a flexible fine andcoarse-grained tracer) developing a library of macros and methodologies usingthe principles of modularity extensibility and structured design from softwareengineering introducing rules for the development of macros for P systems

In this paper we also present an automatic parallelization tool of the existingsequential simulators of the P systems We use a splitting technique of mem-branes in several Java threads and then we develop a P accelerator enabling thecooperation of many Jess instances running in a cluster environment to speedupa P simulator The P accelerator will be further developed to include facilities formembrane dissolution and division Further extensions are under investigation

References

1 G Ciobanu ldquoDistributed algorithms over communicating membrane systemsrdquoBioSystems vol70 123ndash133 Elsevier 2003

2 G Ciobanu W Guo ldquoP Systems Running on a Cluster of Computersrdquo in GhPaunet al (Eds) Proceedings 4th Workshop on Membrane Computing LNCS 2933123ndash139 Springer 2004

3 G Ciobanu D Paraschiv ldquoMembrane Software A P System Simulatorrdquo Funda-menta Informaticae vol49 no1-3 61ndash66 2002

4 G Ciobanu D Petcu ldquoP accelerators Parallelization of sequential simulatorsrdquo inMAGutierrez-Naranjo GhPaun MJPerez-Jimenez (Eds) Cellular Computingcomplexity aspects ESF PESC Exploratory Workshop Fenix Editora Sevilla 177-186 2005

5 CL Forgy ldquoRETE A Fast Algorithm for the Many PatternMany Object PatternMatch Problemrdquo Artificial Intelligence vol19 17ndash37 1982

6 E Friedman-Hill Jess in Action Rule-Based Systems in Java Manning Publica-tions 2003

7 Gh Paun Membrane Computing An Introduction Springer 20028 MJ Perez-Jimenez FJ Romero-Campero ldquoA CLIPS Simulator for Recognizer P

Systems with Active Membranesrdquo Proceedings 2nd Brainstorming Week on Mem-brane Computing University of Sevilla Tech Rep 012004 387-413 2004

68 C Bonchis et al

instance An instance can own none one or several membranes Rules are firedby an instance only if they are associated to an owned membrane Each instancehas copies of the other instance membranes A change in the content of thefather membrane can lead to a change in the children membrane The sourcesand destinations used in the send and receive commands are related to theirmembrane owners The send and receive rules are activated only if the involvedsources and destinations have different owners

45 Running Time

It is easy to note a significant reduction of the running time even when weuse the P accelerator running on one machine of the cluster (ie Jess instancesare running on the same machine) In the following table the shorter time isunderlined for each number of Jess instances working concurrently The lowesttime depends on the dimension of the problem It seems that for a m times mproblem the lowest time is given by m Jess instances

Membranes 1 instance 2 instances 3 instances 4 instances6 1 s 1 s 3 s 3 s10 13 s 5 s 5 s 10 s18 428 s 45 s 25 s 33 s34 Memout 1054 s 325 s 200 s

Further reduction of the simulation time is expected when our P accelerator isrunning on several machines These expectations are confirmed by our tests Thespeedup Sp and the efficiency Ep of the parallel implementation are registeredin the following table the values being close to the ideal ones It is easy toremark a normal increasing of the speedup with the number of rules to be firedIt is expected to obtain even better results for larger dimension of the validityproblem

MembranesInstances Machines 6 10 18 341 1 1 s 13 s 428 s Memory out2 1 1 s 5 s 45 s 1054 s

2 1 s 3 s 23 s 528 sS2 1 17 19 2E2 051 065 095 099

3 1 3 s 5 s 25 s 325 s3 3 s 2 s 10 s 126 sS3 1 25 25 26E3 033 083 083 087

4 1 3 s 10 s 33 s 200 s4 2 s 3 s 9 s 52 sS4 15 33 37 38E4 037 082 091 096

A Web-Based P Systems Simulator and Its Parallelization 69

5 Conclusion and Further Work

We present a new simulator of the P systems It is efficient flexible and does notrequire any previous knowledge or expertise in computers Since the simulatorhas some novel and interesting features related to efficiency ease of use andgenerality it can become a useful tool for the community both theoretically andpractically Being GPL licensed we expect it is eligible to become a simulatorbenchmark reference The simulator is available at httppsystemsieatro

We intend to make the simulator available as a web service Moreover con-tinuing the commitment to standards compliance we will strive for SBML com-patibility for our specification language Further improvements are related tobetter debugging and visualization capabilities (including a flexible fine andcoarse-grained tracer) developing a library of macros and methodologies usingthe principles of modularity extensibility and structured design from softwareengineering introducing rules for the development of macros for P systems

In this paper we also present an automatic parallelization tool of the existingsequential simulators of the P systems We use a splitting technique of mem-branes in several Java threads and then we develop a P accelerator enabling thecooperation of many Jess instances running in a cluster environment to speedupa P simulator The P accelerator will be further developed to include facilities formembrane dissolution and division Further extensions are under investigation

References

1 G Ciobanu ldquoDistributed algorithms over communicating membrane systemsrdquoBioSystems vol70 123ndash133 Elsevier 2003

2 G Ciobanu W Guo ldquoP Systems Running on a Cluster of Computersrdquo in GhPaunet al (Eds) Proceedings 4th Workshop on Membrane Computing LNCS 2933123ndash139 Springer 2004

3 G Ciobanu D Paraschiv ldquoMembrane Software A P System Simulatorrdquo Funda-menta Informaticae vol49 no1-3 61ndash66 2002

4 G Ciobanu D Petcu ldquoP accelerators Parallelization of sequential simulatorsrdquo inMAGutierrez-Naranjo GhPaun MJPerez-Jimenez (Eds) Cellular Computingcomplexity aspects ESF PESC Exploratory Workshop Fenix Editora Sevilla 177-186 2005

5 CL Forgy ldquoRETE A Fast Algorithm for the Many PatternMany Object PatternMatch Problemrdquo Artificial Intelligence vol19 17ndash37 1982

6 E Friedman-Hill Jess in Action Rule-Based Systems in Java Manning Publica-tions 2003

7 Gh Paun Membrane Computing An Introduction Springer 20028 MJ Perez-Jimenez FJ Romero-Campero ldquoA CLIPS Simulator for Recognizer P

Systems with Active Membranesrdquo Proceedings 2nd Brainstorming Week on Mem-brane Computing University of Sevilla Tech Rep 012004 387-413 2004

A Web-Based P Systems Simulator and Its Parallelization 69

5 Conclusion and Further Work

We present a new simulator of the P systems It is efficient flexible and does notrequire any previous knowledge or expertise in computers Since the simulatorhas some novel and interesting features related to efficiency ease of use andgenerality it can become a useful tool for the community both theoretically andpractically Being GPL licensed we expect it is eligible to become a simulatorbenchmark reference The simulator is available at httppsystemsieatro

We intend to make the simulator available as a web service Moreover con-tinuing the commitment to standards compliance we will strive for SBML com-patibility for our specification language Further improvements are related tobetter debugging and visualization capabilities (including a flexible fine andcoarse-grained tracer) developing a library of macros and methodologies usingthe principles of modularity extensibility and structured design from softwareengineering introducing rules for the development of macros for P systems

In this paper we also present an automatic parallelization tool of the existingsequential simulators of the P systems We use a splitting technique of mem-branes in several Java threads and then we develop a P accelerator enabling thecooperation of many Jess instances running in a cluster environment to speedupa P simulator The P accelerator will be further developed to include facilities formembrane dissolution and division Further extensions are under investigation

References

1 G Ciobanu ldquoDistributed algorithms over communicating membrane systemsrdquoBioSystems vol70 123ndash133 Elsevier 2003

2 G Ciobanu W Guo ldquoP Systems Running on a Cluster of Computersrdquo in GhPaunet al (Eds) Proceedings 4th Workshop on Membrane Computing LNCS 2933123ndash139 Springer 2004

3 G Ciobanu D Paraschiv ldquoMembrane Software A P System Simulatorrdquo Funda-menta Informaticae vol49 no1-3 61ndash66 2002

4 G Ciobanu D Petcu ldquoP accelerators Parallelization of sequential simulatorsrdquo inMAGutierrez-Naranjo GhPaun MJPerez-Jimenez (Eds) Cellular Computingcomplexity aspects ESF PESC Exploratory Workshop Fenix Editora Sevilla 177-186 2005

5 CL Forgy ldquoRETE A Fast Algorithm for the Many PatternMany Object PatternMatch Problemrdquo Artificial Intelligence vol19 17ndash37 1982

6 E Friedman-Hill Jess in Action Rule-Based Systems in Java Manning Publica-tions 2003

7 Gh Paun Membrane Computing An Introduction Springer 20028 MJ Perez-Jimenez FJ Romero-Campero ldquoA CLIPS Simulator for Recognizer P

Systems with Active Membranesrdquo Proceedings 2nd Brainstorming Week on Mem-brane Computing University of Sevilla Tech Rep 012004 387-413 2004