C# Class AForge.Fuzzy.InferenceSystem

This class represents a Fuzzy Inference System.

A Fuzzy Inference System is a model capable of executing fuzzy computing. It is mainly composed by a Database with the linguistic variables (see LinguisticVariable) and a Rulebase with the fuzzy rules (see Rule) that represent the behavior of the system. The typical operation of a Fuzzy Inference System is: Get the numeric inputs; Use the Database with the linguistic variables (see LinguisticVariable) to obtain linguistic meaning for each numerical input; Verify which rules (see Rule) of the Rulebase are activated by the input; Combine the consequent of the activated rules to obtain a FuzzyOutput; Use some defuzzifier (see IDefuzzifier) to obtain a numerical output.

The following sample usage is a Fuzzy Inference System that controls an auto guided vehicle avoing frontal collisions:

// linguistic labels (fuzzy sets) that compose the distances FuzzySet fsNear = new FuzzySet( "Near", new TrapezoidalFunction( 15, 50, TrapezoidalFunction.EdgeType.Right ) ); FuzzySet fsMedium = new FuzzySet( "Medium", new TrapezoidalFunction( 15, 50, 60, 100 ) ); FuzzySet fsFar = new FuzzySet( "Far", new TrapezoidalFunction( 60, 100, TrapezoidalFunction.EdgeType.Left ) ); // front distance (input) LinguisticVariable lvFront = new LinguisticVariable( "FrontalDistance", 0, 120 ); lvFront.AddLabel( fsNear ); lvFront.AddLabel( fsMedium ); lvFront.AddLabel( fsFar ); // linguistic labels (fuzzy sets) that compose the angle FuzzySet fsZero = new FuzzySet( "Zero", new TrapezoidalFunction( -10, 5, 5, 10 ) ); FuzzySet fsLP = new FuzzySet( "LittlePositive", new TrapezoidalFunction( 5, 10, 20, 25 ) ); FuzzySet fsP = new FuzzySet( "Positive", new TrapezoidalFunction( 20, 25, 35, 40 ) ); FuzzySet fsVP = new FuzzySet( "VeryPositive", new TrapezoidalFunction( 35, 40, TrapezoidalFunction.EdgeType.Left ) ); // angle LinguisticVariable lvAngle = new LinguisticVariable( "Angle", -10, 50 ); lvAngle.AddLabel( fsZero ); lvAngle.AddLabel( fsLP ); lvAngle.AddLabel( fsP ); lvAngle.AddLabel( fsVP ); // the database Database fuzzyDB = new Database( ); fuzzyDB.AddVariable( lvFront ); fuzzyDB.AddVariable( lvAngle ); // creating the inference system InferenceSystem IS = new InferenceSystem( fuzzyDB, new CentroidDefuzzifier( 1000 ) ); // going Straight IS.NewRule( "Rule 1", "IF FrontalDistance IS Far THEN Angle IS Zero" ); // Turning Left IS.NewRule( "Rule 2", "IF FrontalDistance IS Near THEN Angle IS Positive" ); ... // inference section // setting inputs IS.SetInput( "FrontalDistance", 20 ); // getting outputs try { float newAngle = IS.Evaluate( "Angle" ); } catch ( Exception ) { ... }
Afficher le fichier Open project: holisticware-admin/MonoVersal.AForgeNET Class Usage Examples

Méthodes publiques

Méthode Description
Evaluate ( string variableName ) : float

Executes the fuzzy inference, obtaining a numerical output for a choosen output linguistic variable.

ExecuteInference ( string variableName ) : FuzzyOutput

Executes the fuzzy inference, obtaining the FuzzyOutput of the system for the required LinguisticVariable.

GetLinguisticVariable ( string variableName ) : LinguisticVariable

Gets one of the LinguisticVariable of the Database.

GetRule ( string ruleName ) : Rule

Gets one of the Rules of the Rulebase.

InferenceSystem ( Database database, IDefuzzifier defuzzifier ) : System

Initializes a new Fuzzy InferenceSystem.

InferenceSystem ( Database database, IDefuzzifier defuzzifier, INorm normOperator, ICoNorm conormOperator ) : System

Initializes a new Fuzzy InferenceSystem.

NewRule ( string name, string rule ) : Rule

Creates a new Rule and add it to the Rulebase of the InferenceSystem.

SetInput ( string variableName, float value ) : void

Sets a numerical input for one of the linguistic variables of the Database.

Method Details

Evaluate() public méthode

Executes the fuzzy inference, obtaining a numerical output for a choosen output linguistic variable.
The variable indicated was not found in the database.
public Evaluate ( string variableName ) : float
variableName string Name of the to evaluate.
Résultat float

ExecuteInference() public méthode

Executes the fuzzy inference, obtaining the FuzzyOutput of the system for the required LinguisticVariable.
The variable indicated was not found in the database.
public ExecuteInference ( string variableName ) : FuzzyOutput
variableName string Name of the to evaluate.
Résultat FuzzyOutput

GetLinguisticVariable() public méthode

Gets one of the LinguisticVariable of the Database.
The variable indicated in /// was not found in the database.
public GetLinguisticVariable ( string variableName ) : LinguisticVariable
variableName string Name of the to get.
Résultat LinguisticVariable

GetRule() public méthode

Gets one of the Rules of the Rulebase.
The rule indicated in /// was not found in the rulebase.
public GetRule ( string ruleName ) : Rule
ruleName string Name of the to get.
Résultat Rule

InferenceSystem() public méthode

Initializes a new Fuzzy InferenceSystem.
public InferenceSystem ( Database database, IDefuzzifier defuzzifier ) : System
database Database A fuzzy containing the system linguistic variables.
defuzzifier IDefuzzifier A defuzzyfier method used to evaluate the numeric uotput of the system.
Résultat System

InferenceSystem() public méthode

Initializes a new Fuzzy InferenceSystem.
public InferenceSystem ( Database database, IDefuzzifier defuzzifier, INorm normOperator, ICoNorm conormOperator ) : System
database Database A fuzzy containing the system linguistic /// variables.
defuzzifier IDefuzzifier A defuzzyfier method used to evaluate the numeric otput /// of the system.
normOperator INorm A operator used to evaluate the norms /// in the . For more information of the norm evaluation see .
conormOperator ICoNorm A operator used to evaluate the /// conorms in the . For more information of the conorm evaluation see .
Résultat System

NewRule() public méthode

Creates a new Rule and add it to the Rulebase of the InferenceSystem.
public NewRule ( string name, string rule ) : Rule
name string Name of the to create.
rule string A string representing the fuzzy rule.
Résultat Rule

SetInput() public méthode

Sets a numerical input for one of the linguistic variables of the Database.
The variable indicated in /// was not found in the database.
public SetInput ( string variableName, float value ) : void
variableName string Name of the .
value float Numeric value to be used as input.
Résultat void