Example #1
0
        static public void Minimalization()
        {
            Console.Clear();
            Console.WriteLine("1. Minimalization DFA" +
                              Environment.NewLine + "2. Minimalization Random DFA");
            var ans = Console.ReadLine();
            AutomataMinimalization m = new AutomataMinimalization();
            AutomataConverter      c = new AutomataConverter();
            int choice = 0;

            if (int.TryParse(ans, out choice))
            {
                switch (choice)
                {
                case 1:
                    Console.Clear();
                    Automata <string> a = Tester.TestDFA2();
                    Console.WriteLine("De volgende DFA: ");
                    a.printTransitions();
                    Tester.generateAutomataImage(a);
                    Console.WriteLine("Is in Minimalisatie: (druk op een knop)");
                    Console.ReadLine();
                    Automata <String> mini = m.Minimization(a);
                    mini.printTransitions();
                    Tester.generateAutomataImage(mini);
                    ResetToMenu();
                    break;

                case 2:
                    Console.Clear();
                    Automata <string> b = c.renameStates(Tester.generateRandomDfa());
                    Console.WriteLine("De volgende DFA: ");
                    b.printTransitions();
                    Tester.generateAutomataImage(b);
                    Console.WriteLine("Is in Minimalisatie: (druk op een knop)");
                    Console.ReadLine();
                    Automata <String> mini2 = m.Minimization(b);
                    mini2.printTransitions();
                    Tester.generateAutomataImage(mini2);
                    ResetToMenu();
                    break;

                default:
                    Console.WriteLine("Deze optie is niet beschikbaar." +
                                      Environment.NewLine + "Druk op een knop om terug te gaan");
                    ResetToMenu();
                    break;
                }
            }
            else
            {
                Console.WriteLine("Vul alstublieft het nummer van de keuze in." +
                                  Environment.NewLine + "Druk op een knop om terug te gaan");
                ResetToMenu();
            }
        }
Example #2
0
 public static void Minimalization()
 {
     Console.Clear();
     Console.WriteLine("1. Minimalization DFA" +
     Environment.NewLine + "2. Minimalization Random DFA");
     var ans = Console.ReadLine();
     AutomataMinimalization m = new AutomataMinimalization();
     AutomataConverter c = new AutomataConverter();
     int choice=0;
     if (int.TryParse(ans, out choice))
     {
         switch (choice)
         {
             case 1:
                 Console.Clear();
                 Automata<string> a = Tester.TestDFA2 ();
                 Console.WriteLine("De volgende DFA: ");
                 a.printTransitions();
                 Tester.generateAutomataImage(a);
                 Console.WriteLine("Is in Minimalisatie: (druk op een knop)");
                 Console.ReadLine();
                 Automata<String> mini = m.Minimization(a);
                 mini.printTransitions();
                 Tester.generateAutomataImage(mini);
                 ResetToMenu();
                 break;
             case 2:
                 Console.Clear();
                 Automata<string> b = c.renameStates(Tester.generateRandomDfa());
                 Console.WriteLine("De volgende DFA: ");
                 b.printTransitions();
                 Tester.generateAutomataImage(b);
                 Console.WriteLine("Is in Minimalisatie: (druk op een knop)");
                 Console.ReadLine();
                 Automata<String> mini2 = m.Minimization(b);
                 mini2.printTransitions();
                 Tester.generateAutomataImage(mini2);
                 ResetToMenu();
                 break;
             default:
                 Console.WriteLine("Deze optie is niet beschikbaar." +
                     Environment.NewLine + "Druk op een knop om terug te gaan");
                 ResetToMenu();
                 break;
         }
     }
     else
     {
         Console.WriteLine("Vul alstublieft het nummer van de keuze in."+
             Environment.NewLine + "Druk op een knop om terug te gaan");
         ResetToMenu();
     }
 }
Example #3
0
 public static Automata<String> testMinimalization(Automata<String> automata)
 {
     AutomataMinimalization m = new AutomataMinimalization();
     return m.Minimization(automata);
 }
Example #4
0
        static public Automata <String> testMinimalization(Automata <String> automata)
        {
            AutomataMinimalization m = new AutomataMinimalization();

            return(m.Minimization(automata));
        }
Example #5
0
        public void generateLaTeXExam()
        {
            String tentamenText = frontpageLatex();
            // Folder creation
            String mainExamFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/TentamenGenerator/";
            String currentExamFolder = "";
            String imagesFolder = "";
            String date = DateTime.Now.ToString("dd-MM-yyyy_hh:mm:ss");

            if (Directory.Exists(mainExamFolder)==false) {
                System.IO.Directory.CreateDirectory(mainExamFolder);
            }

            if (Directory.Exists(mainExamFolder + "Tentamen_"+ date + "/") == false)
            {
                Console.WriteLine("Created folder: " + "Tentamen_"+date);
                System.IO.Directory.CreateDirectory(mainExamFolder + date + "/");
                currentExamFolder = mainExamFolder + date + "/";
            }

            if (currentExamFolder == "")
                return;

            imagesFolder = currentExamFolder + "Images/";
            System.IO.Directory.CreateDirectory(imagesFolder);

            AutomataConverter c = new AutomataConverter();
            AutomataMinimalization m = new AutomataMinimalization();

            // defining regexes
            char[] alfabet = {'a', 'b'};
            RegularExpression tentamenRegex_regexDFA = Tester.generateRandomRegex(alfabet, 2);
            RegularExpression tentamenRegex_regexNDFA = Tester.generateRandomRegex(alfabet, 2);
            RegularExpression tentamenRegex_DFAregex = Tester.generateRandomRegex(alfabet, 2);
            RegularExpression tentamenRegex_NDFAregex = Tester.generateRandomRegex(alfabet, 2);
            RegularExpression tentamenRegex_DFAToGrammar = Tester.generateRandomRegex(alfabet, 2);
            RegularExpression tentamenRegex_NDFAToGrammar = Tester.generateRandomRegex(alfabet, 2);

            // Generating exam images
            Tester.generateAutomataImage(Tester.TestNDFA2(),imagesFolder+"NDFA_FOR_NDFA_TO_DFA.pdf","pdf");
            Tester.generateAutomataImage(c.NDFAToDFA(Tester.TestNDFA2()),imagesFolder+"DFA_FOR_NDFA_TO_DFA.pdf","pdf");
            Tester.generateAutomataImage(c.renameStates(c.NDFAToDFA(tentamenRegex_regexDFA.regexToNDFA())),imagesFolder+"DFA_FOR_REGEX_TO_DFA.pdf","pdf");
            Tester.generateAutomataImage(c.renameStates(tentamenRegex_regexNDFA.regexToNDFA()),imagesFolder+"NDFA_FOR_REGEX_TO_NDFA.pdf","pdf");
            Tester.generateAutomataImage(c.renameStates(c.NDFAToDFA(tentamenRegex_DFAregex.regexToNDFA())),imagesFolder+"DFA_FOR_DFA_TO_REGEX.pdf","pdf");
            Tester.generateAutomataImage(c.renameStates(tentamenRegex_NDFAregex.regexToNDFA()),imagesFolder+"NDFA_FOR_NDFA_TO_REGEX.pdf","pdf");
            Tester.generateAutomataImage(Tester.TestDFA(),imagesFolder+"DFA_FOR_MINIMALISE_DFA.pdf","pdf");
            Tester.generateAutomataImage(m.Minimization(Tester.TestDFA()),imagesFolder+"MINIMALISED_DFA_FOR_MINIMALISE_DFA.pdf","pdf");
            Tester.generateAutomataImage(c.renameStates(c.NDFAToDFA(tentamenRegex_DFAToGrammar.regexToNDFA())), imagesFolder+"DFA_FOR_DFA_TO_GRAMMAR.pdf","pdf");
            Tester.generateAutomataImage(c.renameStates(tentamenRegex_NDFAToGrammar.regexToNDFA()), imagesFolder+"NDFA_FOR_NDFA_TO_GRAMMAR.pdf","pdf");

            // Add questions to exam string
            tentamenText += exerciseNDFAToDFA();							//NDFA to DFA
            tentamenText += exerciseRegexToDFA(tentamenRegex_regexDFA);		//Regex to DFA
            tentamenText += exerciseRegexToNDFA(tentamenRegex_regexNDFA);	//Regex to NDFA
            tentamenText += exerciseDFAToRegex();							//DFA to regex
            tentamenText += exerciseNDFAToRegex();							//NDFA to regex
            tentamenText += exerciseMinimaliseDFA();						//Minimalise DFA
            tentamenText += exerciseDFAToGrammar();							//DFA to grammar
            tentamenText += exerciseNDFAToGrammar();						//NDFA to grammar

            // Add answers to exam string
            tentamenText += answersIntro();
            tentamenText += answerNDFAToDFA();
            tentamenText += answerRegexToDFA();
            tentamenText += answerRegexToNDFA();
            tentamenText += answerDFAToRegex(tentamenRegex_DFAregex);
            tentamenText += answerNDFAToRegex(tentamenRegex_NDFAregex);
            tentamenText += answerMinimaliseDFA();
            tentamenText += answerDFAToGrammar(c.renameStates(c.NDFAToDFA(tentamenRegex_DFAToGrammar.regexToNDFA())));
            tentamenText += answerNDFAToGrammar(c.renameStates(c.NDFAToDFA(tentamenRegex_NDFAToGrammar.regexToNDFA())));

            // End exam string
            tentamenText += endOfDocument();

            // Writing exam to file
            System.IO.StreamWriter file = new System.IO.StreamWriter(currentExamFolder+"proeftentamen.tex");

            file.WriteLine(tentamenText);

            file.Close();

            buildAndOpenLaTeXPDF(currentExamFolder);
        }
Example #6
0
        public void generateLaTeXExam()
        {
            String tentamenText = frontpageLatex();
            // Folder creation
            String mainExamFolder    = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/TentamenGenerator/";
            String currentExamFolder = "";
            String imagesFolder      = "";
            String date = DateTime.Now.ToString("dd-MM-yyyy_hh:mm:ss");

            if (Directory.Exists(mainExamFolder) == false)
            {
                System.IO.Directory.CreateDirectory(mainExamFolder);
            }

            if (Directory.Exists(mainExamFolder + "Tentamen_" + date + "/") == false)
            {
                Console.WriteLine("Created folder: " + "Tentamen_" + date);
                System.IO.Directory.CreateDirectory(mainExamFolder + date + "/");
                currentExamFolder = mainExamFolder + date + "/";
            }

            if (currentExamFolder == "")
            {
                return;
            }

            imagesFolder = currentExamFolder + "Images/";
            System.IO.Directory.CreateDirectory(imagesFolder);

            AutomataConverter      c = new AutomataConverter();
            AutomataMinimalization m = new AutomataMinimalization();

            // defining regexes
            char[]            alfabet = { 'a', 'b' };
            RegularExpression tentamenRegex_regexDFA      = Tester.generateRandomRegex(alfabet, 2);
            RegularExpression tentamenRegex_regexNDFA     = Tester.generateRandomRegex(alfabet, 2);
            RegularExpression tentamenRegex_DFAregex      = Tester.generateRandomRegex(alfabet, 2);
            RegularExpression tentamenRegex_NDFAregex     = Tester.generateRandomRegex(alfabet, 2);
            RegularExpression tentamenRegex_DFAToGrammar  = Tester.generateRandomRegex(alfabet, 2);
            RegularExpression tentamenRegex_NDFAToGrammar = Tester.generateRandomRegex(alfabet, 2);

            // Generating exam images
            Tester.generateAutomataImage(Tester.TestNDFA2(), imagesFolder + "NDFA_FOR_NDFA_TO_DFA.pdf", "pdf");
            Tester.generateAutomataImage(c.NDFAToDFA(Tester.TestNDFA2()), imagesFolder + "DFA_FOR_NDFA_TO_DFA.pdf", "pdf");
            Tester.generateAutomataImage(c.renameStates(c.NDFAToDFA(tentamenRegex_regexDFA.regexToNDFA())), imagesFolder + "DFA_FOR_REGEX_TO_DFA.pdf", "pdf");
            Tester.generateAutomataImage(c.renameStates(tentamenRegex_regexNDFA.regexToNDFA()), imagesFolder + "NDFA_FOR_REGEX_TO_NDFA.pdf", "pdf");
            Tester.generateAutomataImage(c.renameStates(c.NDFAToDFA(tentamenRegex_DFAregex.regexToNDFA())), imagesFolder + "DFA_FOR_DFA_TO_REGEX.pdf", "pdf");
            Tester.generateAutomataImage(c.renameStates(tentamenRegex_NDFAregex.regexToNDFA()), imagesFolder + "NDFA_FOR_NDFA_TO_REGEX.pdf", "pdf");
            Tester.generateAutomataImage(Tester.TestDFA(), imagesFolder + "DFA_FOR_MINIMALISE_DFA.pdf", "pdf");
            Tester.generateAutomataImage(m.Minimization(Tester.TestDFA()), imagesFolder + "MINIMALISED_DFA_FOR_MINIMALISE_DFA.pdf", "pdf");
            Tester.generateAutomataImage(c.renameStates(c.NDFAToDFA(tentamenRegex_DFAToGrammar.regexToNDFA())), imagesFolder + "DFA_FOR_DFA_TO_GRAMMAR.pdf", "pdf");
            Tester.generateAutomataImage(c.renameStates(tentamenRegex_NDFAToGrammar.regexToNDFA()), imagesFolder + "NDFA_FOR_NDFA_TO_GRAMMAR.pdf", "pdf");

            // Add questions to exam string
            tentamenText += exerciseNDFAToDFA();                                        //NDFA to DFA
            tentamenText += exerciseRegexToDFA(tentamenRegex_regexDFA);                 //Regex to DFA
            tentamenText += exerciseRegexToNDFA(tentamenRegex_regexNDFA);               //Regex to NDFA
            tentamenText += exerciseDFAToRegex();                                       //DFA to regex
            tentamenText += exerciseNDFAToRegex();                                      //NDFA to regex
            tentamenText += exerciseMinimaliseDFA();                                    //Minimalise DFA
            tentamenText += exerciseDFAToGrammar();                                     //DFA to grammar
            tentamenText += exerciseNDFAToGrammar();                                    //NDFA to grammar

            // Add answers to exam string
            tentamenText += answersIntro();
            tentamenText += answerNDFAToDFA();
            tentamenText += answerRegexToDFA();
            tentamenText += answerRegexToNDFA();
            tentamenText += answerDFAToRegex(tentamenRegex_DFAregex);
            tentamenText += answerNDFAToRegex(tentamenRegex_NDFAregex);
            tentamenText += answerMinimaliseDFA();
            tentamenText += answerDFAToGrammar(c.renameStates(c.NDFAToDFA(tentamenRegex_DFAToGrammar.regexToNDFA())));
            tentamenText += answerNDFAToGrammar(c.renameStates(c.NDFAToDFA(tentamenRegex_NDFAToGrammar.regexToNDFA())));

            // End exam string
            tentamenText += endOfDocument();


            // Writing exam to file
            System.IO.StreamWriter file = new System.IO.StreamWriter(currentExamFolder + "proeftentamen.tex");

            file.WriteLine(tentamenText);

            file.Close();

            buildAndOpenLaTeXPDF(currentExamFolder);
        }