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));
    }
private void initialization(int minXSize, int maxXSize) {
       
        dfaConfig = new DFAConfig();
        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;
        }
       
        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);
       
        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);
        }
       
        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));
    }
private void initialization(int minxsize, int maxxsize) { dfaconfig = new dfaconfig(); 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; } 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); 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); } 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)); }