home Forums # Technical Support What FCL version does Fuzzylite use? Reply To: What FCL version does Fuzzylite use?

#1022
Juan Rada-Vilela
Juan Rada-Vilela
Keymaster

Hi Asho,

In order to import your FCL controller to fuzzylite, you need to perform the following changes:

(1) Change comments indicators // to # (this is a temporary fix until next version).
(2) ACCU : MAX; goes in Defuzzify tip instead of RULEBLOCK (as mentioned before)
(3) Each rules needs to be presented in a single line (not across multiple lines)
(4) In rules, change the case of the keywords if, then, with to lower case.

These changes will let you import your FCL into fuzzylite. However, please have in mind that you should also specify:

(1) The range of input and output variables (standard in FCL). By default, fuzzylite will assume (-inf .. inf)
(2) Explicitly define the Disjunction operator (OR) in Ruleblock. If not defined, fuzzylite will take NULL as operator, and since you use or within the rules, fuzzylite will remind you to select one during its operation.

The following is the FCL code of your engine exported using fuzzylite. Have in mind that ENABLED is an extension to FCL which gives you the option to disable a variable or rule block (useful for testing purposes).

FUNCTION_BLOCK tipper

VAR_INPUT
  service: REAL;
  food: REAL;
END_VAR

VAR_OUTPUT
  tip: REAL;
END_VAR

FUZZIFY service
  ENABLED : TRUE;
  RANGE := (-inf .. inf);
  TERM poor := (0.000, 1.000) (4.000, 0.000);
  TERM good := (1.000, 0.000) (4.000, 1.000) (6.000, 1.000) (9.000, 0.000);
  TERM excellent := (6.000, 0.000) (9.000, 1.000);
END_FUZZIFY

FUZZIFY food
  ENABLED : TRUE;
  RANGE := (-inf .. inf);
  TERM rancid := (0.000, 1.000) (1.000, 1.000) (3.000, 0.000);
  TERM delicious := (7.000, 0.000) (9.000, 1.000);
END_FUZZIFY

DEFUZZIFY tip
  ENABLED : TRUE;
  RANGE := (-inf .. inf);
  TERM cheap := (0.000, 0.000) (5.000, 1.000) (10.000, 0.000);
  TERM average := (10.000, 0.000) (15.000, 1.000) (20.000, 0.000);
  TERM generous := (20.000, 0.000) (25.000, 1.000) (30.000, 0.000);
  METHOD : COG;
  ACCU : MAX;
  DEFAULT := 0.000;
END_DEFUZZIFY

RULEBLOCK  No1
  ENABLED : TRUE;
  AND : MIN;
  ACT : MIN;
  RULE 1 : if service is poor or food is rancid then tip is cheap
  RULE 2 : if service is good then tip is average
  RULE 3 : if service is excellent and food is delicious then tip is generous
END_RULEBLOCK

END_FUNCTION_BLOCK

Although I do prefer the FuzzyLite Language (FLL):

Engine: tipper
InputVariable: service
  enabled: true
  range: -inf inf
  term: poor Discrete 0.000 1.000 4.000 0.000
  term: good Discrete 1.000 0.000 4.000 1.000 6.000 1.000 9.000 0.000
  term: excellent Discrete 6.000 0.000 9.000 1.000
InputVariable: food
  enabled: true
  range: -inf inf
  term: rancid Discrete 0.000 1.000 1.000 1.000 3.000 0.000
  term: delicious Discrete 7.000 0.000 9.000 1.000
OutputVariable: tip
  enabled: true
  range: -inf inf
  accumulation: Maximum
  defuzzifier: Centroid 200
  default: 0.000
  lock-valid: false
  lock-range: false
  term: cheap Discrete 0.000 0.000 5.000 1.000 10.000 0.000
  term: average Discrete 10.000 0.000 15.000 1.000 20.000 0.000
  term: generous Discrete 20.000 0.000 25.000 1.000 30.000 0.000
RuleBlock:  No1
  enabled: true
  conjunction: Minimum
  disjunction: none
  activation: Minimum
  rule: if service is poor or food is rancid then tip is cheap
  rule: if service is good then tip is average
  rule: if service is excellent and food is delicious then tip is generous