OKlibrary  0.2.1.6
ComputeLexicographicalEvaluation.cpp
Go to the documentation of this file.
00001 // Oliver Kullmann, 30.10.2005 (Swansea)
00002 /* Copyright 2005 - 2007 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007 
00018 #include <string>
00019 #include <iterator>
00020 #include <algorithm>
00021 #include <iostream>
00022 
00023 #include <OKlib/Experimentation/Competition/ParsingSingleResult.hpp>
00024 #include <OKlib/Experimentation/Competition/LexicographicalEvaluation.hpp>
00025 
00026 namespace {
00027 
00028   template <bool with_extension>
00029   struct LexicographicalEvaluationRandom_from_file {
00030     typedef OKlib::SATCompetition::LexicographicalEvaluationRandom_from_file<OKlib::SATCompetition::ParserThreeElements> type;
00031   };
00032   template <>
00033   struct LexicographicalEvaluationRandom_from_file<false> {
00034     typedef OKlib::SATCompetition::LexicographicalEvaluationRandom_from_file<> type;
00035   };
00036   
00037   // #############################
00038   
00039   template <bool with_extension>
00040   struct Evaluation {
00041     
00042     const std::string& filename;
00043     const char* const specifier;
00044     
00045     typedef typename ::LexicographicalEvaluationRandom_from_file<with_extension>::type evaluation_from_file_type;
00046     evaluation_from_file_type eval;
00047     
00048     Evaluation(const std::string& filename, const char* const specifier) : filename(filename), specifier(specifier), eval(filename) {
00049       
00050       std::cout << "\nFile name = " << filename;
00051       if (specifier)
00052         std::cout << "\nsyntax specifier = " << specifier;
00053       std::cout << "\n\n";
00054       
00055       std::cout << "\nALL results: ---------------------------------------------------------------------------------------------------------------------\n\n";
00056       std::cout << "Unfolded lexicographical order:\n\n";
00057       eval.evaluation_unfolded_all.print(std::cout);
00058       std::cout << "\n";
00059       std::cout << "Induced lexicographical order:\n\n";
00060       eval.evaluation_induced_all.print(std::cout);
00061       std::cout << "\n";
00062       
00063       std::cout << "\nSAT results: ---------------------------------------------------------------------------------------------------------------------\n\n";
00064       std::cout << "Unfolded lexicographical order:\n\n";
00065       eval.evaluation_unfolded_sat.print(std::cout);
00066       std::cout << "\n";
00067       std::cout << "Induced lexicographical order:\n\n";
00068       eval.evaluation_induced_sat.print(std::cout);
00069       std::cout << "\n";
00070       
00071       std::cout << "\nUNSAT results: ---------------------------------------------------------------------------------------------------------------------\n\n";
00072       std::cout << "Unfolded lexicographical order:\n\n";
00073       eval.evaluation_unfolded_unsat.print(std::cout);
00074       std::cout << "\n";
00075       std::cout << "Induced lexicographical order:\n\n";
00076       eval.evaluation_induced_unsat.print(std::cout);
00077       std::cout << "\n";
00078       
00079     }
00080   };
00081 }
00082 
00083 
00084 // #############################
00085 
00086 int main(const int argc, const char* const argv[]) {
00087 
00088   if (argc <= 1 or argc >= 4) {
00089     std::cerr << "One or two arguments required (the name of the file, and optionally a syntax specifier).\n";
00090     return EXIT_FAILURE;
00091   }
00092   const std::string& file_name(argv[1]);
00093   const bool specifier = (argc == 3);
00094   const char* const specifier_text = (specifier) ? argv[2] : (const char*)(0);
00095 
00096   if (specifier) {
00097     Evaluation<true>(file_name, specifier_text);
00098   }
00099   else {
00100     Evaluation<false>(file_name, specifier_text);
00101   }
00102 }