The class represents a linguistic variable.

Namespace:  AForge.Fuzzy
Assembly:  AForge.Fuzzy (in AForge.Fuzzy.dll) Version: (


public class LinguisticVariable


Linguistic variables are variables that store linguistic values (labels). Fuzzy Inference Systems (FIS) use a set of linguistic variables, called the FIS database, to execute fuzzy computation (computing with words). A linguistic variable has a name and is composed by a set of FuzzySet called its linguistic labels. When declaring fuzzy statements in a FIS, a linguistic variable can be only assigned or compared to one of its labels.

Let us consider, for example, a linguistic variable temperature. In a given application, temperature can be cold, cool, warm or hot. Those will be the variable's linguistic labels, each one a fuzzy set with its own membership function. Ideally, the labels will represent concepts related to the variable's meaning. Futhermore, fuzzy statements like "temperature is warm" or "temperature is not cold" can be used to build a Fuzzy Inference Systems.

Sample usage:

// create a linguistic variable to represent temperature
LinguisticVariable lvTemperature = new LinguisticVariable( "Temperature", 0, 80 );

// create the linguistic labels (fuzzy sets) that compose the temperature 
TrapezoidalFunction function1 = new TrapezoidalFunction( 10, 15, TrapezoidalFunction.EdgeType.Right );
FuzzySet fsCold = new FuzzySet( "Cold", function1 );
TrapezoidalFunction function2 = new TrapezoidalFunction( 10, 15, 20, 25 );
FuzzySet fsCool = new FuzzySet( "Cool", function2 );
TrapezoidalFunction function3 = new TrapezoidalFunction( 20, 25, 30, 35 );
FuzzySet fsWarm = new FuzzySet( "Warm", function3 );
TrapezoidalFunction function4 = new TrapezoidalFunction( 30, 35, TrapezoidalFunction.EdgeType.Left );
FuzzySet fsHot  = new FuzzySet( "Hot" , function4 );

// adding labels to the variable
lvTemperature.AddLabel( fsCold );
lvTemperature.AddLabel( fsCool );
lvTemperature.AddLabel( fsWarm );
lvTemperature.AddLabel( fsHot  );

// showing the shape of the linguistic variable - the shape of its labels memberships from start to end
Console.WriteLine( "Cold; Cool; Warm; Hot" );
for ( float x = 0; x < 80; x += 0.2 )
    float y1 = lvTemperature.GetLabelMembership( "Cold", x );
    float y2 = lvTemperature.GetLabelMembership( "Cool", x );
    float y3 = lvTemperature.GetLabelMembership( "Warm", x );
    float y4 = lvTemperature.GetLabelMembership( "Hot" , x );

    Console.WriteLine( String.Format( "{0:N}; {1:N}; {2:N}; {3:N}", y1, y2, y3, y4 ) );

Inheritance Hierarchy


See Also