Almost Intelligent

Updated on 01-Sep-2007

Back in the good old days, you’d stare at your dirty laundry for a while, think, “Hmm… an hour for this lot,” pop it into the old machine and twist the dial to the one-hour mark. The washing machine, like all the dumb machines of those times, would go about its business, little caring for how dirty the clothes are or how much water it’s supposed to use. Ah, simpler times…

Today, your washing machine takes one look at your laundry, tut-tuts inwardly, and then tells you how much time it’ll take to do its work. As it does so, it’ll also make sure that not a drop of water is wasted, its temperature is just enough not to ruin your delicates without compromising on cleaning power. Short on detergent? No worries-the machine makes amends for that too. Regular super-dhobi, this.

And it’s not just the washing machines, either-refrigerators, air conditioners and a whole assortment of household devices are getting smarter thanks to the miracle of fuzzy logic (no, they’re not smart enough to come after you in your sleep, so stop shaking)-though you’re more likely to have heard the term in a washing machine commercial.

Thinking Different
In the peak of summer, when you exclaim, “Boy, it’s a hot day!”, other humans have no trouble understanding you. Of course, dwellers of the equatorial region may not agree, but they’ll still appreciate the sentiment regardless. A machine-a PC, for instance-won’t have a clue, though. How do you define “hot”? Let’s say you’ve programmed your PC to accept 30° Celsius as “hot.” But machines only understand binary talk-yes or no, this or that, hot or cold. You can’t expect them to have any concept of “maybe” or “somewhat hot.” So to your PC, even 29.999° Celsius doesn’t qualify as “hot”. Silly, yes?

A 50-year old, for example, is in that grey
area between “middle-aged” and “old.”

Human decisions are often based on “fuzzy” or imprecise data. Have you ever heard a human go, “Wow, her height is 174.25 cm!”? Of course not. “Wow, she’s tall!” is what you’ll most likely hear. Except in the Zulu tribes in Africa, where she’d be “somewhat tall”, and “gargantuan” amongst the pygmies. But enough with the tribes-the point is, there’s no real mathematical relationship between a person’s actual height and how tall they’re perceived to be. The most we can do is gather those perceptions to create “fuzzy sets.” In school maths, you’ve learnt that mathematical sets are groups of numbers or objects that meet a specific requirement-numbers greater than 2 but less than 80, for example. All nice and properly defined. The members of fuzzy sets, on the other hand, meet a vague (or fuzzy) definition-old people, dirty clothes, warm days and so on. The members of these sets overlap each other-a 50-year old, for example, is in that grey area between “middle-aged” and “old.” How deep in the grey area? Well, that depends on who’s making the sets. If you’re having trouble with this, look at the image above and all should be clear.

How machines really think. We’d get nowhere in a world like this


This is how fuzzy sets are usually represented. The peaks indicate
complete membership (a value of 1). This will become
clearer as you read on


Your First Washing Machine
We’ll use the washing machine analogy here-you’ve probably already seen it in action, but even if you haven’t, it’s easy enough to relate to. We’ll start simple-building a fuzzy relationship between your clothes’ dirtiness and the time it’ll take to wash them. Washing machines use dirt sensors to measure dirtiness-using either light or sound to detect the presence of dirt on your clothes (very RADAR-like, this is, but we can’t go too much in-depth for lack of space). Let’s say the dirt sensors give us the weight of the dirt (in grams) for every kilogram of clothing. Obviously, we’re assuming our washing machine also comes equipped with a weight sensor.

The fuzzy set for dirty clothes

The first step is to decide what our fuzzy set is going to look like. Let’s group clothes under “Clean”, “Dirty” and “Filthy”. If your load has zero grams of dirt for every kilo of clothes, then they’re clean. It goes downhill from there, and if your clothes have 100 grams of dirt for every kilo of clothes, they’re at the peak of the dirty set. Finally, at 300 grams, they reach the pinnacle of filth (you’re free to make your own stipulations, though). This is what we end up with:

And now, we lay down the law.

The Rules Of The Game
We started out with the intention of building a relationship between dirtiness and time taken to wash-that time has come. The rules for a fuzzy controller are simple “if…then” statements-the kind you learn about when you first learn programming at school. They go thus:

IF {condition} THEN {result}
(No, there’s no ELSE)

Let’s now define the rules for our washing machine:
IF clothes are Clean THEN time = 10 minutes
(This is mostly for psychological effect. Some people want their clothes extra clean)
IF clothes are Dirty THEN time = 45 minutes
IF clothes are Filthy THEN time = 90 minutes

(In the real world, the creation of these rules and fuzzy sets are based on a lot of research and some highly-educated estimates; even if the manufacturers start with this random set of rules, they’ll be modifying them once they run the first simulation and discover that they were wrong)
Well, we’ve built our machine; now let’s see how it works.


Fuzzifying the measured dirtiness-the degree of membership is where the value intersects the Dirty and Filthy sets

The First Batch

When you dump your first load into the machine’s drum, the dirt sensor kicks into action and measures its dirtiness. The result: 200 grams of dirt per kilo. The machine takes this value and “fuzzifies” it-mapping it to the fuzzy sets we fed it in the beginning. As you can see overleaf, this dirt level falls somewhere between Dirty and Filthy-more specifically, it’s 0.4 Dirty and 0.6 Filthy. The numbers are called degrees of membership, and mathematically represent the value’s position in the sets.

To find out how much time it’s going to take to wash these clothes, we need to see what happens when we apply our rules to this value of dirtiness.

I Want The Truth!
Another new term we come across here is degree of truth-a mathematical representation of the extent to which our measured value satisfies a rule. Let’s look at our conditions one by one, and consequently how much truth the corresponding results have.

clothes are Clean
They’re not, so the result time = 10 minutes has no truth
clothes are Dirty
They’re 0.4 Dirty, so the result time = 45 minutes has a 0.4 degree of truth
clothes are Filthy
They’re 0.6 Filthy, so the result time = 90 minutes has a 0.6 degree of truth

Now that we have this information, we need to “de-fuzzify” it to get a single, non-fuzzy output.

Making Sense Of It All
We know that if the clothes were perfectly dirty (a degree of truth of 1 for the second rule, 0 for the others), it would take 45 minutes to wash them. Similarly, it’s 10 minutes for perfectly clean clothes and 90 for perfectly filthy clothes. If we plot these values on a graph, we get something like this:

Now let’s put our findings-viz. 0.4 Dirty and 0.6 Filthy-on this graph. Using a mathematical technique called the Centre of Gravity method (which we won’t get into here), we find that the answer we want is 72 minutes.

Remember that fuzzy logic systems aren’t supposed to be overly
complex-too many variables lead to too many rules


The relationship between time and degree of truth


Voila! An answer!

Complicating Matters
We’ve just designed a very simple washing machine here, but you can see where all this can lead: you can bring more variables into the picture-clothes’ greasiness, water temperature, the weight of the load (to optimally utilise water), and so on. It can be quite the intellectual exercise, this.

Just remember that fuzzy logic systems aren’t supposed to be overly complex-too many variables lead to too many rules (just adding the “greasiness” variable to the machine above causes the number to increase to six), resulting in a lot of inefficiency.

Don’t forget, the washing machine isn’t the only place you’ll find fuzzy logic used. It’s been used in digital cameras to isolate faces from the rest of the scene, optical drives and heaven knows where potential applications lie.

Big Picture
Fuzzy logic is, as you might have guessed, the first step to artificial intelligence. After all, it is trying to duplicate the human thought process, no matter how primitively. For all its complexity, even game AI has its roots in a fuzzy logic system (“If health is low, take cover”-sound about right?).

Unlike true AI (which we’ve talked about a lot in these pages), though, fuzzy logic systems are perfectly realistic, and we’ll continue to see them grow in applications where you don’t need the mechanical versions of Einstein. We see them perfecting speech recognition systems, perhaps even bringing emotion to text-to-speech, and when the nanobots come, it’ll be fuzzy logic telling them the difference between the harmful and harmless cells in your body.

The Fuzz-less Life

What would you do if you had to design a simple, smart washing machine (how’s that for a mind-bender?) like the one we spoke about? One catch, though-pretend that fuzzy logic doesn’t exist.
You’d need to develop a dirt sensor that’s dead accurate even in a tangle of clothes, of course-but that’s not the worst part. You’d need to develop a mathematical relationship between the dirtiness of clothes and the time that it would take to clean them. Even if you could, it’d end up being a complicated quadratic equation in the eighth degree, with fractional coefficients to boot (or as some mathematicians would say, “mind-numbing pain”). Just for fun, what if you were asked to factor in the concentration of the detergent used? Or water temperature?
And then, what if you (miraculously) did it all, only to find out that all the seemingly right calculations in the lab fell apart in the real world?
Fuzzy logic saves lives, you’ll agree. 

Connect On :