11
Implementation of Piecewise Linear Fuzzy Quantities Hans Steyaert, Filip Van Parys, and Rony Baekeland Department for Quantitative Techniques, University of Ghent, Belgium Etienne E. Kerre Department for Applied Mathematics and Computer Science, University of Ghent, Belgium Fuzzy information in expert systems and in fuzzy database systems is often represented by means of piecewise linear fuzzy quantities. In this article we describe an implementa- tion of piecewise linear fuzzy quantities and how to perform fuzzy operations on them. This article can be seen as a natural continuation of Baekeland and Kerre [“Operations on piecewise linear fuzzy quantities: A theoretical approach,” Fuzzy Sets Syst., submit- ted], in which the mathematical properties of piecewise linear fuzzy quantities are investigated 0 1995 John Wiley & Sons, Inc. I. INTRODUCTION A natural way to implement fuzzy information in computer systems is by using piecewise linear fuzzy quantities. After an introduction of a representation for the piecewise linear fuzzy quantities, we will describe implemented algo- rithms for unary and binary operations on piecewise linear fuzzy quantities. Though the exact addition of two arbitrary fuzzy quantities, e.g., takes much computing time, the addition of two piecewise linear fuzzy quantities takes much less time. 11. PRELIMINARIES First of all, we recall some definitions from Ref. 1, that will automatically result in the representation used in our implementation. (1) A fuzzy quantity is a fuzzy set on the real line 3. We will make no distinction between a fuzzy set and its membership function. A fuzzy quantity Q may be seen as a representation for a vaguely known quantity. (2) A network is an ordered list of quadruples ((xI fil f12 fi3) (x2h1 &h3) . . . (xN fNI fm fN3)) with the following properties: INTERNATIONAL JOURNAL OF INTELLIGENT SYSTEMS, VOL. 10, 1049-1059 (1995) 0 1995 John Wiley & Sons, Inc. CCC 0884-8173/95/121049-11

Implementation of piecewise linear fuzzy quantities

  • Upload
    ugent

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Implementation of Piecewise Linear Fuzzy Quantities Hans Steyaert, Filip Van Parys, and Rony Baekeland Department for Quantitative Techniques, University of Ghent, Belgium

Etienne E. Kerre Department for Applied Mathematics and Computer Science, University of Ghent, Belgium

Fuzzy information in expert systems and in fuzzy database systems is often represented by means of piecewise linear fuzzy quantities. In this article we describe an implementa- tion of piecewise linear fuzzy quantities and how to perform fuzzy operations on them. This article can be seen as a natural continuation of Baekeland and Kerre [“Operations on piecewise linear fuzzy quantities: A theoretical approach,” Fuzzy Sets Syst . , submit- ted], in which the mathematical properties of piecewise linear fuzzy quantities are investigated 0 1995 John Wiley & Sons, Inc.

I. INTRODUCTION

A natural way to implement fuzzy information in computer systems is by using piecewise linear fuzzy quantities. After an introduction of a representation for the piecewise linear fuzzy quantities, we will describe implemented algo- rithms for unary and binary operations on piecewise linear fuzzy quantities. Though the exact addition of two arbitrary fuzzy quantities, e.g., takes much computing time, the addition of two piecewise linear fuzzy quantities takes much less time.

11. PRELIMINARIES

First of all, we recall some definitions from Ref. 1, that will automatically result in the representation used in our implementation.

(1) A f u z zy quantity is a fuzzy set on the real line 3. We will make no distinction between a fuzzy set and its membership function. A fuzzy quantity Q may be seen as a representation for a vaguely known quantity.

(2) A network is an ordered list of quadruples ((xI f i l f12 f i 3 ) (x2h1 &h3) . . . (xN fNI fm fN3)) with the following properties:

INTERNATIONAL JOURNAL OF INTELLIGENT SYSTEMS, VOL. 10, 1049-1059 (1995) 0 1995 John Wiley & Sons, Inc. CCC 0884-8173/95/121049-11

1050 STEYAERT ET AL.

( a ) V j = l , 2 , . . . , N ; i = 1 , 2 , 3 : x j E 9 ' t , f , i E [ 0 , 1 ] (b) Vj = 1, . . . , N - 1: ~j < xj.1

(3) A mapping F from 3 to 3 is piecewise linear iff there exists a network ( (x l f l l

f 1 2 fl,) (x2 $21 f 2 2 f i 3 ) f . . ( X N f N 1 f N 2 f N 3 ) ) such that: (a) V i = 1 , . . . , N - 1: if x € ] x i , x i t l [ then

(b) V i = 1 , . . . , N : F(xJ = f i 2 (c) If x < x I then F(x) = fil (d) If x > x N then F(x) = f N 3

(4) A piecewise linear fuzzy quantity (PLFQ for short) is a fuzzy quantity with

(5) An empty network is a strictly increasing list (x l xi . . . x N ) of real numbers. (6) A piecewise linear mapping F has an empty network N = ( x , xi . . . x N ) iff

(Vi = 1, . . . , N - 1) (F is linear onlx,, x i+ , [ and constant for all x < x 1 and

piecewise linear membership function.

x > X N ) . (7) A PLFQ F represented by a network of the form

( ( X I oh2 f13)(x2 fil f 2 2 O ) )

[respectively, ( ( x , 0 O f i 3 ) ( x 2 f z 1 0 O ) ) ] is called a closed basic linear form [respec- tively, an open basic linear form].

( 8 ) A quadruple (x j & I J2 J 3 ) for j = 2, . . . , N - 1 is redundant in the network

straight line connecting the points &j-l)J and ( x ~ + ~ &j+l)l). The quadruple (x, f , l f I ~ f l 3 ) [respectively, ( X N ~ N I f~ fN3)I is redundant i f f41 = f i 2 = f i 3 = &I [respectively, fNl = fN2 = fN3 = & N - 1 ) 3 1 .

( ( X I fi I f i 2 f i J . . . (xN fN1 fNi fm)> iff&, = J2 =z 43 and (xj 7 42) is a point on the

As mentioned in Ref. 1 every network defines just one PLFQ but not vice versa. Two different networks can define the same PLFQ. This already shows that the number of quadruples in a network is not only determined by the PLFQ. For this reason dynamic structures are preferred to represent PLFQ's. For the implementation, we need a programming language with powerful calcu- lating capacities, available on PC and capable of handling dynamic structures. We choose the C language, and make use of the BC +-t 3.0 compiler. This choice assures an easy transportation to UNIX systems. In our implementation we make use of a double-linear list where each element coincides with a quadru- ple of the network.

An element of the list is stored in a variable defined with the following type declaration:

s t r u c t quad { double x; d o u b l e f l , f2, f 3 ; s t r u c t quad f a r "1, *r; 1;

where the list itself is appointed to by means of a variable of the following type:

*

PIECEWISE LINEAR FUZZY QUANTITIES 105 1

void minimizeqlq(p1q t p l q l ) t P k Plq2,Plq3,tmP; tostart-plq(plq1); if (!plql) return; tmp = plql; plqZ=plql->r; if (plq2) plq3=plqZ->r; else plq3zNULL; while (plq3) { if ((dabs(plq2->fl - plqZ->fZ)<small ) && (dabs(plq2->f2 -plq2->fj)<small)) { double ricol, rico2; ricol= (plq3->fl - pIql->f3) / (plq3->x - plql->x); rico2= (plq3->fl- plqZ->fj) / (plqS->x - plqZ->x); if (fabs((ricol-rico2)*(plq3->x - plql->x)) i le-10) remove-quad(plq2);

else plql=plql->r; 1 else plql=plql->r;

pIq2=plql->r; if (plq2) plq3=plq2->r; else plq3=NULL; 1 if (plq2->1) if ((plq2->f3 == plq2->fl) && (plqZ->fl == pIq2->f2) && ((plq2->1)->f3 == pIqz->f2)) { plq2=plq2->1; remove-quad(plqZ->r);

1 p l q k t m p ; if (plql->r) if ((plql->fj == plql->fl) && (plql->fl == plql->f2) && ((plql->r)->fl == plql->fL))

remove-quad(plq1->l); { plqkplq l ->r ;

1 toJtart-plq(plq1);

1

Figure 1. Minimization of a PLFQ.

t ypede f s t r u c t quad f a r * p l q ;

When working with a PLFQ, it is of course desirable to have the smallest amount of quadruples in the network (minimal network). This network can be obtained by omitting all redundant quadruples. In Figure 1 we give the source code for this algorithm as an example of the easiness of the use of linear lists in the implementation.

Looking attentively to this code, one can observe some changes to the original algorithm.' Indeed, we have to solve some numerical problems caused by the impreciseness of the computer representation of real numbers. Therefore we have to replace the "="-sign by a test on the minimality of the difference. The redundancy of a quadruple is tested making use of the slopes. Again we are obliged to build in a certain degree of tolerance.

1052 STEYAERT ET AL.

111. FUZZY OPERATIONS ON PLFQ’S

Due to the representation by means of linear lists most of the fuzzy opera- tions are quite easy to implement. We must stress that this is a consequence of the restriction to PLFQ’s which makes it possible to get exact results for most fuzzy operations in an acceptable computing time. For the proof of the implemented algorithms we refer to Ref. 1.

A. Minimum and Maximum

The minimum of two PLFQ’s F and G is obtained in two steps:

(1) An empty network D is constructed with the breakpoints of F and G and the points where the graphs of F and G intersect.

(2) Out of this empty network D we construct a complete network by adding for each point the minimum of the left limits resp. values resp. right limits of F and G in each point.

Instead of implementing the maximum in a similar way, we choose to use the following property:

max(F, G)(z) = F(z ) + G(z) - min(F, G k ) , Vz E 3

B. Basic Operations

Negation of a PLFQ F , multiplication of a PLFQ F with a scalar m and translation of a PLFQ over a scalar a are defined as follows:2

NOTF(x) = 1 - F(x)

(mF)(x) = F(mx) (F + a)(x) = F(a + x)

They are implemented by a pointwise execution of these definitions in the breakpoints of the networks. Be aware of the fact that a negative m also results in reversing the order of the quadruples of the network.

Using the previous operations we are now able to implement ABS F(x) = max(F(x), F(-x ) ) = max(F(x), (-IF) (x))

In Figure 2 we illustrate the algorithm for the negation.

p lq not-plq(plq p l q l ) { plq res=NULL; toatart -plq( plql); while (plql) { add-quad(res ,plql->x, l -plql->fl , l -plql->~, l -plql->~); plql=plql->r;

to-start-plq(res); return(res);

1

Figure 2. Negation of a PLFQ.

PIECEWISE LINEAR FUZZY QUANTITIES 1053

to-endqlq(F) ; maximum := F- >f3; WHILE F<>NULL DO { IF (maximum < F- >B) AND (maximum > F- >r- >fl) { x = calcintersection(. . .) add-before-quad(res,x,maximum,maximum,maximum) maximum = F- >f3

f2 = f3 = max(F- >B,maximum) maximum = max(F- >fl,rnaximum) maximum = fl = max(F- >fl,maximum) add-before-quad(res,F- >x;fl;f2;f3)

1

F = F- >1

Figure 3. Source code for H(z) .

C. Extended Minimum and Maximum

We recall from Ref. 1

ZkF, G M = max(min(G(z), sup F(x>), min(F(z>, sup G ( y h min(F(z), G(z))) (1)

The first step in the implementation of the extended minimum is the calculation of

x>z Y>Z

H(z ) = sup F(x) X>Z

The algorithm is illustrated using a pseudoprogramming language (Fig. 3). Secondly, the implementation of the extended minimum of two PLFQ’s

can then be done combining minimum, maximum, and the function above us- ing (1).

The extended maximum can be implemented in a similar way.

D. Fuzzy Addition of PLFQ’s

In Ref. 1 a decomposition of F and G in basic linear forms is mentioned working in 3. This decomposition was not immediately suitable for implementa- tion, because of the difficulty arising in the representation of +m and --cc. First we describe a way to overcome this difficulty. Secondly the addition of basic linear forms is illustrated.

1. Decomposition

The fuzzy addition is done using a decomposition of the PLFQ in basic linear forms. We recall the following lemma from Ref. 3 or 4:

LEMMA. Let F , , F 2 , . . . , F N , G, , . . . , G, be fuz zy quantities. Then we have:

1054 STEYAERT ET AL.

max F, @ max Gj = max (Fi @ Gj). (2)

First we replace cz by 1E328.* This creates some numerical problems. Rather then searching solutions for these problems, we make use of the properties of basic linear forms.

; = I . ...A j=I. .... M i= I , ...A j = l ..... M

LEMMA. Let F and G be PLFQ's with empty networks (4, xf, . . . , .&) and (x,", xy, . . . , xc). Zfxo < min($, x,") 5 max(x;, xg) 9 x, , then F @ G is constant in ] - =, 2xo] und in [2xl, +xi .

Proof, We will only prove the first part, as the proof of the second part is similar. Let z I 2x0. Using the definition of the sum of two PLFQ's we can write:

F @ G(z) = sup min(F(x), G( y ) ) X t V ' Z

= max(sup min(F(x), G( y ) ) , sup min(F(x), G( y ) ) ) XZXO X<XO

x t ? ' = z .r+y=z

= max(sup min(F(x), G(xo)), sup min(F(x,,), G(y)))

= max(min(sup F(x), G(xo)), min((F(xo), sup G(y)))

*zx* r<x0

x+.V=z X + y = I

x 2 x o X<X"

x+y=z X+?=Z

Hence we can conclude that F @ G is constant in ] -m , 2x,] rn In the next lemma, we will show that, calculating the sum of two PLFQ's,

it will be possible to cut off F and G at two suitable points yo and yl. We will use the notations x,, x I from the previous lemma, and zo = 2x0, z , = 2x1.

LEMMA. Let F and G be PLFQ's. Let yo = 2x0 - xl - 1 and y , = 2x1 - xo + 1. Define F' = F,[vo,Y,l and GI = G,[Yo,y,l, i.e., F' is fhe restriction o f F to [ y o , yl1. Then:

F1 @ Cl(Z) = Fa3 G(z) vz E [zo , z,l Proof. Let z E [zo, z , ] . We recall the definition of the sum of two PLFQ's:

F @ G(z) = sup min(F(x), G(y))

First we remark that y , < x, and y 1 > x, + 1.

x + y = t

We distinguish several cases: (1) x + y = z and x < yo:

*Biggest count that could be represented.

PIECEWISE LINEAR FUZZY QUANTITIES 1055

From x < yo and y o < xo we obtain F(x) = F(xo) . From x + y = z and x > yo it follows y > z - y o , i.e., y > 2x0 - y o , because z L zo = 2x0. Finally, using the definition of y o , we obtain: y > xI + 1 and hence

Let G ( Y ) = G ( ~ I ) .

Then the following properties hold:

Indeed, one can easily verify that (ii) and (iii) hold for z = zo and z = z I . As u(z ) and u(z) are linear in z , we can conclude that (ii) and (iii) hold for all z E [zo, Z l l .

Thus for each couple ( x , y ) , with x < yo and x + y = z , there exists a new couple (u , ( z ) , u,(z)) , u l ( z ) , ul(z) E [ y o , Y ~ I such that u,(z> + ul(z) = z , F(u,(z)) = F(xo) = F(x) and G(ul(z)) = G(xJ = G(y) .

(2) x + y = z andy < y o : As the problem is symmetric in x and y , we can conclude that there exists a couple (u , ( z ) , ul(z)) such that u,(z) + ul(z) = z , F(ul(z)) = F(xJ = F(x) and G(u,(z)) = G(xo) = G(y) .

(3) x + y = z and x > y 1 or y > y l : Also in these two cases a similar couple ((u2(z), u,(z)) can be constructed.

Consequently we can write Vz E [ zo , z l l :

and hence

F '8 G(z) = sup min(F'(x), GI( y ) ) XE[?O,YlI YE[YO,YIl

x+y=z

= sup min(F'(x), G1( y ) ) x + y = z

= F' '8 G'(z)

Using the preceding lemma, we can conclude that addition of two PLFQ's F and G can be performed in 3 steps:

1056 STEYAERT ET AL.

I I 1 I

tl t 2

Figure 4. Two general BLF’s.

(1) Calculation of y o , y I , z,, , zI , F1 and GI. ( 2 ) Addition of F1 and GI. (3) From F’ ‘3 GI we obtain F CB G.

We will now give a decomposition of F‘ and GI, that will be appropriate for the addition of F’ and GI:

Let (a,a2 . . . a N + l ) and (bib, . . . b,,,) be empty networks for F’ and G’ , respectively. Putting for every i = 1, . . . , N a n d j = 1 , . . . , M :

We obtain

F’ = max Ff GI = max E,! i= l . . . . .N . j = I, ...+ M

Using (2) we can conclude:

F’ CT3 Gl(z) = max Fie Gj ; = I , .... N

. j= 1 ,. . . .M

2. Addition of Two Basic Linear Forms

In 111-D.1 we discussed how the addition of two PLFQ’s could be done adding basic linear forms. We will now illustrate the addition of open basic linear forms. The addition of closed basic linear forms can be performed combining the addition of open BLF’s with minimum and maximum.

At first view there are 75 distinct cases. Using recursion we were able to reduce the amount of different procedures to six. We will now illustrate these 6 “cases”. Let F and G be two open basic linear forms with respective networks

The two BLF’s will look as in Figure 4. We calculate the points tl and t2 ( (a 0 0 fu> ( b fb 0 0)) and t(c 0 0 g,) (d g d 0 0)).

as indicated on the picture and define

PIECEWISE LINEAR FUZZY QUANTITIES 1057

Figure 5. The six basic cases.

Because

F @ G = max (Fi$Gj)

the fuzzy addition of two open basic linear forms is reduced to a combination by means of the maximum of the six specific cases, which are illustrated in Figure 5 .

As an example we look at the following case in detail? (Fig. 6): We can write: g d 5 g, -c: f a 5 fb

F €B G(z) = sup min(F(x), G ( y ) ) = sup G( y ) = sup G(z - x)

i,j= 1,2,3

z=.*+y z=x+y x€la.b[ xEla ,b [ xEla ,b [ z-xElc,d[ yEIc,d[ yEIc,d[

We distinguish two cases:

tSome other cases: see Lemma 5.6 in Ref. 1.

1058 STEYAERT ET AL.

I

Figure 6. Case g d 5 g, 5 f, 5 f b .

( I ) z Elb + c , b + d[

sup xEla.bl

x - x E l r , d [

C(Z - x) = C(Z - 6)

(2) 2 Elu + c , b + cl

We can conclude that the network of F 63 G is ( (a + c , 0, 0, g,)(b + c , g , g,. , &?,.)(b -k d , f?d 2 0 , 0))-

IV. THE FUZZY MULTIPLICATION AND DIVISION OF PLFQS

Fuzzy multiplication of two PLFQ’s does not lead to a PLFQ. In order to obtain an internal operation, it is possible to approximate the

exact result of the fuzzy multiplication. One can work with the same decomposi- tion as for the addition, and reduce the problem to the multiplication of basic linear forms. That multiplication can then be approximated using a PLFQ.

V. CONCLUSION

Using Piecewise Linear Fuzzy Quantities instead of ordinary fuzzy quanti- ties’, we were able to reduce the amount of computing time for calculations drastically, preserving the exactness of the result. The most amazing result might be the addition of two PLFQ’s, where in less then a second the total minimal network of the exact sum is known, working on a AT 486 machine. For this reason, we may conclude that the use of PLFQ’s (as an approximation of ordinary fuzzy quantities) can be a great step forward in practical applications.

PIECEWISE LINEAR FUZZY QUANTITIES 1059

VI. SOURCE CODE

We implemented a range of operations on PLQ’s, using the BORLAND C+ + 3.0 compiler. The source code can be obtained on the following address: H. Steyaert, Department for Quantitative Techniques, Hoveniersberg 4, 9000 Ghent, Belgium. (E-mail: Hans. [email protected] .BE)

References

1. R. Baekeland and E.E. Kerre, “Operations on piecewise linear fuzzy quantities: A

2 . E.E. Kerre, Introduction to the Basic Principles of Fuzzy Set Theory and its Applica-

3 . D. Dubois and H. Prade, Theorie des Possibilite‘s, Masson, Paris, 1985. 4. D. Dubois and H. Prade, Fuzzy Sets and Systems: Theory andApplications, Academic

5 . A. Van Schooten, “Het modelleren van onzekerheid en imprecisie in expert syste-

theoretical approach,” submitted to Fuzzy Sets Syst.

tions, Gent, Communication & Cognition, 1991.

Press, New York, 1980.

men,” Script for obtaining a Master’s degree in Informatics, 1986 (in Dutch).