- Improved system performance
- Improved quality of products
- Energy saving
- Lower-cost of development
- Reduced time to market

- Fuzzy Logic
- Artificial Intelligence
- Knowledge-base
- KB System
- Linguistic Variables
- Fuzzy Logic Systems
- Basic Concepts
- Fuzzy Controller
- Membership Function
- Fuzzy Decision Rules
- Fuzzy Cont. Structure
- Fuzzification
- Inference
- Defuzzification
- Designing Fuzzy Logic

Artificial Intelligence (AI) is a branch of science concerned with the study, understanding and simulation of human intelligence. Started in the forties and flourished in the sixties, AI has presently become an umbrella for many other branches of science, such as the study of language, translation, decision making, common sense, search, machine learning etc. AI theories and methods employ computer programs for implementation. During the 80’s, expert systems appeared as large computer programs to help professionals in decision making. Fuzzy logic is the new generation of expert systems which can be employed in decision-making as well as real-time industrial control.

Expert systems are termed knowledge-based systems. In these systems there are two central components, the inference engine (the thinking mechanism) and the knowledge on which it operates

There is a particular definition for knowledge in artificial intelligence terminology. Knowledge is defined to be the information related to the experience. It is, therefore, domain (or problem) dependent. This means that every problem requires its own special knowledge to address which may be different from the knowledge required to solve other problems. It is evident therefore, that knowledge acquisition is a non-trivial problem. Another significant issue in knowledge is that of its structure, i.e. the way and form in which it is represented such as rules, trees, graphs, etc. It turned out that the knowledge structure and the inference mechanism of an intelligent system are closely inter-related. An inference mechanism which is suitable to work with a certain structure of knowledge representation may not be suitable if this structure changes.

**Inference Engine**

The inference engine is the reasoning mechanism used by intelligent systems to operate on the knowledge-base and infer decisions utilizing input/output data (information) related to real world situations (the external world). In fuzzy logic terminology it is also called the Approximate Reasoning Mechanism.

The inference engine is not domain (or problem) oriented. In other words, it is independent of the problem type. Hence, one inference engine can be utilized to address several different problems and may be used for the control of several types of industrial systems. However, the knowledge-base will be different for every system.

A knowledge-based system is defined to be that system which has an approximate reasoning mechanism (inference engine) and a knowledge-base which are separate and distinct from each other. The human brain is a knowledge-based system.

A system in which the inference engine and the knowledge are not separate from each other is not a knowledge-based system, such as a computer program for solving a problem in which the intelligence and knowledge are distributed throughout the program in the form of equations, parameters, coefficients, instructions and statements.

The knowledge-based system consists of a reasoning mechanism which uses knowledge to manipulate data. Knowledge-based systems are efficient systems since one reasoning mechanism can operate on many knowledge bases to manipulate enormous data and control several systems (figure 3).

KB systems are easy to develop at present. They are available in the form of expert system shells offered by several high tech companies. The shell is a complete expert system which houses the reasoning mechanism (inference engine), data base and user-friendly tools to customize the knowledge base for applications. Generally, no software development and extra coding is required. Users have more time to focus on their own problem. They are only required to define the application knowledge, test and validate the system. Most these shells come with capabilities for linking with extra code that the application may require or to third party software systems.

Compared with programmed systems which:

- Involve a lot of SW development
- Hard coded
- Limited intelligence
- No separation of KB from the programs

**Applications of KB Systems**

KB Systems are now widely used in solving difficult problems, enhancing production and efficiency.

Areas of application include:

- Decision Making
- Production Planning & Scheduling
- Control
- Diagnostics
- Management
- Forecasting

Engineers and scientists are familiar with the variables whose values are numerical. Fuzzy logic introduces the concept of a linguistic variable which is a new type variable not previously used in engineering or science. A linguistic variable is a variable whose value is not a number but a word or a sentence (or more). For example the statement Mark is short says that there is a variable which is the height that has the value short for Mark. Evidently, the value is not precise and the statement is fuzzy. This concept constitutes the key relationship between linguistic variables and fuzzy logic. The statement Mark is short can also be written as:

Height (Mark) = short

where short is a fuzzy subset (or a pattern) of possible heights. The set of all possible heights is called the Universe of Discourse of values to which short belongs. As will be seen later, fuzzy logic captures this concept employing the membership functions.

Fuzzy Logic is a new generation of expert systems developed in the late sixties and early seventies by Lotfi Zadeh of the University of California at Berkeley.It is designed to simulate human thinking to intellectualize computer programs and microprocessor chips operations in decision making and control applications. The idea behind fuzzy logic is to capture human experience which is available in the form of linguistic terms and rules to intellectualize computer software technology. Humans perceive world events not only as black and white, but with a large gray area extending between these two limits. Many adjectives and descriptions used are quite vague. For example, people may be described as being tall, short, fat, thin etc., and even though these labels are vague in the sense that they do not give exact measurements, they are understood. Fuzzy logic refers to this human ability to perform logical reasoning using such usual facts and previous experience (knowledge). Examples of the facts which are fuzzy in nature and contain imprecise statements and descriptions are:

- The temperature is high
- The motor speed is normal

The experience is captured as human rules in the form of “IF … THEN” statements such as:

- IF the flow is low THEN open the valve moderately
- IF car speed is high THEN press brake firmly

Fuzzy logic handles VAGUE situations to provide as PRECISE decisions as possible.

**Features**

Fuzzy logic has two strong features:

- It accepts imprecise, human-like (fuzzy) knowledge, compared to knowledge-based systems with precise knowledge such as traditional expert systems.
- It employs powerful adaptive reasoning mechanism to deduce results from facts (e.g. measurements) and fuzzy (human) knowledge (e.g. rules).

Fuzzy logic is:

- A new way of developing and implementing control systems;
- A method for handling control systems which are:
- too complex,
- highly nonlinear,
- uncertain using traditional techniques and methods.
- Used for complex systems which cannot be modeled mathematically;
- Not in conflict with conventional methods and can be added or integrated to them;
- Solves the question of uncertainty;
- Provides a systematic framework for dealing with linguistic quantifiers such as most, many, few, somewhat, almost etc.

To see what is meant by saying fuzzy logic accepts imprecise knowledge, consider the conventional set theory on which the Boolean logic operates. An object is either a member of a given set of objects or not. In fuzzy set theory, however, an object has a degree of membership in a given set of objects. This degree can be anywhere between 0 (not a member of the set) and 1 (completely in the set). So if we say John is short, Boolean logic would require John to belong to the set of short people and the statement would be either TRUE or FALSE. Fuzzy logic, on the other hand, would not have such a stringent requirement. Instead, it would assign a degree of membership for John in the set of short people, say 0.4 . This allows fuzzy logic to handle human concepts in a natural and simple way.

Fuzzy logic defines operators on the values of membership functions which are analogous to Boolean logic operators. These are AND, OR and NOT and used as shown in the table below:

Fuzzy logic is built on three concepts:

- The concept of fuzzy pattern as a human interpretation of real world and sensor data (High, Low, Fast, Slow etc.).
- The concept of membership function as a continuous mapping of sensor data into fuzzy patterns.
- The concept of approximate reasoning for modeling human inference

These concepts are used in the design of all fuzzy controllers.

A fuzzy controller is an expert system which uses a fuzzy reasoning algorithm (reasoning machine) and an expert knowledge (in the form of rules and membership functions) to provide intelligent decision making and optimum control. Fuzzy controllers are offered in the form of computer programs, or controller HW boards hosting fuzzy microprocessor chips.

**A Fuzzy controller is:**

- Easy to develop and low cost;
- Offers better human interface to the end user;
- Able to incorporate previous human experience to make decision;
- Provides smooth and continuous response;
- Robust against noise, tough disturbances and deterioration of plant characteristics;
- Energy and raw material saver.

**Fuzzy Controller vs. PID Controller**

The fuzzy controller is superior to PID in the following:

- It can handle nonlinear control system with ease;
- Can be used in both decision making and closed loop system control;
- Flexible to accommodate different kinds of knowledge required for implementing advanced control strategies;
- Stable over wide range of set-point variations (does not require re-tuning for each set-point change like the PID);
- Robust against noise, tough disturbances and deterioration of plant characteristics;
- Can be thought of as several PID’s working in parallel.

**Fuzzy Controller Knowledge-base**

- Membership functions: knowledge to capture and describe the observations of real life (the facts, such as sensor measurements)
- Fuzzy rules: knowledge to capture and describe what to do about the observations (our previous experience)

The membership function (MF) is a tool (normally in the form of a curve, triangle or trapezoid) to interpret and quantify fuzzy terms such as: Cold, Warm, Hot, etc. Figure (5) illustrates the MF distribution to interpret the meaning of Low, Medium and High. Such terms may be declared by a human expert to define a process variable, for example Temperature, varying over the range 0-100 deg. C.

In this way the membership function allows linguistic description of sensor data as a fuzzy pattern. It is capable of providing:

- Interpretation of sensor data;
- Human judgment about measurement and process status;
- Human judgment about actions and decisions;
- Description of nonlinearities in linguistic form embedded in statements such as:
- The Temperature is High
- The Motor Speed is Normal

The fuzzy decision rule is a tool for describing a situation and the action required for it linguistically. It captures the knowledge of what to do given a certain situation or fact (measurement). This is in fact describing human experience and translating it into active command. It is called fuzzy because it has vague antecedent and vague consequent. A fuzzy rule is normally expressed in the form of IF … THEN statement. The IF part is the antecedent or premise and the THEN part is the consequent or

conclusion. When applying fuzzy logic to system control the consequent is also called the action (or fuzzy action). Examples are:

- IF the flow is low THEN open the valve moderately
- IF speed is high THEN press brakes firmly.

An example of fuzzy rule vs. crisp type rule (which is used in conventional expert systems) is (figure 6):

The fuzzy knowledge base is usually generated and tuned either manually by experts, or automatically by the use of automatic knowledge-base generation and tuning system. Since the fuzzy inference engine is normally available, the design of the fuzzy controller for a specific system is, in fact, reduced to the task of generating and tuning the knowledge-base of the fuzzy controller for the specific application. This is normally performed using human friendly development tools. These tools consist of software and hardware parts.

The fuzzy controller has three basic blocks:

- The fuzzifier which maps the measurement signals into fuzzy terms (such as High, Low etc.).
- The inference engine (approximate reasoning mechanism) which deduces the control actions in the form of fuzzy terms.
- The defuzzifier which translates the fuzzy control actions into crisp control signals.

The control cycle in fuzzy controllers is similar to that of conventional controllers from the point of view of signal flow between the process and the controller. Fuzzy controllers, howev¬er, operate on different principles in the sense that all sign¬als are treated linguistically. Since the process measurements are available in the form of crisp values, the fuzzy controller converts these crisp values into linguistic terms, works with them in this form, produce the control commands in linguistic terms, then finally converts these linguistic com¬mands into crisp values in the form of control signals going to the process. The fuzzy controller performs these operations using the three blocks of the fuzzifier, inference engine (approximate reasoning) and defuzzifier.

The fuzzy controller operates as follows (figure 8). The input signals are received from the process. They are channeled to the fuzzifier which fuzzifies the data and maps it into linguistic variables. The inference engine performs the approximate reasoning to infer the fuzzy control action (linguistically). The defuzzifier then maps the fuzzy action into crisp data which is then sent to the process as the control signal. There exist several schemes for fuzzification, inference and defuzzification. We will discuss the most widely used techniques here.

Fuzzification determines the fuzzy subset to which the data value belongs as well as its degree of belongingness. The degree of belongingness is the value of the membership function for that particular data.

**For crisp data:**the membership function value (degree of membership which is also called membership grade) is the value of the membership function at that data value (figure 9.a.).**For fuzzy data:**the membership function value is the maximum value of the intersection of the membership function of the fuzzy data and the fuzzy set (figure 9.b.). Note that this intersection is the area common between both of them.

Performing an inference is the process of applying the membership function values (degrees) which are calculated by the fuzzification to determine the control action. Note that the membership function values which are calculated by the fuzzification belong to a fuzzy rule premise (antecedent). In other words, we are inferring the control action from the premise. Several inference methods are available. The most widely used are the max-min and the max-product (also known as the max-dot). Both methods involve simple calculations to compute the membership value to be assigned to the fuzzy rule conclusion. This calculation is either the max or min value among the membership values.

a. **The max-min inference method:** In this method the membership value computed is used to clip the degree of membership of the conclusion: There are two cases:

- The min case: employed if the fuzzy rule uses an AND operator. The min value is used. Example is: If Temperature is Medium AND Humidity is Medium then fan speed is Medium (figure 10.a).
- The max case: employed if the fuzzy rule uses an OR operator. The max value is used. Example is: If Temperature is Low OR Humidity is Low then fan speed is Low (figure 10.b).

b. **The max-product (max-dot) inference method:** In this method the membership value computed is used to scale (instead of clipping) the degree of membership of the conclusion. Again two cases exist, the max and min, as above (figure 11).

The calculation of the area and its moment depends on the area shape and generally involves integration (or summation in the discrete case)

Defuzzification maps the fuzzy output into crisp output value. This is particularly important in control applications. Several defuzzification methods are available. The most commonly used are the centroid (center of gravity) and height methods.

a. **The centroid defuzzification method:** In this method the crisp output value is calculated by finding the center of gravity of the aggregate membership function of the output fuzzy value (shaded areas in figures 10 & 11).

b. **The height (Singleton) defuzzification method:** In this method the output is an average of the weighted output values. The value of each output membership function at the vertex is multiplied by the clipping (or scaling) degree, and then the results are averaged. The name Singleton is also used because this method uses one value at the vertex of the output membership functions (figure 12).

Designing a fuzzy controller involves two stages. The first is to choose the inference engine and defuzzification method of interest. Second is to generate and tune the knowledge-base (fuzzy rules, membership functions and scaling factors). After selecting the inference engine and defuzzification method the problem remains is that of generating and tuning the KB. Three steps are involved:

- Identify linguistic (i.e. process) variables together with their ranges;
- Identify fuzzy labels (patterns, such as Low, Medium, High etc.) and membership functions for each variable. This will automatically decide the number of fuzzy rules and their consequents;
- Identify fuzzy rules. This means deciding on the rule consequents.

**Example**

1. Identify process variables:

- The distance X from the stop line.
- The distance Y from the left lane boundary.
- The distance Z from the curb.

2. For each of these variables identify membership functions, such as positive small (PS), positive medium (PM), positive big (PB), negative small (NS), negative medium (NM) and negative big (NB)

3. Identify fuzzy rules.

IF

X = PB and Y = PM

THEN:

Move forward PB (a lot)

Move to the right PM (medium)

IF

X = PS and Y = PB

THEN

Move forward PS (a little)

Move to the right PB (a lot)

etc.

Shopping Basket