Rule Class |
Namespace: Accord.Fuzzy
The Rule type exposes the following members.
Name | Description | |
---|---|---|
Rule(Database, String, String) |
Initializes a new instance of the Rule class using as
CoNorm the MaximumCoNorm and as Norm the MinimumNorm.
| |
Rule(Database, String, String, INorm, ICoNorm) |
Initializes a new instance of the Rule class.
|
Name | Description | |
---|---|---|
Name |
The name of the fuzzy rule.
| |
Output |
The fuzzy Clause that represents the consequent of the Rule.
|
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
EvaluateFiringStrength |
Evaluates the firing strength of the Rule, the degree of confidence that the consequent of this Rule
must be executed.
| |
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.) | |
GetRPNExpression |
Converts the RPN fuzzy expression into a string representation.
| |
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.) |
A Fuzzy Rule is a fuzzy linguistic instruction that can be executed by a fuzzy system. The format of the Fuzzy Rule is:
IF antecedent THEN consequent
The antecedent is composed by a set of fuzzy clauses (see Clause) connected by fuzzy operations, like AND or OR. The operator NOT can be used to negate expressions:
...Clause1 AND (Clause2 OR Clause3) AND NOT Clause4 ...
Fuzzy clauses are written in form Variable IS Value. The NOT operator can be used to negate linguistic values as well:
...Variable1 IS Value1 AND Variable2 IS NOT Value2 ...
The consequent is a single of fuzzy clauses (Clause). To perform the linguistic computing, the Rule evaluates the clauses and then applies the fuzzy operators. Once this is done a value representing the confidence in the antecedent being true is obtained, and this is called firing strength of the Rule.
The firing strength is used to discover with how much confidence the consequent of a rule is true.
Sample usage:
// 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 ); // create a linguistic variable to represent steel temperature LinguisticVariable lvSteel = new LinguisticVariable( "Steel", 0, 80 ); // adding labels to the variable lvSteel.AddLabel( fsCold ); lvSteel.AddLabel( fsCool ); lvSteel.AddLabel( fsWarm ); lvSteel.AddLabel( fsHot ); // create a linguistic variable to represent stove temperature LinguisticVariable lvStove = new LinguisticVariable( "Stove", 0, 80 ); // adding labels to the variable lvStove.AddLabel( fsCold ); lvStove.AddLabel( fsCool ); lvStove.AddLabel( fsWarm ); lvStove.AddLabel( fsHot ); // create the linguistic labels (fuzzy sets) that compose the pressure TrapezoidalFunction function5 = new TrapezoidalFunction( 20, 40, TrapezoidalFunction.EdgeType.Right ); FuzzySet fsLow = new FuzzySet( "Low", function5 ); TrapezoidalFunction function6 = new TrapezoidalFunction( 20, 40, 60, 80 ); FuzzySet fsMedium = new FuzzySet( "Medium", function6 ); TrapezoidalFunction function7 = new TrapezoidalFunction( 60, 80, TrapezoidalFunction.EdgeType.Left ); FuzzySet fsHigh = new FuzzySet( "High", function7 ); // create a linguistic variable to represent pressure LinguisticVariable lvPressure = new LinguisticVariable( "Pressure", 0, 100 ); // adding labels to the variable lvPressure.AddLabel( fsLow ); lvPressure.AddLabel( fsMedium ); lvPressure.AddLabel( fsHigh ); // create a linguistic variable database Database db = new Database( ); db.AddVariable( lvSteel ); db.AddVariable( lvStove ); db.AddVariable( lvPressure ); // sample rules just to test the expression parsing Rule r1 = new Rule( db, "Test1", "IF Steel is not Cold and Stove is Hot then Pressure is Low" ); Rule r2 = new Rule( db, "Test2", "IF Steel is Cold and not (Stove is Warm or Stove is Hot) then Pressure is Medium" ); Rule r3 = new Rule( db, "Test3", "IF Steel is Cold and Stove is Warm or Stove is Hot then Pressure is High" ); // testing the firing strength lvSteel.NumericInput = 12; lvStove.NumericInput = 35; float result = r1.EvaluateFiringStrength( ); Console.WriteLine( result.ToString( ) );