Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SymmMinimalistInteractionGraph.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 core/pack/interaction_graph/SymmMinimalistInteractionGraph.hh
11 /// @brief
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 #ifndef INCLUDED_core_pack_interaction_graph_SymmMinimalistInteractionGraph_hh
15 #define INCLUDED_core_pack_interaction_graph_SymmMinimalistInteractionGraph_hh
16 
17 // Unit Headers
19 
20 // Package Headers
22 
23 #include <ObjexxFCL/FArray3D.hh>
24 
25 #include <utility/vector1.hh>
26 
27 
28 namespace core {
29 namespace pack {
30 namespace interaction_graph {
31 
33 {
34 public:
35  /// @brief main constructor, no default ctor, uncopyable
37  InteractionGraphBase * owner,
38  int node_id,
39  int num_states
40  );
41 
42  /// @brief virtual dstor
43  virtual ~SymmMinimalistNode();
44 
45  //virtual methods inherited from NodeBase
46  /// @brief symmin ig does not have to do anything before sim annealing begins
47  virtual void prepare_for_simulated_annealing();
48  /// @brief write internal energy and bookkeeping data to standard out
49  virtual void print() const;
50  /// @brief state 0 represents the unasigned state
51  virtual bool state_unassigned() const { return current_state_ == 0;}
52  /// @brief return the total energy for this node; includes full energies to neighboring residues
54 
55  /// @brief set to state 0
56  void assign_zero_state();
57  /// @brief set to a particular state -- updates the energies internally
58  void assign_state(int new_state);
59  /// @brief first half of an entire-graph state assignment that avoids unnecessary energy updates
60  /// as produced in assign_state. Adjust all node's states first, then update all energies.
61  void partial_assign_state( int new_state );
62  /// @brief second half of the entire-graph state assignment.
64 
65  /// @brief return the index of the currently assigned state
66  inline
67  int get_current_state() const
68  { return current_state_; }
69 
70  /// @brief return the one-body energy for the currently assigned state
71  inline
73  { return curr_state_one_body_energy_; }
74 
75  /// @brief compute the change in energy induced by substituting the currently assigned state with
76  /// some alternative state
78  (
79  int alternate_state,
80  core::PackerEnergy & prev_node_energy
81  );
82 
83  /// @brief proceed to change the currently assigned state to the alternative state considered in
84  /// the last call to project_deltaE_for_substitution
86 
87  /// @brief update bookkeeping info to acknolwedge that the last alternative state considered was not
88  /// in fact chosen for the currently assigned state.
90 
91  /// @brief comupute the interaction energy between the currently assigned state on this residue and
92  /// the currently assigned state on a neighboring residue, identified by the index of the edge connecting
93  /// the two
94  core::PackerEnergy compute_pair_energy_for_current_state( int edge_making_energy_request );
95  /// @brief comupute the interaction energy between the alternate state being considered on this residue and
96  /// the currently assigned state on a neighboring residue, identified by the index of the edge connecting
97  /// the two
98  core::PackerEnergy compute_pair_energy_for_alternate_state( int edge_making_energy_request );
99 
100  inline
102  int edge_to_altered_neighbor,
103  core::PackerEnergy new_edge_energy,
104  int other_node_new_state
105  );
106 
107  void
109  int edge_to_altered_neighbor,
110  int other_node_new_state
111  );
112 
113  // Undefinded, commenting out to fix PyRosetta build inline SparseMatrixIndex const & get_sparse_mat_info_for_curr_state() const;
114 
115  void print_internal_energies() const;
116 
118 
119  virtual unsigned int count_static_memory() const;
120  virtual unsigned int count_dynamic_memory() const;
121 
122 private:
123 
125 
126 public:
127 
128  inline
129  SymmMinimalistEdge const * get_incident_symmin_edge( int index ) const;
130 
131  inline
133 
134  inline
135  SymmMinimalistNode const * get_adjacent_symmin_node( int index ) const;
136 
137  inline
139 
140  inline
142  get_symmin_ig_owner() const;
143 
144  inline
147 
148 private:
149  /// Data
150 
152 
157 
162 
165 
166 };
167 
169 {
170 public:
172  InteractionGraphBase* owner,
173  int first_node_ind,
174  int second_node_ind
175  );
176 
177  virtual ~SymmMinimalistEdge();
178 
179  virtual core::PackerEnergy get_two_body_energy( int const node1state, int const node2state) const;
180 
181  //virtual methods inherited from EdgeBase
182  virtual void prepare_for_simulated_annealing();
183 
185 
187  int node_ind,
188  int new_state,
189  core::PackerEnergy & new_energy
190  );
191  void acknowledge_state_zeroed( int node_ind );
192 
194  int node_ind,
195  int new_state
196  );
197 
199 
202  int changing_node_index
203  );
204 
205 
208 
209 
210  inline
212  int substituted_node_index,
214  int nodes_new_state
215  );
216 
217  int get_two_body_table_size() const;
218  virtual void declare_energies_final();
219 
220  void print_current_energy() const;
221 
222  virtual unsigned int count_static_memory() const;
223  virtual unsigned int count_dynamic_memory() const;
224 
225  virtual void set_edge_weight( Real weight );
226 
227 private:
228 
229  inline SymmMinimalistNode const * get_symmin_node( int index ) const;
230  inline SymmMinimalistNode * get_symmin_node( int index );
233 
234  void
236  int node_substituted,
237  int node_not_substituted,
238  int bumped_recent_history_index
239  );
240 
242 
243  void wipe( int node );
244 
245  bool store_rpes_[ 2 ];
246  ObjexxFCL::FArray2D< core::PackerEnergy > stored_rpes_[ 2 ];
247  ObjexxFCL::FArray2D< unsigned char > sparse_aa_neighbors_;
252 
253  //no default constructor, uncopyable
257 
258 };
259 
261 {
262 public:
263  SymmMinimalistInteractionGraph( int numNodes );
265 
266  //virtual methods inherited from InteractionGraphBase
267  virtual void blanket_assign_state_0();
268  virtual core::PackerEnergy set_state_for_node(int node_ind, int new_state);
269  virtual core::PackerEnergy set_network_state( ObjexxFCL::FArray1_int & node_states);
270  virtual void consider_substitution(
271  int node_ind,
272  int new_state,
273  core::PackerEnergy & delta_energy,
274  core::PackerEnergy & prev_energy_for_node
275  );
278  virtual int get_edge_memory_usage() const;
279  virtual void print_current_state_assignment() const;
280  virtual void set_errorfull_deltaE_threshold( core::PackerEnergy deltaE );
281  virtual core::PackerEnergy get_energy_sum_for_vertex_group( int group_id );
282  virtual void prepare_for_simulated_annealing();
283 
284  //bool build_sc_only_rotamer() const;
285 
286  virtual unsigned int count_static_memory() const;
287  virtual unsigned int count_dynamic_memory() const;
288 
289 protected:
290 
291  virtual NodeBase* create_new_node( int node_index, int num_states);
292  virtual EdgeBase* create_new_edge( int index1, int index2);
293 
294  //Hooks for SASAInterationGraph< V, E, G >
297 
298  inline
299  SymmMinimalistNode const * get_symmin_node(int index) const
300  {
301  return static_cast< SymmMinimalistNode const * > (get_node( index ));
302  }
303 
304  inline
306  {
307  return static_cast< SymmMinimalistNode * > (get_node( index ));
308  }
309 
310 private:
311 
317 
319 
320  static const int COMMIT_LIMIT_BETWEEN_UPDATES = 1024; // 2^10
321 
322  //no default constructor, uncopyable
326 };
327 
328 
329 inline
332 {
333  return static_cast< SymmMinimalistInteractionGraph const * > (get_owner());
334 }
335 
336 inline
339 {
340  return static_cast< SymmMinimalistInteractionGraph * > (get_owner());
341 }
342 
343 inline
344 SymmMinimalistEdge const *
346 {
347  return static_cast< SymmMinimalistEdge const * > (get_incident_edge( index ));
348 }
349 
350 inline
353 {
354  return static_cast< SymmMinimalistEdge * > (get_incident_edge( index ));
355 }
356 
357 inline
358 SymmMinimalistNode const *
360 {
361  return static_cast< SymmMinimalistNode const * > (get_adjacent_node( index ));
362 }
363 
364 inline
367 {
368  return static_cast< SymmMinimalistNode * > (get_adjacent_node( index ));
369 }
370 
371 inline
372 SymmMinimalistNode const *
374 {
375  return static_cast< SymmMinimalistNode const * > (get_node( index ));
376 }
377 
378 inline
381 {
382  return static_cast< SymmMinimalistNode * > (get_node( index ));
383 }
384 
385 
386 inline
389 {
390  return static_cast< SymmMinimalistInteractionGraph const * > (get_owner());
391 }
392 
393 inline
396 {
397  return static_cast< SymmMinimalistInteractionGraph * > (get_owner());
398 }
399 
400 
401 inline
402 void
404  int substituted_node_index,
405  core::PackerEnergy const curr_state_energy,
406  int nodes_new_state
407 )
408 {
409  int node_not_substituted = substituted_node_index == get_node_index(0) ? 1 : 0;
410 
413  get_edges_position_in_nodes_edge_vector( node_not_substituted ),
415  nodes_new_state
416  );
417 }
418 
419 inline
420 void
422  int edge_to_altered_neighbor,
423  core::PackerEnergy new_edge_energy,
424  int other_node_new_state
425 )
426 {
428  new_edge_energy - curr_state_two_body_energies_[ edge_to_altered_neighbor ];
429  curr_state_two_body_energies_[ edge_to_altered_neighbor ] = new_edge_energy;
430  neighbors_curr_state_[ edge_to_altered_neighbor ] = other_node_new_state;
431 }
432 
433 
434 }
435 }
436 }
437 
438 #endif
439