00001 #ifndef ross_stats_header
00002 #define ross_stats_header
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
00040
00041
00042
00043
00044
00045
00046
00047 #include <cmath>
00048 #include <iostream>
00049 #include <vector>
00050
00051 #include "long_int.hpp"
00052 template <typename T>
00053 class turing_machine;
00054 class tm_stats
00055 {
00056 public:
00057
00058 enum reason{candidate=0, not_in_standard_position, holdout, simple_nonproductive, complex_nonproductive, empty_tape, first_write_1, first_move_right, backTracker, subsetLoop, simpleLoop, christmasTree, alternateChristmasTree, leaningChristmasTree, tripleSweepChristmasTree, quadrupleSweepChristmasTree, quintupleSweepChristmasTree, counter};
00059 enum machine_type{implicit_halt, explicit_halt};
00060
00061 static const char* names[];
00062 private:
00063
00064 static const int num_reasons=18;
00065 public:
00066
00067
00068 tm_stats()
00069 :counts(num_reasons, 0)
00070 {}
00071
00072
00073 void increment(reason why, long_int amount)
00074 {
00075
00076 counts[why]+=amount;
00077 }
00078 void reset()
00079 {
00080 for(int i=0; i<num_reasons; ++i)
00081 {
00082 counts[i]=0;
00083 }
00084 }
00085
00086 void print(std::ostream &out) const
00087 {
00088 long_int accum=0;
00089
00090 out<<"elimination statistics"<<std::endl;
00091 for(int i=0; i<num_reasons; ++i)
00092 {
00093 out<<' '<<names[i]<<": "<<counts[i]<<std::endl;
00094 accum+=counts[i];
00095 }
00096 out<<" total: "<<accum<<std::endl;
00097 }
00098 private:
00099 std::vector<long_int> counts;
00100 };
00101
00102 const char* tm_stats::names[]={"halter/candidate", "non-standard halt", "holdout", "ss transition", "ss-prime transition", "empty-tape", "first-write-1", "first-move-R", "backTracker", "subsetLoop", "simpleLoop", "christmasTree", "alternateChristmasTree", "leaningChristmasTree", "tripleSweepChristmasTree", "quadrupleSweepChristmasTree", "quintupleSweepChristmasTree", "counter"};
00103
00104
00105 std::ostream& operator<<(std::ostream &out, const tm_stats &to_print)
00106 {
00107 to_print.print(out);
00108 return out;
00109 }
00110
00111 #endif