forked from edesmontils/JFSM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JFSM.java
112 lines (93 loc) · 3.2 KB
/
JFSM.java
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**
*
* Copyright (C) 2017 Emmanuel DESMONTILS
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
*
*
* E-mail:
* Emmanuel.Desmontils@univ-nantes.fr
*
*
**/
/**
* JFSM.java
*
*
* Created: 2017-08-25
*
* @author Emmanuel Desmontils
* @version 1.0
*/
import java.util.Set;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
public class JFSM {
public static void main(String argv []) throws JFSMException {
// Set<String> A = new HashSet<String>();
// A.add("a");A.add("b");A.add("c");
// Set<Etat> Q = new HashSet<Etat>();
// Q.add(new Etat("1"));Q.add(new Etat("2"));Q.add(new Etat("3"));
// Set<Transition> mu = new HashSet<Transition>();
// mu.add(new Transition("1","a","2"));
// mu.add(new Transition("1","b","3"));
// mu.add(new Transition("2","a","1"));
// mu.add(new Transition("2","c","3"));
// mu.add(new Transition("2","b","2"));
// mu.add(new Transition("3","b","2"));
// Set<String> F = new HashSet<String>();
// F.add("3");
// Automate afn = new AFD(A, Q, "1", F, mu);
// afn.next("a");
// afn.next("c");
// System.out.println(afn.accepte());
Set<String> A = new HashSet<String>();
A.add("a");A.add("b");A.add("c");
Set<Etat> Q = new HashSet<Etat>();
Q.add(new Etat("1"));Q.add(new Etat("2"));Q.add(new Etat("3"));
Set<Transition> mu = new HashSet<Transition>();
mu.add(new TransitionMealy("1","a","1","2"));
mu.add(new TransitionMealy("1","b","0","3"));
mu.add(new TransitionMealy("2","a","0","1"));
mu.add(new TransitionMealy("2","c","1","3"));
mu.add(new TransitionMealy("2","b","1","2"));
mu.add(new TransitionMealy("3","b","0","2"));
Set<String> F = new HashSet<String>();
F.add("3");
Mealy afn = new Mealy(A, Q, "1", F, mu);
List<String> l = new ArrayList<String>();
l.add("a");l.add("c");
afn.run(l);
System.out.println(afn.accepte());
System.out.println(afn.histo);
System.out.println(afn.res);
afn.run(l);
System.out.println(afn.accepte());
System.out.println(afn.histo);
Set<Etat> Q2 = new HashSet<Etat>();
Q2.add(new EtatMoore("1","0"));Q2.add(new EtatMoore("2","1"));Q2.add(new EtatMoore("3","0"));
Moore afn2 = new Moore(A,Q2,"1",F,mu);
afn2.run(l);
System.out.println(afn2.accepte());
System.out.println(afn2.histo);
System.out.println(afn2.res);
}
}