Main Page | Modules | Alphabetical List | Compound List | File List | Compound Members | Related Pages

stats.hpp

00001 #ifndef ross_stats_header
00002 #define ross_stats_header
00003 
00004 /*Authored 2002    by  Kyle  Ross,  Undergraduate  Philosophy   Thesis
00005 (Advisor: Professor Bram van Heuveln)
00006 
00007 Modified 2003    by Owen Kellett, Undergraduate Research
00008 (Advisor: Professor Bram van Heuveln)
00009 
00010 
00011 This  file is part of the   "Generic Turing Machine Implementation for
00012 Use in the Exploration of the Busy Beaver Problem".
00013 
00014 The "Generic Turing Machine Implementation for  Use in the Exploration
00015 of the Busy Beaver Problem" is free  software; you can redistribute it
00016 and/or modify it under the terms of the  GNU General Public License as
00017 published   by the Free Software Foundation;   either version 2 of the
00018 License, or (at your option) any later version.
00019 
00020 This programme is distributed in the hope that it  will be useful, but
00021 WITHOUT    ANY  WARRANTY;  without   even  the    implied warranty  of
00022 MERCHANTABILITY or FITNESS FOR  A  PARTICULAR  PURPOSE.  See  the  GNU
00023 General Public License for more details.
00024 
00025 You should have received   a copy of  the  GNU General Public  License
00026 along  with  this   programme; if  not,  write   to the Free  Software
00027 Foundation, Inc., 59  Temple Place, Suite  330, Boston, MA  02111-1307
00028 USA (or visit http://www.fsf.org/licenses/licenses.html)
00029 
00030 Created as part of the Busy Beaver Project:
00031 Bram van Heuveln <heuveb@rpi.edu>
00032 Boleshaw Szymanski <szymansk@cs.rpi.edu>
00033 Selmer Bringsjord <selmer@rpi.edu>
00034 Carlos Varela <cvarela@cs.rpi.edu>
00035 Owen Kellett <kelleo@rpi.edu>
00036 Shailesh Kelkar <kelkas@rpi.edu>
00037 Kyle Ross <rossk2@rpi.edu>
00038 Rensselaer Reasoning Group
00039 Department of Cognitive Science
00040 Department of Computer Science
00041 Rensselaer Polytechnic Institute
00042 Troy, New York 12180
00043 U.S.A.
00044 */
00045 //implements a simple class for tracking statistics of turing machines during runs
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         //the reasons for elimination of machines
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         //names of reasons for display ... this must be the same length as the enumerated reasons
00061         static const char* names[];
00062         private:
00063                 //this must match the length of the enumerated reasons
00064                 static const int num_reasons=18;
00065         public:
00066 
00067         //initialise all counts to 0
00068         tm_stats()
00069         :counts(num_reasons, 0)
00070         {}
00071 
00072         //increment a count by the specified amount
00073         void increment(reason why, long_int amount)
00074         {
00075                 //std::cout<<"eliminated for reason: "<<names[why]<<" representing: "<<amount<<std::endl<<std::endl;
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         //print out the stats
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

Generated on Thu Nov 20 00:17:32 2003 for BusyBeaver by doxygen 1.3.3