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 <iomanip>
00035 #include <gecode/set.hh>
00036
00037 namespace Gecode {
00038
00039 StdSetTracer::StdSetTracer(std::ostream& os0)
00040 : os(os0) {}
00041
00042 void
00043 StdSetTracer::init(const Space&, const SetTraceRecorder& t) {
00044 os << "trace<Set>::init(id:" << t.id();
00045 if (t.group().in())
00046 os << ",g:" << t.group().id();
00047 os << ") slack: 100.00% (" << t.slack().initial() << " values)"
00048 << std::endl;
00049 }
00050
00051 void
00052 StdSetTracer::prune(const Space&, const SetTraceRecorder& t,
00053 const ViewTraceInfo& vti, int i, SetTraceDelta& d) {
00054 os << "trace<Set>::prune(id:" << t.id();
00055 if (t.group().in())
00056 os << ",g:" << t.group().id();
00057 os << "): [" << i << "] = " << t[i] << " + {";
00058 {
00059 SetTraceDelta::Glb glb(d.glb());
00060 if (glb()) {
00061 os << glb.min() << ".." << glb.max();
00062 ++glb;
00063 while (glb()) {
00064 os << "," << glb.min() << ".." << glb.max();
00065 ++glb;
00066 }
00067 }
00068 }
00069 os << "} - {";
00070 {
00071 SetTraceDelta::Lub lub(d.lub());
00072 if (lub()) {
00073 os << lub.min() << ".." << lub.max();
00074 ++lub;
00075 while (lub()) {
00076 os << "," << lub.min() << ".." << lub.max();
00077 ++lub;
00078 }
00079 }
00080 }
00081 os << "} by " << vti << std::endl;
00082 }
00083
00084 void
00085 StdSetTracer::fix(const Space&, const SetTraceRecorder& t) {
00086 os << "trace<Set>::fix(id:" << t.id();
00087 if (t.group().in())
00088 os << ",g:" << t.group().id();
00089 os << ") slack: ";
00090 double sl_i = static_cast<double>(t.slack().initial());
00091 double sl_p = static_cast<double>(t.slack().previous());
00092 double sl_c = static_cast<double>(t.slack().current());
00093 double p_c = 100.0 * (sl_c / sl_i);
00094 double p_d = 100.0 * (sl_p / sl_i) - p_c;
00095 os << std::showpoint << std::setprecision(4)
00096 << p_c << "% - "
00097 << std::showpoint << std::setprecision(4)
00098 << p_d << '%'
00099 << std::endl;
00100 }
00101
00102 void
00103 StdSetTracer::fail(const Space&, const SetTraceRecorder& t) {
00104 os << "trace<Set>::fail(id:" << t.id();
00105 if (t.group().in())
00106 os << ",g:" << t.group().id();
00107 os << ") slack: ";
00108 double sl_i = static_cast<double>(t.slack().initial());
00109 double sl_p = static_cast<double>(t.slack().previous());
00110 double sl_c = static_cast<double>(t.slack().current());
00111 double p_c = 100.0 * (sl_c / sl_i);
00112 double p_d = 100.0 * (sl_p / sl_i) - p_c;
00113 os << std::showpoint << std::setprecision(4)
00114 << p_c << "% - "
00115 << std::showpoint << std::setprecision(4)
00116 << p_d << '%'
00117 << std::endl;
00118 }
00119
00120 void
00121 StdSetTracer::done(const Space&, const SetTraceRecorder& t) {
00122 os << "trace<Set>::done(id:" << t.id();
00123 if (t.group().in())
00124 os << ",g:" << t.group().id();
00125 os << ") slack: 0%" << std::endl;
00126 }
00127
00128 StdSetTracer StdSetTracer::def;
00129
00130 }
00131
00132