Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PDInteractionGraph.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/PDInteractionGraph.hh
11 /// @brief Pairwise Decomposable interaction graph class header
12 /// @author Andrew Leaver-Fay (leaverfa@email.unc.edu)
13 
14 
15 #ifndef INCLUDED_core_pack_interaction_graph_PDInteractionGraph_hh
16 #define INCLUDED_core_pack_interaction_graph_PDInteractionGraph_hh
17 
18 // Unit headers
20 
21 // Package Headers
26 
27 // ObjexxFCL Headers
28 #include <ObjexxFCL/FArray1D.hh>
29 #include <ObjexxFCL/FArray2D.hh>
30 #include <ObjexxFCL/FArray3D.hh>
31 
32 // Utility Headers
33 //#include <utility/io/all.fwd.hh>
34 
35 // C++ Headers
36 // AUTO-REMOVED #include <vector>
37 #include <list>
38 
39 #include <utility/vector1.hh>
40 #include <ObjexxFCL/FArray1A.hh>
41 
42 
43 
44 namespace core {
45 namespace pack {
46 namespace interaction_graph {
47 
48 class PDNode;
49 class PDEdge;
50 class PDInteractionGraph;
51 
53 {
54 public:
55  PDNode(InteractionGraphBase * owner, int node_id, int num_states);
56  virtual ~PDNode();
57  /// @brief prints a description of the node and all of it's one-body energies
58  virtual void print() const;
59  /// @brief sets the amino acid type for each state
60  virtual void set_amino_acid_types( std::vector< int > const & );
61  /// @brief return the amino acid type for a particular state -- this indexing is of course completely
62  /// arbitrary
63  virtual
64  int aatype_for_state( int state ) const;
65  /// @brief returns an FArray & with the number of states for each amino acid type
67  /// @brief update energy to the one-body energy for state
68  virtual void update_one_body_energy( int state, core::PackerEnergy energy );
69  /// @brief set all the one-body energies for this node
70  virtual void update_one_body_energies( ObjexxFCL::FArray1< core::PackerEnergy > & energies );
71  /// @brief adds energy to the one-body energy for state state
72  virtual void add_to_one_body_energy( int state, core::PackerEnergy energy );
73  /// @brief adds all the energies in energies to the one-body energies for this node
74  virtual void add_to_one_body_energies( ObjexxFCL::FArray1< core::PackerEnergy > & energies );
75  virtual void zero_one_body_energies();
76  /// @brief returns the one body energy for a state
78  /// @brief prepares node for simulated annealing
79  virtual void prepare_for_simulated_annealing();
80 
81  /// @brief assigns node's state to it's zero, or "unassigned" state.
82  void assign_zero_state();
83  virtual bool state_unassigned() const { return current_state_ == 0;}
84  /// @brief assigns node a new_state
85  void assign_state(int new_state);
86  /// @brief returns the state the node is currently assigned
87  int get_current_state() const;
88  /// @brief returns the one body energy for the state the node is currently assigned
90 
91  /// @brief
92  /// returns the change in energy that would be induced by switching this node
93  /// from its current state into another state
94  ///
96  (
97  int alternate_state,
98  core::PackerEnergy & prev_node_energy
99  );
101 
102  // <directed_design>
103  /// @brief returns the change in weighted energy that would be induced
104  /// by switching this node from its current state into another state
106  (
107  int alternate_state,
108  core::PackerEnergy & deltaE_unweighted,
109  core::PackerEnergy & prevE_unweighted,
110  core::PackerEnergy& deltaE_weighted,
111  core::PackerEnergy& prevE_weighted,
112  ObjexxFCL::FArray2D< core::PackerEnergy > const& weights
113  );
114  core::PackerEnergy get_weighted_energy_with_higher_indexed_nodes(ObjexxFCL::FArray2D< core::PackerEnergy > const& weights) const;
115  // </directed_design>
116 
117  inline
119  int edge_to_altered_neighbor,
120  core::PackerEnergy new_edge_energy,
121  int other_node_new_state,
122  SparseMatrixIndex const & other_node_new_state_sparse_info);
123 
124  SparseMatrixIndex const &
125  get_sparse_mat_info_for_state(int state) const;
126 
127  SparseMatrixIndex const &
129 
130 
131  int get_num_states_for_aa_type(int aa_type) const;
132  void print_internal_energies() const;
133 
135 
136  virtual unsigned int count_static_memory() const;
137  virtual unsigned int count_dynamic_memory() const;
138 
139 
140  /*
141  void prepare_to_write_to_file();
142  void initialize_aa_for_state_array();
143  void clean_up_after_writing_to_file();
144  void prepare_to_read_energies_from_file( int num_states_for_node_in_file );
145  void clean_up_after_reading_energies_from_file();
146 
147  void set_aa_for_file_state(int file_state, int aa );
148  void set_instance_state_correspondence( int instance_state, int state_from_file );
149  int get_correspondence_for_state( int instance_state );
150 
151  int get_num_rots_absent_from_file();
152  void get_absent_rots( ObjexxFCL::FArray1_int & rots_absent );
153 
154  int get_num_states_in_file();
155  int & get_aatypes_for_file_states();
156 
157  int & get_aatypes_for_states();
158  int & get_num_file_states_for_aa();
159  int & get_file_states_2_instance_states_array();
160 
161  bool get_node_corresponded_to_file_node();
162  */
163 
164 protected:
166 
167  //Hooks for SASANode< V, E, G > class
170  void set_alternate_state( int alt ) { alternate_state_ = alt; }
171  int get_alternate_state() const { return alternate_state_; }
172  void calc_deltaEpd( int alternate_state );
174  {
176  }
177 
178 private:
179 
180  void
181  set_alt_aa_offsets_from_edge(int edge_index, ObjexxFCL::FArray2D_int const & offsets);
182 
183  inline
184  PDEdge const * get_incident_pd_edge( int index ) const;
185 
186  inline
187  PDEdge * get_incident_pd_edge( int index );
188 
189  inline
190  PDInteractionGraph const * get_pdig_owner() const;
191 
192  inline
194 
197  std::vector< SparseMatrixIndex > sparse_mat_info_for_state_;
198  std::vector< core::PackerEnergy > one_body_energies_;
199 
200  ObjexxFCL::FArray3D_int aa_offsets_for_edges_;
202  std::vector< int > neighbors_curr_state_;
203  std::vector< SparseMatrixIndex > neighbors_curr_state_sparse_info_;
204  std::vector< ObjexxFCL::FArray1A< core::PackerEnergy > > edge_matrix_ptrs_;
205 
206 
211  std::vector< core::PackerEnergy > curr_state_two_body_energies_;
212 
217  std::vector< core::PackerEnergy > alternate_state_two_body_energies_;
218 
219 /*
220  //variables for I/O
221  int num_states_in_file_;
222  ObjexxFCL::FArray1D_int instance_states_2_file_states_;
223  ObjexxFCL::FArray1D_int file_states_2_instance_states_;
224  ObjexxFCL::FArray1D_int aa_types_for_file_states_;
225  ObjexxFCL::FArray1D_int aa_types_for_instance_states_; //useful only for I/O
226  ObjexxFCL::FArray1D_int num_file_states_for_aa_;
227 */
229 
230  //no default constructor, uncopyable
231  PDNode();
232  PDNode( PDNode const & );
233  PDNode & operator = ( PDNode const & );
234 };
235 
237 {
238 public:
239  PDEdge(InteractionGraphBase* owner, int first_node_ind, int second_node_ind);
240  virtual ~PDEdge();
241  virtual void set_sparse_aa_info(ObjexxFCL::FArray2_bool const & sparse_conn_info);
242  virtual void force_aa_neighbors(int node1aa, int node2aa);
243  virtual void force_all_aa_neighbors();
244  virtual bool get_sparse_aa_info( int node1aa, int node2aa) const;
245  virtual void add_to_two_body_energy(int const, int const, core::PackerEnergy const);
246  virtual void
247  add_to_two_body_energies( ObjexxFCL::FArray2< core::PackerEnergy > const & res_res_energy_array );
248  virtual
249  void set_two_body_energy(int const, int const, core::PackerEnergy const);
250  virtual
251  void clear_two_body_energy(int const, int const);
252  virtual core::PackerEnergy get_two_body_energy( int const, int const ) const;
253 
254  virtual void declare_energies_final();
255  virtual void prepare_for_simulated_annealing();
256  //virtual unsigned int getMemoryUsageInBytes() const;
257 
259 
261  int node_ind,
262  int new_state,
263  SparseMatrixIndex const & new_state_sparse_info,
264  core::PackerEnergy & new_energy
265  );
266 
267  /// @brief updates bookkeeping information when one of the two nodes enters its
268  /// "unassigned" state.
269  void acknowledge_state_zeroed( int node_ind );
270 
271  static
272  inline
274  int first_node_alt_state,
275  int second_node_orig_state,
276  SparseMatrixIndex const & second_node_orig_state_sparse_info,
277  int first_node_state_offset_minus_1,
278  int second_node_curr_num_states_per_aatype,
279  int aa_neighbor_offset,
280  ObjexxFCL::FArray1< core::PackerEnergy > & edge_energy_table
281  );
282 
283  static
284  inline
286  int first_node_orig_state,
287  int second_node_alt_state,
288  SparseMatrixIndex const & first_node_orig_state_sparse_info,
289  SparseMatrixIndex const & second_node_alternate_state_sparse_info,
290  int second_node_alt_state_num_states_per_aatype,
291  int aa_neighbor_offset,
292  ObjexxFCL::FArray1< core::PackerEnergy > & edge_energy_table
293  );
294 
295  inline void acknowledge_substitution(
296  int substituted_node_index,
297  core::PackerEnergy const curr_state_energy,
298  int nodes_new_state,
299  SparseMatrixIndex const & nodes_new_state_sparse_info
300  );
301 
302  /// @brief Returns the array of offsets into the sparse two-body energy table
303  /// for amino-acid neighbors. Used in transferring information from edges
304  /// onto nodes for cache efficiency.
305  ObjexxFCL::FArray2D_int const & get_offsets_for_aatypes( );
306 
307  /// @brief returns an FArray of the number of states for each amino acid type for the
308  /// higher-indexed node
310 
311  int get_two_body_table_size() const;
313 
314  virtual unsigned int count_static_memory() const;
315  virtual unsigned int count_dynamic_memory() const;
316 
317  ObjexxFCL::FArray2D< core::PackerEnergy >
319  int node1aa,
320  int node2aa
321  ) const;
322 
323 /*
324  void read_edge_energies_from_file( std::ifstream & infile );
325  static void skip_over_edge_energies_from_file
326  (
327  std::ifstream & infile,
328  int num_aa,
329  ObjexxFCL::FArray1_int & num_file_states_for_aa_node1,
330  ObjexxFCL::FArray1_int & num_file_states_for_aa_node2
331  );
332  void write_edge_energies_to_file( std::ofstream & outfile );
333 */
334 
335  virtual void set_edge_weight( Real weight );
336 
337 protected:
338 
339  //Hooks for SASAEdge< V, E, G > class
342  bool pd_edge_table_all_zeros() const;
343 
344 private:
345 
346  inline
347  PDNode const * get_pd_node( int index ) const;
348 
349  inline
350  PDNode * get_pd_node( int index );
351 
352  inline
353  PDInteractionGraph const * get_pdig_owner() const;
354 
355  inline
357 
360 
361 private: // Data
362 
366 
367  //no default constructor, uncopyable
368  PDEdge();
369  PDEdge( PDEdge const & );
370  PDEdge & operator = ( PDEdge const & );
371 };
372 
374 {
375 public:
376  PDInteractionGraph(int num_nodes);
377  virtual void initialize( rotamer_set::RotamerSetsBase const & rot_sets );
378 
379  virtual core::PackerEnergy get_one_body_energy_for_node_state( int node, int state);
380 
381  /// @brief sets the number of amino acid types present.
382  //virtual void set_num_aatypes(int);
383  virtual int get_num_aatypes() const;
384 
385  virtual void add_edge(int node1, int node2);
386 
387  virtual void blanket_assign_state_0();
388  virtual core::PackerEnergy set_state_for_node(int node_ind, int new_state);
389  virtual core::PackerEnergy set_network_state( ObjexxFCL::FArray1_int & node_states);
390  virtual void consider_substitution
391  (
392  int node_ind,
393  int new_state,
394  core::PackerEnergy & delta_energy,
395  core::PackerEnergy & prev_energy_for_node
396  );
398  /// @ brief O(1) total energy report. Protected read access for derived classes.
400 
401  /// @brief older scheme for memory accounting -- replace this asap
402  /// @brief returns the number of floats used in all edge two-body energy tables
403  virtual int get_edge_memory_usage() const;
404  /// @brief outputs the current state for each node, useful for debugging
405  virtual void print_current_state_assignment() const;
407 
408  virtual unsigned int count_static_memory() const;
409  virtual unsigned int count_dynamic_memory() const;
410 
411 
412 /*
413  //Methods for I/O
414  void prepare_to_read_energies_from_file();
415  void declare_finished_reading_from_file();
416  void set_num_file_aatypes( int num_file_aatypes );
417  int get_num_file_aatypes();
418  void set_num_nodes_in_file( int num_nodes_in_file );
419  void set_node_correspondence( int instance_node, int file_node );
420  void set_num_states_for_file_node(int node, int num_file_states);
421  void set_aa_for_file_node_state( int file_node, int file_state, int state_aa );
422  void set_correspondence_for_state(int node, int state, int file_state);
423  int get_correspondence_for_state(int node, int state );
424  bool get_node_corresponded_to_file_node( int node );
425 
426  int get_num_rots_absent_from_file(int node);
427  void get_absent_rots(int node, ObjexxFCL::FArray1_int & rots_absent );
428 
429  void read_edge_energies_from_file( std::ifstream & infile );
430  void write_edge_energies_to_file( std::ofstream & outfile );
431 */
432 
433  /// @brief a user may define subsets of the vertex set for which they would like to
434  /// know the internal energy sum.
435  virtual core::PackerEnergy get_energy_sum_for_vertex_group( int group_id );
436 
437  // <directed_design>
438  core::PackerEnergy get_weighted_energy(ObjexxFCL::FArray2D< core::PackerEnergy > const &weights) const;
439  core::PackerEnergy set_network_state( ObjexxFCL::FArray1_int & node_states, ObjexxFCL::FArray2D< core::PackerEnergy > const& weights);
440  virtual void consider_substitution
441  (
442  int node_ind,
443  int new_state,
444  core::PackerEnergy & deltaE_unweighted,
445  core::PackerEnergy & prevE_unweighted, // !!! remember this is the energy just for this node
446  core::PackerEnergy & deltaE_weighted,
447  core::PackerEnergy & prevE_weighted,
448  ObjexxFCL::FArray2D< core::PackerEnergy > const& weights
449  );
450  virtual core::PackerEnergy commit_considered_substitution(ObjexxFCL::FArray2D< core::PackerEnergy > const& weights);
451  // </directed_design>
452 
453  /// @brief Override the InteractionGraphBase class's implementation of this function
454  /// to return 'true'.
455  virtual
456  bool
458 
459  virtual
461  int node_ind,
462  int node_state
463  ) const;
464 
465  virtual
466  ObjexxFCL::FArray2D< core::PackerEnergy >
468  int node1,
469  int node2,
470  int node1aa,
471  int node2aa
472  ) const;
473 
474 protected:
475  virtual unsigned int getMemoryUsageInBytes() const;
476 
477  /// @brief factory method that instantiates a PDNode.
478  virtual NodeBase* create_new_node( int node_index, int num_states);
479  /// @brief factory method that instantiates a PDEdge
480  virtual EdgeBase* create_new_edge( int index1, int index2);
481 
482  //Hooks for SASAInterationGraph< V, E, G >
484  /// @brief removes numerical drift that can accumulate over the course of
485  /// many state assignment changes within simulated annealing
487 
488  inline
489  PDNode* get_pd_node(int index) const
490  { return (PDNode*) get_node( index );}
491 
492  inline
493  PDEdge const * get_pd_edge( int node1, int node2 ) const
494  {
495  return (PDEdge const *) find_edge( node1, node2 );
496  }
497 
498  inline
499  PDEdge * get_pd_edge( int node1, int node2 )
500  {
501  return (PDEdge *) find_edge( node1, node2 );
502  }
503 
504 
505 private:
511 
512 
513  //variables for I/O
516  ObjexxFCL::FArray1D_int file_node_2_instance_node_;
517  ObjexxFCL::FArray1D_int instance_node_2_file_node_;
518  ObjexxFCL::FArray1D< ObjexxFCL::FArray1D_int > aa_types_for_states_on_file_nodes_;
519  ObjexxFCL::FArray1D< ObjexxFCL::FArray1D_int > num_file_states_for_aa_for_node_;
520 
521  static const int COMMIT_LIMIT_BETWEEN_UPDATES = 1024; // 2^10
522 
523  //no default constructor, uncopyable
527 };
528 
529 inline
530 PDEdge const *
532 {
533  return static_cast< PDEdge const * > ( get_incident_edge( index ));
534 }
535 
536 inline
537 PDEdge *
539 {
540  return static_cast< PDEdge * > ( get_incident_edge( index ));
541 }
542 
543 inline
544 PDInteractionGraph const *
546 {
547  return static_cast< PDInteractionGraph const * > (get_owner());
548 }
549 
550 inline
553 {
554  return static_cast< PDInteractionGraph * > (get_owner());
555 }
556 
557 
558 inline
559 PDNode const *
560 PDEdge::get_pd_node( int index ) const
561 {
562  return static_cast< PDNode const *> (get_node( index ));
563 }
564 
565 inline
566 PDNode *
568 {
569  return static_cast< PDNode *> (get_node( index ));
570 }
571 
572 inline
573 PDInteractionGraph const *
575 {
576  return static_cast< PDInteractionGraph const * > (get_owner());
577 }
578 
579 inline
582 {
583  return static_cast< PDInteractionGraph * > (get_owner());
584 }
585 
586 /// @brief static method that looks up the two body energy when the
587 /// node with the smaller index on an edge is considering an alternate state
588 ///
589 /// @param first_node_alt_state - [in] - the alternate state for the lower-indexed node
590 /// @param second_node_orig_state - [in] - the current state for the higher-indexed node
591 /// @param second_node_orig_state_sparse_info - [in] - the sparse matrix info for
592 /// the higher-indexed node
593 /// @param first_node_state_offset_minus_1 - [in] - part of the sparse matrix info
594 /// for the lower-indexed node where 1 is subtracted from the state offset.
595 /// @param second_node_num_states_per_aatype - [in] - number of states with current aa
596 /// type for node 2
597 /// @param aa_neighbor_offset - [in] - offset for the amino-acid neighbor pair for
598 /// the sparse two-body energy table
599 /// @param edge_energy_table - [in] - the proxy FArray pointing at the edge table
600 /// connecting the two nodes.
601 ///
602 inline
603 float
605  int first_node_alt_state,
606  int second_node_orig_state,
607  SparseMatrixIndex const & second_node_orig_state_sparse_info,
608  int first_node_state_offset_minus_1,
609  int second_node_curr_num_states_per_aatype,
610  int aa_neighbor_offset,
611  FArray1< core::PackerEnergy > & edge_energy_table
612 )
613 {
614 
615  if (first_node_alt_state == 0 || second_node_orig_state == 0) {
616  return 0.0f;
617  } else {
619  second_node_orig_state_sparse_info,
620  first_node_state_offset_minus_1,
621  second_node_curr_num_states_per_aatype,
622  aa_neighbor_offset,
623  edge_energy_table );
624  }
625 }
626 
627 /// @brief update bookkeeping information when one of the nodes an edge is incident
628 /// upon changes state
629 ///
630 /// @param substituted_node_index - [in] - index of the node that chagned its state
631 /// @param curr_state_energy - [in] - the two body energy given the new state
632 /// @param nodes_new_state - [in] - the state the node just transitioned into
633 /// @param nodes_new_state_sparse_info - [in] - sparse matrix info for the new state
634 ///
635 inline
636 void
638  int substituted_node_index,
639  float const curr_state_energy,
640  int nodes_new_state,
641  SparseMatrixIndex const & nodes_new_state_sparse_info
642 )
643 {
644  int node_substituted = substituted_node_index == get_node_index(0) ? 0 : 1;
645  int node_not_substituted = ! node_substituted;
646 
647  curr_state_energy_ = curr_state_energy;
648 
649  get_pd_node( node_not_substituted )->
650  acknowledge_neighbors_state_substitution (
651  get_edges_position_in_nodes_edge_vector( node_not_substituted ),
653  nodes_new_state,
654  nodes_new_state_sparse_info
655  );
656 
657  return;
658 }
659 
660 /// @brief static method that looks up the two body energy when the
661 /// node with the larger index on an edge is considering an alternate state
662 ///
663 /// @param first_node_orig_state - [in] - the current state for the lower-indexed node
664 /// @param second_node_alt_state - [in] - the alt state for the higher-indexed node
665 /// @param first_node_orig_state_sparse_info - [in] - the sparse matrix info for
666 /// the lower-indexed node
667 /// @param second_node_alt_state_sparse_info - [in] - the sparse matrix info for
668 /// the higher-indexed node
669 /// @param first_node_state_offset_minus_1 - [in] - part of the sparse matrix info
670 /// for the lower-indexed node where 1 is subtracted from the state offset.
671 /// @param second_node_alt_state_num_states_per_aatype - [in] - number of states
672 /// with alternate aa type for node 2
673 /// @param aa_neighbor_offset - [in] - offset for the amino-acid neighbor pair for
674 /// the sparse two-body energy table
675 /// @param edge_energy_table - [in] - the proxy FArray pointing at the edge table
676 /// connecting the two nodes.
677 ///
678 inline
679 float
681  int first_node_orig_state,
682  int second_node_alt_state,
683  SparseMatrixIndex const & first_node_orig_state_sparse_info,
684  SparseMatrixIndex const & second_node_alternate_state_sparse_info,
685  int second_node_alt_state_num_states_per_aatype,
686  int aa_neighbor_offset,
687  FArray1< core::PackerEnergy > & edge_energy_table
688 )
689 {
690 
691  if (first_node_orig_state == 0 || second_node_alt_state == 0) {
692  return 0.0f;
693  } else {
695  first_node_orig_state_sparse_info,
696  second_node_alternate_state_sparse_info,
697  second_node_alt_state_num_states_per_aatype,
698  aa_neighbor_offset,
699  edge_energy_table );
700  }
701 }
702 
703 /// @brief updates bookkeeping arrays for when a neighbor has changed its state
704 ///
705 /// @param edge_to_altered_neighbor - [in] - the index for the edge that connects
706 /// this node to the node that just changed its state
707 /// @param new_edge_energ - [in] - the pair energy between this node in its current
708 /// state and the new state of the node that just changed its state
709 /// @param other_node_new_state - [in] - the state the neighbor just adopted
710 /// @param other_node_new_state_sparse_info - [in] - the sparse-matrix info
711 /// corresponding to the neighbor's new state
712 ///
713 inline
715  int edge_to_altered_neighbor,
716  float new_edge_energy,
717  int other_node_new_state,
718  SparseMatrixIndex const & other_node_new_state_sparse_info
719 )
720 {
721 
723  new_edge_energy - curr_state_two_body_energies_[edge_to_altered_neighbor];
724  curr_state_two_body_energies_[edge_to_altered_neighbor] = new_edge_energy;
725  neighbors_curr_state_[ edge_to_altered_neighbor ] = other_node_new_state;
726  neighbors_curr_state_sparse_info_[ edge_to_altered_neighbor ] =
727  other_node_new_state_sparse_info;
728  return;
729 }
730 
731 /// @detais iterates across the incident edges for a node in two phases:
732 /// in the first phase, it examines edges leading to higher-indexed nodes
733 /// in the second phase, it examines edges leading to smaller-indexed nodes.
734 /// for cache efficiency, all of the amino-acid-neighbor-offset information
735 /// that each edge calculates is stored on the nodes themselves. The edges
736 /// are never touched; rather, their private information is stored on the nodes
737 /// and handed to static member functions of the PDEdge class. This "store
738 /// edge information on the nodes" strategy gives me performance equivalent
739 /// to the previous energy2b lookup tables.
740 ///
741 /// @param alternate_state - [in] - the alternate state to consider
742 /// @param previous_energy_for_node - [out] - the old energy1b/energy2b sum for this
743 /// node; used by simulate annealing.
744 inline
745 float
747  int alternate_state,
748  float & prev_energy_for_node
749 )
750 {
751 
753  //std::cout << "proj_deltaE: node - " << get_node_index() << " alt state " << alternate_state << "...";
754 
755  alternate_state_ = alternate_state;
758  //std::cout << "alternate_state_one_body_energy_: " << alternate_state_one_body_energy_ << std::endl;
760  prev_energy_for_node = curr_state_total_energy_;
761 
762  int alt_state_num_states_per_aa_type =
764  int alt_state_for_aa_type_minus_1 =
766  int nstates_offset =
768  int aa_neighb_linear_index_offset = aa_offsets_for_edges_.
769  index(1, 1, alt_state_sparse_mat_info_.get_aa_type() ) - 1;
770 
771 
772  for (int ii = 1; ii <= get_num_edges_to_smaller_indexed_nodes();
773  ++ii, aa_neighb_linear_index_offset += num_aa_types_) {
774 
777  get_alternate_state_energy_second_node(
782  alt_state_num_states_per_aa_type,
784  aa_neighb_linear_index_offset +
785  neighbors_curr_state_sparse_info_[ii].get_aa_type()
786  ],
788  );
790  //if ( alternate_state_two_body_energies_[ ii ] != 0.0 ) {
791  // std::cout << "( " << get_index_of_adjacent_node( ii ) << " , " << alternate_state_two_body_energies_[ ii ] <<" ) ";
792  //}
793  }
794 
795  for (int ii = get_num_edges_to_smaller_indexed_nodes() + 1;
796  ii <= get_num_incident_edges();
797  ++ii, aa_neighb_linear_index_offset += num_aa_types_,
798  nstates_offset += num_aa_types_) {
799 
802  get_alternate_state_energy_first_node(
805  //alt_state_sparse_mat_info_,
807  alt_state_for_aa_type_minus_1,
809  nstates_offset +
810  neighbors_curr_state_sparse_info_[ii].get_aa_type()
811  ],
813  aa_neighb_linear_index_offset +
814  neighbors_curr_state_sparse_info_[ii].get_aa_type()
815  ],
817  );
819  //if ( alternate_state_two_body_energies_[ ii ] != 0.0 ) {
820  // std::cout << "( " << get_index_of_adjacent_node( ii ) << " , " << alternate_state_two_body_energies_[ ii ] <<" ) ";
821  //}
822  }
823 
824  //std::cerr<< "..done" << std::endl;
825 
827 
828 }
829 
830 
831 } //end namespace interaction_graph
832 } //end namespace pack
833 } //end namespace core
834 
835 #endif //SPARSE_PD_INTERACTION_GRAPH_H