-
Notifications
You must be signed in to change notification settings - Fork 4
/
FsmEnumerator.h
53 lines (42 loc) · 1.58 KB
/
FsmEnumerator.h
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
#ifndef FSM_ENUMERATOR_H_
#define FSM_ENUMERATOR_H_
#include <memory>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <deque>
#include "fsm/Fsm.h"
/**
* A simple enumerator that enumerates all FSMs using a given number of states, inputs and outputs.
* Returns connected and observable but possibly non-deterministic and/or partial FSMs.
*
* A flag in the constructor defines whether all states of the generated FSMs must be reachable.
* The generated FSMs may use fewer inputs than the maximum numbers given.
*/
class FsmEnumerator
{
private:
const int maxInput;
const int maxOutput;
const int maxState;
const bool generateSmallerFsms;
int candidateNum = 0;
Fsm fsm;
std::vector<std::vector<std::vector<int>>> currentTable;
bool updateTable();
Fsm generateFsmFromTable();
public:
/**
* @param maxInput The largest input to be used.
* @param maxOutput The largest output to be used.
* @param maxState The largest state index to be used.
* @param presentationLayer The presentation layer to be used in returned FSMs.
* @param generateSmallerFsms If true, then all FSMs with up to (maxState+1) reachable states are generated.
* Otherwise, all FSMs with exactly (maxState+1) reachable states are generated.
*/
FsmEnumerator(int maxInput, int maxOutput, int maxState, const std::shared_ptr<FsmPresentationLayer>& presentationLayer, bool generateSmallerFsms = false);
bool hasNext();
Fsm getNext();
};
#endif // FSM_ENUMERATOR_H_