TSPLIB
|
00001 00011 #include <iostream> 00012 00013 #include <xercesc/util/XMLException.hpp> 00014 #include <xercesc/util/OutOfMemoryException.hpp> 00015 00016 #include "ValidateConstantsFunctionsAndClasses.hpp" 00017 #include "ValidateIO.hpp" 00018 #include "ValidateInstance.hpp" 00019 00020 using namespace std; 00021 using namespace xercesc; 00022 00023 XERCES_CPP_NAMESPACE_USE 00024 00025 00037 int main(int argc, char* argv[]) { 00038 /* 00039 * Initialling. 00040 */ 00041 cout << "Validate.cpp:" << endl; 00042 cout << "----------------------------------------------------------------" << endl; 00043 00044 string inputFileName; 00045 try{ 00046 inputFileName = parseCommandLineArguments(argc, argv); 00047 } 00048 catch (CommandLineArgumentsInvalid &e) { 00049 cerr << "The command-line arguments are invalid!" << endl; 00050 return (1); 00051 } 00052 00053 //Writing the used filename on the standard output 00054 cout << "Input file: " << inputFileName << endl; 00055 00056 00057 /* 00058 * Reading of the input file. 00059 */ 00060 cout << "Reading the file \"" << inputFileName << "\" ... " << flush; 00061 00062 Instance *instance = 0; 00063 try { 00064 instance = instanceIn(inputFileName); 00065 } 00066 catch (bad_alloc &e) { 00067 cerr << "the input graph is too large!" << endl; 00068 return (1); 00069 } 00070 catch (OutOfMemoryException &e) { 00071 cerr << "the input graph is too large!" << endl; 00072 return (1); 00073 } 00074 catch (XMLException &e) { 00075 cerr << "Xerces failed!" << endl; 00076 return (1); 00077 } 00078 catch (ValidationSchemaDoesNotExist &e) { 00079 cerr << "the validation schema does not exist!" << endl; 00080 return (1); 00081 } 00082 catch (ValidationFailed &e) { 00083 cerr << "the validation failed!" << 00084 " Note that all costs have to be \"double\" type compatible." << 00085 " The number of vertices has to be \"unsigned int\" compatible." << endl; 00086 return (1); 00087 } 00088 /* catch ( ... ) { 00089 cerr << "an exception occurs!" << endl; 00090 return (1); 00091 }*/ 00092 00093 cout << "OK" << endl; 00094 cout << "----------------------------------------------------------------" << endl; 00095 00096 00097 /* 00098 * Printing the results. 00099 */ 00100 if (instance->getGraph()->getIsUndirected()) { 00101 cout << 00102 "The file \"" << 00103 inputFileName << 00104 "\" responds to a valid instance of the symmetric travelling salesman problem." << 00105 endl; 00106 } 00107 else { 00108 cout << 00109 "The file \"" << 00110 inputFileName << 00111 "\" responds to a valid instance of the asymmetric travelling salesman problem." << 00112 endl; 00113 } 00114 cout << "\tName: " << instance->getName() << endl; 00115 cout << "\tSource: " << instance->getSource() << endl; 00116 cout << "\tDescription: " << instance->getDescription() << endl; 00117 cout << "\tNumber of vertices: " << instance->getGraph()->getN() << endl; 00118 00119 00120 // cout << endl << endl << *instance << endl << endl; 00121 00122 00123 /* 00124 * Releasing of the memory and returning 0. 00125 */ 00126 delete instance; 00127 00128 return (0); 00129 }