00001 // -*- C++ -*- 00002 #ifndef __LEMGA_AGGREGATING_H__ 00003 #define __LEMGA_AGGREGATING_H__ 00004 00011 #include <vector> 00012 #include "learnmodel.h" 00013 #include "shared_ptr.h" 00014 00015 namespace lemga { 00016 00017 typedef var_shared_ptr<LearnModel> pLearnModel; 00018 00043 class Aggregating : public LearnModel { 00044 void clear (); 00045 00046 protected: 00047 pLearnModel lm_base; 00048 std::vector<pLearnModel> lm; 00049 UINT n_in_agg; 00050 UINT max_n_model; 00051 00052 public: 00053 Aggregating (); 00054 Aggregating (const Aggregating&); 00055 const Aggregating& operator= (const Aggregating&); 00056 00057 virtual Aggregating* create () const = 0; 00058 virtual Aggregating* clone () const = 0; 00059 00061 void set_base_model (const LearnModel&); 00062 const LearnModel& base_model () const { return *lm_base; } 00064 00065 virtual void initialize (); 00066 void set_max_models (UINT max) { max_n_model = max; } 00067 00069 00070 UINT size () const { return lm.size(); } 00071 bool empty () const { return lm.empty(); } 00072 const LearnModel& model (UINT n) const { return *lm[n]; } 00073 const LearnModel& operator[] (UINT n) const { return *lm[n]; } 00075 00076 virtual bool set_aggregation_size (UINT); 00077 UINT aggregation_size () const { return n_in_agg; } 00078 virtual void set_train_data (const pDataSet&, const pDataWgt& = 0); 00079 00080 protected: 00081 virtual bool serialize (std::ostream&, ver_list&) const; 00082 virtual bool unserialize (std::istream&, ver_list&, 00083 const id_t& = empty_id); 00084 }; 00085 00086 } // namespace lemga 00087 00088 #ifdef __AGGREGATING_H__ 00089 #warning "This header file may conflict with another `aggregating.h' file." 00090 #endif 00091 #define __AGGREGATING_H__ 00092 #endif