script.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
00035
00036
00037
00038
00039 #include <gecode/driver.hh>
00040
00041 #include <cmath>
00042
00043 namespace Gecode { namespace Driver {
00044
00045 void
00046 stop(Support::Timer& timer, std::ostream& os) {
00047 double t = timer.stop();
00048 unsigned int sec = static_cast<unsigned int>(floor(t / 1000.0));
00049 unsigned int o_msec = static_cast<unsigned int>
00050 (t - 1000.0*static_cast<double>(sec));
00051 unsigned int min = sec / 60;
00052 unsigned int o_sec = sec - 60 * min;
00053 unsigned int hour = min / 60;
00054 unsigned int o_min = min - 60 * hour;
00055 unsigned int day = hour / 24;
00056 unsigned int o_hour = hour - 24 * day;
00057 if (day)
00058 os << day << " days, ";
00059 if (o_hour)
00060 os << o_hour << ":";
00061 if (o_hour || o_min) {
00062 if (o_hour) {
00063 os.width(2); os.fill('0');
00064 }
00065 os << o_min << ":";
00066 os.width(2); os.fill('0');
00067 }
00068 os << o_sec << ".";
00069 os.width(3); os.fill('0');
00070 os << o_msec
00071 << " ("
00072 << std::showpoint << std::fixed
00073 << std::setprecision(3) << t << " ms)";
00074 }
00075
00076
00077 double
00078 am(double t[], int n) {
00079 if (n < 1)
00080 return 0.0;
00081 double s = 0;
00082 for (int i=n; i--; )
00083 s += t[i];
00084 return s / n;
00085 }
00086
00087 double
00088 dev(double t[], int n) {
00089 if (n < 2)
00090 return 0.0;
00091 double m = am(t,n);
00092 double s = 0.0;
00093 for (int i=n; i--; ) {
00094 double d = t[i]-m;
00095 s += d*d;
00096 }
00097 return ::sqrt(s / (n-1)) / m;
00098 }
00099
00100 bool Cutoff::sigint;
00101
00102 }}
00103
00104