With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

The Triangular Fuzzy Set Class
A triangular fuzzy set is defined by three values: a peak point, a left offset,
and a right offset. See Figure 10.24.
The declaration of the class encapsulating this data is as follows:
class FuzzySet_Triangle : public FuzzySet
{
private:
//the values that define the shape of this FLV
double m_dPeakPoint;
double m_dLeftOffset;
double m_dRightOffset;
public:
FuzzySet_Triangle(double mid,
double lft,
double rgt):FuzzySet(mid),
m_dPeakPoint(mid),
m_dLeftOffset(lft),
m_dRightOffset(rgt)
{}
//this method calculates the degree of membership for a particular value
double CalculateDOM(double val)const;
};
As you can see, it’s very straightforward. Notice how the midpoint of the
triangle is passed to the constructor of the base class as the representative
value for this shape. The interface from
FuzzySet only defines one method
that must be implemented:
CalculateDOM, the method that determines the
degree of membership of a value to the set. The following is the code for
that implementation:
double FuzzySet_Triangle::CalculateDOM(double val)const
{
//test for the case where the triangle's left or right offsets are zero
440 | Chapter 10
From Theory to Application: Coding a Fuzzy Logic Module
Figure 10.24. A triangular membership function

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required