00001 #ifndef MMVL_P_CONDENSATION_HH
00002 #define MMVL_P_CONDENSATION_HH
00003
00004 #include "condensation.h"
00005
00006 namespace mimas{
00007 namespace hf{
00008
00014 template<typename Hypothesis_T>
00015 class p_condensation: public condensation<Hypothesis_T>
00016 {
00017 public:
00018
00032 void partial_reset(const Hypothesis_T &init, float proportion, float weight_discrimination, float weight_initialization, bool drift_switch = true)
00033 {
00034 unsigned int number_particle_to_relocate = (unsigned int)(condensation<Hypothesis_T>::hypotheses_CD.size() * proportion);
00035
00036 unsigned int i = 0;
00037 unsigned int exit_safety = 0;
00038 while(i < number_particle_to_relocate)
00039 {
00040 if(exit_safety >= condensation<Hypothesis_T>::hypotheses_CD.size())
00041 {
00042 break;
00043 std::cerr<<"Apparently their is not enough hypothesis with a lower weight to be reinitialised"<<std::endl;
00044 }
00045 int j = int(Dice::uniform_random() * condensation<Hypothesis_T>::hypotheses_CD.size());
00046 if( (condensation<Hypothesis_T>::hypotheses_CD.at( j ) ).weight < Dice::uniform_random() * weight_discrimination){
00047 if(drift_switch)
00048 condensation<Hypothesis_T>::hypotheses_CD.at( j ) = init.drift();
00049 else
00050 condensation<Hypothesis_T>::hypotheses_CD.at( j ) = init;
00051 (condensation<Hypothesis_T>::hypotheses_CD.at( j ) ).weight = weight_initialization;
00052
00053 i++;
00054 }
00055 else
00056 exit_safety++;
00057 }
00058 }
00059
00060 protected:
00061
00062 p_condensation(std::vector<Hypothesis_T> &hypotheses)
00063 :condensation<Hypothesis_T>(hypotheses){}
00064
00065 };
00066
00067 }
00068 }
00069 #endif