contrib/mul/msm/msm_box_limiter.h
Go to the documentation of this file.
00001 #ifndef msm_box_limiter_h_
00002 #define msm_box_limiter_h_
00003 //:
00004 // \file
00005 // \author Tim Cootes
00006 // \brief Apply limits to each parameter independently
00007 
00008 #include <msm/msm_param_limiter.h>
00009 #include <vnl/vnl_vector.h>
00010 #include <vcl_iosfwd.h>
00011 
00012 //: Apply limits to each parameter independently
00013 //  Each parameter is forced to lie in range [-k*s_i,+k*s_i],
00014 //  where s_i is the standard deviation for the i-th parameter.
00015 class msm_box_limiter : public msm_param_limiter
00016 {
00017  private:
00018   //: SD on each mode
00019   vnl_vector<double> mode_sd_;
00020 
00021   //: Number of SDs to limit at
00022   double n_sds_;
00023 
00024   //: Proportion of Gaussian to be accepted
00025   //  Used to set M_max when mode_var defined.
00026   double accept_prop_;
00027 
00028  public:
00029 
00030   msm_box_limiter();
00031 
00032   virtual ~msm_box_limiter() {}
00033 
00034   //: Define variance on each parameter
00035   virtual void set_param_var(const vnl_vector<double>& v);
00036 
00037   //: Set the limits so that a given proportion pass
00038   //  Where the parameters are described by a pdf, choose
00039   //  limits so that on average a proportion prop (in [0,1])
00040   //  are acceptable when using n_modes modes. If n_modes==0,
00041   //  then assume all available modes to be used.
00042   virtual void set_acceptance(double prop, unsigned n_modes=0);
00043 
00044   //: Apply limit to parameter vector b
00045   virtual void apply_limit(vnl_vector<double>& b) const;
00046 
00047   //: Define number of SDs to limit at
00048   void set_n_sds(double n_sds);
00049 
00050 
00051   //: Name of the class
00052   virtual vcl_string is_a() const;
00053 
00054   //: Create a copy on the heap and return base class pointer
00055   virtual msm_param_limiter* clone() const;
00056 
00057   //: Print class to os
00058   virtual void print_summary(vcl_ostream& os) const;
00059 
00060   //: Save class to binary file stream
00061   virtual void b_write(vsl_b_ostream& bfs) const;
00062 
00063   //: Load class from binary file stream
00064   virtual void b_read(vsl_b_istream& bfs);
00065 
00066   //: Initialise from a text stream.
00067   // The default implementation is for attribute-less normalisers,
00068   // and throws if it finds any data in the stream.
00069   virtual void config_from_stream(vcl_istream &is);
00070 };
00071 
00072 #endif // msm_box_limiter_h_