Added Exceptions framework (and more)
authorJoris Mooij <jorism@osun.tuebingen.mpg.de>
Fri, 19 Sep 2008 09:59:51 +0000 (11:59 +0200)
committerJoris Mooij <jorism@osun.tuebingen.mpg.de>
Fri, 19 Sep 2008 09:59:51 +0000 (11:59 +0200)
- Updated ChangeLog and STATUS
- Added exceptions.h/cpp from SVN head
- Removed all remaining NANs
- Added --report-time option to tests/test,
  which allows for simplifications in tests/testregression.

21 files changed:
ChangeLog
Makefile
Makefile.win
STATUS
include/dai/enum.h
include/dai/exceptions.h [new file with mode: 0644]
include/dai/lc.h
include/dai/mr.h
include/dai/prob.h
src/alldai.cpp
src/exceptions.cpp [new file with mode: 0644]
src/factorgraph.cpp
src/hak.cpp
src/mf.cpp
src/properties.cpp
src/treeep.cpp
tests/test.cpp
tests/testall
tests/testall.bat
tests/testfast.out
tests/testregression

index b1e6f67..973f7a2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 libDAI-0.2.2 (2008-??-??)
 -------------------------
 
+* Now compiles also under Visual C++.
+* Added Exceptions framework.
+* Added more features to utils/createfg for creating factor graphs.
 * Pervasive change of BipartiteGraph implementation (based on an idea by
   Giuseppe Passino). BipartiteGraph no longer stores the node properties 
   (former _V1 and _V2), nor does it store a dense adjacency matrix anymore, 
@@ -44,7 +47,11 @@ libDAI-0.2.2 (2008-??-??)
   normtype is now Prob::NORMPROB by default.
 * VarSet is now implemented using a std::vector<Var> instead of a
   std::set<Var>, which yields a significant speed improvement.
+* Improved MaxSpanningTreePrims algorithm (uses boost::graph)
 * Small optimization in Diffs
+* Improved ClusterGraph implementation, yielding significant speedups
+  for the JunctionTree algorithm on large factorgraphs.
+* Improved documetation
 * Interface changes:
   - VarSet::
       stateSpace() -> states()
@@ -77,7 +84,6 @@ libDAI-0.2.2 (2008-??-??)
   - Factor::max() -> Factor::maxVal()
   - toc() in util.h now returns seconds as a double
   - VarSet::operator&&
-* Added possibility to build for Windows in Makefile
 
 
 libDAI-0.2.1 (2008-05-26)
index 154debc..5740a10 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -100,7 +100,7 @@ MEXFLAGS := $(MEXFLAGS) -DSMALLMEM
 endif
 endif
 
-HEADERS = $(INC)/bipgraph.h $(INC)/diffs.h $(INC)/index.h $(INC)/var.h $(INC)/factor.h $(INC)/varset.h $(INC)/prob.h $(INC)/daialg.h $(INC)/properties.h $(INC)/alldai.h $(INC)/enum.h $(INC)/x2x.h
+HEADERS = $(INC)/bipgraph.h $(INC)/diffs.h $(INC)/index.h $(INC)/var.h $(INC)/factor.h $(INC)/varset.h $(INC)/prob.h $(INC)/daialg.h $(INC)/properties.h $(INC)/alldai.h $(INC)/enum.h $(INC)/x2x.h $(INC)/exceptions.h
 
 TARGETS = tests utils $(LIB)/libdai.a example testregression doc
 ifdef WITH_MATLAB
@@ -111,8 +111,8 @@ all : $(TARGETS)
 
 matlabs : matlab/dai.$(MEXEXT) matlab/dai_readfg.$(MEXEXT) matlab/dai_writefg.$(MEXEXT) matlab/dai_removeshortloops.$(MEXEXT) matlab/dai_potstrength.$(MEXEXT)
 
-$(LIB)/libdai.a : bipgraph.o daialg.o alldai.o clustergraph.o factorgraph.o properties.o regiongraph.o util.o weightedgraph.o x2x.o $(OBJECTS)
-       ar rcs $(LIB)/libdai.a bipgraph.o daialg.o alldai.o clustergraph.o factorgraph.o properties.o regiongraph.o util.o weightedgraph.o x2x.o $(OBJECTS)
+$(LIB)/libdai.a : bipgraph.o daialg.o alldai.o clustergraph.o factorgraph.o properties.o regiongraph.o util.o weightedgraph.o x2x.o exceptions.o $(OBJECTS)
+       ar rcs $(LIB)/libdai.a bipgraph.o daialg.o alldai.o clustergraph.o factorgraph.o properties.o regiongraph.o util.o weightedgraph.o x2x.o exceptions.o $(OBJECTS)
 
 tests : tests/test
 
@@ -174,6 +174,9 @@ mr.o : $(SRC)/mr.cpp $(INC)/mr.h $(HEADERS)
 properties.o : $(SRC)/properties.cpp $(HEADERS)
        $(CC) $(CCFLAGS) -c $(SRC)/properties.cpp
 
+exceptions.o: $(SRC)/exceptions.cpp $(HEADERS)
+       $(CC) $(CCFLAGS) -c $(SRC)/exceptions.cpp
+
 alldai.o : $(SRC)/alldai.cpp $(HEADERS)
        $(CC) $(CCFLAGS) -c $(SRC)/alldai.cpp
 
@@ -218,14 +221,14 @@ matlab/matlab.o : matlab/matlab.cpp matlab/matlab.h $(HEADERS)
 # UTILS
 ########
 
-utils/createfg : utils/createfg.cpp $(HEADERS) factorgraph.o weightedgraph.o util.o bipgraph.o
-       $(CC) $(CCFLAGS) -o utils/createfg utils/createfg.cpp factorgraph.o weightedgraph.o util.o bipgraph.o $(BOOSTFLAGS)
+utils/createfg : utils/createfg.cpp $(HEADERS) factorgraph.o weightedgraph.o util.o bipgraph.o exceptions.o
+       $(CC) $(CCFLAGS) -o utils/createfg utils/createfg.cpp factorgraph.o weightedgraph.o util.o bipgraph.o exceptions.o $(BOOSTFLAGS)
 
-utils/fg2dot : utils/fg2dot.cpp $(HEADERS) factorgraph.o
-       $(CC) $(CCFLAGS) -o utils/fg2dot utils/fg2dot.cpp factorgraph.o
+utils/fg2dot : utils/fg2dot.cpp $(HEADERS) factorgraph.o exceptions.o
+       $(CC) $(CCFLAGS) -o utils/fg2dot utils/fg2dot.cpp factorgraph.o exceptions.o
 
-utils/remove_short_loops : utils/remove_short_loops.cpp $(HEADERS) factorgraph.o
-       $(CC) $(CCFLAGS) -o utils/remove_short_loops utils/remove_short_loops.cpp factorgraph.o
+utils/remove_short_loops : utils/remove_short_loops.cpp $(HEADERS) factorgraph.o exceptions.o
+       $(CC) $(CCFLAGS) -o utils/remove_short_loops utils/remove_short_loops.cpp factorgraph.o exceptions.o
 
-utils/fginfo : utils/fginfo.cpp $(HEADERS) factorgraph.o bipgraph.o
-       $(CC) $(CCFLAGS) -o utils/fginfo utils/fginfo.cpp factorgraph.o bipgraph.o
+utils/fginfo : utils/fginfo.cpp $(HEADERS) factorgraph.o bipgraph.o exceptions.o
+       $(CC) $(CCFLAGS) -o utils/fginfo utils/fginfo.cpp factorgraph.o bipgraph.o exceptions.o
index 77252af..3eecc01 100755 (executable)
@@ -108,7 +108,7 @@ MEXFLAGS = $(MEXFLAGS) /DSMALLMEM
 !ENDIF\r
 !ENDIF\r
 \r
-HEADERS = $(INC)/bipgraph.h $(INC)/diffs.h $(INC)/index.h $(INC)/var.h $(INC)/factor.h $(INC)/varset.h $(INC)/prob.h $(INC)/daialg.h $(INC)/properties.h $(INC)/alldai.h $(INC)/enum.h $(INC)/x2x.h\r
+HEADERS = $(INC)/bipgraph.h $(INC)/diffs.h $(INC)/index.h $(INC)/var.h $(INC)/factor.h $(INC)/varset.h $(INC)/prob.h $(INC)/daialg.h $(INC)/properties.h $(INC)/alldai.h $(INC)/enum.h $(INC)/x2x.h $(INC)/exceptions.h\r
 \r
 TARGETS = tests utils $(LIB)/libdai.lib example.exe\r
 # testregression disabled, it uses sh and awk\r
@@ -120,8 +120,8 @@ all : $(TARGETS)
 \r
 matlabs : matlab/dai.$(MEXEXT) matlab/dai_readfg.$(MEXEXT) matlab/dai_writefg.$(MEXEXT) matlab/dai_removeshortloops.$(MEXEXT) matlab/dai_potstrength.$(MEXEXT)\r
 \r
-$(LIB)/libdai.lib : bipgraph.obj daialg.obj alldai.obj clustergraph.obj factorgraph.obj properties.obj regiongraph.obj util.obj weightedgraph.obj x2x.obj $(OBJECTS)\r
-       lib /out:$(LIB)/libdai.lib bipgraph.obj daialg.obj alldai.obj clustergraph.obj factorgraph.obj properties.obj regiongraph.obj util.obj weightedgraph.obj x2x.obj $(OBJECTS)\r
+$(LIB)/libdai.lib : bipgraph.obj daialg.obj alldai.obj clustergraph.obj factorgraph.obj properties.obj regiongraph.obj util.obj weightedgraph.obj x2x.obj exceptions.obj $(OBJECTS)\r
+       lib /out:$(LIB)/libdai.lib bipgraph.obj daialg.obj alldai.obj clustergraph.obj factorgraph.obj properties.obj regiongraph.obj util.obj weightedgraph.obj x2x.obj exceptions.obj $(OBJECTS)\r
 \r
 tests : tests/test.exe\r
 \r
@@ -183,6 +183,9 @@ mr.obj : $(SRC)/mr.cpp $(INC)/mr.h $(HEADERS)
 properties.obj : $(SRC)/properties.cpp $(HEADERS)\r
        $(CC) $(CCFLAGS) -c $(SRC)/properties.cpp\r
 \r
+exceptions.obj : $(SRC)/exceptions.cpp $(HEADERS)\r
+       $(CC) $(CCFLAGS) -c $(SRC)/exceptions.cpp\r
+\r
 alldai.obj : $(SRC)/alldai.cpp $(HEADERS)\r
        $(CC) $(CCFLAGS) -c $(SRC)/alldai.cpp\r
 \r
@@ -229,14 +232,14 @@ matlab/matlab.obj : matlab/matlab.cpp matlab/matlab.h $(HEADERS)
 # UTILS\r
 ########\r
 \r
-utils/createfg.exe : utils/createfg.cpp $(HEADERS) factorgraph.obj weightedgraph.obj util.obj bipgraph.obj\r
-       $(CC) $(CCFLAGS) /Feutils/createfg utils/createfg.cpp factorgraph.obj weightedgraph.obj util.obj bipgraph.obj /link $(LIBS) $(BOOSTLIBS)\r
+utils/createfg.exe : utils/createfg.cpp $(HEADERS) factorgraph.obj weightedgraph.obj util.obj bipgraph.obj exceptions.obj\r
+       $(CC) $(CCFLAGS) /Feutils/createfg utils/createfg.cpp factorgraph.obj weightedgraph.obj util.obj bipgraph.obj exceptions.obj /link $(LIBS) $(BOOSTLIBS)\r
 \r
-utils/fg2dot.exe : utils/fg2dot.cpp $(HEADERS) factorgraph.obj\r
-       $(CC) $(CCFLAGS) /Feutils/fg2dot utils/fg2dot.cpp factorgraph.obj /link $(LIBS)\r
+utils/fg2dot.exe : utils/fg2dot.cpp $(HEADERS) factorgraph.obj exceptions.obj\r
+       $(CC) $(CCFLAGS) /Feutils/fg2dot utils/fg2dot.cpp factorgraph.obj exceptions.obj /link $(LIBS)\r
 \r
-utils/remove_short_loops.exe : utils/remove_short_loops.cpp $(HEADERS) factorgraph.obj\r
-       $(CC) $(CCFLAGS) /Feutils/remove_short_loops utils/remove_short_loops.cpp factorgraph.obj /link $(LIBS)\r
+utils/remove_short_loops.exe : utils/remove_short_loops.cpp $(HEADERS) factorgraph.obj exceptions.obj\r
+       $(CC) $(CCFLAGS) /Feutils/remove_short_loops utils/remove_short_loops.cpp factorgraph.obj exceptions.obj /link $(LIBS)\r
 \r
-utils/fginfo.exe : utils/fginfo.cpp $(HEADERS) factorgraph.obj bipgraph.obj\r
-       $(CC) $(CCFLAGS) /Feutils/fginfo utils/fginfo.cpp factorgraph.obj bipgraph.obj /link $(LIBS)\r
+utils/fginfo.exe : utils/fginfo.cpp $(HEADERS) factorgraph.obj bipgraph.obj exceptions.obj\r
+       $(CC) $(CCFLAGS) /Feutils/fginfo utils/fginfo.cpp factorgraph.obj bipgraph.obj exceptions.obj /link $(LIBS)\r
diff --git a/STATUS b/STATUS
index f34afcc..1f17959 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -18,28 +18,12 @@ A disadvantage of this approach may be worse cachability.
 - Can the FactorGraph constructors be optimized further?
 - Move FactorGraph::_normType somewhere else (maybe to InfAlg or DAIAlg<T>)
 - Remove updatedFactor
-- Add Exceptions framework; this can e.g. be used as follows: if *.logZ() is
-called, it can return an exception if this method is not implemented, and the
-caller can catch this exception and handle it correctly. Then, you don't need
-a hasLogZ function/constant that tells whether this functionality is available.
-- Add an option to tests/test that it doesn't report the time needed; this is
-useful for the regression testing.
-
-DONE IN PREVIOUS COMMITS:
-- Added a few methods to BipartiteGraph
-- Improved ClusterGraph implementation (taken from SVN head)
-- Improved MaxSpanningTree algorithm (using boost::graph library, taken from SVN head)
-- Updated doxygen.conf
-- Made compatible with Visual C++
-- Merged improved index.h from svn
-- Rename stateSpace -> states
-- Optimized Diffs
-- Renamed Regenerate() -> create() 
 
 TODO FOR RELEASE:
 - Test Visual C++ compatibility
 - Figure out which libraries are required and document in README
-  boost headers, boost::program_options library
+  boost headers, boost::program_options library, boost::graph library,
+  boost::math library (under Windows)
 
 FILES IN SVN HEAD THAT ARE NO LONGER RELEVANT FOR GIT MASTER
 diffs.h
@@ -53,3 +37,5 @@ clustergraph.cpp
 varset.h
 var.h
 utils/createfg.cpp
+exceptions.h
+exceptions.cpp
index f2618f7..bc1ccb8 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <cstring>
 #include <iostream>
+#include <dai/exceptions.h>
 
 
 namespace dai {
@@ -53,7 +54,7 @@ namespace dai {
                    break;\
                }\
            if( i == sizeof(labels) / sizeof(char const *) )\
-               throw "Unknown " #x " value";\
+               DAI_THROW(UNKNOWN_ENUM_VALUE);\
         }\
 \
         operator value () const { return v; }\
@@ -99,7 +100,7 @@ namespace dai {
                    break;\
                }\
            if( i == sizeof(labels) / sizeof(char const *) )\
-               throw "Unknown " #x " value";\
+               DAI_THROW(UNKNOWN_ENUM_VALUE);\
         }\
 \
         operator value () const { return v; }\
@@ -145,7 +146,7 @@ namespace dai {
                    break;\
                }\
            if( i == sizeof(labels) / sizeof(char const *) )\
-               throw "Unknown " #x " value";\
+               DAI_THROW(UNKNOWN_ENUM_VALUE);\
         }\
 \
         operator value () const { return v; }\
@@ -191,7 +192,7 @@ namespace dai {
                    break;\
                }\
            if( i == sizeof(labels) / sizeof(char const *) )\
-               throw "Unknown " #x " value";\
+               DAI_THROW(UNKNOWN_ENUM_VALUE);\
         }\
 \
         operator value () const { return v; }\
@@ -237,7 +238,7 @@ namespace dai {
                    break;\
                }\
            if( i == sizeof(labels) / sizeof(char const *) )\
-               throw "Unknown " #x " value";\
+               DAI_THROW(UNKNOWN_ENUM_VALUE);\
         }\
 \
         operator value () const { return v; }\
diff --git a/include/dai/exceptions.h b/include/dai/exceptions.h
new file mode 100644 (file)
index 0000000..2a5e8f4
--- /dev/null
@@ -0,0 +1,66 @@
+/*  Copyright (C) 2006-2008  Joris Mooij  [j dot mooij at science dot ru dot nl]
+    Radboud University Nijmegen, The Netherlands
+    
+    This file is part of libDAI.
+
+    libDAI is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    libDAI is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with libDAI; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+
+#ifndef __defined_libdai_exceptions_h
+#define __defined_libdai_exceptions_h
+
+
+#include <exception>
+#include <stdexcept>
+#include <string>
+
+
+#define DAI_QUOTE(x) #x
+#define DAI_TOSTRING(x) DAI_QUOTE(x)
+
+#define DAI_THROW(cod) throw dai::Exception(dai::Exception::cod, std::string(__FILE__ ", line " DAI_TOSTRING(__LINE__)))
+
+
+namespace dai {
+
+
+    class Exception : public std::runtime_error {
+        public:
+            Exception(size_t code, const std::string& msg = "") : std::runtime_error(ErrorStrings[code] + " [" +  msg + "]") {}
+
+        enum {NOT_IMPLEMENTED,
+              UNKNOWN_DAI_ALGORITHM,
+              UNKNOWN_PROPERTY_TYPE,
+              MALFORMED_PROPERTY,
+              UNKNOWN_ENUM_VALUE,
+              CANNOT_READ_FILE,
+              CANNOT_WRITE_FILE,
+              INVALID_FACTORGRAPH_FILE,
+              NOT_ALL_PROPERTIES_SPECIFIED,
+              MULTIPLE_UNDO,
+              FACTORGRAPH_NOT_CONNECTED,
+              INTERNAL_ERROR,
+              NUM_ERRORS};  // NUM_ERRORS should be the last entry
+
+        private:
+            static std::string ErrorStrings[NUM_ERRORS];
+    };
+
+
+}
+
+
+#endif
index 2de05f5..fbfaf9a 100644 (file)
@@ -27,6 +27,7 @@
 #include <dai/daialg.h>
 #include <dai/enum.h>
 #include <dai/factorgraph.h>
+#include <dai/exceptions.h>
 
 
 namespace dai {
@@ -81,18 +82,32 @@ class LC : public DAIAlgFG {
 
         std::string identify() const;
         Factor belief (const Var &n) const { return( _beliefs[findVar(n)] ); }
-        Factor belief (const VarSet &/*ns*/) const { assert( 0 == 1 ); return Factor(); }
+        Factor belief (const VarSet &/*ns*/) const { 
+            DAI_THROW(NOT_IMPLEMENTED);
+            return Factor(); 
+        }
         std::vector<Factor> beliefs() const { return _beliefs; }
-        Complex logZ() const { /*assert( 0 == 1 );*/ return 0.0; }
+        Complex logZ() const { 
+            DAI_THROW(NOT_IMPLEMENTED);
+            return 0.0; 
+        }
         void CalcBelief (size_t i);
         const Factor & belief (size_t i) const { return _beliefs[i]; };
         const Factor & pancake (size_t i) const { return _pancakes[i]; };
         const Factor & cavitydist (size_t i) const { return _cavitydists[i]; };
 
-        void clamp( const Var &/*n*/, size_t /*i*/ ) { assert( 0 == 1 ); }
-        void undoProbs( const VarSet &/*ns*/ ) { assert( 0 == 1 ); }
-        void saveProbs( const VarSet &/*ns*/ ) { assert( 0 == 1 ); }
-        virtual void makeCavity(const Var & /*n*/) { assert( 0 == 1 ); }
+        void clamp( const Var &/*n*/, size_t /*i*/ ) { 
+            DAI_THROW(NOT_IMPLEMENTED);
+        }
+        void undoProbs( const VarSet &/*ns*/ ) { 
+            DAI_THROW(NOT_IMPLEMENTED);
+        }
+        void saveProbs( const VarSet &/*ns*/ ) { 
+            DAI_THROW(NOT_IMPLEMENTED);
+        }
+        virtual void makeCavity(const Var & /*n*/) { 
+            DAI_THROW(NOT_IMPLEMENTED);
+        }
         bool checkProperties();
 };
 
index d786527..ef7b6b0 100644 (file)
@@ -28,6 +28,7 @@
 #include <dai/factorgraph.h>
 #include <dai/daialg.h>
 #include <dai/enum.h>
+#include <dai/exceptions.h>
 
 
 namespace dai {
@@ -71,9 +72,15 @@ class MR : public DAIAlgFG {
         void solveM();
         double run();
         Factor belief( const Var &n ) const;
-        Factor belief( const VarSet &/*ns*/ ) const { assert( 0 == 1 ); return Factor(); }
+        Factor belief( const VarSet &/*ns*/ ) const { 
+            DAI_THROW(NOT_IMPLEMENTED);
+            return Factor(); 
+        }
         std::vector<Factor> beliefs() const;
-        Complex logZ() const { /*assert( 0 == 1 );*/ return 0.0; }
+        Complex logZ() const { 
+            DAI_THROW(NOT_IMPLEMENTED);
+            return 0.0; 
+        }
         void init() { assert( checkProperties() ); }
         static const char *Name;
         std::string identify() const;
index 8b5f6ef..d11cda1 100644 (file)
@@ -233,9 +233,6 @@ template <typename T> class TProb {
             assert( size() == q.size() );
 #endif
             for( size_t i = 0; i < size(); i++ ) {
-#ifdef DAI_DEBUG
-//              assert( q[i] != 0.0 );
-#endif
                 if( q[i] == 0.0 )
                     _p[i] = 0.0;
                 else
index b8b8b24..40e0343 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <string>
 #include <dai/alldai.h>
+#include <dai/exceptions.h>
 
 
 namespace dai {
@@ -59,7 +60,7 @@ InfAlg *newInfAlg( const string &name, const FactorGraph &fg, const Properties &
         return new MR (fg, opts);
 #endif
     else
-        throw "Unknown inference algorithm";
+        DAI_THROW(UNKNOWN_DAI_ALGORITHM);
 }
 
 
diff --git a/src/exceptions.cpp b/src/exceptions.cpp
new file mode 100644 (file)
index 0000000..6f8f787
--- /dev/null
@@ -0,0 +1,44 @@
+/*  Copyright (C) 2006-2008  Joris Mooij  [j dot mooij at science dot ru dot nl]
+    Radboud University Nijmegen, The Netherlands
+    
+    This file is part of libDAI.
+
+    libDAI is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    libDAI is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with libDAI; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+
+#include <dai/exceptions.h>
+
+
+namespace dai {
+
+
+    std::string Exception::ErrorStrings[NUM_ERRORS] = {
+        "This feature is not implemented",
+        "Unknown DAI algorithm",
+        "Unknown Property type",
+        "Malformed Property",
+        "Unknown ENUM value",
+        "Cannot read file",
+        "Cannot write file",
+        "Invalid FactorGraph file",
+        "Not all mandatory Properties specified",
+        "Multiple undo levels unsupported",
+        "FactorGraph is not connected",
+        "Internal error"
+    }; 
+
+
+}
index 38a6b5a..9c0f0ae 100644 (file)
@@ -29,6 +29,7 @@
 #include <functional>
 #include <dai/factorgraph.h>
 #include <dai/util.h>
+#include <dai/exceptions.h>
 
 
 namespace dai {
@@ -121,13 +122,13 @@ istream& operator >> (istream& is, FactorGraph& fg) {
             getline(is,line);
         is >> nr_f;
         if( is.fail() )
-            throw "ReadFromFile: unable to read number of Factors";
+            DAI_THROW(INVALID_FACTORGRAPH_FILE);
         if( verbose >= 2 )
             cout << "Reading " << nr_f << " factors..." << endl;
 
         getline (is,line);
         if( is.fail() )
-            throw "ReadFromFile: empty line expected";
+            DAI_THROW(INVALID_FACTORGRAPH_FILE);
 
         for( size_t I = 0; I < nr_f; I++ ) {
             if( verbose >= 3 )
index 094d3fa..5a5a19b 100644 (file)
@@ -23,6 +23,7 @@
 #include <dai/hak.h>
 #include <dai/util.h>
 #include <dai/diffs.h>
+#include <dai/exceptions.h>
 
 
 namespace dai {
@@ -136,7 +137,7 @@ HAK::HAK(const FactorGraph & fg, const Properties &opts) : DAIAlgRG(opts) {
                 cout << *cli << endl;
         }
     } else
-        throw "Invalid Clusters type";
+        DAI_THROW(INTERNAL_ERROR);
 
     RegionGraph rg(fg,cl);
     RegionGraph::operator=(rg);
@@ -229,7 +230,7 @@ double HAK::doGBP() {
             Qb_new.normalize( _normtype );
             if( Qb_new.hasNaNs() ) {
                 cout << "HAK::doGBP:  Qb_new has NaNs!" << endl;
-                return NAN;
+                return 1.0;
             }
 //          _Qb[beta] = Qb_new.makeZero(1e-100);    // damping?
             _Qb[beta] = Qb_new;
@@ -246,7 +247,7 @@ double HAK::doGBP() {
                 Qa_new.normalize( _normtype );
                 if( Qa_new.hasNaNs() ) {
                     cout << "HAK::doGBP:  Qa_new has NaNs!" << endl;
-                    return NAN;
+                    return 1.0;
                 }
 //              _Qa[alpha] = Qa_new.makeZero(1e-100); // damping?
                 _Qa[alpha] = Qa_new;
@@ -330,7 +331,7 @@ double HAK::doDoubleLoop() {
 
         // Inner loop
         if( isnan( doGBP() ) )
-            return NAN;
+            return 1.0;
 
         // Calculate new single variable beliefs and compare with old ones
         for( size_t i = 0; i < nrVars(); ++i ) {
index 1ffc360..5587a3e 100644 (file)
@@ -111,7 +111,7 @@ double MF::run() {
 
         if( jan.hasNaNs() ) {
             cout << "MF::run():  ERROR: jan has NaNs!" << endl;
-            return NAN;
+            return 1.0;
         }
 
         diffs.push( dist( jan, _beliefs[i], Prob::DISTLINF ) );
index 49860fd..b259914 100644 (file)
@@ -22,6 +22,7 @@
 #include <iostream>
 #include <dai/properties.h>
 #include <dai/alldai.h>
+#include <dai/exceptions.h>
 
 
 namespace dai {
@@ -69,7 +70,7 @@ std::ostream& operator<< (std::ostream & os, const Property & p) {
         os << boost::any_cast<LC::UpdateType>(p.second);
 #endif
     else
-        throw "Unknown property type";
+        DAI_THROW(UNKNOWN_PROPERTY_TYPE);
     return( os );
 }
 
@@ -96,7 +97,7 @@ std::istream& operator >> (std::istream& is, Properties & ps) {
 
     // Check whether s is of the form "[.*]"
     if( (s.length() < 2) || (s.at(0) != '[') || (s.at(s.length()-1)) != ']' )
-        throw "Malformed property";
+        DAI_THROW(MALFORMED_PROPERTY);
 
     size_t N = s.length() - 1;
     for( size_t token_start = 1; token_start < N; ) {
@@ -107,7 +108,7 @@ std::istream& operator >> (std::istream& is, Properties & ps) {
             if( s[token_end] == '=' )
                 break;
         if( token_end == N )
-            throw "Malformed property key";
+            DAI_THROW(MALFORMED_PROPERTY);
         // we found a key
         std::string key = s.substr(token_start, token_end - token_start);
 
@@ -123,7 +124,7 @@ std::istream& operator >> (std::istream& is, Properties & ps) {
                 break;
         }
         if( !(level == 0) )
-            throw "Malformed property value";
+            DAI_THROW(MALFORMED_PROPERTY);
         // we found a vlue
         std::string value = s.substr(token_start, token_end - token_start);
 
index d5c4614..1fee924 100644 (file)
@@ -247,7 +247,7 @@ TreeEP::TreeEP( const FactorGraph &fg, const Properties &opts ) : JTree(fg, opts
             // find maximal spanning tree
             ConstructRG( MaxSpanningTreePrims( wg ) );
         } else {
-            assert( 0 == 1 );
+            DAI_THROW(INTERNAL_ERROR);
         }
     }
 }
index 2ac19e4..eb96814 100644 (file)
@@ -47,8 +47,9 @@ class TestAI {
         double          logZ;
         double          maxdiff;
         double          time;
+        bool            has_logZ;
 
-        TestAI( const FactorGraph &fg, const string &_name, const Properties &opts ) : obj(NULL), name(_name), err(), q(), logZ(0.0), maxdiff(0.0), time(0) {
+        TestAI( const FactorGraph &fg, const string &_name, const Properties &opts ) : obj(NULL), name(_name), err(), q(), logZ(0.0), maxdiff(0.0), time(0), has_logZ(true) {
             double tic = toc();
             obj = newInfAlg( name, fg, opts );
             time += toc() - tic;
@@ -105,7 +106,12 @@ class TestAI {
                 obj->init();
                 obj->run();
                 time += toc() - tic;
-                logZ = real(obj->logZ());
+                try {
+                    logZ = real(obj->logZ());
+                    has_logZ = true;
+                } catch( Exception &e ) {
+                    has_logZ = false;
+                }
                 maxdiff = obj->MaxDiff();
                 q = allBeliefs();
             };
@@ -179,6 +185,7 @@ int main( int argc, char *argv[] ) {
         double tol;
         size_t maxiter;
         size_t verbose;
+        bool report_time = true;
 
         po::options_description opts_required("Required options");
         opts_required.add_options()
@@ -193,6 +200,7 @@ int main( int argc, char *argv[] ) {
             ("tol", po::value< double >(&tol), "Override tolerance")
             ("maxiter", po::value< size_t >(&maxiter), "Override maximum number of iterations")
             ("verbose", po::value< size_t >(&verbose), "Override verbosity")
+            ("report-time", po::value< bool >(&report_time), "Report calculation time")
         ;
 
         po::options_description cmdline_options;
@@ -204,7 +212,7 @@ int main( int argc, char *argv[] ) {
 
         if( vm.count("help") || !(vm.count("filename") && vm.count("methods")) ) {
             cout << "Reads factorgraph <filename.fg> and performs the approximate" << endl;
-            cout << "inference algorithms <method*>, reporting clocks, max and average" << endl;
+            cout << "inference algorithms <method*>, reporting calculation time, max and average" << endl;
             cout << "error and relative logZ error (comparing with the results of" << endl;
             cout << "<method0>, the base method, for which one can use JTREE_HUGIN)." << endl << endl;
             cout << opts_required << opts_optional << endl;
@@ -251,8 +259,10 @@ int main( int argc, char *argv[] ) {
             cout << "# " << filename << endl;
             cout.width( 40 );
             cout << left << "# METHOD" << "  ";
-            cout.width( 10 );
-            cout << right << "SECONDS" << "   ";
+            if( report_time ) {
+                cout.width( 10 );
+                cout << right << "SECONDS" << "   ";
+            }
             cout.width( 10 );
             cout << "MAX ERROR" << "  ";
             cout.width( 10 );
@@ -282,8 +292,10 @@ int main( int argc, char *argv[] ) {
                 cout.width( 40 );
 //                cout << left << piet.identify() << "  ";
                 cout << left << methods[m] << "  ";
-                cout.width( 10 );
-                cout << right << piet.time << "    ";
+                if( report_time ) {
+                    cout.width( 10 );
+                    cout << right << piet.time << "    ";
+                }
 
                 if( m > 0 ) {
                     cout.setf( ios_base::scientific );
@@ -295,8 +307,12 @@ int main( int argc, char *argv[] ) {
                     double ae = clipdouble( piet.avgErr(), 1e-9 );
                     cout << ae << "  ";
                     cout.width( 10 );
-                    double le = clipdouble( piet.logZ / logZ0 - 1.0, 1e-9 );
-                    cout << le << "  ";
+                    if( piet.has_logZ ) {
+                        double le = clipdouble( piet.logZ / logZ0 - 1.0, 1e-9 );
+                        cout << le << "  ";
+                    } else {
+                        cout << "N/A         ";
+                    }
                     cout.width( 10 );
                     double md = clipdouble( piet.maxdiff, 1e-9 );
                     if( isnan( me ) )
index 2cf6099..aecb684 100755 (executable)
@@ -1,2 +1,2 @@
 #!/bin/bash
-./test --aliases aliases.conf --filename $1 --methods JTREE_HUGIN JTREE_SHSH BP_SEQFIX BP_SEQRND BP_SEQMAX BP_PARALL BP_SEQFIX_LOG BP_SEQRND_LOG BP_SEQMAX_LOG BP_PARALL_LOG MF_SEQRND TREEEP TREEEPWC GBP_MIN GBP_DELTA GBP_LOOP3 GBP_LOOP4 HAK_MIN HAK_DELTA HAK_LOOP3 HAK_LOOP4 MR_RESPPROP_FULL MR_CLAMPING_FULL MR_EXACT_FULL MR_RESPPROP_LINEAR MR_CLAMPING_LINEAR MR_EXACT_LINEAR LCBP_FULLCAV_SEQFIX LCBP_FULLCAVin_SEQFIX LCBP_FULLCAV_SEQRND LCBP_FULLCAVin_SEQRND LCBP_FULLCAV_NONE LCBP_FULLCAVin_NONE LCBP_PAIRCAV_SEQFIX LCBP_PAIRCAVin_SEQFIX LCBP_PAIRCAV_SEQRND LCBP_PAIRCAVin_SEQRND LCBP_PAIRCAV_NONE LCBP_PAIRCAVin_NONE LCBP_UNICAV_SEQFIX LCBP_UNICAV_SEQRND
+./test --report-time false --aliases aliases.conf --filename $1 --methods JTREE_HUGIN JTREE_SHSH BP_SEQFIX BP_SEQRND BP_SEQMAX BP_PARALL BP_SEQFIX_LOG BP_SEQRND_LOG BP_SEQMAX_LOG BP_PARALL_LOG MF_SEQRND TREEEP TREEEPWC GBP_MIN GBP_DELTA GBP_LOOP3 GBP_LOOP4 HAK_MIN HAK_DELTA HAK_LOOP3 HAK_LOOP4 MR_RESPPROP_FULL MR_CLAMPING_FULL MR_EXACT_FULL MR_RESPPROP_LINEAR MR_CLAMPING_LINEAR MR_EXACT_LINEAR LCBP_FULLCAV_SEQFIX LCBP_FULLCAVin_SEQFIX LCBP_FULLCAV_SEQRND LCBP_FULLCAVin_SEQRND LCBP_FULLCAV_NONE LCBP_FULLCAVin_NONE LCBP_PAIRCAV_SEQFIX LCBP_PAIRCAVin_SEQFIX LCBP_PAIRCAV_SEQRND LCBP_PAIRCAVin_SEQRND LCBP_PAIRCAV_NONE LCBP_PAIRCAVin_NONE LCBP_UNICAV_SEQFIX LCBP_UNICAV_SEQRND
index 0241a04..dc568a9 100755 (executable)
@@ -1 +1 @@
-test --aliases aliases.conf --filename %1 --methods JTREE_HUGIN JTREE_SHSH BP_SEQFIX BP_SEQRND BP_SEQMAX BP_PARALL BP_SEQFIX_LOG BP_SEQRND_LOG BP_SEQMAX_LOG BP_PARALL_LOG MF_SEQRND TREEEP TREEEPWC GBP_MIN GBP_DELTA GBP_LOOP3 GBP_LOOP4 HAK_MIN HAK_DELTA HAK_LOOP3 HAK_LOOP4 MR_RESPPROP_FULL MR_CLAMPING_FULL MR_EXACT_FULL MR_RESPPROP_LINEAR MR_CLAMPING_LINEAR MR_EXACT_LINEAR LCBP_FULLCAV_SEQFIX LCBP_FULLCAVin_SEQFIX LCBP_FULLCAV_SEQRND LCBP_FULLCAVin_SEQRND LCBP_FULLCAV_NONE LCBP_FULLCAVin_NONE LCBP_PAIRCAV_SEQFIX LCBP_PAIRCAVin_SEQFIX LCBP_PAIRCAV_SEQRND LCBP_PAIRCAVin_SEQRND LCBP_PAIRCAV_NONE LCBP_PAIRCAVin_NONE LCBP_UNICAV_SEQFIX LCBP_UNICAV_SEQRND
+test --report-time false --aliases aliases.conf --filename %1 --methods JTREE_HUGIN JTREE_SHSH BP_SEQFIX BP_SEQRND BP_SEQMAX BP_PARALL BP_SEQFIX_LOG BP_SEQRND_LOG BP_SEQMAX_LOG BP_PARALL_LOG MF_SEQRND TREEEP TREEEPWC GBP_MIN GBP_DELTA GBP_LOOP3 GBP_LOOP4 HAK_MIN HAK_DELTA HAK_LOOP3 HAK_LOOP4 MR_RESPPROP_FULL MR_CLAMPING_FULL MR_EXACT_FULL MR_RESPPROP_LINEAR MR_CLAMPING_LINEAR MR_EXACT_LINEAR LCBP_FULLCAV_SEQFIX LCBP_FULLCAVin_SEQFIX LCBP_FULLCAV_SEQRND LCBP_FULLCAVin_SEQRND LCBP_FULLCAV_NONE LCBP_FULLCAVin_NONE LCBP_PAIRCAV_SEQFIX LCBP_PAIRCAVin_SEQFIX LCBP_PAIRCAV_SEQRND LCBP_PAIRCAVin_SEQRND LCBP_PAIRCAV_NONE LCBP_PAIRCAVin_NONE LCBP_UNICAV_SEQFIX LCBP_UNICAV_SEQRND
index ac36f23..ff7e880 100644 (file)
@@ -1,43 +1,43 @@
 # testfast.fg
-# METHOD                                      CLOCKS     MAX ERROR   AVG ERROR  LOGZ ERROR     MAXDIFF
-JTREE_HUGIN                                        2    
-JTREE_SHSH                                         2     1.000e-09   1.000e-09   1.000e-09   1.000e-09
-BP_SEQFIX                                          1     9.483e-02   3.078e-02   1.737e-02   1.000e-09
-BP_SEQRND                                          1     9.483e-02   3.078e-02   1.737e-02   1.000e-09
-BP_SEQMAX                                          0     9.483e-02   3.078e-02   1.737e-02   1.000e-09
-BP_PARALL                                          1     9.483e-02   3.078e-02   1.737e-02   1.000e-09
-BP_SEQFIX_LOG                                      1     9.483e-02   3.078e-02   1.737e-02   1.000e-09
-BP_SEQRND_LOG                                      0     9.483e-02   3.078e-02   1.737e-02   1.000e-09
-BP_SEQMAX_LOG                                      1     9.483e-02   3.078e-02   1.737e-02   1.000e-09
-BP_PARALL_LOG                                      1     9.483e-02   3.078e-02   1.737e-02   1.000e-09
-MF_SEQRND                                          3     3.607e-01   1.904e-01  -9.409e-02   1.000e-09
-TREEEP                                             5     3.268e-02   8.023e-03   6.340e-04   1.000e-09
-TREEEPWC                                           4     2.356e-02   1.026e-02   4.876e-03   1.000e-09
-GBP_MIN                                            2     9.483e-02   3.078e-02   1.737e-02   1.000e-09
-GBP_DELTA                                          8     6.291e-01   3.350e-01  -3.303e-01   1.000e-09
-GBP_LOOP3                                          2     9.483e-02   3.078e-02   1.737e-02   1.000e-09
-GBP_LOOP4                                          6     7.893e-01   3.569e-01  -3.781e-01   1.000e-09
-HAK_MIN                                           27     9.483e-02   3.078e-02   1.737e-02   1.000e-09
-HAK_DELTA                                        394     3.684e-01   1.892e-01   9.675e-01   1.000e-09
-HAK_LOOP3                                         27     9.483e-02   3.078e-02   1.737e-02   1.000e-09
-HAK_LOOP4                                        726     4.970e-03   1.486e-03  -2.503e-04   1.000e-09
-MR_RESPPROP_FULL                                  36     1.676e-02   4.933e-03         nan   1.000e-09
-MR_CLAMPING_FULL                                  22     8.359e-03   2.508e-03         nan   1.000e-09
-MR_EXACT_FULL                                     20     3.527e-03   1.038e-03         nan   1.000e-09
-MR_RESPPROP_LINEAR                                37     1.932e-02   5.506e-03         nan   1.000e-09
-MR_CLAMPING_LINEAR                                21     1.089e-02   3.076e-03         nan   1.000e-09
-MR_EXACT_LINEAR                                   20     5.617e-03   1.742e-03         nan   1.000e-09
-LCBP_FULLCAV_SEQFIX                               31     1.225e-03   5.589e-04         nan   1.000e-09
-LCBP_FULLCAVin_SEQFIX                             33     1.225e-03   5.589e-04         nan   1.000e-09
-LCBP_FULLCAV_SEQRND                               30     1.225e-03   5.589e-04         nan   1.000e-09
-LCBP_FULLCAVin_SEQRND                             33     1.225e-03   5.589e-04         nan   1.000e-09
-LCBP_FULLCAV_NONE                                 25     1.318e-02   2.644e-03         nan   1.000e+00
-LCBP_FULLCAVin_NONE                               26     1.318e-02   2.644e-03         nan   1.000e+00
-LCBP_PAIRCAV_SEQFIX                               27     1.564e-02   5.284e-03         nan   1.000e-09
-LCBP_PAIRCAVin_SEQFIX                             27     1.564e-02   5.284e-03         nan   1.000e-09
-LCBP_PAIRCAV_SEQRND                               25     1.564e-02   5.284e-03         nan   1.000e-09
-LCBP_PAIRCAVin_SEQRND                             26     1.564e-02   5.284e-03         nan   1.000e-09
-LCBP_PAIRCAV_NONE                                 19     1.869e-01   6.816e-02         nan   1.000e+00
-LCBP_PAIRCAVin_NONE                               20     1.869e-01   6.816e-02         nan   1.000e+00
-LCBP_UNICAV_SEQFIX                                 6     9.483e-02   3.078e-02         nan   1.000e-09
-LCBP_UNICAV_SEQRND                                 8     9.483e-02   3.078e-02         nan   1.000e-09
+# METHOD                                  MAX ERROR   AVG ERROR   LOGZ ERROR  MAXDIFF   
+JTREE_HUGIN                               
+JTREE_SHSH                                1.000e-09   1.000e-09   1.000e-09   1.000e-09 
+BP_SEQFIX                                 9.483e-02   3.078e-02   1.737e-02   1.000e-09 
+BP_SEQRND                                 9.483e-02   3.078e-02   1.737e-02   1.000e-09 
+BP_SEQMAX                                 9.483e-02   3.078e-02   1.737e-02   1.000e-09 
+BP_PARALL                                 9.483e-02   3.078e-02   1.737e-02   1.000e-09 
+BP_SEQFIX_LOG                             9.483e-02   3.078e-02   1.737e-02   1.000e-09 
+BP_SEQRND_LOG                             9.483e-02   3.078e-02   1.737e-02   1.000e-09 
+BP_SEQMAX_LOG                             9.483e-02   3.078e-02   1.737e-02   1.000e-09 
+BP_PARALL_LOG                             9.483e-02   3.078e-02   1.737e-02   1.000e-09 
+MF_SEQRND                                 3.607e-01   1.904e-01   -9.409e-02  1.000e-09 
+TREEEP                                    3.268e-02   8.023e-03   6.340e-04   1.000e-09 
+TREEEPWC                                  2.356e-02   1.026e-02   4.876e-03   1.000e-09 
+GBP_MIN                                   9.483e-02   3.078e-02   1.737e-02   1.000e-09 
+GBP_DELTA                                 6.291e-01   3.350e-01   -3.303e-01  1.000e-09 
+GBP_LOOP3                                 9.483e-02   3.078e-02   1.737e-02   1.000e-09 
+GBP_LOOP4                                 7.893e-01   3.569e-01   -3.781e-01  1.000e-09 
+HAK_MIN                                   9.483e-02   3.078e-02   1.737e-02   1.000e-09 
+HAK_DELTA                                 3.684e-01   1.892e-01   9.675e-01   1.000e-09 
+HAK_LOOP3                                 9.483e-02   3.078e-02   1.737e-02   1.000e-09 
+HAK_LOOP4                                 4.970e-03   1.486e-03   -2.503e-04  1.000e-09 
+MR_RESPPROP_FULL                          1.676e-02   4.933e-03   N/A         1.000e-09 
+MR_CLAMPING_FULL                          8.359e-03   2.508e-03   N/A         1.000e-09 
+MR_EXACT_FULL                             3.527e-03   1.038e-03   N/A         1.000e-09 
+MR_RESPPROP_LINEAR                        1.932e-02   5.506e-03   N/A         1.000e-09 
+MR_CLAMPING_LINEAR                        1.089e-02   3.076e-03   N/A         1.000e-09 
+MR_EXACT_LINEAR                           5.617e-03   1.742e-03   N/A         1.000e-09 
+LCBP_FULLCAV_SEQFIX                       1.225e-03   5.589e-04   N/A         1.000e-09 
+LCBP_FULLCAVin_SEQFIX                     1.225e-03   5.589e-04   N/A         1.000e-09 
+LCBP_FULLCAV_SEQRND                       1.225e-03   5.589e-04   N/A         1.000e-09 
+LCBP_FULLCAVin_SEQRND                     1.225e-03   5.589e-04   N/A         1.000e-09 
+LCBP_FULLCAV_NONE                         1.318e-02   2.644e-03   N/A         1.000e+00 
+LCBP_FULLCAVin_NONE                       1.318e-02   2.644e-03   N/A         1.000e+00 
+LCBP_PAIRCAV_SEQFIX                       1.564e-02   5.284e-03   N/A         1.000e-09 
+LCBP_PAIRCAVin_SEQFIX                     1.564e-02   5.284e-03   N/A         1.000e-09 
+LCBP_PAIRCAV_SEQRND                       1.564e-02   5.284e-03   N/A         1.000e-09 
+LCBP_PAIRCAVin_SEQRND                     1.564e-02   5.284e-03   N/A         1.000e-09 
+LCBP_PAIRCAV_NONE                         1.869e-01   6.816e-02   N/A         1.000e+00 
+LCBP_PAIRCAVin_NONE                       1.869e-01   6.816e-02   N/A         1.000e+00 
+LCBP_UNICAV_SEQFIX                        9.483e-02   3.078e-02   N/A         1.000e-09 
+LCBP_UNICAV_SEQRND                        9.483e-02   3.078e-02   N/A         1.000e-09 
index 22f71bb..55630a1 100755 (executable)
@@ -1,16 +1,8 @@
 #!/bin/bash
 TMPFILE1=`mktemp /var/tmp/testfast.XXXXXX`
 trap 'rm -f $TMP_FILE' 0 1 15
-TMPFILE2=`mktemp /var/tmp/testfast.XXXXXX`
-trap 'rm -f $TMP_FILE2' 0 1 15
-TMPFILE3=`mktemp /var/tmp/testfast.XXXXXX`
-trap 'rm -f $TMP_FILE3' 0 1 15
 
 ./testall testfast.fg > $TMPFILE1
-awk '/^#/ {} NF == 2 && !/^#/ {} NF == 6 && !/^#/ { print $1, $3, $4, $5, $6; }' $TMPFILE1 > $TMPFILE2
-awk '/^#/ {} NF == 2 && !/^#/ {} NF == 6 && !/^#/ { print $1, $3, $4, $5, $6; }' testfast.out > $TMPFILE3
-diff -s $TMPFILE2 $TMPFILE3
+diff -s $TMPFILE1 testfast.out
 
 rm -f $TMPFILE1
-rm -f $TMPFILE2
-rm -f $TMPFILE3