# Fuzzy Logic = Clear Opportunity

September 28, 2006

No Comments

The next sentence is true. But the previous sentence is false.

Epimenides of Knossos (Crete) was a semi-mythical philosopher-poet from the 6th century. One day, in a fit of poetic inspiration, it is said that he proclaimed, "All Cretans are liars!" Being a Cretan himself, he is remembered to this day for the Cretan paradox.

In Aristotelian logic, where something cannot be both true and false at the same time, these self-negating statements cannot be reconciled. If they are true, then they are false, but if they are false, then they are true. Enter fuzzy logic, a calculus that allows variables to have partial membership in a set. True and false are no longer absolutes - things can be somewhat true or somewhat false. Using this reasoning, one could mathematically prove that the Epimenides Paradox is exactly 50% true and 50% false.

As such, fuzzy logic is fundamentally incompatible with Aristotelian logic, particularly the law of tertium non datur (Latin for "a third is not given"), also called the law of excluded middle

For a less colorful example of places where fuzzy logic is useful, consider the concept of coldness. Most people will be able to answer the question, "Are you cold?" In general (unless you are talking to a post-graduate physics student), people will understand that the question is not asking if you are cold in an absolute sense. While 0° Kelvin is definitely cold, 65°F might not be cold to some.

Machines, on the other hand, have no such distinction. If cold is defined to be less than 65°, then 64.99° is cold, and 65° is not.

Consider Figure 1. Here, we have created a graph to assist in the interpretation of the idea of temperature as a human perceives it. At 60°, the temperature is cold, and at 80°, it is hot. At 65°, it is somewhat cold and somewhat comfortable. We will call this group of descriptions the human temperature membership function.

We could just as easily create more sets to describe human temperature. For example, we could add very cold and very hot sets. Similarly, we could describe different membership functions to describe other concepts, such as open or closed, or related concepts such as chiller temperature or cooling tower temperature.

It has been shown that a fuzzy system is a universal approximator, meaning that it can be used to approximate a very large class of linear or non-linear systems. Not only does this allow for a non-linear controls strategy with less valve action and overshoot, but it also allows the application of expert human knowledge to computer reasoning.

There are many possible definitions of these basic operations, a few of which are shown in Table 1. Incidentally, all these definitions apply equally well to Boolean logic (just plug in 0 and 1 to test them).

In Boolean logic, false takes on the value of 0, while true is represented with a 1. Similarly, in fuzzy logic, truth ranges from 0 to 1, so if it is cold to a degree of 0.1, then it is NOT(cold) to a degree of 0.9.

Before we continue, you might want to return to the Epimenides Paradox and try solving it (mathematically, A = NOT(A), where A is how true the statement is). For extra credit, you could try to figure out the sound of one hand clapping ...

There are many different techniques to do this, but we can consider just one to illustrate the process.

Height defuzzification outputs the weighted sum of fuzzy set peaks. It has several disadvantages, including a weakness at dealing with lopsided membership functions, but it has the advantage of being one of the simplest to understand.

For example, we assume that a set of rules that control a valve results in the following conclusion:

Closed: 0.1

Somewhat Closed: 0.2

Somewhat Open: 0.7

Open: 0.3

Notice that the total of the numbers is not 1 or 100%. This is because we are not dealing with probabilities or percentages, but rather degrees of membership. Using height defuzzification gives us:

Value= (0 x 0.1 + 0.2 x 25 + 0.7 x 75 + 0.3 x 100) / (0.1 + 0.2 + 0.7 + 0.3)

= (0 + 5 + 52.5 + 30)/(1.3)

= 87.5/1.3

= 67.3% Open

To illustrate the applicability of fuzzy logic to building automation, we list below a few rules that might improve efficiency in a building or help with fault detection. Italics are placed on terms that are fuzzy quantities.

Also, the vast majority of information that a fuzzy system requires to operate efficiently should be automatically supplied during the initial commissioning of the software. Leaving this up to the building engineer programming the system would be negligent on the part of the BAS developers and would effectively result in it not being used in the majority of installations. For example, membership functions (Figures 1 and 2) for quantities commonly used in building automation should be provided. And if a space temperature or a VAV controller is added, the software should be able to automatically assign appropriate membership functions to the points.

As energy prices continue to rise and it becomes clear that advanced failure detection is possible, building engineers and managers should keep their eyes open for innovative solutions. Fuzzy logic is a buzz phrase that, if done right, may just live up to its expectations.

2. For an example of a fuzzy logic algorithm that generally outperforms PID controls, take a look at the Mamdani controller at www.esru.strath.ac.uk/Reference/concepts/fuzzy/fuzzy.htm.

3. A longer list can be found at www.esru.strath.ac.uk/Reference/concepts/fuzzy/fuzzy_appl.10.htm.

His seminal paper on fuzzy logic was published in 1965, and it was not received well in some parts of the academic community. Even now, 40 years later, some of the controversy remains, but fuzzy logic has become well established in the toolbox of controls and estimation engineers.

A = NOT(A)

So, if we limit ourselves to Boolean logic, we come to the wholly unsatisfactory answer: 0 = 1. However, using fuzzy logic, we can solve the equation simply by applying the operations:

A = NOT(A)

A = 1 - A

2A = 1

A = 0.5

So, the sentence is exactly 50% true and 50% false.

Epimenides of Knossos (Crete) was a semi-mythical philosopher-poet from the 6th century. One day, in a fit of poetic inspiration, it is said that he proclaimed, "All Cretans are liars!" Being a Cretan himself, he is remembered to this day for the Cretan paradox.

In Aristotelian logic, where something cannot be both true and false at the same time, these self-negating statements cannot be reconciled. If they are true, then they are false, but if they are false, then they are true. Enter fuzzy logic, a calculus that allows variables to have partial membership in a set. True and false are no longer absolutes - things can be somewhat true or somewhat false. Using this reasoning, one could mathematically prove that the Epimenides Paradox is exactly 50% true and 50% false.

As such, fuzzy logic is fundamentally incompatible with Aristotelian logic, particularly the law of tertium non datur (Latin for "a third is not given"), also called the law of excluded middle

^{1}. Basically, it states that either something is true or it is not true. These postulates seem so basic that they are often considered unquestionable.For a less colorful example of places where fuzzy logic is useful, consider the concept of coldness. Most people will be able to answer the question, "Are you cold?" In general (unless you are talking to a post-graduate physics student), people will understand that the question is not asking if you are cold in an absolute sense. While 0° Kelvin is definitely cold, 65°F might not be cold to some.

Machines, on the other hand, have no such distinction. If cold is defined to be less than 65°, then 64.99° is cold, and 65° is not.

## Fuzzy Set Theory

While fuzzy logic has traditionally been the domain of graduate students, the basic concepts are surprisingly simple.Consider Figure 1. Here, we have created a graph to assist in the interpretation of the idea of temperature as a human perceives it. At 60°, the temperature is cold, and at 80°, it is hot. At 65°, it is somewhat cold and somewhat comfortable. We will call this group of descriptions the human temperature membership function.

We could just as easily create more sets to describe human temperature. For example, we could add very cold and very hot sets. Similarly, we could describe different membership functions to describe other concepts, such as open or closed, or related concepts such as chiller temperature or cooling tower temperature.

It has been shown that a fuzzy system is a universal approximator, meaning that it can be used to approximate a very large class of linear or non-linear systems. Not only does this allow for a non-linear controls strategy with less valve action and overshoot, but it also allows the application of expert human knowledge to computer reasoning.

## Fuzzy Operators

In order to define an algebra equation for handling fuzzy math, we need to define the operators. Boolean logic normally deals with a small set of operators from which all other operations proceed: NOT, AND, OR.There are many possible definitions of these basic operations, a few of which are shown in Table 1. Incidentally, all these definitions apply equally well to Boolean logic (just plug in 0 and 1 to test them).

In Boolean logic, false takes on the value of 0, while true is represented with a 1. Similarly, in fuzzy logic, truth ranges from 0 to 1, so if it is cold to a degree of 0.1, then it is NOT(cold) to a degree of 0.9.

Before we continue, you might want to return to the Epimenides Paradox and try solving it (mathematically, A = NOT(A), where A is how true the statement is). For extra credit, you could try to figure out the sound of one hand clapping ...

## Defuzzification

Very few valves know how to open up "just a little." In general, a piece of equipment prefers crisp numbers (such a 0 to 10V signal), which are produced by a process called "defuzzification." Defuzzification can convert the semantic knowledge contained in a fuzzy system into a realizable control strategy^{2}.There are many different techniques to do this, but we can consider just one to illustrate the process.

Height defuzzification outputs the weighted sum of fuzzy set peaks. It has several disadvantages, including a weakness at dealing with lopsided membership functions, but it has the advantage of being one of the simplest to understand.

For example, we assume that a set of rules that control a valve results in the following conclusion:

Closed: 0.1

Somewhat Closed: 0.2

Somewhat Open: 0.7

Open: 0.3

Notice that the total of the numbers is not 1 or 100%. This is because we are not dealing with probabilities or percentages, but rather degrees of membership. Using height defuzzification gives us:

Value= (0 x 0.1 + 0.2 x 25 + 0.7 x 75 + 0.3 x 100) / (0.1 + 0.2 + 0.7 + 0.3)

= (0 + 5 + 52.5 + 30)/(1.3)

= 87.5/1.3

= 67.3% Open

## Fuzzy Logic Applications

When fuzzy logic first came out, you would find articles in the scientific journals about possible applications of the theory. As the field advanced, lists started popping up of places where fuzzy logic was used in real-world applications. As it stands now, the list would be far too long to publish, but looking at a few examples illustrates how widely applicable fuzzy logic is to controls and expert knowledge mapping^{3}:- Cruise control and efficiency/stability enhancements to car engines (Nissan, Subaru)
- Handwriting recognition for PDAs (Sony)
- Safety improvement for nuclear reactors (Hitachi, Bernard, Nuclear Fuel Div.)
- Robot control (Toshiba, Fuji Electric, Omron)
- Industrial controls applications (Aptronix, Omron, Meiden, Sha, Micom, Nisshin-Denki, Mitsubishi, Oku-Electronics, and others)

To illustrate the applicability of fuzzy logic to building automation, we list below a few rules that might improve efficiency in a building or help with fault detection. Italics are placed on terms that are fuzzy quantities.

## Control

- If most of my VAV dampers are closed and at least some VAV reheat valves are open, then make supply setpoint higher.
- If most zone dampers are closed or almost closed for a long time, then make cold deck setpoint higher.
- If most zone dampers are open or almost open for a long time, then make cold deck setpoint lower.

## Fault Detection and Diagnosis

- Unit failure = most units' error is very low and my error is very high
- System failure = units have been running a long time and most units' error is high
- Sticktion = PID has been running a long time and PID error variance is high, if sticktion is high:
*Suggest a sticktion test*- If sticktion test passes:
*Badly tuned PID = PID error variance is high or PID mean error is high*

- If cooling:
*Leaky duct = units have been running a long time and return air is cold and average space temperature is hot*

- If heating:
*Leaky duct = units have been running a long time and return air is hot and average temperature is cold*

## Fuzzy Logic in Building Automation

While fuzzy logic may indeed be the next frontier in building automation, it is important to remember that in order to use fuzzy logic in a meaningful fashion, the BAS software needs to be built from the ground up with this functionality in mind. Not only must the language used to define the rules be well integrated into the operation of the software, but the distinction between conventional control agents or resources (such as PIDs, schedules, alarms, and so on) and fuzzy control must be clearly delineated. Incomplete integration or ill-defined conventional-to-fuzzy relationships may give rise to some very hard-to-find bugs.Also, the vast majority of information that a fuzzy system requires to operate efficiently should be automatically supplied during the initial commissioning of the software. Leaving this up to the building engineer programming the system would be negligent on the part of the BAS developers and would effectively result in it not being used in the majority of installations. For example, membership functions (Figures 1 and 2) for quantities commonly used in building automation should be provided. And if a space temperature or a VAV controller is added, the software should be able to automatically assign appropriate membership functions to the points.

As energy prices continue to rise and it becomes clear that advanced failure detection is possible, building engineers and managers should keep their eyes open for innovative solutions. Fuzzy logic is a buzz phrase that, if done right, may just live up to its expectations.

**ES**## FOOTNOTES

1. Two other laws of Aristotelian logic are also violated by fuzzy logic: the law of identity, which states that if something is true then it is true; and the law of contradiction, which states that something cannot be true and false simultaneously.2. For an example of a fuzzy logic algorithm that generally outperforms PID controls, take a look at the Mamdani controller at www.esru.strath.ac.uk/Reference/concepts/fuzzy/fuzzy.htm.

3. A longer list can be found at www.esru.strath.ac.uk/Reference/concepts/fuzzy/fuzzy_appl.10.htm.

## Lotfi Zadeh, The Father Of Fuzzy

Born in 1921, Dr. Lotfi Zadeh is considered the founder of the field of fuzzy logic. He graduated in 1942 from the University of Tehran, Iran, with a degree in Electrical Engineering, and later traveled to America to attend MIT (1946) and Columbia University (1949), where he taught system theory.His seminal paper on fuzzy logic was published in 1965, and it was not received well in some parts of the academic community. Even now, 40 years later, some of the controversy remains, but fuzzy logic has become well established in the toolbox of controls and estimation engineers.

Incidentally, while he is known primarily for developing fuzzy logic, he was also one of the pioneers that developed the z-transform for use in discrete signals and system analysis, a field with which anyone interested in using microcontrollers to perform digital signal processing or controls must become acquainted.

## Three Fuzzy Misconceptions

- Fuzzy logic is imprecise. Fuzzy logic is not inherently any more imprecise than standard arithmetic. It is in fact, a very precise way of dealing with imprecise information.
- Fuzzy logic is a form of probabilistic reasoning. Probability deals with chance that something may occur, while fuzzy logic deals with the event itself. Fuzzy logic generally deals with ambiguity, not uncertainty.
- Fuzzy logic is built from a number of heuristics. While the intuitive nature of fuzzy logic makes it seem that the rules are arbitrarily chosen or based on nothing more than common sense, they have, in fact, been rigorously proven to be correct.

## Epimenides Paradox

In its most basic form, the Epimenides Paradox can be expressed as: "This sentence is false." Put into algebraic terms, it looks like this:A = NOT(A)

So, if we limit ourselves to Boolean logic, we come to the wholly unsatisfactory answer: 0 = 1. However, using fuzzy logic, we can solve the equation simply by applying the operations:

A = NOT(A)

A = 1 - A

2A = 1

A = 0.5

So, the sentence is exactly 50% true and 50% false.