# Begin Fuzzy

Verb: `beginFuzzy`

Available from: <Enterprise>

Begins a fuzzy logic set and defines the precision range to work with.

## Syntax

`beginFuzzy --intervals(Numeric) `

## Inputs

Script Designer Required AcceptedTypes Description
--intervals Intervals Required Number Range of solution-set elements that are considered when calculating the center of mass function, which results in a crisp value.

## Example

The Begin Fuzzy command begins a fuzzy logic set with Intervals = 1000. 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}
endFuzzy
evaluate --expression "\${tip}" tipValue=value