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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#Code automatically generated with fuzzylite 6.0.
library(ggplot2);
engine.name = "cubic_approximator"
engine.fll = "Engine: cubic_approximator
InputVariable: X
enabled: true
range: -5.000 5.000
lock-range: false
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
OutputVariable: ApproxXCubed
enabled: true
range: -5.000 5.000
lock-range: false
aggregation: none
defuzzifier: WeightedAverage TakagiSugeno
default: nan
lock-previous: false
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
RuleBlock:
enabled: true
conjunction: none
disjunction: none
implication: none
activation: General
rule: if X is AboutNegFive then ApproxXCubed is TangentatNegFive
rule: if X is AboutNegFour then ApproxXCubed is TangentatNegFour
rule: if X is AboutNegThree then ApproxXCubed is TangentatNegThree
rule: if X is AboutNegTwo then ApproxXCubed is TangentatNegTwo
rule: if X is AboutNegOne then ApproxXCubed is TangentatNegOne
rule: if X is AboutZero then ApproxXCubed is TangentatZero
rule: if X is AboutOne then ApproxXCubed is TangentatOne
rule: if X is AboutTwo then ApproxXCubed is TangentatTwo
rule: if X is AboutThree then ApproxXCubed is TangentatThree
rule: if X is AboutFour then ApproxXCubed is TangentatFour
rule: if X is AboutFive then ApproxXCubed is TangentatFive"
engine.fldFile = "cubic_approximator.fld"
if (require(data.table)) {
engine.df = data.table::fread(engine.fldFile, sep="auto", header="auto")
} else {
engine.df = read.table(engine.fldFile, header=TRUE)
}
engine.plot.i1_o1 = ggplot(engine.df, aes(X, ApproxXCubed)) +
geom_line(aes(color=ApproxXCubed), size=3, lineend="round", linejoin="mitre") +
scale_color_gradient(low="yellow", high="red") +
ggtitle("X vs ApproxXCubed")
engine.plot.o1_i1 = ggplot(engine.df, aes(X, ApproxXCubed)) +
geom_line(aes(color=ApproxXCubed), size=3, lineend="round", linejoin="mitre") +
scale_color_gradient(low="yellow", high="red") +
coord_flip() +
ggtitle("ApproxXCubed vs X")
if (require(gridExtra)) {
engine.plots = arrangeGrob(engine.plot.i1_o1, engine.plot.o1_i1, ncol=2, top=engine.name)
ggsave(paste0(engine.name, ".pdf"), engine.plots)
if (require(grid)) {
grid.newpage()
grid.draw(engine.plots)
}
}
|