tracer.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <gecode/search.hh>
00035
00036 namespace Gecode {
00037
00038 const char*
00039 StdSearchTracer::t2s[SearchTracer::EngineType::AOE + 1] = {
00040 "DFS", "BAB", "LDS",
00041 "RBS", "PBS",
00042 "AOE"
00043 };
00044
00045 StdSearchTracer::StdSearchTracer(std::ostream& os0)
00046 : os(os0) {}
00047
00048 void
00049 StdSearchTracer::init(void) {
00050 os << "trace<Search>::init()" << std::endl;
00051 for (unsigned int e=0U; e<engines(); e++) {
00052 os << "\t" << e << ": "
00053 << t2s[engine(e).type()];
00054 if (engine(e).meta()) {
00055 os << ", engines: {";
00056 for (unsigned int i=engine(e).efst(); i<engine(e).elst(); i++) {
00057 os << i; if (i+1 < engine(e).elst()) os << ",";
00058 }
00059 } else {
00060 os << ", workers: {";
00061 for (unsigned int i=engine(e).wfst(); i<engine(e).wlst(); i++) {
00062 os << i; if (i+1 < engine(e).wlst()) os << ",";
00063 }
00064 }
00065 os << "}" << std::endl;
00066 }
00067 }
00068
00069 void
00070 StdSearchTracer::round(unsigned int eid) {
00071 os << "trace<Search>::round(e:" << eid << ")" << std::endl;
00072 }
00073
00074 void
00075 StdSearchTracer::skip(const EdgeInfo& ei) {
00076 os << "trace<Search>Search::skip(w:" << ei.wid()
00077 << ",n:" << ei.nid()
00078 << ",a:" << ei.alternative() << ")" << std::endl;
00079 }
00080
00081 void
00082 StdSearchTracer::node(const EdgeInfo& ei, const NodeInfo& ni) {
00083 os << "trace<Search>::node(";
00084 switch (ni.type()) {
00085 case NodeType::FAILED:
00086 os << "FAILED";
00087 break;
00088 case NodeType::SOLVED:
00089 os << "SOLVED";
00090 break;
00091 case NodeType::BRANCH:
00092 os << "BRANCH(" << ni.choice().alternatives() << ")";
00093 break;
00094 }
00095 if (!ei)
00096 os << ",root";
00097 os << ",w:" << ni.wid() << ',';
00098 if (ei)
00099 os << "p:" << ei.nid() << ',';
00100 os << "n:" << ni.nid() << ')';
00101 if (ei) {
00102 if (ei.wid() != ni.wid())
00103 os << " [stolen from w:" << ei.wid() << "]";
00104 os << std::endl
00105 << '\t' << ei.string()
00106 << std::endl;
00107 } else {
00108 os << std::endl;
00109 }
00110 }
00111
00112 void
00113 StdSearchTracer::done(void) {
00114 os << "trace<Search>::done()" << std::endl;
00115 }
00116
00117 StdSearchTracer::~StdSearchTracer(void) {}
00118
00119 StdSearchTracer StdSearchTracer::def;
00120
00121 }
00122
00123