00001 #ifndef rrel_wgted_ran_sam_search_h_ 00002 #define rrel_wgted_ran_sam_search_h_ 00003 //: 00004 // \file 00005 // \brief Weighted/Non-uniform Random sampling search for minimization of a robust objective function 00006 // \author Gehua Yang (yangg2@rpi.edu) 00007 // \date Nov 2004 00008 00009 #include <rrel/rrel_ran_sam_search.h> 00010 #include <vcl_vector.h> 00011 00012 class rrel_wgted_ran_sam_search : public rrel_ran_sam_search 00013 { 00014 public: 00015 //: Constructor using a non-deterministic random-sampling seed. 00016 rrel_wgted_ran_sam_search( ) 00017 : rrel_ran_sam_search(), is_sim_wgt_set_( false ) 00018 { } 00019 00020 //: Constructor using a given random-sampling seed. 00021 rrel_wgted_ran_sam_search( int seed ) 00022 : rrel_ran_sam_search( seed ), is_sim_wgt_set_( false ) 00023 { } 00024 00025 ~rrel_wgted_ran_sam_search( ); 00026 00027 // ---------------------------------------- 00028 // Main estimation functions 00029 // ---------------------------------------- 00030 00031 //: \brief Estimation for an "ordinary" estimation problem. 00032 virtual bool 00033 estimate( const rrel_estimation_problem* problem, 00034 const rrel_objective* obj_fcn ); 00035 00036 // ----------------------------------------- 00037 // Access to results and computed parameters 00038 // ----------------------------------------- 00039 00040 protected: 00041 // ------------------------------------------------------------ 00042 // Random sampling functions. Don't call directly. These are 00043 // public for test purposes. 00044 // ------------------------------------------------------------ 00045 00046 //: Determine the next random sample, filling in the "sample" vector. 00047 virtual void 00048 next_sample( unsigned int taken, unsigned int num_points, vcl_vector<int>& sample, 00049 unsigned int points_per_sample ); 00050 00051 protected: 00052 struct prob_interval { 00053 int index_; 00054 double lower_; 00055 double upper_; 00056 00057 prob_interval() : index_(-1), lower_(-1.0), upper_(-1.0) { } 00058 00059 bool operator< ( const prob_interval& rhs ) const { 00060 return this->upper_ < rhs.upper_; 00061 } 00062 }; 00063 00064 //: store the intervals 00065 vcl_vector<prob_interval> intervals_; 00066 bool is_sim_wgt_set_; 00067 }; 00068 00069 #endif