fix when -DLIBA_JAVASCRIPT=1 and -DLIBA_CXX=0
[liba.git] / java / test / _pid_fuzzy.java
blob71e259d4698802bab00c48d7f6c2c8dba32dac83
1 import liba.mf;
2 import liba.pid_fuzzy;
4 class _pid_fuzzy {
5 public static void main(String[] args) {
6 int NL = -3;
7 int NM = -2;
8 int NS = -1;
9 int ZO = 0;
10 int PS = +1;
11 int PM = +2;
12 int PL = +3;
13 double[][] me = {
14 { mf.TRI, NL, NL, NM },
15 { mf.TRI, NL, NM, NS },
16 { mf.TRI, NM, NS, ZO },
17 { mf.TRI, NS, ZO, PS },
18 { mf.TRI, ZO, PS, PM },
19 { mf.TRI, PS, PM, PL },
20 { mf.TRI, PM, PL, PL },
22 NL = -6;
23 NM = -4;
24 NS = -2;
25 ZO = 0;
26 PS = +2;
27 PM = +4;
28 PL = +6;
29 double[][] mec = {
30 { mf.TRI, NL, NL, NM },
31 { mf.TRI, NL, NM, NS },
32 { mf.TRI, NM, NS, ZO },
33 { mf.TRI, NS, ZO, PS },
34 { mf.TRI, ZO, PS, PM },
35 { mf.TRI, PS, PM, PL },
36 { mf.TRI, PM, PL, PL },
38 NL = -15;
39 NM = -10;
40 NS = -5;
41 ZO = 0;
42 PS = +5;
43 PM = +10;
44 PL = +15;
45 double[][] mkp = {
46 { NL, NL, NM, NM, NS, ZO, ZO },
47 { NL, NL, NM, NS, NS, ZO, PS },
48 { NM, NM, NM, NS, ZO, PS, PS },
49 { NM, NM, NS, ZO, PS, PM, PM },
50 { NS, NS, ZO, PS, PS, PM, PM },
51 { NS, ZO, PS, PM, PM, PM, PL },
52 { ZO, ZO, PM, PM, PM, PL, PL },
54 NL = -3;
55 NM = -2;
56 NS = -1;
57 ZO = 0;
58 PS = +1;
59 PM = +2;
60 PL = +3;
61 double[][] mki = {
62 { PL, PL, PM, PM, PS, ZO, ZO },
63 { PL, PL, PM, PS, PS, ZO, ZO },
64 { PL, PM, PS, PS, ZO, NS, NS },
65 { PM, PM, PS, ZO, NS, NM, NM },
66 { PM, PS, ZO, NS, NS, NM, NL },
67 { ZO, ZO, NS, NS, NM, NL, NL },
68 { ZO, ZO, NS, NM, NM, NL, NL },
70 double[][] mkd = {
71 { NS, PS, PL, PL, PL, PM, NS },
72 { NS, PS, PL, PM, PM, PS, ZO },
73 { ZO, PS, PM, PM, PS, PS, ZO },
74 { ZO, PS, PS, PS, PS, PS, ZO },
75 { ZO, ZO, ZO, ZO, ZO, ZO, ZO },
76 { NL, NS, NS, NS, NS, NS, NL },
77 { NL, NM, NM, NM, NS, NS, NL },
79 pid_fuzzy obj = new pid_fuzzy();
80 obj.rule(me, mec, mkp, mki, mkd).block(2);
81 obj.kpid(10, 0.1, 1);
82 System.out.print(obj.zero().pos(1, 0) + " ");
83 System.out.print(obj.zero().inc(1, 0) + " ");
84 System.out.println(obj.run(1, 0));
85 obj.kp(obj.kp());
86 obj.ki(obj.ki());
87 obj.kd(obj.kd());
88 obj.summax(obj.summax());
89 obj.summin(obj.summin());
90 obj.sum();
91 obj.outmax(obj.outmax());
92 obj.outmin(obj.outmin());
93 obj.out();
94 obj.fdb();
95 obj.err();
96 obj.order();
97 obj.block(obj.block());