A Beginner Introduction to Fuzzy Logic with Matlab - Part 1
Hossein TooToonchy
I help overworked professionals turn their expertise into 6-7-figure revenue streams in 6 months using Productized OS? Framework | Ex-Amazon
In this short article I would explain the Fuzzy Logic and the need for it in the technology age. We do hear often about the Machine Learning, Artificial Intelligence, and Neural Networks yet little surfaces about the Fuzzy Logic and how wide spread this technology is in our lives. In order to get notified about the complete course, please register here : This is the first part of our new fuzzy logic course with Matlab. Please register here to get notified when the complete course goes live.
https://www.coursovie.com/fuzzy
If you prefer watching a video instead of reading this article, please see the Youtube video below.
Computers Vs Human
As you might already know, computers can only process information in the binary format that includes 0 and 1. It means that if you want to communicate with the computer, you need to learn code. Also, the program you write will later be translated into something called hardware level code that is understandable by machines as it contains only 0s and 1s.
Although the binary system is perfect for machines, it is far from convenient for humans. Look at this example, imagine you want to tell your friend about the large yellow shirt you have bought recently. In order to describe these characteristics to a computer, you need to define variables such as Large, Yellow, and shirt in the binary format. Well, for those of you who are familiar with programming, the solution is to define variables and containers for adjectives like Yellow and nouns like shirts. Although the binary system is perfect for machines, it is not really suitable for us as humans.
Instead, we prefer to interact with each other through descriptive words that we are already familiar with such as Yellow, Green, Red, Large, Small, Shirt, Car, and Apple. We don’t need an intermediate system to translate these variables for us. We have learned them a long time ago as a kid and while we grow up we had many years perfecting this as something we know as language. It is intuitive for us rather than intuitive for machines. Fuzzy logic will give that power back to us to be able to communicate with machines in our own languages instead of machines’ language. In subsequent sections, we will learn more about the accuracy and other requirements that make this communication even more efficient. Here we will review multiple examples of fuzzy logic to demonstrate that we already been using it on a daily basis without being aware of it.
Imprecision & Significance
In order to provide a clear description of Fuzzy logic, we need to explain some concepts first. The most important one is the case of imprecision. Today, when computers only understand 0 and 1 logic; trying to define imprecise data and information may look trivial or even unnecessary. However, it looks like that the majority of physical processes around us are largely based on imprecise data. In another word, imprecise data (when compared to the precise information required by computers) is much more valuable for us as humans. Ultimately it is the significance that matters to us. In order to drive the point home, please look at this example below:
In the left example, we see that almost accurate information is given to the person in danger. Although this information is accurate and could be used by computers to formulate a reaction to this scenario, it is pretty useless because it is not the way we humans interact with the world around us. On the right side and in a similar situation, a simple and understandable warning without any of the exact metrics is exactly what that person needs. Therefore, even without having the information about the mass, speed or direction of the car, we could make the right decision to inform the person and save him from danger. This is a great example to demonstrate that not all of the processes around us require to be precise or have complete information.
Adjusting Temperature (Showering Example)
As we learned so far, although we interact with machines on a daily basis, yet humans are living in a world where we communicate via words rather than bits and bytes of data. For us, the world is not only 0 or 1, but there are a lot of possibilities in between. Take showering as an example. When you take a shower, do you know what is your ideal temperature? Have you ever paid attention to how do you adjust the temperature every time?
Imagine that you want a computer to adjust the temperature for you. It looks like that if you know the degree you would like the temperature to be, it is will be a fairly straightforward task for a computer to adjust it using the temperature valve. However, we don’t have any temperature in our mind to adjust the temperature. We seem to do it intuitively. Instead of using numbers, formulas, and degrees. We use descriptive words such as cold, warm, too hot to adjust the water temperature accordingly. This method is much faster and more convenient than having a computer doing it for us.
As a matter of fact, this task is much more complicated than it looks like. Different people have different temperature preferences. Something is considered too cold for one person might be an ideal temperature for another. Even you might have different temperature preferences during different seasons of the year. Bringing all these variations to a computer program will soon turn that into a hugely complicated program to solve. Later, in this course, I will demonstrate how trivial problems can become challenging ones very quickly using a restaurant tipping problem.
Why Fuzzy Logic is Necessary? (State of an Apple)
We all can agree that what an apple should look like. Although apples come in different shapes, sizes and even colors, we can intuitively recognize one as soon as we see it. That is because we naturally think in the Fuzzy state.
An apple belongs to the set of apples if we imagine that such a set exists. If you take a bite out that apple, is that still an apple? Does that apple still belong to the apple set we defined earlier? If your answer is yes, take another bite and then answer the same question. After a couple of more bites, we can agree that the apple no longer belongs to the apple set we defined earlier and now belongs to a new set and we call it apple core.
But can you tell when that apple actually changed its state from an apple to an apple core? We can distinguish an apple from an apple core fairly easily, but how about all those states between the two? That area seems not to belong to an either of those. From a computer view, as soon as you take a bite out of an apple, that does not belong to the apple set anymore because it does not satisfy all of the apple set requirements. At the same time, it does not belong to the apple core set either because it does not qualify for its requirements. If you are following me, you get the idea that physical phenomenon in this world cannot be categorized in True or False or 0 and 1 states only. We need to be able to define much more states in between, and that is where Fuzzy System shines.
Fuzzy sets would resolve this issue by allowing its members to have multiple degrees of membership. We will explain the Fuzzy Sets and Fuzzy Memberships in next chapter in detail. However, we can learn that an apple in a Fuzzy set has a degree of membership that specifies to what extent that Apple belongs to the set. An apple with one bite out of it still belongs to the apple set but with less degree of membership than a whole apple. The same goes for the apples with more bites out of them. As the apple is eaten more and more, it loses its membership degree in the apple set and gains a higher degree of membership in apple core set.
Industrial examples of Fuzzy Logic (Washing Machine, Trains, Petrochemical Plants)
1999, Japan, Washing Machine
One of the earliest industrial implementations of Fuzzy Logic happened in early 1999 when Japan introduced washing machines that were equipped with Fuzzy controllers. These washing machines were able to measure the dirtiness of clothes and determine the level of water and cleaning solution required.
This was particularly an important product because such a solution was not possible using conventional controllers. There was no such a thing as a standard metric for dirtiness, and developing a controller to be able to do that would have introduced a lot of complexity and cost issues. Yet, a Fuzzy enabled controller was a perfect solution for this project and could save water and energy for the owners.
Sendai Metro with Fuzzy Controller
One of the most successful Fuzzy implementations was the use of the Fuzzy controller in Sendai Subway, Japan. The Fuzzy system controls the acceleration, deceleration, and breaking of the train very efficiently. Unlike the similar controlling systems that used Proportional Integral Derivative (PID) controllers, the Fuzzy logic controller was able to reduce 10% energy consumption and also provide a much more pleasant driving experience for the passengers. The Fuzzy controller also avoided all of the common disadvantages of the PID controllers such as overshoot, lagging and more. The operation and implementation of the Fuzzy logic is arguably half of the classic controllers, and any adjustment or changes is very easy to do.
What is Fuzzy Logic?
At this stage, we are in a good position to introduce a more official description of the Fuzzy Logic. Fuzzy Logic is a branch of Boolean Logic that deals with Partial Truth. Unlike classical controllers that requires everything to be either 0 or 1, Fuzzy logic replaces boolean values with degrees of truth that are similar to probabilities except they need not add up to 100%. This allows values between 0 and 1, shades of gray and maybe it allows partial membership in a set. We will review the Fuzzy Sets and Possibility Theory for more details.
Now consider the following examples,
- With having the information about the quality of the service at a restaurant we can now determine the amount of the tip
- With having the preference for the water temperature, the fuzzy system can adjust the faucet value to deliver the right amount of heat.
- With information about how far the object is from you, the fuzzy system can adjust the camera lens for you
- With information about how fast the car is moving, the fuzzy system can shift gears for you
These are just simple examples in which Fuzzy system can be employed to deliver results much faster than the conventional systems. Towards the end of the course, we will build very complex projects using the fuzzy logic that can not be solved using conventional control methods. This concludes the end of part one and in the next article we will explore more aspects of Fuzzy Logic.
For more information, please visit us at www.coursovie.com.
Written By : Hossein Tootoonchy