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