Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EvaluatedArchive.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file protocols/jd2/MPIWorkPoolJobDistributor.hh
10 /// @brief header for MPIWorkPoolJobDistributor - intended for continuous resamplig jobs that spawn new jobs based on a pool/archive of
11 /// structures
12 /// @author Oliver Lange olange@u.washington.edu
13 
14 #ifndef INCLUDED_protocols_jd2_archive_EvaluatedArchive_hh
15 #define INCLUDED_protocols_jd2_archive_EvaluatedArchive_hh
16 
17 // Unit headers
21 //#include <protocols/jd2/archive/EvaluatedArchive.fwd.hh>
22 // AUTO-REMOVED #include <core/scoring/constraints/ConstraintSet.hh>
23 
24 // Package headers
26 #include <core/pose/Pose.fwd.hh>
27 // AUTO-REMOVED #include <core/scoring/ScoreFunction.hh>
28 
29 // AUTO-REMOVED #include <protocols/evaluation/PoseEvaluator.hh>
30 
31 // Utility headers
32 #include <core/types.hh>
33 #include <utility/pointer/ReferenceCount.hh>
34 #include <utility/exit.hh>
35 
36 // C++ headers
37 #include <string>
38 #include <list>
39 
43 #include <utility/vector1.hh>
44 
45 
46 namespace protocols {
47 namespace jd2 {
48 namespace archive {
49 //class ArchiveManager;
50 
51 
52 
53 ///@brief Tags used to tag messeges sent by MPI functions used to decide whether a slave is requesting a new job id or
54 ///flagging as job as being a bad input
55 
56 ///@details This job distributor is meant for running jobs where the machine you are using has a large number of
57 ///processors, the number of jobs is much greater than the number of processors, or the runtimes of the individual jobs
58 ///could vary greatly. It dedicates the head node (whichever processor gets processor rank #0) to handling job requests
59 ///from the slave nodes (all nonzero ranks). Unlike the MPIWorkPartitionJobDistributor, this JD will not work at all
60 ///without MPI and the implementations of all but the interface functions have been put inside of ifdef directives.
61 ///Generally each function has a master and slave version, and the interface functions call one or the other depending
62 ///on processor rank.
63 
64 class EvaluatedArchive : public ArchiveBase {
66 public:
67 
68  ///@brief Constructor and Destructor
72 
73  ///@brief Archive specific options
74  static void register_options();
75 
76  ///@brief add decoy to Archive
77  ///@detail evaluate decoy and call add_evaluated_structure
78  virtual bool add_structure( core::io::silent::SilentStructOP from_batch, Batch const& );
79 
80  ///@brief compute score according to select_weights --- this can contain any evaluator columns
82 
83  ///@brief set common evaluators: eg. ConstraintEvaluator if -cst_file is present
85 
86  ///@brief overloaded that we can sort the pool after reading
87  virtual bool restore_from_file();
88 
89  ///@brief only overloaded this to add some verbosity each time we read structures
90  virtual void read_structures( core::io::silent::SilentFileData&, Batch const& batch );
91 
92  ///@brief overloaded to make input decoys appear the same as decoys coming from batches
93  virtual void init_from_decoy_set( core::io::silent::SilentFileData const& sfd ) = 0;
94 
95  ///@brief typedefs for Evaluators and Weights
96  typedef std::map< std::string, core::Real > WeightMap;
97  typedef std::map< std::string, evaluation::PoseEvaluatorCOP > EvaluatorMap;
98 
99  void start_evaluation_timer() const;
100  ///@brief yields an "evaluated" silent-struct which can be queried with select_score
101  ///@detail will run scoring-process if evaluate_local() otherwise just returns the intpu-silent-struct
103 
104  ///@brief add an evaluated decoy to Archive (i.e, evaluated_decoy = evaluate( some_decoy ) );
105  virtual bool add_evaluated_structure( core::io::silent::SilentStructOP evaluated_decoy, Batch const& );
106 
107  ///@brief specify if decoys are evaluated on the master or (non-local i.e., on the individual slave nodes)
108  bool evaluate_local() const {
110  }
111 
112  void set_evaluate_local( bool setting ) {
113  b_evaluate_incoming_decoys_ = setting;
114  }
115 
116  ///@brief recompute all score-values of all decoys and re-order the archive by (new) select_score
117  virtual void rescore();
118 
119  ///@brief add new PoseEvaluation to set of evaluators, specify weight for contribution to select_score()
121 
122  ///@brief remove Evaluator
123  void remove_evaluation( std::string const& column );
124 
125  ///@brief is a certain elvaluator present ?
126  bool has_evaluator( std::string const& column );
127 
128  ///@brief set weight of an evaluator or a column otherwise present in silent-structs
129  /// (i.e, score, chainbreak, external evaluation like score_final )
130  void set_weight( std::string const& column, core::Real weight );
131 
132  core::Real get_weight( std::string const& column ) const;
133 
134  ///@brief set scorefxn used for evaluation
136 
137  core::scoring::ScoreFunction const & scorefxn() const;
138 
139  virtual WeightMap const& score_variations() const;
140 
141  virtual core::Real score_variation( std::string const& col ) const;
142 
143  WeightMap const& weights() const {
144  return select_weights_;
145  }
146 
147  EvaluatorMap const& evaluators() const {
148  return evaluators_;
149  }
150 
151  void set_weights( WeightMap const& setting );
152  void set_evaluators( EvaluatorMap const&, WeightMap const& );
153 
154  ///overloaded to save / restore the variance_archive_
155  virtual void save_to_file( std::string suffix = "" );
156 
157 protected:
159 
160  ///@brief score a pose
161  virtual void score( core::pose::Pose& pose ) const;
162 
163  virtual void invalidate_score_variations() {}
164 
165 private:
166  ///@brief call score( pose ) and collect energies into result
167  /// this is low-level function: it expects that result already contains the coordinates of the pose
168  /// for convenience the pointer result is also return value
170 
171  ///@brief re-sort decoys based on select_score
172  void sort();
173 
174  ///@brief scorefxn_ for evaluate( SilentStruct, Pose const& )
176 
177  ///@brief Evaluators and weights for select_score and evaluate
180 
182 
183  ///@brief keep track wether cached scores in _archive_select_score_ are up-to-date
184  mutable bool scores_are_clean_; //false after add_evaluation or change of scorefxn_
185 
187 
188  ///@brief local evaluation or is evaluation outsourced to slave nodes?
190 
191  ///@brief keep track whether our options have been registered at start up
192  static bool options_registered_;
193 
194  mutable time_t start_eval_time_;
195 
197 };
198 
199 
200 }//archive
201 }//jd2
202 }//protocols
203 
204 
205 #endif //INCLUDED_protocols_jd2_Archive_HH