So what is fuzzy logic?
Take a look at the first sentence in this text. Expressions like "very flexible", "easily integrated" and "good solution" were used. This type of vague expressions are characteristic of the way we humans communicate through language and as such is an integral part of our thinking process. This contrasts sharply with the traditional Boolean logic of computer programming. Fuzzy logic bridges the gap between them, providing a framework that allows you to numerically encode linguistic expressions and through that gives you a flexible rule-based system.
This is the first part of a two-part tutorial and will cover the basic fuzzy logic theory. The second part will be more practical and deal with fuzzy logic in Synapse and the creation of hybrid fuzzy-adaptive systems.
0
or
1?
The traditional way of the computer is binary, either true (1) or false (0) and nothing in-between. There are some great advantages to digital representation, but ultimately we live in an analogue world and when describing it we are used to analogue terms defined through language. Suppose we say "Bob is tall". How would we quantify that? In the digital world, it would look something like this:
However, this would mean that while Bob, who is 180.1 cm in height is tall, while Frank who is 179.9 cm is not. That doesn't really reflect the way we would normally think. Instead, we would probably say that Bob and Frank are both rather tall. A fuzzy representation of the "tall" variable would look perhaps something like this:
As you can see, no sharp boundary at 180 cm, but a smooth transition. On the vertical axis we have "Membership Degree", indicating to what degree the value of a variable is in a set. In the digital world, membership degree can be 1 or 0, but in the fuzzy world it can be any value between 0 and 1. To understand this, let's expand on this example and look at a problem involving several regions. Suppose we wish to divide height into three classes: short, average and tall. A Boolean representation would perhaps look something like this:
Again we see those sharp boundaries. A fuzzy representation on the other hand might look something like this:
Note how the regions are overlapping - this is one fundamental feature of fuzzy sets: membership in a set isn't exclusive. A person that is 165 cm in height is a member of both the "Short" and the "Average" sets. Also note that there is nothing preventing you from creating Boolean (sharp) sets by using fuzzy logic. The regular Boolean logic is in fact a special case of the more general fuzzy logic.
So, how do we read the graphs above? Suppose height is 182 cm. Find the value on the horizontal axis and see where it intersects the membership functions for the three variables. The membership functions are in this case triangle shaped.
182 cm is outside the range of "Short", so short = 0, It intersects average at 0.4 and tall at 0.08. Also note that the values are not normalized, so the sum of membership degrees doesn't have to add up to 1.
Set
Logic
To be able to express ourselves with this new fuzzy thing, we need some basic rules. Our ultimate goal is to be able to define logical expressions that we later can turn into statements.
There are three relevant operators in the fuzzy set logic: OR, AND and NOT. They also obviously exist for regular Boolean logic, but we need to expand their definition to support our new non-sharp membership functions:
How do we apply this? Let's look at two examples. Suppose we introduce a new variable, "Weight" and in the same way we divided "Height", we divide this one into "Light", "Average" and "Heavy".
Let Height = 165 and Weight = 100. If we wanted to say "Height is short or Weight is heavy", it would look something like this:
As we did before, to find out the membership degree, we see the value of the membership function (vertical axis) for the variable value. We do this for both Height and Weight and then apply the OR rule (which is simply the maximum value).
In the same way if wee look at the AND rule:
Rules
and
hedges
A fuzzy rule is assembled as follows:
IF antecedent
THEN consequent
- Antecedent:
"height is tall and weight is light) or (weight is average and height is short" - Consequent:
"price is high"
Before putting it all together, there is one final concept we need to look at - hedges. When communicating in a natural language a form of mitigating device is commonly used to weaken or strengthen the impact of an statement. We might say "That's a very big house" or "The answer was more or less correct" or "She felt slightly uncomfortable". "Very", "more or less" and "slightly" are all examples of hedges.
In terms of fuzzy logic, hedges are operators that are applied on the membership function. The operators are defined in such a way to reflect their linguistic meaning and they create a sort of virtual set. For instance a "very" hedge would have this effect:
So for instance a person with a height of 185 cm would be a member of Tall set, but not of the Very Tall set. A person with a height of 190 cm on the other hand would be member of both.
Here are some examples of hedges that are supported in Synapse (the pictures show the effect of the hedges on a triangle shaped membership function):
| Hedge | Operator | Effect |
| A little | ||
| Slightly | ||
| Very | ||
| Extremely | ||
| Very very | ||
| Somewhat | ||
| Indeed |
Fuzzy
Inference
When we put it all together we can construct fuzzy inference systems. Fuzzy inference consists of basically four distinct steps:
- Fuzzification
This is the mapping from "crisp" numerical values to the membership functions of the fuzzy variables. - Rule evaluation
The rules defined are evaluated using the set logic we defined earlier. - Aggregation
The results of the rules are aggregated so that they are mapped to the output variables. - Defuzzyfication
The final step is the mapping from fuzzy output variables to crisp numerical values
Example
Suppose we want to design a risk-assessment system for some form of project. We wish to determine the risk depending on project funding and staffing. The fist step is to design our fuzzy variables, which are funding, staffing and risk. For each of these variables, we define the membership functions:
The next step is to define the rules for the system, using these variables. For instance one such set of rules may be:
- If funding is adequate or staffing is small then risk is low
- If funding is marginal and staffing is large then risk is normal
- If funding is inadequate then risk is high
Suppose we have a funding of f0 and a staffing of s0 people. What would the risk r0 be?
The first step, fuzzification is done like this:
We have mapped the "crisp" (i.e. raw values) f0 and s0 to the membership functions and found (for instance) that f0 has a 0.5 membership degree of "inadequate" and a 0.2 membership degree of "marginal". The same way s0 has a 0.1 membership degree of "small" and 0.7 membership degree of "large".
The next step is to evaluate the rules we have defined:
After we have evaluated all the rules, we aggregate the results to a single output area:
The output area is then deffuzified to get a crisp (i.e. single numerical) output r0. There are a number of methods of how you can do that, but a common solution is to take the center of mass of the result output area:
Normally the software (like Synapse) that you use handle the whole thing. Generally speaking, what is left to you is to define the initial membership functions and the rules while the evaluation is handled automatically. However, it is still good to know the basic principles of operation even if you are never going to do it manually.
Discussion
Fuzzy logic is a powerful tool for defining systems through a natural use of language. It is more flexible and corresponds better to our analogue world than traditional Boolean logic. However as with any tool, you must know when to use it and as always there is no such thing as a free lunch: it comes with a cost. The principal problem of defining a fuzzy system is not only that you must know the rules but also that you have to define the membership functions. Compared to adaptive systems, such as neural networks, that autonomously learn from data it may seem like an unnecessary hassle. There are however situations where you have expert knowledge that you wish to include in the system.
Data is seldom perfect, and giving an adaptive system a helping hand by a fuzzy preprocessing stage can help a lot. Fuzzy systems are especially good when they are combined with adaptive systems as the two complement each other and the adaptive system can compensate for the shortcomings of the fuzzy model (such as incorrect rules or badly defined membership functions).
There are also ways of doing a mapping of a neural network to do what the fuzzy system does (for instance ANFIS - Adaptive-Network-Based Fuzzy Inference System), which allows you to automatically extract fuzzy rules from data. Such neuro-fuzzy systems on the other hand have some problems of their own and the most powerful, useful and simple arrangement is to use a classical fuzzy system in combination with an adaptive system.
In the next tutorial we shall take a look at how you can use the Fuzzy Logic component in Synapse to do so.
Luka Crnkovic-Dodig / Peltarion
댓글 없음:
댓글 쓰기