summaryrefslogtreecommitdiff
path: root/examples/takagi-sugeno/octave/cubic_approximator.fcl
blob: db88e44432e5178bff25a1540100e1c0c12dd7f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
FUNCTION_BLOCK Cubic-Approximator

VAR_INPUT
  X: REAL;
END_VAR

VAR_OUTPUT
  ApproxXCubed: REAL;
END_VAR

FUZZIFY X
  RANGE := (-5.000 .. 5.000);
  TERM AboutNegFive := Triangle -6.000 -5.000 -4.000;
  TERM AboutNegFour := Triangle -5.000 -4.000 -3.000;
  TERM AboutNegThree := Triangle -4.000 -3.000 -2.000;
  TERM AboutNegTwo := Triangle -3.000 -2.000 -1.000;
  TERM AboutNegOne := Triangle -2.000 -1.000 0.000;
  TERM AboutZero := Triangle -1.000 0.000 1.000;
  TERM AboutOne := Triangle 0.000 1.000 2.000;
  TERM AboutTwo := Triangle 1.000 2.000 3.000;
  TERM AboutThree := Triangle 2.000 3.000 4.000;
  TERM AboutFour := Triangle 3.000 4.000 5.000;
  TERM AboutFive := Triangle 4.000 5.000 6.000;
END_FUZZIFY

DEFUZZIFY ApproxXCubed
  RANGE := (-5.000 .. 5.000);
  TERM TangentatNegFive := Linear 75.000 250.000;
  TERM TangentatNegFour := Linear 48.000 128.000;
  TERM TangentatNegThree := Linear 27.000 54.000;
  TERM TangentatNegTwo := Linear 12.000 16.000;
  TERM TangentatNegOne := Linear 3.000 2.000;
  TERM TangentatZero := Linear 0.000 0.000;
  TERM TangentatOne := Linear 3.000 -2.000;
  TERM TangentatTwo := Linear 12.000 -16.000;
  TERM TangentatThree := Linear 27.000 -54.000;
  TERM TangentatFour := Linear 48.000 -128.000;
  TERM TangentatFive := Linear 75.000 -250.000;
  METHOD : COGS;
  DEFAULT := nan;
END_DEFUZZIFY

RULEBLOCK 
  RULE 1 : if X is AboutNegFive then ApproxXCubed is TangentatNegFive
  RULE 2 : if X is AboutNegFour then ApproxXCubed is TangentatNegFour
  RULE 3 : if X is AboutNegThree then ApproxXCubed is TangentatNegThree
  RULE 4 : if X is AboutNegTwo then ApproxXCubed is TangentatNegTwo
  RULE 5 : if X is AboutNegOne then ApproxXCubed is TangentatNegOne
  RULE 6 : if X is AboutZero then ApproxXCubed is TangentatZero
  RULE 7 : if X is AboutOne then ApproxXCubed is TangentatOne
  RULE 8 : if X is AboutTwo then ApproxXCubed is TangentatTwo
  RULE 9 : if X is AboutThree then ApproxXCubed is TangentatThree
  RULE 10 : if X is AboutFour then ApproxXCubed is TangentatFour
  RULE 11 : if X is AboutFive then ApproxXCubed is TangentatFive
END_RULEBLOCK

END_FUNCTION_BLOCK