You are on page 1of 7

Popular and Democratic Algerian Republic

Ministry of high education and scientific research

UNIVERSITY OF 20 AUGUST 1955


FACULTY OF TECHNOLOGY
DEPARTEMENT OF PETROCHEMISTY AND PROCESS ENGINEERING
MASTER II IN AUTOMATION IN PETROCHEMICAL INDUSTRIES

ARTIFICIAL INTELLIGENCE LAB


WORK
TP1 ON FUZZY SETS

Academic year : 2018-2019


TP 1 FUZZY SETS

Objective:
The goal of this lab work is to work on fuzzy sets and make operations on them (like
the union of two sets, the complement of a set …) using matlab.

Theory on fuzzy logic :


DESCRIPTION OF FUZZY LOGIC
Fuzzy logic has two different meanings. In a narrow sense, fuzzy logic is a logical
system, which is an extension of multivalued logic. However, in a wider sense fuzzy
logic (FL) is almost synonymous with the theory of fuzzy sets, a theory which relates to
classes of objects with unsharp boundaries in which membership is a matter of
degree. In this perspective, fuzzy logic in its narrow sense is a branch of FL. Even in its
more narrow definition, fuzzy logic differs both in concept and substance from
traditional multivalued logical systems.

In this sense, fuzzy logic is both old and new because, although the modern and
methodical science of fuzzy logic is still young, the concepts of fuzzy logic relies on
age-old skills of human reasoning

Fuzzy logic is all about the relative importance of precision: How important is it to be
exactly right when a rough answer will do?

1
WHY USE FUZZY LOGIC?
Here is a list of general observations about fuzzy logic:

 Fuzzy logic is conceptually easy to understand.

The mathematical concepts behind fuzzy reasoning are very simple. Fuzzy logic is a
more intuitive approach without the far-reaching complexity.

 Fuzzy logic is flexible.

With any given system, it is easy to layer on more functionality without starting again
from scratch.

 Fuzzy logic is tolerant of imprecise data.

Everything is imprecise if you look closely enough, but more than that, most things
are imprecise even on careful inspection. Fuzzy reasoning builds this understanding
into the process rather than tacking it onto the end.

 Fuzzy logic can model nonlinear functions of arbitrary complexity.

You can create a fuzzy system to match any set of input-output data. This process is
made particularly easy by adaptive techniques like Adaptive Neuro-Fuzzy Inference
Systems (ANFIS), which are available in Fuzzy Logic Toolbox software.

 Fuzzy logic can be built on top of the experience of experts.

In direct contrast to neural networks, which take training data and generate
opaque, impenetrable models, fuzzy logic lets you rely on the experience of people
who already understand your system.

 Fuzzy logic can be blended with conventional control techniques.

Fuzzy systems don't necessarily replace conventional control methods. In many


cases fuzzy systems augment them and simplify their implementation.

 Fuzzy logic is based on natural language.

The basis for fuzzy logic is the basis for human communication. This observation
underpins many of the other statements about fuzzy logic. Because fuzzy logic is built
on the structures of qualitative description used in everyday language, fuzzy logic is
easy to use.

FUZZY SETS
Fuzzy logic starts with the concept of a fuzzy set. A fuzzy set is a set without a crisp,
clearly defined boundary. It can contain elements with only a partial degree of
membership.

In fuzzy logic, the truth of any statement becomes a matter of degree.

In this LABWORK we’ll see how to make operations on fuzzy sets (like the union of two
sets, the complement of a set …) using matlab

2
OPERATIONS ON FUZZY SETS:
the union is calculated by using the maximum degree of membership of the two sets

the intersection is calculated by the using the minimum degree of membership of


the two sets

the complement is calculated as follow: 1-the degree of membership

In Matlab:
EX 1
We consider the following fuzzy sets :

A = {2/1, 3/0.5, 4/0.3, 5/0.2, 6/0.6}

B = {2/0.5, 3/0.7, 4/0.2, 5/0.4}

we are to calculate AUB , A∩B ,𝐴, 𝐵

By Expressing the fuzzy sets and using the rules on making operations on fuzzy sets we
solve the problem using the following code in matlab:
% start of code

% we input the fuzzy set using vectors


A=[2,1, 3,0.5, 4,0.3, 5,0.2, 6,0.6];
B=[2,0.5, 3,0.7, 4,0.2, 5,0.4, 0,0];

% we use the known rules of operation on fuzzy sets


for i=2:2:length(A)
union(i)=max(A(i),B(i));
union(i-1)=max(A(i-1),B(i-1));
intersection(i)=min(A(i),B(i));
intersection(i-1)=min(A(i-1),B(i-1));
complementA(i)=1-A(i);
complementA(i-1)=A(i-1);
complementB(i)=1-B(i);
complementB(i-1)=B(i-1);
end

% we then display the resulting fuzzy sets

union
intersection
complementA
complementB

% end of code

3
By executing the code, we get the following results in the command window

EX2
We consider the following fuzzy sets :

A = {2/0.1, 3/0.6, 4/0.4, 5/0.3, 6/0.8}

B = {2/0.5, 3/0.8, 4/0.4, 5/0.6, 6/0.4}

We are to calculate A∩𝐵 , 𝐴∩B

Using the rules on making operations on fuzzy sets that we know we solve the
problem using the following code in matlab:

% start of code
% we input the fuzzy set using vectors

A=[2,0.1, 3,0.6, 4,0.4, 5,0.3, 6,0.8];


B=[2,0.5, 3,0.8, 4,0.4, 5,0.6, 6,0.4];

% we use the known rules of making operations on fuzzy sets

for i=2:2:length(A)

intersectionAavecBbarre(i)=min(A(i),1-B(i));
intersectionAavecBbarre(i-1)=min(A(i-1),B(i-1));
intersectionBavecAbarre(i)=min(1-A(i),B(i));
intersectionBavecAbarre(i-1)=min(A(i-1),B(i-1));
end

% we display the resulting fuzzy set


intersectionAavecBbarre
intersectionBavecAbarre
% end of code

4
By executing the code, we get the following results in the command window

EX 3
We consider the following fuzzy sets:

A = {10/0.8, 15/0.3, 20/0.6, 25/0.2}

B = {10/0.4, 15/0.2, 20/0.9, 25/0.1}

We are to calculate Demorgan’s law 𝐴∩𝐵 , 𝐴U𝐵

Using the rules on making operations on fuzzy sets that we know we solve the
problem using the following code in matlab:

% start of code
% we input the fuzzy set using vectors

A=[10,0.8, 15,0.3, 20,0.6, 25,0.2];


B=[10,0.4, 15,0.2, 20,0.9, 25,0.1];

% we use the known rules of making operations on fuzzy sets


for i=2:2:length(A)

intersectionBarre(i)=min(1-A(i),1-B(i));
intersectionBarre(i-1)=min(A(i-1),B(i-1));
unionBarre(i)=max(1-A(i),1-B(i));
unionBarre(i-1)=max(A(i-1),B(i-1));
end
% we display the resulting fuzzy set

intersectionBarre
unionBarre
% end of code

By executing the code, we get the following results in the command window

5
Conclusion:
We can can conclude from this lab work that it is possible to make a lot of
operations on fuzzy sets like unions, intersections, complements or even Demorgan’s
law and that it is very easy to do them in Matlab .

You might also like