C# Class Accord.Fuzzy.LinguisticVariable

The class represents a linguistic variable.

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 ) ); }
Datei anzeigen Open project: accord-net/framework Class Usage Examples

Public Methods

Method Description
AddLabel ( FuzzySet label ) : void

Adds a linguistic label to the variable.

Linguistic labels are fuzzy sets (FuzzySet). Each label of the variable must have a unique name. The range of the label (left and right limits) cannot be greater than the linguistic variable range (start/end).

ClearLabels ( ) : void

Removes all the linguistic labels of the linguistic variable.

GetLabel ( string labelName ) : FuzzySet

Returns an existing label from the linguistic variable.

GetLabelMembership ( string labelName, float value ) : float

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.

LinguisticVariable ( string name, float start, float end ) : System

Initializes a new instance of the LinguisticVariable class.

Method Details

AddLabel() public method

Adds a linguistic label to the variable.
Linguistic labels are fuzzy sets (FuzzySet). Each label of the variable must have a unique name. The range of the label (left and right limits) cannot be greater than the linguistic variable range (start/end).
The fuzzy set was not initialized. The linguistic label name already exists in the linguistic variable. The left limit of the fuzzy set can not be lower than the linguistic variable's starting point. "The right limit of the fuzzy set can not be greater than the linguistic variable's ending point."
public AddLabel ( FuzzySet label ) : void
label FuzzySet A that will be a linguistic label of the linguistic variable.
return void

ClearLabels() public method

Removes all the linguistic labels of the linguistic variable.
public ClearLabels ( ) : void
return void

GetLabel() public method

Returns an existing label from the linguistic variable.
The label indicated was not found in the linguistic variable.
public GetLabel ( string labelName ) : FuzzySet
labelName string Name of the label to retrieve.
return FuzzySet

GetLabelMembership() public method

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.
The label indicated in labelName was not found in the linguistic variable.
public GetLabelMembership ( string labelName, float value ) : float
labelName string Label (fuzzy set) to evaluate value's membership.
value float Value which label's membership will to be calculated.
return float

LinguisticVariable() public method

Initializes a new instance of the LinguisticVariable class.
public LinguisticVariable ( string name, float start, float end ) : System
name string Name of the linguistic variable.
start float Left limit of the valid variable range.
end float Right limit of the valid variable range.
return System