Fuzzy Rule

Verb: fuzzyRule

Available from: <Enterprise>

Defines a fuzzy rule for inference in a fuzzy logic system, returning an output according to a Condition.


fuzzyRule --name(String) --condition(Fuzzy) --variable(Fuzzy) --set(FuzzySet)


Script Designer Required AcceptedTypes Description
--name Rule name Required Text Name of the rule that should be defined.
--condition Condition Required Fuzzy, Fuzzy Set Text that concatenates variables and AND, OR, and NOT logical operators to define the rule.
The IF instantiator is not required for the rule construction
--variable Fuzzy variable Required Fuzzy Fuzzy variable where the solution set is stored in during fuzzy inference.
--set Fuzzy set Required Fuzzy Set Defines the fuzzy set that should be part of the Fuzzy variable's solution set during fuzzy inference.


A fuzzy logic set is initiated using the Begin Fuzzy command, with Intervals = 1000. The Fuzzy Rule command creates fuzzy logic to measure the quality of a restaurant's service. The End Fuzzy command terminates the set.

defVar --name low --type FuzzySet
defVar --name medium --type FuzzySet
defVar --name good --type FuzzySet
defVar --name serviceQuality --type Fuzzy
defVar --name foodQuality --type Fuzzy
defVar --name littleTip --type FuzzySet
defVar --name reasonableTip --type FuzzySet
defVar --name generousTip --type FuzzySet
defVar --name tip --type Fuzzy
defVar --name foodGrade --type Numeric --value "7.5"
defVar --name serviceGrade --type Numeric --value 6
defVar --name tipValue --type Numeric
beginFuzzy --intervals 1000
   fuzzySet --function "Trapezoidal" --shape "Number" --edge "Right" --m1 0 --m2 5 low=value
   fuzzySet --function "Trapezoidal" --shape "Triangular" --m1 3 --m2 5 --m3 7 medium=value
   fuzzySet --function "Trapezoidal" --shape "Number" --edge "Left" --m1 5 --m2 10 good=value
   fuzzyVariable --left 0 --right 10 --labels "${low} ${medium} ${good}" serviceQuality=value
   fuzzyVariable --left 0 --right 10 --labels "${low} ${medium} ${good}" foodQuality=value
   fuzzySet --function "Trapezoidal" --shape "Number" --edge "Right" --m1 0 --m2 12.5 littleTip=value
   fuzzySet --function "Trapezoidal" --shape "Triangular" --m1 6.25 --m2 12.5 --m3 18.75 reasonableTip=value
   fuzzySet --function "Trapezoidal" --shape "Number" --edge "Left" --m1 12.5 --m2 25 generousTip=value
   fuzzyVariable --left 0 --right 25 --labels "${littleTip} ${reasonableTip} ${generousTip}" tip=value
//The food was rancid or the service was poor.
   fuzzyRule --name "Terrible food or service" --condition "${foodQuality} IS ${low} OR ${serviceQuality} IS ${low}" --variable ${tip} --set ${littleTip}
//The service was reasonable.
   fuzzyRule --name "Average service" --condition "${serviceQuality} IS ${medium}" --variable ${tip} --set ${reasonableTip}
//The food was delicious or the service was good.
   fuzzyRule --name "Great Food or Service" --condition "${foodQuality} IS ${good} OR ${serviceQuality} IS ${good}" --variable ${tip} --set ${generousTip}
setVar --name "${foodQuality}" --value "${foodGrade}"
setVar --name "${serviceQuality}" --value "${serviceGrade}"
evaluate --expression "${tip}" tipValue=value
logMessage --message "Tip Value: ${tipValue};\r\nFood Grade: ${foodGrade};\r\nService Grade: ${serviceGrade}" --type "Info"


In the Rule name parameter, names must be unique among the defined rules.

The Begin Fuzzy command starts the fuzzy logic set, and the End Fuzzy command terminates it.

See Also

  • Begin Fuzzy
  • End Fuzzy
  • Fuzzy Sets
  • Fuzzy Variable