From 3d97f7df0ec141ef9266dd1253e0c59c00294fe7 Mon Sep 17 00:00:00 2001 From: Tomas Pecka <peckato1@fit.cvut.cz> Date: Tue, 18 Nov 2014 16:15:12 +0100 Subject: [PATCH] aminimize: optionally select algorithm --- aminimize2/src/aminimize.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/aminimize2/src/aminimize.cpp b/aminimize2/src/aminimize.cpp index 3a6c226ecf..f0b7596108 100644 --- a/aminimize2/src/aminimize.cpp +++ b/aminimize2/src/aminimize.cpp @@ -11,6 +11,7 @@ #include <factory/DataFactory.hpp> #include "automaton/simplify/Minimize.h" +#include "automaton/simplify/MinimizeBrzozowski.h" int main(int argc, char** argv) { @@ -20,6 +21,11 @@ int main(int argc, char** argv) { TCLAP::ValueArg<std::string> input( "a", "automaton", "Automaton to minimize", false, "-", "file"); cmd.add( input ); + std::vector<std::string> algorithms {"Hopcroft", "Brzozowski" }; + TCLAP::ValuesConstraint<std::string> algorithmVals( algorithms ); + TCLAP::ValueArg<std::string> algorithm( "g", "algorithm", "Use specific algorithm. Hopcroft default.", false, "", &algorithmVals); + cmd.add( algorithm ); + cmd.parse(argc, argv); std::list<sax::Token> tokens; @@ -33,7 +39,15 @@ int main(int argc, char** argv) { sax::SaxParseInterface::parseStdin(tokens); } - alib::DataFactory::toStdout(automaton::simplify::Minimize::minimize(alib::DataFactory::fromTokens<automaton::Automaton>(tokens))); + if(algorithm.getValue() == "Hopcroft" || algorithm.getValue() == "") { + alib::DataFactory::toStdout(automaton::simplify::Minimize::minimize(alib::DataFactory::fromTokens<automaton::Automaton>(tokens))); + } + else if(algorithm.getValue() == "Brzozowski") { + alib::DataFactory::toStdout(automaton::simplify::MinimizeBrzozowski::minimize(alib::DataFactory::fromTokens<automaton::Automaton>(tokens))); + } else { + throw exception::AlibException("Unknown algorithm selected."); + } + return 0; } catch (const exception::AlibException& exception) { -- GitLab