contrib/rpl/rgrl/rgrl_converge_status.h
Go to the documentation of this file.
00001 #ifndef rgrl_converge_status_h_
00002 #define rgrl_converge_status_h_
00003 
00004 //:
00005 // \file
00006 // \brief Class to represent the registration status.
00007 // \author Chuck Stewart
00008 // \date 27 Dec 2002
00009 //
00010 // \verbatim
00011 // modifications:
00012 // Feb 2003 Amitha Perera, impl the functions
00013 // \endverbatim
00014 
00015 #include "rgrl_object.h"
00016 
00017 //: Represent the registration status
00018 //
00019 class rgrl_converge_status
00020   : public rgrl_object
00021 {
00022 public:
00023 
00024   enum converge_type { conv_on_going, converged, stagnated };
00025   
00026   enum status_type { status_on_going, good_enough, failed, good_and_terminate };
00027 
00028   //: default ctor
00029   rgrl_converge_status( );
00030   
00031   //: default ctor
00032   rgrl_converge_status( converge_type conv, 
00033                         status_type stat, 
00034                         double error, 
00035                         unsigned osc_count,
00036                         double error_diff );
00037                         
00038 
00039   //:
00040   rgrl_converge_status( bool     has_converged,
00041                         bool     has_stagnated,
00042                         bool     is_good_enough,
00043                         bool     in_is_failed,
00044                         double   error,
00045                         unsigned oscillation_count,
00046                         double   error_diff );
00047 
00048   virtual ~rgrl_converge_status();
00049 
00050 
00051   //:  Return true if the estimation has converged to a viable estimate.
00052   //
00053   bool has_converged() const;
00054 
00055   //:  Return true if the estimation has stagnated without reaching a viable estimate.
00056   //
00057   //   Only one of has_converged() and has_stagnated() can be true.
00058   bool has_stagnated() const;
00059 
00060   //:  Return true if the current estimate should be considered "good enough" to solve the problem.
00061   //
00062   bool is_good_enough() const;
00063 
00064   //:  Return true if the current estimate should be considered "a failure" that would not solve the problem.
00065   //
00066   bool is_failed() const;
00067 
00068   //: return true is the current estimate is so good that registration can be terminated
00069   //
00070   bool is_good_and_should_terminate() const;
00071   
00072   //: return converge enum
00073   converge_type current_converge() const;
00074   
00075   //: return current status
00076   status_type  current_status() const;
00077 
00078   //: set current coverage
00079   void set_current_converge( converge_type c );
00080   
00081   //: set current coverage
00082   void set_current_status( status_type s );
00083   
00084   //: set objective value
00085   void set_objective_value( double obj );
00086   
00087   //: Current value of the objective function
00088   //
00089   //  Lower is better.
00090   //
00091   double objective_value() const;
00092 
00093   //: Same as the objective value
00094   //
00095   double error() const;
00096 
00097   //: A signed difference between the error of the current status and the error of the previous. 
00098   //
00099   double error_diff() const;
00100 
00101   //: Return the number of times that the error_diff changes the sign
00102   //
00103   unsigned int oscillation_count() const;
00104 
00105   // Defines type-related functions
00106   rgrl_type_macro( rgrl_converge_status, rgrl_object );
00107 
00108 protected:
00109   converge_type conv_;
00110   status_type   status_;
00111   double   error_;
00112   unsigned oscillation_count_;
00113   double   error_diff_;
00114 };
00115   
00116 #endif // rgrl_converge_status_h_