"Yes, it works in practice.  But will it work in theory?"


Rick Landau
20 June 94



Three or four years ago, I read some articles and a book about fuzzy logic.  They were, well, interesting, but I didn't get it. So I read another book, and another.  It was clear that there was something going on, but I still didn't grasp how one would use the idea.  Then I found a textbook with some demo software.  It was almost a year before I installed and ran the demos.  Whoa.  Big mistake.  A couple simple demos convinced me, at least, that fuzzy logic is a technology waiting for applications.

Here's the basic idea.  Most variables in the world don't fall into neat, binary categories.  Instead of even trying to classify phenomena into precise categories, use deliberately overlapping, vague categories.  Any particular observation will fall into more than one of these categories to some extent or other.  Assign numbers to the extents to which the observation fits the categories, sort of the degree to which the categories' assertions are true about the observation.  Then you can do meaningful arithmetic and logic with those numbers.

We often state rules using such overlapping categories.   "If it's cold, turn on the heat."  "If it's hot, turn on the cooling." "Hot" and "cold" are vague regions and many observations will match both of them to some extent.  Instead of being uncomfortable with the gray area between categories, fuzzy logic uses the gray area. Just such vague rules can actually be useful to machines as well as people.

As an example of fundamental imprecision, temperature, in the region of interest to human comfort, ranges from "hot" to "cold" without a really clear dividing line between these two states. Ignore for the moment the subjectivity of my private definition of the hot-cold boundary versus your private definition; the problem is much more fundamental than that.  Even if the dividing line is specified precisely, deciding whether any particular situation is hot or cold is problematical.  The more accurately you try to measure the deciding variable, the more the situation looks vague. You can *estimate* average temperature with fair accuracy in a confined region; that's what a thermostat does.  How do you measure temperature at the microscopic level?  Is this atom hot or cold? The macro level is no clearer.  Is this room hot or cold?  Parts of it may be both.

The temperature ranges of interest to jet engines, or geologists, or astronomers, may be very different from our common one.  The terms "hot" and "cold" still apply, though with very different meanings, but the division between hot and cold is no clearer.

If we wanted to be more precise about hot versus cold, we could add some other descriptive terms to the spectrum: freezing, nippy, chilly, cool, tepid, lukewarm, warm, toasty, and beastly, for instance.  There are more of them across the range.  They are more precise.  Adjacent categories probably overlap, so that for a given temperature, we might be willing to say that both "chilly" and "cool" applied to some extent.

In a fuzzy logic system, a term like "chilly" defines a "fuzzy set," and observations have a membership value relative to that set.  The membership value ranges from 0 (zero) for "not at all like the category" to 1 (one) for "perfectly typical of the category."  In normal set theory, elements are either members or not members, that is, all the membership values will be zero or one.  In fuzzy set theory, some elements have intermediate membership values.  For example, 50 degrees Fahrenheit (10 degrees Celsius) is not at all typical of the category "toasty" so it has a zero membership in that fuzzy set.  However, it probably has non- zero values in both the fuzzy set "chilly" and the fuzzy set "cool."



In a real fuzzy logic system, we give precise, if somewhat arbitrary, meaning to these vague categories, so that we can compute membership values and use those values to help make decisions.  The remarkable thing about fuzzy logic, to me at least, is how robust it is to the arbitrary nature of the categories we use.  Just where the center of the category "chilly" is, and how wide it is, and what shape the distribution is, probably make little difference in the outcome of a model filled with such arbitrary choices.

A rule in a fuzzy logic model may be conditional or unconditional. An unconditional rule, for example, might be "The room should be warm."  A conditional rule might be like "If it is hot outside, then the cooling should be on."  There can be multiple conditions in a rule, as in "If it is hot and humid outside, then the cooling should be on."

A model may contain many rules.  All the rules are evaluated in parallel, and any that generate non-zero output contribute to the final results for the output variable(s).

The logic in a fuzzy logic model is performed with relatively simple logical and linear operations: usually just min, max, and simple arithmetic.  It is suitable for embedding in custom silicon; several companies have done this.

So, here are the steps in running a fuzzy logic model:

  1. Collect the input values and "fuzzify" them.  That is, determine their membership values in all the possible fuzzy sets.

  2. Evaluate all the rules based on the membership values.  If the conditions of a rule result in a non-zero value, then evaluate the predicate of that rule.  In general, the predicate produces a fuzzy set that is part of the solution.    

  3. For each output variable, "defuzzify" the collection of fuzzy sets contributed to the solution by all the rules.

Sounds too simple and vague to be useful, right?  Well, each of the steps seems to model the way we reason about everyday situations.

First, we tend to reason not with precise characterizations, but with generalizations.  "If it's cold, dress warmly."  Not "If it's above 53.5 degrees, then wear the light sweater.  If it's below that, wear the heavy sweater.  If it's below 2 degrees, wear the ski suit."  Reasoning is always stated in generalizations.  The degrees to which various general statements are true determine actual behavior.  Which brings us to the next point.

Second, fuzzy rules can model the way we normally think about things, though that might not be obvious at first.  To continue the hot-cold example, the degree to which the temperature matches "hot" determines the degree to which the cooling system ought to be on. The more the temperature matches the concept of "hot," the more the cooling ought to be on.  The less "hot," the less cooling is necessary.  The compound rule makes sense, too: the more the conditions match "hot" and the conditions match "humid" then the more the cooling system will run.  The less hot and humid, the less the cooling will be wanted.  This process of assessing quantity -- matching the intensity level of the output to the intensity level of the input -- is used all the time.  Fit the punishment to the crime.  "If guilty, then jail."  More guilty means more jail.  Less guilty means less jail.

Third, we reason with many rules at once, often conflicting ones. The room should be warm.  If it's hot outside, the room should be cool.  A number of rules can contribute to the ultimate decision. Each of them contributes something to the thought process.

Fourth, we have some way of reaching discrete decisions based on the collection of rules.  We "weigh the evidence."  Many rules can contribute some evidence to the balance.  Some are more important than others, either inherently or because they seem more appropriate to the current situation.

End of ranting.  An example follows.



Let's try a simple problem, a control system.  The problem is balancing an inverted pendulum.  Specifically, a stick with a weight on the end of it is attached to the shaft of a motor. Starting from any position, the task is to bring the stick to the upright vertical position and keep it there.  The control system can sense the stick's position (and its velocity by differencing), and can send an impulse to the motor that applies a force to the stick in either direction.

This is a standard problem for the first course in control systems theory, which is usually late undergraduate or early graduate school in engineering disciplines.  This is considered a simple problem.  There is a closed form, exact solution for any combination of pendulum weight and motor strength.

One possible fuzzy logic solution uses a surprisingly small number of sets and rules.  First, quantify position and velocity. The zero position is upright; horizontal left is -1; horizontal right is +1. Use the same units for velocity, unless you have some compelling reason to use some other units.  Then classify the position and velocity into five fuzzy sets: zero, small positive, small negative, large positive, large negative.  For any position and velocity, some of these fuzzy sets will be true to some degree.

Wait a minute.  What dividing lines do we use between zero and small, between small and medium?  Well, I think that, within a moderate range, it doesn't matter.  The first time I coded this model, I chose 40% for small and 80% for large.  They worked.  I haven't bothered to change the values.  I'm sure that some tuning would improve the results, slightly, but why bother.

Wait another minute.  What shape are the fuzzy sets?  What degree of overlap?  Well, I chose triangular sets for the simplest arithmetic, and they worked, so I haven't changed them.  To be precise,

I'd draw you pictures, but then I couldn't mail this document easily and you couldn't read it on your terminal.  Maybe I'll try some ASCII art.

Back to the problem.  If position and velocity each fall into one or more of five fuzzy sets, then there are 5x5 = 25 possible fuzzy situations.  For each of these 25 situations, we can assert a rule, an action, to help determine the output impulse.  The action will be taken in case both variables have a non-zero truth value for the two fuzzy sets for the input variables.

What rules do we use?  Common sense for balancing an object says that, if the object is sort of vertical and sort of stationary, then you probably ought not to do anything to move it.  Thus, we will probably want the action Z, for "motor impulse should be zero" in this case.

Wait a minute.  What does "motor impulse should be zero" mean? Possible impulse values are also divided into the same five fuzzy sets as the input variables.

So, here are some rules that work.

First, probably most obvious rule: If it's vertical and it's stable, don't perturb it.  In the terminology of this model, that translates to

Second, if it's leaning a little bit to one side, then push it back a little in the other direction.  In the terminology of the model,

Similarly for the other side, that is if it is leaning a little bit to the positive side, then push it a little bit to the negative side.  Sounds right, right?

Similarly, if it is leaning a lot to one side or the other, then push it back a lot in the other direction.  That is, replace SMALL with LARGE in the previous rules.

Now, one might think that these five rules would be enough, but there is an important factor missing.  If you try the model with just these rules, and you'll find that, even for fairly small starting perturbations, the pendulum oscillates forever.  For perturbations over about 30%, it oscillates between the limit values of -1 and +1.  Not good.

What is missing is "damping."  As the pendulum approaches the zero position, the controller needs to slow it down so that it does not overshoot zero by too much.  Clearly the two sides are symmetrical, so this reduction in velocity must occur in both directions. Suppose the pendulum is on the positive side but has considerable negative velocity.  When it nears the zero position, the controller needs a rule to provide the pendulum with some positive impulse to counter the negative velocity that will push it past zero.  This translates to the rule

And its opposite.

With these new rules installed, as the pendulum approaches vertical, the controller will give it an impulse in the opposite direction to shed some of its excess velocity.  Insert this rule and rerun the model.  You'll find that it reaches a stable vertical position very quickly from any starting position.  Yes, it still overshoots zero two or three times, but not by much.  It isn't optimal, but it is practical.

To be entirely fair, you need two more damping rules for the cases of VELOCITY is LARGE positive and negative.  These are important for cases where the pendulum inertia is very large relative to the motor strength.  But that's a nit, relatively.

Believe it or not, a real controller with these few rules really works. (Demo software is available.)



Yes, this problem has a closed-form solution and can be solved by any engineering students in a course on control systems.  But they have to use Laplace transforms and we get away with mere common sense.  A non-engineer with reasonable skills in logic and algebra could solve this problem.  Before I saw it, I would not have guessed that a mere seven common-sense rules stated in vague terms would suffice to provide stable control for this problem.

This type of solution is stable over a very wide range of conditions of pendulum weight, motor strength, and perturbation size.  Such broad stability is generally not characteristic of optimized control systems.  You can increase the ratio of pendulum weight to motor strength by a factor of ten or twenty, and the system will still be stable in the presence of moderate perturbations.



Lots of places, some that you've heard about and some not.  Your Japanese camcorder may have a fuzzy logic focusing or de-jittering system.  Your Japanese camera may have a fuzzy focusing system, despite the odd juxtaposition of terms in that expression.  Your Japanese automatic transmission or anti-lock brakes might have a fuzzy shift controller.  Your elevator probably uses a fuzzy controller.  Your Japanese vacuum cleaner almost certainly has a fuzzy controller for the wheels and brushes in the head.  Your microwave, refrigerator, and CD player probably use some fuzzy controls.  And your future washing machine will probably have one, too.

The technology is being applied in some more complex situations, too.  Control systems for chemical and manufacturing plants. Helicopter control systems.  Subway control systems.

In some cases, fuzzy logic controllers have achieved a degree of subtlety that traditional control systems have not.  Examples: a helicopter system that can stabilize a chopper with a broken rotor blade; a pendulum-balancer for a three-segment hinged pendulum; a subway control so smooth that many passengers don't hold on to the straps and poles.

In many of these cases, classical control systems were used for years with great success.  Why then are manufacturers moving to this new technology?  Three things ought to be noted here, I think.

From my (admittedly very little) experience with this technology, I conclude that the power of the technology, at least in the area of control, derives from a couple very simple attributes.

And I should mention one other interesting development.  In cases where you might not be able to articulate the rules directly, it is possible to use neural nets to discover rules by observing and analyzing the actions of experts performing the task, whatever it is.  So, find out from an expert what all the important input variables are.  Record these and the actions of the expert.  Feed the data to your neural net as input, get a rule set as output. Feed the rules to a fuzzy controller as input.  Have the expert watch its behavior and suggest improvements in the rules.  Loop until the controller works well enough.



The first formal expressions of these ideas were articles by Lofti Zadeh at U.C. Berkeley in the late 1960s and early 1970s.  The response of the engineering, math, and A.I. communities was, at best, a yawn.

In some cases the reaction was less agreeable.  A fellow professor at Berkeley commented, "Fuzzy logic is wrong, wrong and pernicious. What we need is more logical thinking not less.  The danger of fuzzy logic is that it will encourage the sort of imprecise thinking that has brought us so much trouble.  Fuzzy logic is the cocaine of science."  Pretty strong stuff, eh?  What on earth is this person afraid of?  This is the kind of -- pardon my value judgment -- ranting that one used to hear in religious arguments. Actually, I think the Inquisition was more gentle in its treatment of Galileo.

The reaction of some academic communities to this technology is understandable.  It isn't a deep theory.  There's some theory behind it, but much of it is ad hoc application.  We have a deep- seated prejudice for theory and against mere practice in the absence of good, testable theory.  Or in some cases, deep math. Much crackpot-ism, charlatanism, and superstition have been practiced in the name of empirical application.  "Try it.  It works.  I have no idea why, but I'll invent some mumbo-jumbo that sounds good."  Pyramids, copper, crystals, etc.

There has been a lot of information in the popular press, and some in the technical press, lately, so more information will be available on this subject.  The utility of this ad hoc technology has, apparently, finally overcome the lack of theory.






There has been a flurry of articles in the press recently on fuzzy logic.  Some of them include real code listings.  Try these for a start.


I've written a Windows-based demo, FUZZ1, as a first learning tool. It simulates the inverted pendulum controller.  With it, you can specify any rules and initial conditions for the problem, then single step the simulation and inspect the effects of the rules and scaling algorithms.  An archive should be available on the network somewhere.

And I'm working on another demo for a more complex problem.  The problem with demo software is not the fuzzy arithmetic; that's easy.  But visualizing the fuzzy spaces and the rules for multiple input and output variables is hard.


Comments and flames to the author: webmaster@ricksoft.com
"Why use logic when there's a flamethrower handy?" Hey, go ahead. I didn't exactly leave the gloves on when I wrote this.

Home Page
All contents copyright (C) 1994, 2001, Richard Landau. All rights reserved.
Revised: 2001/01/14