00001
00002
00003
00004
00005
00006
00007 #ifndef IMPDOMINO_DOMINO_OPTIMIZER_H
00008 #define IMPDOMINO_DOMINO_OPTIMIZER_H
00009
00010 #include "domino_config.h"
00011 #include "RestraintGraph.h"
00012 #include "JunctionTree.h"
00013 #include "RestraintEvaluatorI.h"
00014 #include "CombState.h"
00015 #include <IMP/RestraintSet.h>
00016
00017 #include <IMP/Optimizer.h>
00018 #include <IMP/Restraint.h>
00019 #include <IMP/Model.h>
00020
00021 IMPDOMINO_BEGIN_NAMESPACE
00022
00023
00024
00025
00026 class IMPDOMINOEXPORT DominoOptimizer : public Optimizer
00027 {
00028 typedef boost::tuple<Restraint *,Particles,Float> OptTuple;
00029 public:
00030
00031
00032
00033
00034
00035
00036
00037
00038 DominoOptimizer(const JunctionTree &jt, Model *m,
00039 RestraintEvaluatorI *r_eval);
00040
00041 IMP_OPTIMIZER(DominoOptimizer);
00042
00043 void set_sampling_space(DiscreteSampler *ds);
00044
00045
00046
00047 void show_restraint_graph(std::ostream& out = std::cout) const {
00048 g_->show(out);
00049 }
00050 void show_optimum_configuration(unsigned int conf_ind,
00051 std::ostream& out = std::cout) const {
00052 out<<"OPT_CONF:";
00053 g_->get_opt_combination(conf_ind)->show(out);
00054 }
00055 DiscreteSampler *get_sampling_space() const {return ds_;}
00056 RestraintGraph *get_graph() const {return g_;}
00057 void set_restraint_evaluator(RestraintEvaluatorI *rstr_eval) {
00058 rstr_eval_=rstr_eval;
00059 }
00060 inline unsigned int get_number_of_solutions() const {
00061 return num_of_solutions_;}
00062 inline void set_number_of_solutions(unsigned int n){num_of_solutions_=n;}
00063 void move_to_opt_comb(unsigned int i) const;
00064
00065
00066
00067
00068
00069
00070 void add_restraint(Restraint *r);
00071
00072
00073
00074
00075
00076
00077
00078
00079 void add_restraint(Restraint *r,Particles ps,float weight=1.);
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 void exhaustive_enumeration(CombStates &states, bool calc_score=false,
00091 bool use_rsr_eval=false);
00092
00093
00094
00095
00096
00097
00098
00099
00100 void score_combinations(const CombStates &states,
00101 std::vector<Floats> &scores);
00102
00103 protected:
00104
00105
00106
00107
00108
00109
00110 void add_restraint_recursive(Restraint *rs, Float weight);
00111
00112 void clear();
00113
00114
00115
00116
00117
00118
00119 void add_jt_node(int node_index, std::vector<Int> &particles_ind,
00120 Model &m);
00121
00122
00123
00124
00125 void add_jt_edge(int node1_ind, int node2_ind);
00126
00127 void initialize_jt_graph(int number_of_nodes);
00128 DiscreteSampler *ds_;
00129 RestraintGraph *g_;
00130 unsigned int num_of_solutions_;
00131 std::vector<OptTuple> rs_;
00132 RestraintEvaluatorI *rstr_eval_;
00133 };
00134 IMPDOMINO_END_NAMESPACE
00135
00136 #endif