# Fuzzy Logic- Introduction and Implementation

### FUZZY LOGIC

Founded by Lotfi A Zadeh in 1965, Fuzzy Logic was first implemented in steam engine speed control.

#### So what actually is Fuzzy Logic?

It is considered an extension of Boolean logic and a logic that handles the concept of partial truth. The range of truth value is between yes and no. It can be certainly yes, slightly yes, no, strictly no or anything and these are the terms under fuzzy set. It mimics the human reasoning about things. Like if we ask someone, “hows the weather today?”, different people may have different answers. One may say “Its hot”, another may say “Its too hot” , some may say “Its normal” or someone living in Solukhumbu may say “Its too cold”. The logic always represents vagueness.

Also according to Zadeh, the logic involves computing using words as linguistic variables. Any linguistic variable can be represented as <x,T(x),U,G,M> where

x=linguistic variable, T(x)=set of terms, U=universe of discourse, G= syntax rules, M= semantic rules.

#### Linguistic Variables

Linguistic variables are those variables whose values are not number but words or sentences. Fuzzy logic bridges between these words and numbers.

e.g. temperature is a linguistic variable and set of terms=(too cold, cold, warm, hot, too hot). These terms are mapped to numerical values using membership functions.

#### Classic Logic Vs Fuzzy Logic

-fixed logic like boolean -extremities(range of values)

-based on crisp set(0,1) – based on fuzzy set(all values beween 0 and 1)

#### Applications of Fuzzy Logic

Its implemented in consumer electronics such as cameras, camcorders, washing machines, and microwave ovens and in industrial process control, medical instrumentation, decision-support systems, natural language processing and in many other fields.

#### Architecture of Fuzzy Logic

**Fuzzifier**

It involves fuzzification process where crisp numbers obtained from sensors are converted into fuzzy sets.

If we obtain speed of car from sensors to be a number like 3kmph, it is mapped to fuzzy function and words are collected like;

Car is moving to **too** **slow.**

**Rules / Rule Base and Inference Engine**

Rule Base contains all the rules and the if then conditions offered by the experts to control the decision making

system.

Inference Engine helps you to determines the degree of match between fuzzy input and the rules Based on the

match, it determines which rules we need to implement according to the given input field. After this, the applied rules

are combined to develop the control actions.

**Defuzzifier**

It involves defuzzification process where fuzzy sets are converted to crisp value for quantifiable result. Defuzzification is the interpretation of the membership degree for collected vague values in

first step of fuzzification.

Example: Very slow is indicated by 0.1 .

A bit faster is indicated by 0.9.

Different methods like center of sum, center of gravity are used.

Input: Aggregate output fuzzy set

Output: Single Number

**Fuzzy Logic vs Probability**

Some people have wrong view about Fuzzy Logic and Probability but these are completely different. Fuzzy logic always represents vagueness or partial truth about something. On the other hand, probability is about events to occur or not occur and it captures partial knowledge about something.

Advantages

The structure of fuzzy logic system is easy and understandable.

It helps you to control machines and consumer products.

It may not offer accurate reasoning, but the only acceptable reasoning.

It helps you to deal with the uncertainty in engineering.

Mostly robust as no precise inputs required.

It can easily be modified to improve or alter system performance.

Inexpensive sensors can be used which helps you to keep the overall system cost.

It provides a most effective solution to complex issues.

**Disadvantages of Fuzzy Logic**

We can see that the logic is about partial truth so its not always accurate. Also the verification and validation process requires extensive testing.

**References**

- L. A. Zadeh, “Fuzzy sets”, Information Control,vol. 8, pp.338–353, 1965.
- Shuaibu Maianguwa, Ali. (2021). AN OVERVIEW: FUZZY LOGIC APPLICATIONS ON WASHING MACHINE.
- A very brief introduction to Fuzzy Logic and Fuzzy Systems. (2022). Retrieved 26 February 2022, from https://towardsdatascience.com/a-very-brief-introduction-to-fuzzy-logic-and-fuzzy-systems-d68d14b3a3b8
- Kimia Lab. (2019, April 13).
**M**achine Intelligence – Lecture 17 (Fuzzy Logic, Fuzzy Inference)

[Video]. YouTube. https://www.youtube.com/watch?v=TReelsVxWxg

Get all slides regarding fuzzy logic and its implementation in washing machine here.

Get code here .