Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MinimalistFlexbbInteractionGraph.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 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/flexpack/interaction_graph/MinimalistFlexbbInteractionGraph.hh
11 /// @brief Class declaration for minimimalist on-the-fly RPE calculating FlexbbInteractionGraph
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 #ifndef INCLUDED_protocols_flexpack_interaction_graph_MinimalistFlexbbInteractionGraph_hh
15 #define INCLUDED_protocols_flexpack_interaction_graph_MinimalistFlexbbInteractionGraph_hh
16 
17 /// Unit headers
19 
20 /// Package headers
22 
23 #include <utility/vector1.hh>
24 
25 
26 namespace protocols {
27 namespace flexpack {
28 namespace interaction_graph {
29 
31 {
32 public:
35 
36 public:
37 
38  MinimalistFlexbbNode( MinimalistFlexbbInteractionGraph * owner, int node_id, int num_states);
40 
41  /// Virtual functions from NodeBase not covered by FlexbbNode
42  virtual void assign_zero_state();
43  virtual void prepare_for_simulated_annealing();
44  virtual void print() const;
45 
46  /// Virtual functions from OTFFlexbbNode
47 
48  /// Other functions
49 
52  int alternate_state,
53  PackerEnergy & prev_energy_for_node
54  );
55 
56  /// @brief Traverse incident edges and inform them of the alternate
57  /// state being considered at this node. Return true if the alternate
58  /// state is valid.
59  bool
60  prepare_for_altbb_move_to_state( int alt_state );
61 
62  /// @brief Set the alternate state to be the one on the alternate backbone
63  /// most similar to the currently assigned state.
64  /// Traverse incident edges and inform them of the alternate
65  /// state being considered at this node. Return true if the alternate
66  /// state is valid.
67  bool
69 
72 
75 
76  /*
77  PackerEnergy
78  project_deltaE_with_backbone_move(
79  int new_state,
80  PackerEnergy & prev_energy_for_flexseg,
81  bool & valid_motion
82  );
83 
84  PackerEnergy
85  project_deltaE_for_backbone_move(
86  int alt_bb,
87  PackerEnergy & prev_energy_for_flexseg,
88  bool & valid_motion
89  );
90  */
91 
92  void
94 
95  void
96  commit_considered_substitution( ObjexxFCL::FArray1_int & state_on_node );
97 
98  void
99  commit_alt_bb_substitution( ObjexxFCL::FArray1_int & state_on_node );
100 
101  void
103  int which_edge,
104  PackerEnergy alternate_energy
105  );
106 
107  void
109 
110  /// @brief assign a new state to this node and return the change in energy induced
112  assign_state( int new_state );
113 
114  /// @brief For assinging network states to the interaction graph: when substituting
115  /// two adjacent nodes i and j from states r and s to states r' and s', this
116  /// function, along with its partner function, complete_partial_state_assignment,
117  /// guarantees that neither the energies r' with s nor s' with r are computed
118  /// which would be wasteful. This function is meant to be called by the
119  /// owning interaction graph and not meant to be called by the outside world.
120  void
121  partially_assign_state( int new_state );
122 
123  /// @brief See description of partially_assign_state.
124  void
126 
127  virtual unsigned int count_static_memory() const;
128  virtual unsigned int count_dynamic_memory() const;
129 
130 protected:
131 
132  /// Downcast pointers to incident edges, adjacent nodes, and the owning graph
133  inline
134  MinimalistFlexbbEdge const * get_incident_minimalistflexbb_edge( int index ) const;
135 
136  inline
138 
139  inline
140  MinimalistFlexbbNode const * get_adjacent_minimalistflexbb_node( int index ) const;
141 
142  inline
144 
145  inline
147 
148  inline
150 
151 
152 protected:
153 
155  get_altE_for_bb_move( PackerEnergy & curr_frag_etotal );
156 
157 
158 
159 private:
160 
161 
162 };
163 
165 {
166 public:
168  typedef core::Real Real;
169 
170 public:
171  MinimalistFlexbbEdge( MinimalistFlexbbInteractionGraph * owner, int node1, int node2 );
173 
174  /// Virtual functions from EdgeBase
175  virtual void declare_energies_final();
176  virtual void prepare_for_simulated_annealing();
177  virtual void set_edge_weight( Real weight );
178 
179 
181  get_alt_stateE();
182 
183  void
184  acknowledge_substitution( int node_changing_state );
185 
186  void
187  acknowledge_state_zeroed( int node_index );
188 
189  virtual unsigned int count_static_memory() const;
190  virtual unsigned int count_dynamic_memory() const;
191 
192 protected:
193 
194  /// Downcasts
195 
196  inline
197  MinimalistFlexbbNode const * get_minimalistflexbb_node( int index ) const;
198 
199  inline
201 
202  inline
204 
205  inline
207 
208 private:
209 
210 };
211 
213 {
214 public:
216 
217 public:
218  MinimalistFlexbbInteractionGraph( int num_nodes );
220 
221  /// Virtual functions from InteractionGraphBase
222  virtual void initialize( core::pack::rotamer_set::RotamerSetsBase const & rot_sets );
223  virtual PackerEnergy get_one_body_energy_for_node_state( int node, int state);
224  virtual void blanket_assign_state_0();
225  virtual PackerEnergy set_state_for_node(int node_ind, int new_state);
226  virtual PackerEnergy set_network_state( ObjexxFCL::FArray1_int & node_states);
227  virtual void consider_substitution(
228  int node_ind,
229  int new_state,
230  PackerEnergy & delta_energy,
231  PackerEnergy & prev_energy_for_node);
234  virtual int get_edge_memory_usage() const;
235  virtual void print_current_state_assignment() const;
236  virtual void set_errorfull_deltaE_threshold( PackerEnergy deltaE );
237  virtual PackerEnergy get_energy_sum_for_vertex_group( int group_id );
238 
239 
240  /// Virtual functions from FlexbbInteractionGraph
241  virtual
243  int bb_id,
244  core::PackerEnergy & delta_energy,
245  core::PackerEnergy & prev_flexseg_energy,
246  bool & valid_motion,
247  int & num_nodes_changing_state
248  );
249 
250  virtual
252  int node_ind,
253  int new_state,
254  core::PackerEnergy & delta_energy,
255  core::PackerEnergy & prev_energy_for_flexseg,
256  bool & valid_motion,
257  int & num_nodes_changing_state
258  );
259 
260 protected:
261  void
263  core::PackerEnergy & delta_energy,
264  core::PackerEnergy & prev_energy_for_flexseg,
265  bool & valid_motion,
266  int & num_nodes_changing_state
267  );
268 
269 private:
270 
271  virtual
274  ObjexxFCL::FArray1_int & rotamer_on_node
275  );
276 
277  /// Virtual functions from OTFFlexbbInteractionGraph
278 
279 
280  /// @brief returns the change in energy that would be induced by switching this node
281  /// from its current state into another state on the same backbone
284  int alternate_state,
285  PackerEnergy & prev_energy_for_node
286  );
287 
288 protected:
289  /// Downcasts
290  inline
291  MinimalistFlexbbNode const * get_minimalistflexbb_node( int index ) const;
292 
293  inline
295 
296  inline
297  MinimalistFlexbbEdge const * find_minimalist_flexbb_edge( int node1, int node2 ) const;
298 
299  inline
300  MinimalistFlexbbEdge * find_minimalist_flexbb_edge( int node1, int node2 );
301 
302  inline
303  MinimalistFlexbbEdge const * cast_minimalist_flexbb_edge( EdgeBase const * edge ) const;
304 
305  inline
307 
308 protected:
309  /// Virtual functions from InteractionGraphBase
310  virtual unsigned int count_static_memory() const;
311  virtual unsigned int count_dynamic_memory() const;
312 
313  virtual core::pack::interaction_graph::NodeBase * create_new_node( int node_index, int num_states);
314  virtual core::pack::interaction_graph::EdgeBase * create_new_edge( int index1, int index2);
315 
316 
318 
319  /// Virtual functions from OTFFlexbbInteractionGraph
320 
321 private:
322 
323 
324 };
325 
326 /// Node Downcast
327 inline
328 MinimalistFlexbbEdge const *
330 { return static_cast< MinimalistFlexbbEdge const * > ( get_incident_edge( index )); }
331 
332 inline
335 { return static_cast< MinimalistFlexbbEdge * > ( get_incident_edge( index )); }
336 
337 inline
338 MinimalistFlexbbNode const *
340 { return static_cast< MinimalistFlexbbNode const * > ( get_adjacent_node( index )); }
341 
342 inline
345 { return static_cast< MinimalistFlexbbNode * > ( get_adjacent_node( index )); }
346 
347 
348 inline
351 { return static_cast< MinimalistFlexbbInteractionGraph const * > (get_owner()); }
352 
353 inline
356 { return static_cast< MinimalistFlexbbInteractionGraph * > (get_owner()); }
357 
358 /// Edge Downcasts
359 
360 inline
361 MinimalistFlexbbNode const *
363 { return static_cast< MinimalistFlexbbNode const * > (get_node( index )); }
364 
365 inline
368 { return static_cast< MinimalistFlexbbNode * > (get_node( index )); }
369 
370 inline
373 { return static_cast< MinimalistFlexbbInteractionGraph const * > (get_owner()); }
374 
375 inline
378 { return static_cast< MinimalistFlexbbInteractionGraph * > (get_owner()); }
379 
380 
381 /// Graph Downcasts
382 inline
383 MinimalistFlexbbNode const *
385 { return static_cast< MinimalistFlexbbNode const * > (get_node( index )); }
386 
387 inline
390 { return static_cast< MinimalistFlexbbNode * > (get_node( index )); }
391 
392 inline
393 MinimalistFlexbbEdge const *
395 {
396  core::pack::interaction_graph::EdgeBase const * edge = find_edge( node1, node2 );
397  if ( edge ) return static_cast< MinimalistFlexbbEdge const * > ( edge );
398  else return 0;
399 }
400 
401 inline
404 {
405  core::pack::interaction_graph::EdgeBase * edge = find_edge( node1, node2 );
406  if ( edge ) return static_cast< MinimalistFlexbbEdge * > ( edge );
407  else return 0;
408 }
409 
410 inline
411 MinimalistFlexbbEdge const *
413 { assert( mine( edge ) ); return static_cast< MinimalistFlexbbEdge const * > ( edge ); }
414 
415 inline
418 { assert( mine( edge ) ); return static_cast< MinimalistFlexbbEdge * > ( edge ); }
419 
420 
421 }
422 }
423 }
424 
425 #endif
426