// randomly fill the alphabet
private void initialization(int minXSize, int maxXSize) {
        // TODO: current implementation is less elegant. code refactoring may be needed.
        dfaConfig = new DFAConfig(); // allocates a new config every time.
        Random r = new Random();
        dfaConfig.stateSize = r.nextInt((maxXSize - minXSize) + 1) + minXSize;
        dfaConfig.faultyStateSize = Math.max(dfaConfig.stateSize / 10, 4);
        LOGGER.debug("Generated overall state size and faulty state size: {}, {}",
                dfaConfig.stateSize, dfaConfig.faultyStateSize);
        dfaConfig.states = new int[dfaConfig.stateSize];
        for (int i = 0; i < dfaConfig.stateSize; i++) {
            dfaConfig.states[i] = i;
        }
        // alphabet size: range[6 ~ 16] or [10, 20]
        int base = dfaConfig.stateSize > 20 ? 10 : 6;
        int alphabetSize = r.nextInt(11) + base;
        dfaConfig.alphabet = new char[alphabetSize];
        LOGGER.debug("Chosen alphabet size is {}", alphabetSize);
        // randomly fill the alphabet
        int alphabetSpaceLen = dfaConfig.alphabetSpace.length();
        boolean[] tempFlags = new boolean[alphabetSpaceLen];
        int tempIndex;
        for (int i = 0; i < dfaConfig.alphabet.length; i++) {
            tempIndex = r.nextInt(alphabetSpaceLen);
            while (tempFlags[tempIndex]) {
                tempIndex = r.nextInt(alphabetSpaceLen);
            }
            tempFlags[tempIndex] = true;
            dfaConfig.alphabet[i] = dfaConfig.alphabetSpace.charAt(tempIndex);
        }
        // faulty event size (make sure it less than a half of alphabet size)
        int faultEventSize = Math.max(dfaConfig.faultyStateSize / 2, 2);
        faultEventSize = faultEventSize >= 5 ? 4 : faultEventSize;
        if (alphabetSize > 15 && (dfaConfig.faultyStateSize / faultEventSize) > 3) {
            faultEventSize = faultEventSize + r.nextInt(2) + 1;
        }
        dfaConfig.faultyEvents = new int[faultEventSize];
        LOGGER.debug("Chosen faulty event size: {}", faultEventSize);
        boolean[] chosenFaultMarks = new boolean[alphabetSize];
        int choose;
        for (int i = 0; i < faultEventSize; i++) {
            choose = r.nextInt(alphabetSize);
            while (chosenFaultMarks[choose])
                choose = r.nextInt(alphabetSize);
            chosenFaultMarks[choose] = true;
            dfaConfig.faultyEvents[i] = choose;
        }
        LOGGER.debug("Generated alphabet set: {}", Arrays.toString(dfaConfig.alphabet));
        LOGGER.debug("Faulty events (index): {}", Arrays.toString(dfaConfig.faultyEvents));
        Set<Integer> faultyEventIndexSet = new HashSet<>();
        for (int fi : dfaConfig.faultyEvents)
            faultyEventIndexSet.add(fi);
        int ui = 0;
        int oi = 0;
        dfaConfig.observableEvents = new char[alphabetSize - faultEventSize];
        dfaConfig.unobservableEvents = new char[faultEventSize];
        for (int i = 0; i < alphabetSize; i++) {
            if (faultyEventIndexSet.contains(i))
                dfaConfig.unobservableEvents[ui++] = dfaConfig.alphabet[i];
            else
                dfaConfig.observableEvents[oi++] = dfaConfig.alphabet[i];
        }
        LOGGER.debug("selected observable events : {}", Arrays.toString(dfaConfig.observableEvents));
        LOGGER.debug("selected unobservable events : {}", Arrays.toString(dfaConfig.unobservableEvents));
    }
dfaConfig.alphabet = new char[alphabetSize];
LOGGER.debug("Chosen alphabet size is {}", alphabetSize);
// randomly fill the alphabet
int alphabetSpaceLen = dfaConfig.alphabetSpace.length();
boolean[] tempFlags = new boolean[alphabetSpaceLen];
dfaConfig.stateSize, dfaConfig.faultyStateSize);
dfaConfig.states = new int[dfaConfig.stateSize];
for (int i = 0; i < dfaConfig.stateSize; i++) {
dfaConfig.states[i] = i;
}
// alphabet size: range[6 ~ 16] or [10, 20]
int base = dfaConfig.stateSize > 20 ? 10 : 6;
int alphabetSize = r.nextInt(11) + base;
dfaConfig.alphabet = new char[alphabetSize];
LOGGER.debug("Chosen alphabet size is {}", alphabetSize);
// randomly fill the alphabet
int alphabetSpaceLen = dfaConfig.alphabetSpace.length();
boolean[] tempFlags = new boolean[alphabetSpaceLen];
int tempIndex;
for (int i = 0; i < dfaConfig.alphabet.length; i++) {
tempIndex = r.nextInt(alphabetSpaceLen);
while (tempFlags[tempIndex]) {
tempIndex = r.nextInt(alphabetSpaceLen);
}
tempFlags[tempIndex] = true;
dfaConfig.alphabet[i] = dfaConfig.alphabetSpace.charAt(tempIndex);
private void initialization(int minXSize, int maxXSize) {
// TODO: current implementation is less elegant. code refactoring may be needed.
dfaConfig = new DFAConfig(); // allocates a new config every time.
Random r = new Random();
dfaConfig.stateSize = r.nextInt((maxXSize - minXSize) + 1) + minXSize;
dfaConfig.faultyStateSize = Math.max(dfaConfig.stateSize / 10, 4);
LOGGER.debug("Generated overall state size and faulty state size: {}, {}",
dfaConfig.stateSize, dfaConfig.faultyStateSize);
dfaConfig.states = new int[dfaConfig.stateSize];
for (int i = 0; i < dfaConfig.stateSize; i++) {
dfaConfig.states[i] = i;
}
// alphabet size: range[6 ~ 16] or [10, 20]
int base = dfaConfig.stateSize > 20 ? 10 : 6;
int alphabetSize = r.nextInt(11) + base;
dfaConfig.alphabet = new char[alphabetSize];
LOGGER.debug("Chosen alphabet size is {}", alphabetSize);
// randomly fill the alphabet
int alphabetSpaceLen = dfaConfig.alphabetSpace.length();
boolean[] tempFlags = new boolean[alphabetSpaceLen];
int tempIndex;
for (int i = 0; i < dfaConfig.alphabet.length; i++) {
tempIndex = r.nextInt(alphabetSpaceLen);
while (tempFlags[tempIndex]) {
tempIndex = r.nextInt(alphabetSpaceLen);
}
tempFlags[tempIndex] = true;
dfaConfig.alphabet[i] = dfaConfig.alphabetSpace.charAt(tempIndex);
}
// faulty event size (make sure it less than a half of alphabet size)
int faultEventSize = Math.max(dfaConfig.faultyStateSize / 2, 2);
faultEventSize = faultEventSize >= 5 ? 4 : faultEventSize;
if (alphabetSize > 15 && (dfaConfig.faultyStateSize / faultEventSize) > 3) {
faultEventSize = faultEventSize + r.nextInt(2) + 1;
}
dfaConfig.faultyEvents = new int[faultEventSize];
LOGGER.debug("Chosen faulty event size: {}", faultEventSize);
boolean[] chosenFaultMarks = new boolean[alphabetSize];