Towards Design and Implementation it should support the user with a 'well{known' syntax and should allow including funcof Concurrent Fuzzy Systems with PCN (C-like) tions from other languages (C or Fortran). At C. Geiger1 & B. Kaltho & G. Lehrenfeld Department of Mathematics and Computer Science University of Paderborn D-33095 Paderborn, Germany fcgei,bodo,
[email protected]
Abstract In this paper we present the prototyp of a Fuzzy{Library for the concurrent programming language PCN [3]. PCN (Parallel Composition Language) is based on parallel logic programming(like Strand) and allows an easy formulation of parallel programs which can be executed on a heterogenous processor network. From our point of view this combination of Fuzzy Logic with parallelism oers at least two advantages: The parallel excecution of large Fuzzy rule based systems is much faster than the sequential case. This is due to the inherent parallelism which underlies such rule bases and the used inference mechanism. Additionally, the descriptive power of PCN allows an easy formulation of asynchronous systems, e.g. Petri nets. By this we get the basis of a modeling tool for rapid prototyping of such systems in which the system description (by the program) and the system simulation (by the excecution of the program) are carried out in a common environment. We motivate these advantages by processing a rule base consisting of about 10.000 rule tests and by modeling concepts of Fuzzy Petri nets.
Introduction The ecient design of complex systems (e.g. in the CIM{area) is a dicult undertaking and many approaches try to deal with the arising problems. An environment which should aid the user in designing such systems requires a certain amount of intelligence for this task in order to handle the underlying knowledge which is often uncertain, incomplete or partial inconsistent. Additional aspects are the high complexity which arises when these systems are described exactly and the consideration of dynamic parts of the system which may act concurrently (e.g. machines in a exible manufacturing system). This leads to the demand for a language which can easily handle descriptions of complex systems, uncertain data and dynamic process behaviour in an ecent way. Moreover, 1 Supportedby DFG-Graduiertenkolleg \Parallele Rechnernetzwerke in der Produktionstechnik", ME 872/4-1.
least it should be easy to execute written programs on several multi{processor architectures (even on workstation clusters) in order to be as exible as possible to most users. We think that PCN is a good candidate for such a language and that a Fuzzy{library for PCN is a promising concept for the design of complex fuzzy systems. The declarative notation allows ecient modeling, the including of C-source code is provided and PCN runs on a wide range of multi{ processor networks. With the use of the Fuzzy{ library many real world problems could be tackled eciently. The term concurrent is used with two dierent meanings in this paper. On the one hand the natural parallelism in real physical systems has to be modeled, on the other the parallel execution of a modeled system is of interest. Thus we have to consider the fact that the simulation of a concurrent model can done sequentially as well as concurrently. One essential quality of physical systems is the natural existing concurrency of single components and the interaction between them. A good language which models these systems must be able to represent this concurrency in the same way as it is present in reality. One method of validating models of real system is simulation which can be done on sequential or parallel computers. Due to the fact that parallel computers become more and more available the importance of the following advantages of parallel simulations become obvious. Firstly, the indeterminism of real systems can be represented in a fair and simple way. This can be done on sequential computers only with an increased simulation overhead. Secondly, we have a decreasing simulation time by the use of parallel computing. This is an important point because highly complex systems consists of a number of parameters and rules for describing system behavior.
PCN (Parallel Composition Notation) PCN has been developed at Caltech and Argonne National Labs [3]. In opposite to PVM (Parallel Virtual Machine) [2] it is not only a C{library for handling process communication and control but a parallel speci cation language which is based on logic programming languages. PCN has a C{ similar syntax and allows the user to include sequential code written in C or Fortran. Because PCN supports a virtual processor topology it is
possible to port PCN{programs directly to every machine architecture which supports PCN. Up to date there are a wide variety of supported systems like Sequent Symmetry, Intel ipsc860 and work stations like Sun4, IBM RS6000 and SGI. The implementation of PCN on a transputer network is under development at University of Paderborn. A PCN program consists of instructions and functions, which are formed to blocks by a sequential operator ";" or a parallel operator "||".
send(a){; ... a = [X|send_new], send(a) } receive(b){? b ?= [X|receive_new] -> {; ... receive(receive_new) } }
Parallel Computation of Large Rule Bases There are only a few approaches in the considered literature which deal with concurrency in Fuzzy systems [9]. We think that the inherent parallelism in these systems should be used when computing large rule bases. Even if we consider simple production rules of type IF P1 ; : : :; Pn THEN C1; : : :; Cm rules with Max-Min-inference [10] we can identify the following parallel processing steps.
IF
A
P 11
P 12
... P1i
THEN
C
11
C
12
... C1i
IF
...
Communication in PCN is based on the shared logical variables which are used as channels. This is the communication principle of most parallel logic programming languages. These variables are single assignment variables and thus a communication stream between functions is realized by the principle of incomplete messages. A logic variable is bound to a tuple which consists of the original value and, additionally, a new (unbound) variable which serves as communication channel for the next communication request. Synchronization is achieved with the guard operators "?" and "->". If the function receive in the example below receives data frome send the block after the corresponding "->" is executed if the guards are full lled (here b is composed of a head element x and a tail list receive new ). If more than one guard is satis ed, the executed block is chosen nondeteministically.
C
B
...
main(argc,argv,exit_code){; {|| % do parallel send(out), receive(out) } exit_code = 0 }
Given an input vector (V1 ; : : :; Vn) we conclude, that
P j1
P j2
... Pji
THEN
D
...
Figure 1: Parallelism in Fuzzy Production Rules the test of reable rule can be done in parallel (A). Synchronization is needed only when combining the results from each rule during defuzzi cation (D). within each rule the matching of each Vi and Pi can be done independently (B). Synchronization is needed only at the calculation of the inference. The computing of each corresponding conclusion can be don in parallel too (C). If we consider only one{staged rules (the matching of an input value and a premise does not require the evaluating of another rulebase) we notice that the underlying parallelism is ne grained because each parallel job runs only a short time. This kind of parallelism may be inecient on multiprocessor architectures which have expensive communication costs (e.g. workstation nets, message passing systems). Shared memory architectures are better suited for this kind of parallelism.
Fuzzy{Library for PCN The developement of the Fuzzy-Library was focused on the two goals parallelism and universality, thus leading to a set of fuzzy functions that can be combined to model proper functionality of fuzzy systems. The input and output of each function is based on linked lists. This enables the function to determine the number of input and output variables. So the user has to deal only with a small number of functions to model the requested Fuzzy concepts. All parallelism is totally transparent to the user. This fact facilitates the rapid prototyping of complex systems. The following functions are used in this paper:
Measuring Parallel Inference We used a Sun4 workstation net as basis for our rst experiments. Thus we considered only parallel rule ring and omitt parallel processing in each rule. Before we represent results he have to de ne the following parameters: execution time t(p) : execution time for a parallel execution with p processors
speed-up s(p) = tt((1) p) .
In gure 2 we show the speed-up results for the parallel implementation of a simple production rule base where the rule testing is distributed on the processors. All measures were done on a network of Sun4 workstations Plot 1 shows the speed-up for a rulebase of 128 rules, each consisting of 2 premises and 1 conclusion. In plot 2 the rulebase consists of 256 rules. In plot3 (128 rules) and plot 4 (256 rules) each rule represents 8 premises and 1 conclusion. To achieve realistic measuring conditions each program is looped 200 times. In all cases we obtain a speed-up that is nearly linear with the number of
plot4
8 7
plot3
6 plot2
speedup
pcn init rulebase(): This function speci es the rulebase which is used for inference. The rulebase is a set of production rules of the form: f; ; g, where inp sets represents linguistic premises (modeled by fuzzy sets) and sups support values for the conclusion sets out sets. Each fuzzy set fs is de ned by a shape function (triangle, trapezoidal or other piecewise linear functions). pcn inferenz(,): This describes the fuzzy reasoning process based on the matching of input values in in and the rule base RB. The inference method is given in method. This function splits the rulebase into single rules and calls subfunctions for every rule. These subfunctions realize the inference on the rule level and are computed in parallel. Each functions matches the input values with the appropriated input sets (again in parallel), combines the results and evaluates the output sets (parallel). pcn defuzzy(,): This function is necessary for achieving crisp results. Pcn defuzzy evaluates a crisp value for every given conclusion using the defuzzi cation method speci ed in method . Other functions for fuzzy operators, linguistic hedges, rule modifying, etc. are implemented or under development.
5 plot1
4 3 2 1
1
2
4
8
processors
Figure 2: Speed{Up results of the parallel implementation processor. With an increasing number of processors the system time spent for processor synchronisation becomes larger and speed{up decreases. This is shown by the break of rise in plot 3/4 at 4 processors. Logic languages allocate data store dynamically. This requires system time for allocation and store reorganisation. In a parallel logic program each processor stores only a fraction of data. So the time for store organisation might be smaller than in the sequential case. In plot 1/2 this eect compensates the increasing time for synchronisation. As we can see even for small data bases parallel programming achieves good results.
Modeling of Fuzzy Petri Nets There are many approaches which deal with Fuzzy Petri Nets (cf. [8, 6, 1]). Most of them use Petri nets as a representation of an uncertain production system and the token race for a description of the reasoning process. However, these approaches do not cover all aspects of Petri nets, e.g. concurrency. In [8] R. Valette points out that high level Petri nets (Predicate Transitions nets) dier essentially from rst{order logic. This results from the inability of classical logic to handle resources. As concurrency is one inherent concept of Petri Nets, we are interested in these nets as a candidate for modeling asynchronous systems. One well known application is the use of Petri nets in the CIM{area. Fuzzy Logic is well suited for dealing with problems which come from this eld (cf. [10]) and approaches which combine Fuzzy Logic and Petri nets have been presented by [5, 7]. In
the following we show how concepts of FPN ca be modeled easily in our approach. S1
T1
T2
S2
S3
Figure 3: A Simple Petri Net Due to space limitations we restrict the net's fuzziness to a (crisp) ring of transition based on uncertain rules. As an example we consider the simple net in gure 3. Tokens in this net are individual objects. Based on the tokens' attributs a transition res if all its input places have a token and the evaluation of the transition rules exceed a prede ned threshold. As an application one can imagine the modeling of alternative product ow in a production unit. Jobs are modeled by tokens. A token i in an incoming place of a transition A can be viewed as the availability of of job i for machine A. Whether an available job is processed on a machine depends on the machine's demand for this job. Criterias for demand are the job's priority and the job's processing time on the particuliar machine. Both values are attributes of the job and measured by crisp values. Rules for evaluating these attributes and computing the resulting demand are local to each transition and consists of linguistic values. (IF priority is () AND process time is () THEN demand is () ). If the resulting demand exceeds a given threshold the job is processed on that machine. If more than one machine have a demand for a job there exists a con ict which is solved by choosing one machine non deterministically. The corresponding PCN program and a short description is given in the appendix. Extensions: If we extend the net to multiple ring (cycles of transitions and places) we can model this in PCN by lists and recursive calls of the corresponding transitions. Other Fuzzy concepts (e.g. uncertain transitions, places or ring) can be easily modeled but require additional program code. This would exceed the scope of this paper.
Conclusion and Future Work We have presented a rst prototype of a FuzzyLibrary for the parallel programming language PCN. Although fuzziness is no inherent part of
the underlying language and therefore less powerful as [4]) this approach seems to be more practical to potential users because PCN is already running on several architectures and easy to use. First experiments show the usefulness of parallel execution of large fuzzy rule bases and the modeling of concepts of asynchronous fuzzy systems like Fuzzy Petri nets. The time spent from the design of the lib's prototype until the successful execution of the mentioned examples took nearly one month for one person. Future time is planned to be spend on increasing the functionality of the library. In particuliar we try to automate the used parallelism in resoning with respect to the underlying architecture. This would cause a parallel inference process executed on a workstation to process only parallel rule ring while a inference process running on a shared memory machine would process premises and conclusions in single rules in parallel too. Moreover we want to apply PCN plus Fuzzy-library to more complex system (e.g. exible manufacturing systems).
References
[1] S. M. Chen, J.-S. Ke, and J.-F. Chang. Knowledge representation using fuzzy Petri nets. IEEE Transaction on Knowledge and Data Engineering, 2(3):311 { 319, 1990. [2] A. Geist et al. PVM 3.1 User's Guide And Reference Manual. Oak Ridge National Laboratory, Oak Ridge, Tennessee, May 1993. [3] I. Foster, R. Olson, and S. Tuecke. Productive Parallel Programming: The PCN Approach. Scienti c Programming, 1(1):51 { 66, 1992. [4] C. Geiger and G. Lehrenfeld. Using ConFuP in Modeling of Concurrent Fuzzy Systems. In Proceedings of the 3rd IEEE International Conference on Fuzzy Systems, 26 June- 2 July, Orlando, 1994. (to appear). [5] Hans-Peter Lipp. Application of timed fuzzy Petri nets in expert systems for operative management of complex production systems. In G. Hommel, editor, Prozessrechensysteme '91. (Process Computer Systems '91) Proceedings, pages 103{112, Berlin, Heidelberg, New York, 1991. Springer-Verlag. [6] C.G. Looney. Fuzzy petri nets for rule-nased decisionmaking. IEEE Transactons on Systems, Man, and Cybernetics, 18(1):178 { 183, January 1988. [7] Robert Valette, J. Cardoso, and Didier Dubois. Monitoring manufacturing systems by means of Petri nets with imprecise markings. In IEEE International Symposium on Intelligent Control 1989, 25-26 Sept., Albany N.Y., USA, pages 233{238, 1989. URL: ftp://laas.laas.fr/pub/robert/albany.tex. [8] Robert Valette and M. Courvoisier. Petri nets and arti cial intelligence. In IEEE/SICE International Workshop an Emerging Technologies for Factory Automation, Palm Cove, Cairns, North Queensland, Australia, August 17-19 1992, pages 218{238, 1992. URL: ftp://laas.laas.fr/pub/robert/rp ia92.ps. [9] X. Zhao and Z. Wang. A paralle fuzzy reasoning model for fuzzy production systems on a multiprocessor. In
IEEE Int. Conference on Fuzzy Systems, pages pp 251 {154. IEEE, 1993. [10] Hans-Jurgen Zimmermann. Fuzzy Set Theory | and Its Applications. Kluwer Academic Publishers, 2nd, revised edition, 1991.
PCN{Program net(s1,s2,s3,RB1,RB2){|| conflict(T1_enabled, T2_enabled,selected_trans), T1(s1,s2,s3,T1_enabled,selected_trans,RB1), T2(s1,s2,s3,T2_enabled,selected_trans,RB2)} conflict(T1_enabled, T2_enabled,selected_trans){? T1_enabled == "TRUE" -> selected_trans = "T1", % fair indeterminism T2_enabled == "TRUE" -> selected_trans = "T2"} T1(s1,s2,s3,T1_enabled,selected_trans,RB){? s1 ?=[Token1|ns1] ->{; enable(Token1,T1_enabled,RB), fire("T1",selected_trans,fired), % is T1 fireable ? new_token_T1(s2,s3,ns2,ns3,fired), % set new token }, s1 ?=[] -> {;}} T2(s1,s2,s3,T2_enabled,selected_trans,RB) ... enable(Token,enabled,RB){? Token ?={Id,costs} -> {; erglist = inferenz([costs],RB), value_list = defuzzy(erglist), value = first_value(value_list), enabled = threshold(value,0.5) % TRUE , if value }} % > 0.5
The function net de nes a simple network that consist of the places s1, s2 ,s3 and the transitions T1 and T2. The function conflict realizes the token race between T1 and T2. When a Transition Ti is enabled, it sends the message "'TRUE"' to function conflict. This function realizes the token race between T1 and T2. Conflict sends the name of the enabled transition back to T1 and T2. If both transitions are enabled, conflict chooses the name of the transition indeterministically. The function fire compairs the name of transition with the name received from conflict and decides wether the transition can modify the input and output places or terminate without any further action. So either T1 or T2 can re and the race con ict is solved.