IMP  2.4.0
The Integrative Modeling Platform
EnsembleGenerator.h
Go to the documentation of this file.
1 /**
2  * \file IMP/multi_state/EnsembleGenerator.h
3  * \brief implements branch&bound enumeration of an ensemble of good scoring MultiStateModels
4  *
5  * \authors Dina Schneidman
6  * Copyright 2007-2015 IMP Inventors. All rights reserved.
7  *
8  */
9 
10 #ifndef IMPMULTI_STATE_ENSEMBLE_GENERATOR_H
11 #define IMPMULTI_STATE_ENSEMBLE_GENERATOR_H
12 
13 #include "MultiStateModel.h"
14 #include "MultiStateModelScore.h"
15 
16 IMPMULTISTATE_BEGIN_NAMESPACE
17 
18 // Ensemble is a set of multi-state models
19 typedef std::vector<MultiStateModel> Ensemble;
20 
21 class IMPMULTISTATEEXPORT EnsembleGenerator {
22 public:
23  EnsembleGenerator(unsigned int population_size,
24  unsigned int best_k,
25  std::vector<MultiStateModelScore*>& scorers,
26  float min_weight_threshold);
27 
28  void generate(unsigned int multi_state_model_size);
29 
30 private:
31  void init();
32 
33  // enumerate MultiStateModels of size N from MultiStateModels of size N-1
34  void add_one_state(const Ensemble& init_ensemble,
35  Ensemble& new_ensemble);
36 
37  void rescore(Ensemble& ensemble,
38  Ensemble& rescored_ensemble,
39  std::vector<std::vector<IMP::saxs::WeightedFitParameters> >& rfps) const;
40 
41  void output(Ensemble& ensemble,
42  const std::vector<std::vector<IMP::saxs::WeightedFitParameters> >& fps) const;
43 
44  double get_score(const MultiStateModel& e) const {
45  double ret = 0;
46  for(unsigned int i=0; i<scorers_.size(); i++) {
47  ret += scorers_[i]->get_score(e);
48  }
49  return ret;
50  }
51 
52  void get_state_probabilities(const Ensemble& ensemble,
53  std::vector<double>& state_prob) const;
54 
55  void get_weights_average_and_std(const Ensemble& ensemble,
56  const std::vector<IMP::saxs::WeightedFitParameters>& fps,
57  std::vector<double>& weights_average,
58  std::vector<double>& weights_variance) const;
59 
60 private:
61  unsigned int N_;
62  unsigned int K_;
63  std::vector<MultiStateModelScore*> scorers_;
64  std::vector<Ensemble > ensembles_;
65  float min_weight_threshold_; // default=5%
66 };
67 
68 IMPMULTISTATE_END_NAMESPACE
69 
70 #endif /* IMPMULTI_STATE_ENSEMBLE_GENERATOR_H */
base class for MultiStateModel