Fuzzy Logic Toolbox    

Observations

Here are some observations about the example so far. We found a piecewise linear relation that solved the problem. It worked, but it was something of a nuisance to derive, and once we wrote it down as code, it wasn't very easy to interpret. On the other hand, the fuzzy system is based on some "common sense" statements. Also, we were able to add two more rules to the bottom of the list that influenced the shape of the overall output without needing to undo what had already been done. In other words, the subsequent modification was pretty easy.

Moreover, by using fuzzy logic rules, the maintenance of the structure of the algorithm decouples along fairly clean lines. The notion of an average tip might change from day to day, city to city, country to country, but the underlying logic is the same: if the service is good, the tip should be average. You can recalibrate the method quickly by simply shifting the fuzzy set that defines average without rewriting the fuzzy rules.

You can do this sort of thing with lists of piecewise linear functions, but there is a greater likelihood that recalibration will not be so quick and simple.

For example, here is the piecewise linear tipping problem slightly rewritten to make it more generic. It performs the same function as before, only now the constants can be easily changed.

Notice the tendency here, as with all code, for creeping generality to render the algorithm more and more opaque, threatening eventually to obscure it completely. What we're doing here isn't (shouldn't be!) that complicated. True, we can fight this tendency to be obscure by adding still more comments, or perhaps by trying to rewrite it in slightly more self-evident ways, but the medium is not on our side.

The truly fascinating thing to notice is that if we remove everything except for three comments, what remain are exactly the fuzzy rules we wrote down before.

If, as with a fuzzy system, the comment is identical with the code, think how much more likely your code is to have comments! Fuzzy logic lets the language that's clearest to you, high level comments, also have meaning to the machine, which is why it's a very successful technique for bridging the gap between people and machines.

Or think of it this way: by making the equations as simple as possible (linear) we make things simpler for the machine but more complicated for us. But really the limitation is no longer the computer -- it's our mental model of what the computer is doing. We all know that computers have the ability to make things hopelessly complex; fuzzy logic is really about reclaiming the middle ground and letting the machine work with our preferences rather than the other way around. It's about time.


  The Fuzzy Approach Tutorial