Control via Fuzzy Logic
The previous chapter, The Basics of Control Theory, designed controllers by exact mathematical means — for instance choosing the feedback gains of a linear feedback control so the controlled system ends up with the eigenvalues, and hence the stability and response, we want. That approach is precise, but it is not always intuitive: it tells you which matrix to build, not in plain words why the controller acts the way it does, and it leans on having a mathematical model accurate enough to compute with.
Fuzzy logic is a different apparatus for the same job. Instead of sharp numerical thresholds it reasons with graded, human-readable notions like cold, lukewarm, and hot, and with intuitive IF–THEN rules an expert could state in words. Before we apply it to a control problem, we build up its vocabulary: fuzzy sets, the operations on them, and linguistic variables.
Crisp sets and fuzzy sets
Ordinary set membership is all-or-nothing: a given element is either in a set or it is not. Fuzzy logic relaxes exactly this, so the first thing it does is rename the ordinary kind of set to keep the two apart.
A crisp set is a set in the ordinary sense — finite or infinite — in which membership is all-or-nothing: every element either belongs to or does not.
A concrete element of a crisp set, such as a definite measured number, is called a crisp value (also a sharp value) — a plain, exact number with no ambiguity about it.
A fuzzy set keeps the same underlying collection of candidate elements but softens what “belongs” means.
A fuzzy set over a crisp set generalizes the all-or-nothing notion of membership: rather than being simply in or out, each element belongs to to a degree of membership between and , assigned by a membership function
The value states, for every element , the degree to which belongs to the fuzzy set : means “not a member”, means “fully a member”, and an intermediate value like means “largely a member” while means “barely a member”. One can write the fuzzy set out as its set of element–degree pairs,
The three-argument notation keeps explicit which element (), which underlying crisp set (), and which fuzzy set () we are asking about — useful once several fuzzy sets live over the same .
A degree of membership is not a probability. It looks superficially like one — a number in — but it obeys no normalization rule. If and are two fuzzy sets over the same , the same element can belong substantially to both, so
is perfectly possible. The degree measures how well fits the description , not how likely is to be something.
Two special cases tie the new notion back to the familiar one. Viewing the whole crisp set as a fuzzy set over itself gives full membership everywhere, for all ; and any ordinary crisp set is just the special fuzzy set whose membership is on its elements, for all (and off it). So crisp sets are the corner case of fuzzy sets where the only degrees used are and .
Two derived notions pick out parts of a fuzzy set by their degree of membership.
The support of a fuzzy set is the crisp set of all elements with nonzero membership,
For a level , the -level-set (also called the -cut) of keeps exactly those element–degree pairs whose membership reaches at least ,
A closely related operation does not throw the low-membership elements away but instead caps every degree at the level .
The cut fuzzy set bounds the degrees of membership from above at the level : it keeps a degree unchanged where it is already at most , and clips it down to wherever it would exceed it,
The distinction between the two is worth fixing: the -cut discards elements below the level but leaves the surviving degrees alone, whereas the cut fuzzy set keeps every element but flattens the top of the membership function at height . The cut fuzzy set is the one that does the work later, when a partly-satisfied rule is only allowed to fire partly.
Shapes of the membership function
Once the framework is in place, the essential modeling task is concrete: defining the shape and values of the membership function for each fuzzy set. This is where the modeler’s knowledge enters. The plain -to- leap recovers ordinary crisp sets; everything in between is a design choice, and many shapes are imaginable — piecewise linear, piecewise polynomials of higher degree, and so on. Available fuzzy-logic systems offer a handful of simple, ready-made options.
A useful way to read any of these shapes: plotted with the element on the horizontal axis and the degree on the vertical axis, a vertical side is an abrupt jump between full and zero membership — a crisp boundary — while a sloped side is a transition region of graded, partial membership, where the answer to “does belong?” is “somewhat”. The shapes below differ mainly in how wide and how smooth they make those transition regions.
- rectangle — both sides vertical, no transition region at all. This is just a crisp set drawn as a membership function: full membership inside the interval, none outside.
- triangle — often isosceles, but not necessarily. Membership rises linearly to a single peak at and falls back, so the two sloped sides are pure transition regions meeting at one fully-typical value.
- trapezoid — often symmetric, but not necessarily. Like a triangle but with a flat top: a band of values at full membership , flanked by two linear transition regions.
Smoother and one-sided shapes round out the catalog:
- S-form and Z-form — typically used for one-sided delimited terms, where membership saturates at one end. An S-form rises from to as increases (e.g. “large”, which only gets more true the bigger is); a Z-form is its mirror, falling from to .
- bell curve — often used for both-sided delimited terms: membership is high over a central band and tapers smoothly to on either side, like a rounded trapezoid.
- Also common are polygonal lines and a sinus half-period for the rising and falling flanks.
Operations on fuzzy sets
To reason with fuzzy sets we need counterparts to the standard set operations (and, equivalently, the logical connectives) — an intersection, a union, and a complement. There is wide scope in how to realize them concretely, adjustable to the application, but one restriction keeps the whole framework honest: the usual rules of logic must still hold in the crisp limit case, where every membership function is identically or identically (, ). Fuzzy logic is meant to extend crisp set theory, not to replace it with something unrelated, so whatever definitions we pick must reduce to ordinary intersection, union, and complement when the degrees collapse back to and .
The standard choices are the simplest ones that pass that test.
The intersection takes the pointwise minimum of the two membership functions,
The union takes the pointwise maximum of the two membership functions,
The complement flips each degree of membership about ,
Why these reduce to ordinary set operations
Restrict the degrees to the crisp values and . For the intersection, returns only when both inputs are — exactly the AND truth table — and otherwise, so becomes the ordinary intersection. For the union, returns as soon as either input is — the OR truth table — recovering the ordinary union. And swaps and , the NOT operation, so becomes the ordinary complement. The definitions therefore satisfy the crisp-limit restriction.
Linguistic variables
Working directly with membership functions is precise but unwieldy. To give an expert something intuitive to reason with, fuzzy control groups the fuzzy sets over one quantity under everyday words — cold, warm, hot — and treats those words as the values a variable can take.
A linguistic variable is characterized by its name and its possible values, the linguistic terms. It carries:
- an associated crisp set — the ordinary scale the quantity is measured on;
- a term set , the set of all linguistic terms the variable may take;
- one fuzzy set over for each term — so each word like “cold” is a fuzzy set, whose membership function says to what degree any given measured value counts as that word.
For example, a linguistic variable named temperature has the temperature scale as its crisp set and a term set such as freezing cold – cold – neutral – lukewarm – warm – hot; a linguistic variable named color has a frequency range (roughly ) as its crisp set and terms like green – yellowish-green – yellow-green – greenish-yellow – yellow.
Two design decisions come up immediately, and both are matters of modeling judgment rather than fixed rules. How many terms? Enough to express the distinctions the model needs, but not so many that neighboring terms can no longer be told apart. What shape for each term? Any of the membership-function shapes above, chosen to fit how the quantity behaves.
For the linguistic variable temperature, the crisp set is the temperature scale (real numbers, or a subinterval of them), the terms are freezing cold – cold – neutral – lukewarm – warm – hot, and each term gets its own membership function over that scale. The terms overlap: around a borderline reading, a temperature can count partly as cold and partly as neutral at the same time. The two end terms are one-sided — freezing cold stays at full membership for everything cold enough (open to the left) and hot likewise for everything hot enough (open to the right).
Two guidelines make such a layout usable. First, the terms should cover the whole range of values to be described, with no gaps — a gap would be a span of temperatures the system has no word for, and it could say nothing there. Second, the terms should still be distinguishable — piling many heavily-overlapping terms on top of each other leaves no reading that picks out one term clearly. A good layout is well spread and gapless. Note that, since the degrees come from independent fuzzy sets, the sum of all degrees of membership at a given value need not be — this is the non-probabilistic nature of fuzzy membership again, seen across the terms of one variable.
Fuzzy control systems
With this vocabulary in hand — fuzzy sets, their operations, and linguistic variables — fuzzy logic can be turned into a controller. A fuzzy control system is today very common, especially in consumer products like washing machines, dishwashers, and cameras, where the control task does not demand high precision. Its appeal comes from three places:
- No mathematical model needed. For many processes there is no model available, or the available one is far too complex to be useful. The previous chapter, The Basics of Control Theory, considered only the comparatively simple case of a system of homogeneous linear ODEs; the real world is usually much more complicated, and handling it by exact mathematics demands considerable effort. A fuzzy controller sidesteps the need for such a model.
- Modest mathematics. Building one is possible with little more than “school mathematics” — no eigenvalue analysis, no matrix algebra.
- Intuitive rules. The behavior is specified by linguistic, colloquial IF–THEN rules of the kind a human expert can simply state in words, which makes the controller easy to design and easy to read.
Inside the controller everything is evaluated fuzzily, but the two ends of the chain are firmly crisp: at the very beginning a sensor delivers a crisp value (a measured temperature, say), the fuzzy apparatus takes the detour through its fuzzy world, and at the very end the result is translated back into a crisp value — the setting actually applied to the actuator.
A fuzzy control system is a controller that maps a crisp measured value to a crisp control value by reasoning, in between, with fuzzy sets and intuitive linguistic IF–THEN rules. The input and output are crisp; only the processing is fuzzy.
Every fuzzy controller is built from the same four steps, run in order:
- Fuzzification — translate the crisp measured quantities into the fuzzy world: define the linguistic variables, their terms, and the membership functions, and read off the degree of membership of each measured value.
- Rule base — the IF–THEN rules relating the variables, drawn from expert knowledge.
- Inference — apply suitable inference operators to carry the fuzziness of the measured variables over to the control variables.
- Defuzzification — collapse the resulting fuzzy control values back into crisp control values.
We follow these four steps through one running example: controlling a cooling valve. The state variable is the temperature , and the control variable is the position (taking concrete values ) of the cooling valve — how far it is opened. Throughout, a capital letter (, ) names the linguistic variable together with the crisp scale it lives on, while the matching lowercase letter (, ) denotes a concrete crisp value on that scale.
Step 1: Fuzzification
The general principle of fuzzification is short:
- the measured values originate from crisp sets — each measured quantity is a linguistic variable with its own scale;
- for every linguistic variable there are several fuzzy sets, its linguistic terms, laid out to match human perception;
- for every measured value we determine its degree of membership in all of those terms.
So a single sharp reading does not pick out one term — it produces a whole profile of degrees. Measure , for instance, and we ask to what degree that reading counts as low, as medium, and as high, getting a number in for each.
Fuzzification is the first step of a fuzzy control system: it takes a crisp measured value and, for each fuzzy set (linguistic term) of the relevant linguistic variable, computes the degree of membership of that value. One crisp number is thereby replaced by a profile of membership degrees, one per term.
In the cooling-valve example a temperature value has been measured, and two linguistic variables (each with its own fuzzy sets) are in play: the temperature , with terms low, medium, high; and the valve position , with terms almost closed, ajar, almost open over the position scale . The temperature is what we measure; the valve position is what we will ultimately control.
Fuzzifying the reading against the temperature terms gives its degrees of membership, e.g.
The reading is largely low, somewhat medium, and not at all high — the overlapping terms let it count as more than one thing at once.
Step 2: The rule base
The second step encodes the controller’s behavior as rules, and like the membership-function shapes it draws on domain expertise. Its pieces are:
- an elementary condition of the form — a linguistic variable (on its crisp set) set equal to one of its fuzzy sets (terms) . Read it as “the variable currently takes the term ”, e.g. "" means “the temperature is low”;
- a logical connection of elementary conditions through the usual operators AND, OR, NOT;
- a triggered action of the form — a linguistic variable set to a term .
Putting these together gives rules of the form
with their respective linguistic variables and terms. The double subscript on keeps the bookkeeping straight: the first index says which input variable the condition is about, the second says which rule it belongs to.
Two things about the notation are worth pinning down, because both stretch the symbols a little.
First, here names a linguistic variable, even though the very same letter stood for a plain crisp set back when we defined fuzzy sets and membership functions . There is no real conflict: a linguistic variable is identified with the crisp scale it is measured on, so does double duty — it is both the variable and its underlying crisp set, and the elementary condition simply picks out one of the fuzzy sets (terms) living over that set.
Second, the "" is not literal equality — a variable is not the same kind of object as a fuzzy set, so it cannot actually equal one. It is shorthand for “the variable is described by the term ”. And even that is rarely all-or-nothing: at a concrete measured value , the reading does not simply satisfy or fail the condition "", it satisfies it to a degree — namely its degree of membership
So "" is really asking to what degree is the measured temperature low?, and a borderline reading can be partly low and partly medium at once. Collapsing each such question down to a single number for the whole IF-part is exactly the job of the inference step that follows.
The rule base of a fuzzy control system is its collection of IF–THEN rules, drawn from expert knowledge. Each rule connects elementary conditions (a variable equal to a term) with the operators AND (logical conjunction), OR (logical disjunction), NOT (logical negation) in its IF-part, and names a triggered action in its THEN-part.
For the cooling valve a small rule base suffices to illustrate the mechanics:
- rule 1: IF THEN (half-open);
- rule 2: IF THEN .
This is a deliberately reduced rule base, kept to the two rules the measured value will actually trigger — it says nothing about what to do when . A complete controller would add a rule for the high term too, so that the rules cover the whole range of temperatures with no gaps, exactly the design guideline already noted for the terms of a linguistic variable. Each rule here also happens to use a single elementary condition, so the AND/OR/NOT machinery only comes into play once rules have several conditions.
Step 3: Inference
Inference is where the fuzziness of the measured value is carried across to the control variable — in this example the valve position , the quantity the controller will ultimately set. At the measured value we first calculate the degree of membership for each elementary condition (each clause of an IF-part, e.g. ), and then combine those degrees according to the rule’s connectives, the logical operators AND, OR, and NOT that join the conditions:
- AND as the intersection of fuzzy sets — the minimum of the membership degrees;
- OR as the union of fuzzy sets — the maximum of the membership degrees;
- NOT as the complement — one minus the membership degree.
A single elementary condition just reads off the one degree of the term it names: contributes the number and nothing else, and how strongly the reading belongs to the other terms (low or high) plays no part in it. The connectives (AND, OR, NOT) then fold several such degrees into one, using the minimum, maximum, and complement rules just listed. The net effect is that the entire IF-part (the left side of the rule) collapses to a single fuzzy membership degree . Informally the rule has become “IF THEN …”, and that one number measures how strongly the rule’s premise is met.
The obvious inference strategy then propagates that strength to the conclusion: the value of the IF-part limits the membership degree of the fuzzy set in the THEN-part. The reasoning is that an only partly fulfilled premise should imply an only partly executed conclusion. Concretely, for each rule we form the cut fuzzy set — the action’s membership function, capped at the height .
Inference evaluates each rule of the rule base at the measured value. The IF-part is reduced to a single degree by combining the membership degrees of its elementary conditions with the connectives — AND as minimum, OR as maximum, NOT as (complement). This then caps the THEN-part fuzzy set from above, yielding the cut fuzzy set for rule .
Back to the example. Each of the two rules has a single condition, so its IF-part degree is read straight off the fuzzification:
- rule 1 yields — about at the measured — and caps its action accordingly: ;
- rule 2 yields and caps its action: .
Because is large the ajar term is barely cut, while the smaller cuts the almost open term down hard. What remains is, for each rule, a flat-topped fuzzy set over the valve scale . Turning these into a single crisp valve position is the job of the fourth and last step.
Step 4: Defuzzification
The final step turns the fuzzy outcome back into a crisp setting. By the time inference is done, every rule that fired has handed back a clipped term over the valve’s opening scale: in our example rule 1 returned ajar (but only up to the height ) and rule 2 returned almost open (up to the height ). It helps to picture these on one axis — the horizontal axis is the valve opening (a position on it is the value , running from fully shut on the left to wide open on the right), and the height above each opening is the degree to which that opening is currently endorsed. Defuzzification is the job of boiling all of these partial, overlapping verdicts down to a single number: the one opening we will actually set the valve to.
The first thing to settle is what to do when several rules reach for the same term. Suppose three rules had all concluded almost open, each with its own strength — one at , one at , one at . We do not add them up or average them; we keep the strongest, taking at every opening the maximum of their degrees. This is the fuzzy union, and the reasoning is plain: a term is called for as strongly as the most confident rule that calls for it, so almost open ends up endorsed at and the weaker duplicates add nothing. It is the same pointwise maximum that stood for OR inside a rule’s premise, now merging rules that agree on a conclusion rather than combining conditions within one premise. And notice what it runs over: all the almost open verdicts are folded together, and separately all the ajar verdicts are folded together — the union is not trying to blend ajar into almost open.
After that merging, each concluded term is left with a single clipped shape — one for ajar, one for almost open. These sit in different stretches of the opening axis (ajar around a half-open position, almost open nearer wide open), so putting them together is mostly just laying both shapes on the same axis at once; only where two happen to overlap does the same maximum keep the higher one. The combined picture that results is the accumulation: one fuzzy shape over the whole opening range that carries every rule’s conclusion together.
Reconciling those different terms into a single opening is then a separate step, and it is the part that actually produces the crisp number. Rather than merging ajar and almost open into each other, it picks the one opening that best represents the whole combined shape. In the running example there is just one ajar rule and one almost open rule, so the union has no duplicates to merge — it simply places and side by side on the opening axis — and all the real work falls to this final step. Whichever way it is taken, the answer is a position on the opening axis, and everything being averaged along the way is likewise a position on that axis, never a degree of membership. In particular, the “maximum” and “minimum” in the first two methods below are the largest and smallest opening in a support — the right and left ends of the stretch where the shape has any height at all — and not the peak and floor of its height. There are several ways to take it:
- the mean of the maximum and minimum of the support of the fuzzy union — find where the accumulated shape starts and where it stops, and take the midpoint of those two openings. If it runs from to , the crisp answer is . Only the outer boundaries count: how many terms fired, where they sit inside that stretch, and how strongly each one fired all drop out;
- the mean of the maximum and minimum of the supports of the individual cut fuzzy sets — the same endpoint-midpoint, but computed per term first and only then averaged. If ajar’s support runs from to it contributes the representative opening , and if almost open’s runs from to it contributes ; the mean of those two representatives is . Because every active term hands in one position of its own, this method does register how many terms fired and where each of them lies, which the outer envelope of the first method cannot see;
- the centroid of the accumulated area — its balance point, which leans toward whichever term fired more strongly and so contributes the most area;
- the weighted centroid, for weighted rules — the same balance point, but with each rule’s contribution additionally scaled by an importance weight.
Defuzzification is the last step of a fuzzy control system. For each control variable it takes the cut fuzzy sets that inference produced for that variable and accumulates them into one combined fuzzy set by fuzzy union. From these it then determines a single crisp control value — the number the controller actually applies — using the centroid of the accumulated area, a mean over its support, a rule working from the individual cut sets, or a similar collapse.
The most common collapse is the centroid. Writing for a value from the output range (the prospective control value), for the membership function of the fuzzy union, for the weight of rule , for the result of the IF-part of rule , and for the area under the membership function of fuzzy set , the -coordinate of the centroid is
This is just the center of gravity (balance point) of the area under the accumulated membership function, projected onto the output axis. When the rules carry different weights, one instead takes the weighted average of the individual centroids,
where is the centroid of rule ‘s own cut fuzzy set and its weight folds together the cut set’s area , the rule’s firing degree , and the design weight .
For the cooling valve we now have two cut fuzzy sets over the valve scale: (barely cut, since is large) and (cut hard, since is small). Accumulating them by fuzzy union and taking the centroid of the combined area gives a point ; its -coordinate is the crisp answer, and the valve is adjusted to that position. The simplest alternative — the mean of the maximum and minimum of the support — would instead just average the outer boundaries of the accumulated region.
There are also adaptive fuzzy control systems, which do not keep the rule weights and membership functions fixed but adapt them over time as the system runs — tuning the fuzzy world itself to the process it controls.
Example: the inverted pendulum
A classic test problem for any control method is the inverted pendulum (also called a balanced pole): a rigid pole stands on a cart, hinged at its base so that it can only tip along the single direction the cart is free to move. The cart, of mass , rolls left and right on a track, and we may push it with a horizontal force in either direction. Left to itself the pole topples; the control task is to drive the cart back and forth so that the pole stays balanced upright.
The state of the system is captured by a few quantities: the angle of the pole away from vertical, the rate at which that angle is changing, the cart’s horizontal displacement (written as it varies in time), and the cart’s velocity .
Classical modeling attacks this by writing the mechanics down directly. Balancing the horizontal and vertical forces on the pole’s center of mass, accounting for its rotational motion, and balancing the horizontal motion of the cart give four equations, which together form a system of four linear ordinary differential equations in the unknowns , , , and .
A fuzzy controller for the pendulum
Designing a controller for that model — even a linear feedback control — is relatively involved. Fuzzy control offers an alternative that sidesteps the model altogether: describe the situation in plain words and write down a handful of intuitive IF–THEN rules. The controller works with three linguistic variables:
- the angle , with terms negative, zero, positive;
- the angular velocity (the rate of change of the angle — how fast, and in which direction, the lean is shifting), with terms negative, zero, positive;
- the actuating force (the manipulated variable — the horizontal push applied to the cart), with terms large negative, negative, zero, positive, large positive.
To read the terms we fix a sign convention. We take the angle positive for a lean to the right (so that it grows rightward like the track’s own left-to-right axis), making a negative a lean to the left and the upright position. The force is then taken positive in the opposite direction — a push to the left — and with that choice the table below comes out so that the controller always drives the cart toward the side the pole leans (the note below sorts out what here is a free convention and what is actually fixed). The angular velocity follows from the angle: positive means is increasing, i.e. the pole is tipping further toward the right.
The rules pair the angle with the angular velocity using a simple AND, nine in all — one for each combination of a term with a term. A representative one is
Behind all nine sits a single intuition: push the cart toward the side the pole is falling, sliding the support back under the toppling mass, and push harder the faster it is going over. A pole leaning left and still falling left calls for the strongest push left (large positive); one that is upright and steady calls for nothing at all (zero); and a lean that is already correcting itself needs only a gentle nudge. The example rule above is one such gentle case: the pole leans left ( negative) but its angle is already increasing back toward vertical ( positive), so a moderate push toward that side (positive, a leftward push) suffices.
All nine rules are collected in a single table — the columns are the angle , the rows the angular velocity , and each entry is the actuating force the rule prescribes:
| negative | zero | positive | |
|---|---|---|---|
| negative | large positive | positive | negative / zero |
| zero | positive | zero | negative |
| positive | positive / zero | negative | large negative |
The two far corners are the clearest: a pole leaning left and falling further left (both and negative) gets the strongest push left, large positive; a pole leaning right and falling further right (both positive) gets the strongest push right, large negative. The center cell, upright and not moving, prescribes zero, and everything in between grades smoothly between these extremes.
Sign conventions: what’s free and what’s fixed
None of the left/right choices made above are dictated by the problem; they are conventions, and the text simply had to settle on some. The angle is counted positive for a lean to the right — a clockwise tilt away from upright, in step with the rightward direction of the Cartesian -axis, which is the convenient choice for a cart on a left-to-right track — but the unit-circle convention, with positive running counterclockwise (so a lean to the left is positive), would serve just as well. The force is just as free: its positive direction could point either way.
The one thing this example does fix is the relationship between the two. Positive is set opposite to positive , so the two conventions are not independent: once you choose which way the angle counts as positive, the force’s positive direction is settled as the other way, and choosing the angle the other way flips with it. That tie is all that is pinned down — the absolute “left” and “right” are not.
And even the tie is just bookkeeping in service of the single physical fact underneath: the controller pushes the cart toward whichever side the pole leans. With the rule table written as it is here, opposing the two positives is what makes its abstract terms read out as a push toward the lean; lay the table out the other way around and the two positives would line up instead, describing the very same controller. Nothing here is written in stone — so whenever a particular problem states or draws its own positive directions, adopt those and adapt every sign to match. And if a problem gives you none, pick them yourself — fix a positive direction for the angle and one for the force at the outset, then hold to that choice consistently throughout.
Summary
Pulling the pieces together, a fuzzy control system runs each cycle as a fixed process chain that carries a crisp measurement into the fuzzy world, reasons there, and emerges with a crisp setting:
- read the crisp measured value for each input variable;
- fuzzification — set up the fuzzy world: the linguistic variables with the fuzzy sets of their terms, and the degree to which each measured value belongs to each term;
- rule base — the IF–THEN implications that hold in that fuzzy world, drawn from expert knowledge;
- inference — for each rule, reduce its IF-part to a single degree of membership, then use that degree to cut the fuzzy set of its THEN-part down to a cut fuzzy set;
- defuzzification — for each control variable, take the fuzzy union of those cut fuzzy sets to recover one fuzzy set over the variable, and find the center of gravity of that accumulated area to read off a single crisp control value;
- set each control variable to its crisp control value.