Documentation /  Fuzzy Logic /  Manual /

Creating Fuzzy SetsFuzzy Operations

1.2 Creating Fuzzy Relations

1.2.1 Introduction

Fuzzy Logic provides a number of convenient ways to create fuzzy relations. In this chapter, we will demonstrate these functions and the options associated with each function.

This loads the package.

In[1]:=

1.2.2 Basic Objects

Fuzzy relation object.

FuzzyRelation is one of the fundamental objects used in the package. Here is its full form:    

    FuzzyRelation[{{(v1, }, R11}, ... , {{vn, wm}, Rnm}},

         UniversalSpaceRule
{{a1, b1, c1}, {a2, b2, c2}}]

where (v1, w1), (v2, w2), ... , (vn, wm) are elements of the universal space and R11, ... , Rnm are the values of the function fuzzy relation for these elements. The values are the grade of membership of the elements in a fuzzy relation.

Option for FuzzyRelation.

By default the universal space is set to {{0, 10, 1}, {0, 10, 1}}. When creating fuzzy relations, if an explicit universal space is not given, this default value will be used. Universal spaces for fuzzy sets and fuzzy relations are defined with three numbers. The first two numbers specify the start and end of the universal space, and the third argument specifies the increment between discrete elements.

Like fuzzy sets, fuzzy relations can also be created manually by surrounding the appropriate descriptors with the FuzzyRelation head. Here we create a simple fuzzy relation.

In[2]:=Rel1 = FuzzyRelation[{{{1, 1}, 0.5}, {{2, 1}, 0.8}, {{3, 2}, 0.4}},
UniversalSpace -> {{0, 5, 1}, {0, 4, 1}}]

Out[2]=

In[3]:=FuzzyPlot3D[Rel1];

1.2.3 Functions for Creating Fuzzy Relations

Creating fuzzy relations using the basic definition can be quite tedious. Fuzzy Logic provides functions for the most commonly used practice techniques for creating fuzzy relations.

Functions for creating fuzzy relations.

Here are a number of examples on how to create fuzzy relations.

FuzzyTrapezoid[{ax, bx, cx, dx},{ay, by, cy, dy},h,opts] returns a new trapezoidal fuzzy relation with membership grades that linearly increase from 0 to h in both the x and y directions from a to b, equal h from b to c, and linearly decrease from h to 0 from c to d. If h is not explicitly given, the function uses h = 1. As with fuzzy sets, it is possible to explicitly define the universal space or to accept the default setting for fuzzy relations.

In[4]:=Rel2 = FuzzyTrapezoid[{1, 3, 5, 7}, {0, 3, 6, 8}, 0.8,
UniversalSpace -> {{0, 7,1}, {0, 8,1}}];

Here we use the function FuzzySurfacePlot to look at our newly created fuzzy relation.

In[5]:=FuzzySurfacePlot[Rel2];

SetsToRelation[func, A, B] returns a new fuzzy relation with elements from the Cartesian product of the universal spaces of fuzzy sets A and B. The membership grades for the elements are arrived at by applying func to the corresponding membership grades of A and B.

To demonstrate this function, we first need to create some fuzzy sets. We use a couple of the fuzzy set creation functions described earlier in this manual to create two fuzzy sets.

In[6]:=FS1 = FuzzyGaussian[4, 2, UniversalSpace -> {1, 7}]

Out[6]=

In[7]:=FS2 = FuzzyTrapezoid[1, 3, 5, 8, UniversalSpace -> {1, 8,0.5}]

Out[7]=

With two fuzzy sets, we can now use the SetsToRelation command to create a fuzzy relation. In this example, we use Mathematica's Max function to combine the fuzzy sets.

In[8]:=Rel3 = SetsToRelation[Max, FS1, FS2];

Here we use the function FuzzySurfacePlot to look at our newly created fuzzy relation.

In[9]:=FuzzySurfacePlot[Rel3];

FromMembershipMatrix[mat,{{va, vb}, {wa, wb}}] returns a new fuzzy relation by combining the matrix of membership grades, mat, with the elements specified by the ranges {va, vb} and {wa, wb}. If no ranges are given, the function assumes the membership grades are for the elements starting at 1 with a size corresponding to the dimension of the matrix, mat.

To demonstrate the FromMembershipMatrix function, we first create a membership matrix that contains the membership grades that will be used in the relation. We then call our function with the matrix as the argument.

In[10]:=MyMembMat := {{0.1, 0.2, 0.3, 0.4, 0.5}, {0.2, 0.3, 0.4, 0.5, 0.6},
{0.3, 0.4, 0.5, 0.6, 0.7}, {0.4, 0.5, 0.6, 0.7, 0.8}}

In[11]:=Rel4 = FromMembershipMatrix[MyMembMat,{{4,7},{6,10}}];

Here we use function FuzzySurfacePlot to look at our newly created fuzzy relation.

In[12]:=FuzzySurfacePlot[Rel4];

CreateFuzzyRelation[func,{{va, vb, c1}, {wa, wb, c2}},opts] returns a new fuzzy relation with membership grades that are the result of applying func to all the elements in the specified range, {{va, vb, c1}, {wa, wb, c2}}. If no range is given, the function is applied to all of the elements in the universal space. Be sure the function provided causes membership grades to be in the correct range, 0 to 1.

The following is an example of creating a fuzzy relation from a function. The first command defines the function, and the second command creates the fuzzy relation. We explicitly declare a universal space in this function rather that accept the default setting. Because fuzzy relations are quite large, we suppress the output by putting a semicolon at the end of the function. To examine the relation, we use one of Fuzzy Logic's graphing functions. More information about graphing fuzzy relations can be found in Chapter 1.6, Fuzzy Relation Visualization.

In[13]:=MyFunction2[x_, y_]:=1/2*(Sin[x + y]+1)

In[14]:=Rel5 = CreateFuzzyRelation[MyFunction2,{{1,6,0.5},{1,7,0.5}},
UniversalSpace -> {{0,7,0.5},{0, 8,0.5}}];

You can use function FuzzySurfacePlot to look at newly created fuzzy relation.

In[15]:=FuzzySurfacePlot[Rel5];

RandomFuzzyRelation[{{a1, b1}, {a2, b2}}] creates a random fuzzy relation with universal space of {{a1, b1}, {a2, b2}} and increments c1 = c2 = 1. By default, this function will create a random trapezoidal fuzzy relation. The option Type can be used to create a Complete random fuzzy relation. In addition, there is an option called Normal that produces a normal random fuzzy relation, when set to True.

Options for RandomFuzzyRelation.

In[16]:=

In[17]:=

Out[17]=

In[18]:=

In[19]:=

Creating Fuzzy SetsFuzzy Operations


Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information