LinguisticVariable Class |
Namespace: Accord.Fuzzy
The LinguisticVariable type exposes the following members.
Name | Description | |
---|---|---|
LinguisticVariable |
Initializes a new instance of the LinguisticVariable class.
|
Name | Description | |
---|---|---|
End |
Right limit of the valid variable range.
| |
Name |
Name of the linguistic variable.
| |
NumericInput |
Numerical value of the input of this linguistic variable.
| |
Start |
Left limit of the valid variable range.
|
Name | Description | |
---|---|---|
AddLabel |
Adds a linguistic label to the variable.
| |
ClearLabels |
Removes all the linguistic labels of the linguistic variable.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetLabel |
Returns an existing label from the linguistic variable.
| |
GetLabelMembership |
Calculate the membership of a given value to a given label. Used to evaluate linguistics clauses like
"X IS A", where X is a value and A is a linguistic label.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(Type) | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) | |
ToT | Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.) |
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 ) ); }