Advertisement

Fuzzy Logic- Defuzzification problems

Started by March 22, 2009 09:56 AM
0 comments, last by Predictor 15 years, 8 months ago
I'm writing a appliction that is to use fuzzy logic to simulate a car sterring in a game. So far I've not had to much trouble when it comes to coding it. The application takes in 2 crisp values that represent the cars distance from the racing line (the optimal line for the car to follow) and for the rate of chage that the car is moving away or towards the racing line. These crisp values are then fuzzified using membership functions that are previously defined. My current problem is how to code the defuzzification method. I want to use the centroid method of finding the crisp output value but cant relate this to code. Does anybody have any suggestions as to the best way to code this? EDIT: Maybe I should be more specific. My problem is how do I code a way to define a shape from the combined areas underneath the clipped output membership functions? Following that, how do i then split up this complex shape, into a series of simpler shapes so that I can find the centroids of these shapes to find the overall centroid? There might be a simple solution to this and I'm just over thinking it, but its beyond me right now. Anyone who could explain how I would go about solving this, will be a god or godess to me. [Edited by - ScottH87 on March 22, 2009 11:43:03 AM]
The usual method for centroid defuzzification is to perform a weighted averaging in the output domain, and this is typically done on the composite output fuzzy set, not on the fuzzy antecedents of the individual rules.

As an example, let's say the output variable is "vehicle speed", and 4 different fuzzy rules have fired. The output domain is sampled from the minimum possible value to the maximum possible value in, say, 100 increments. The fuzzy outputs of each of those 4 rules is some sort of shape, represented along the output domain as a sampled function. Note that, for any one of those rules, many of the 100 sampled values will be 0.0. Some sort of composition method (the simplest being minimum, since you are ANDing the rules together) is applied across all of the individual rules outputs, yielding a single vector of 100 samples in the domain "vehicle speed". The centroid of this composite fuzzy set is taken by performing a weighted average: multiply each sample (which is fuzzy truth which can range from 0.0 to 1.0) by its corresponding value in the domain (each of 100 specific "vehicle speeds"), and sum. Divide this sum by the sum of those fuzzy truth values to obtain the centroid "vehicle speed" (and, hence, the crisp output of the fuzzy rule set).


-Will Dwinnell
Data Mining in MATLAB

This topic is closed to new replies.

Advertisement