Depending on the number of variables and rules that you define, a ruleset can become rather lengthy, but in reality, the structure of a source fuzzy rule file is quite simple, as the following is meant to show. All of the statements shown are defined in detail elsewhere, but for now, sit back and let the essence of a ruleset permeate the core of your very being.
RuleSet <nameOfRuleSet> ( AlphaCut ( <numericValue> ) CorrelationMethod( Product | Minimum ) DefuzzifyMethod ( Centroid | MaxHeight ) InferenceMethod ( FuzzyAdd | MinMax | ProductOr ) Variables( <Variable definitions>+ ) InputVariables ( <[variableName1[[,] ... [variableNamen]]]> ) OutputVariables( <[variableName1[[,] ... [variableNamen]]]> ) Sensors ( <[sensorName1[[,] ... [sensorNamen]]]> ) Effectors ( <[effectorName1[[,] ... [effectorNamen]]]> ) Rules ( <Rule definitions>+ ) ) ;End of ruleset
There are four types of variables that you can declare and use in a ruleset; the "quick reference" syntax is outlined below. Full details can be found here, or by following the individual links. Of the four types of variables, only Continuous, with its required fuzzy set definitions, is the fuzzy variable type.
<variableName> Boolean ( True | False ) <variableName> Numeric ( <initialValue> ) <variableName> Symbolic( <symbol1[[,] ... [symboln]]> ) <variableName> Continuous( <low> [to | ,] <high> ) SetDefinitions( <setName> Beta ( center[,] width[[,] weight=1.00] ) <setName> Gaussian ( center[,] width ) <setName> Linear ( begin[,] end[,] Up|Down ) <setName> Pi ( center[,] width ) <setName> Segments ( pt1 tv1, pt2 tv2, ... ptn tvn ) <setName> Shoulder ( begin[,] end[,] Left|Right ) <setName> Sigmoid ( left[,] flex[,] right[,] Up|Down ) <setName> Trapezoid( left[,] leftCore[,] rightCore[,] right ) <setName> Triangle ( left[,] center[,] right ) )
There are two types of rules that you can use in a ruleset: assertions and conditionals. The "quick reference" syntax of each type of rule is outlined immediately below. Full details of all rule syntax can be found beginning here, or you can follow these individual links:
ruleLabel : booleanVariable = { booleanVariable | booleanLiteral | sensorName(<arg>*) } ruleLabel : numericVariable = { numericVariable | numericLiteral | sensorName(<arg>*) } ruleLabel : symbolicVariable = { symbol | sensorName(<arg>*) } ruleLabel : continuousVariable = { numericLiteral | sensorName(<arg>*) } ruleLabel : continuousVariable Is <hedge>* setName
ruleLabel : IF | = | booleanVariable | <> | { booleanVariable | booleanLiteral | sensorName(<arg>*) } [<[weight]>] AND | != | | = | | < | | <= | numericVariable | > | { numericVariable | numericLiteral | sensorName(<arg>*) } [<[weight]>] AND | >= | | <> | | != | | = | symbolicVariable | <> | { symbol | sensorName(<arg>*) } [<[weight]>] AND | != | | = | | < | | <= | continuousVariable | > | { numericVariable | numericLiteral | sensorName(<arg>*) } [<[weight]>] AND | >= | | <> | | != | continuousVariable Is <hedge>* setName THEN --- | | booleanVariable = { booleanVariable | booleanLiteral | effectorName(<arg>*) } | numericVariable = { numericVariable | numericLiteral | effectorName(<arg>*) } | symbolicVariable = { symbol | effectorName(<arg>*) } | continuousVariable = { numericLiteral | effectorName(<arg>*) } | continuousVariable Is <hedge>* setName | ---