00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IMPSTATISTICS_KML_PROXY_H
00009 #define IMPSTATISTICS_KML_PROXY_H
00010
00011 #include "statistics_config.h"
00012 #include <IMP/Particle.h>
00013 #include <IMP/Model.h>
00014 #include <vector>
00015 #include <iostream>
00016 #include <ctime>
00017 #include <cmath>
00018 #include <string>
00019 #include "KMTerminationCondition.h"
00020 #include "KMData.h"
00021 #include "KMFilterCenters.h"
00022 #include "KMLocalSearch.h"
00023 #include "KMLocalSearchLloyd.h"
00024
00025 IMPSTATISTICS_BEGIN_NAMESPACE
00026
00027 #ifndef IMP_DOXYGEN
00028 inline double elapsed_time(clock_t start) {
00029 return double(clock() - start)/double(CLOCKS_PER_SEC);
00030 }
00031 #endif
00032
00033
00034
00035
00036 class IMPSTATISTICSEXPORT KMLProxy
00037 {
00038 public:
00039 KMLProxy();
00040
00041
00042
00043
00044
00045
00046
00047
00048 void initialize(Model *m,const Particles &ps,
00049 const std::vector<FloatKey> &atts,unsigned int num_centers);
00050
00051
00052
00053
00054
00055 void run(Particles *ps=NULL);
00056 std::string get_cmm_string() const;
00057 void log_header() const;
00058
00059 unsigned int get_particle_assignment(Particle *p) const;
00060 Particles get_centers() const {return centroids_;}
00061 protected:
00062 void log_summary(KMFilterCentersResults *ctrs, Float run_time,
00063 std::ostream &out=std::cout) const;
00064 void reset();
00065 bool is_init_;
00066 bool is_calculated;
00067 void set_default_values();
00068
00069
00070 KMData *data_;
00071 unsigned int dim_;
00072 unsigned int data_size_;
00073 unsigned int kcenters_;
00074
00075
00076 unsigned int max_swaps_;
00077 Float damp_factor_;
00078 unsigned int n_color_;
00079 bool new_clust_;
00080 unsigned int max_dim_;
00081 DistributionType distr_;
00082 Float std_dev_;
00083 Float corr_coef_;
00084 Float clus_sep_;
00085 unsigned int max_visit_;
00086 unsigned int seed_;
00087 KMLocalSearchLloyd *lloyd_alg_;
00088 Float kc_build_time_;
00089 bool print_points_;
00090 bool show_assign_;
00091 bool validate_;
00092 KMTerminationCondition term_;
00093
00094
00095 Model *m_;
00096 Particles ps_;
00097 Particles centroids_;
00098 std::vector<FloatKey> atts_;
00099 std::map<Particle *,unsigned int> assignment_;
00100
00101 };
00102 IMPSTATISTICS_END_NAMESPACE
00103 #endif