Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LazyInteractionGraph.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/LazyInteractionGraph.hh
11 /// @brief Interaction graph that computes each rotamer pair energy at most once
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 #ifndef INCLUDED_core_pack_interaction_graph_LazyInteractionGraph_hh
15 #define INCLUDED_core_pack_interaction_graph_LazyInteractionGraph_hh
16 
17 // Unit headers
19 
20 // Package Headers
23 
24 #include <ObjexxFCL/FArray3D.hh>
25 
26 #include <utility/vector1.hh>
27 #include <ObjexxFCL/FArray1A.hh>
28 
29 
30 //Lazy interaction graph uses as much memory as a PDInteractionGraph, but it evaulates
31 //rotamer pair energies only as it needs them and stores them for later, instead
32 //of requiring an extensive precomputation phase.
33 
34 namespace core {
35 namespace pack {
36 namespace interaction_graph {
37 
38 class LazyNode : public OnTheFlyNode
39 {
40 public:
41  LazyNode(
42  InteractionGraphBase * owner,
43  int node_id,
44  int num_states
45  );
46 
47  virtual ~LazyNode();
48 
49  //virtual methods inherited from NodeBase
50  virtual void prepare_for_simulated_annealing();
51  virtual void print() const;
52  virtual bool state_unassigned() const { return current_state_ == 0;}
54 
55  void assign_zero_state();
56  void assign_state(int new_state);
57  void partial_assign_state( int new_state );
59 
60  inline
61  int get_current_state() const { return current_state_; }
62 
63  inline
65  { return curr_state_one_body_energy_; }
66 
67  inline
69  (
70  int alternate_state,
71  core::PackerEnergy & prev_node_energy
72  );
73 
75  core::PackerEnergy compute_pair_energy_for_current_state( int edge_making_energy_request );
76 
77  inline
79  int edge_to_altered_neighbor,
80  core::PackerEnergy new_edge_energy,
81  int other_node_new_state,
82  SparseMatrixIndex const & other_node_new_state_sparse_info
83  );
84 
85  void
87  int edge_to_altered_neighbor,
88  int other_node_new_,
89  SparseMatrixIndex const & other_node_new_state_sparse_info
90  );
91 
92  inline
93  SparseMatrixIndex const &
95 
96  void print_internal_energies() const;
97 
99 
100  virtual unsigned int count_static_memory() const;
101  virtual unsigned int count_dynamic_memory() const;
102 
103  virtual
104  int aatype_for_state( int state ) const;
105 
106 protected:
107 
108  /*inline
109  rotamer_trie const &
110  get_current_rotamer()
111  {
112  return get_rotamer( current_state_ );
113  }*/
114 
115  /*
116  inline
117  core::PackerEnergy &
118  get_curr_rotamer_actcoords();
119  */
120 
121  //Hooks for SASANode< V, E, G > class
124  void set_alternate_state( int alt ) { alternate_state_ = alt; }
125  int get_alternate_state() const { return alternate_state_; }
126  void calc_deltaEpd( int alternate_state );
128  {
130  }
131 
132 
133 private:
134 
135  //void
136  //set_alt_aa_offsets_from_edge(int edge_index, FArray2D_int const & offsets);
137 
139 
140  /// Pointer Downcasts
141  inline LazyEdge const * get_incident_lazy_edge( int index ) const;
142  inline LazyEdge * get_incident_lazy_edge( int index ) ;
143  inline LazyNode const * get_adjacent_lazy_node( int index ) const;
144  inline LazyNode * get_adjacent_lazy_node( int index ) ;
145  inline LazyInteractionGraph const * get_lazy_ig_owner() const;
147 
148 private:
149  // DATA
150 
151  FArray3D_int aa_offsets_for_edges_;
153  std::vector< FArray1A< core::PackerEnergy > > edge_matrix_ptrs_;
154  std::vector< int > neighbors_curr_state_;
155  std::vector< SparseMatrixIndex > neighbors_curr_state_sparse_info_;
156 
161  std::vector< core::PackerEnergy > curr_state_two_body_energies_;
162 
167  std::vector< core::PackerEnergy > alternate_state_two_body_energies_;
168 
171 
172  //no default constructor, uncopyable
173  LazyNode();
174  LazyNode( LazyNode const & );
175  LazyNode & operator = ( LazyNode const & );
176 
177 };
178 
179 class LazyEdge : public OnTheFlyEdge
180 {
181 public:
182  LazyEdge(
183  InteractionGraphBase* owner,
184  int first_node_ind,
185  int second_node_ind
186  );
187 
188  virtual ~LazyEdge();
189 
190  virtual
191  void
193  FArray2_bool const &
194  );
195 
196  virtual
197  void force_aa_neighbors( int node1aa, int node2aa);
198 
199  virtual
200  void force_all_aa_neighbors();
201 
202  virtual
203  bool
205  int node1aa,
206  int node2aa
207  ) const;
208 
209  virtual core::PackerEnergy get_two_body_energy( int const node1state, int const node2state) const;
210 
211  //virtual methods inherited from EdgeBase
212  virtual void declare_energies_final();
213  virtual void prepare_for_simulated_annealing();
214 
216 
218  int node_ind,
219  int new_state,
220  SparseMatrixIndex const & new_state_sparse_info,
221  core::PackerEnergy & new_energy
222  );
223  void acknowledge_state_zeroed( int node_ind );
224 
226  int node_ind,
227  int new_state,
228  SparseMatrixIndex const & new_state_sparse_info
229  );
231 
232  static
233  inline
235  int first_node_alt_state,
236  int second_node_orig_state,
237  SparseMatrixIndex const & second_node_orig_state_sparse_info,
238  int first_node_state_offset_minus_1,
239  int second_node_curr_num_states_per_aatype,
240  int aa_neighbor_offset,
241  FArray1< core::PackerEnergy > & edge_energy_table
242  );
243 
244  static
245  inline
247  int first_node_orig_state,
248  int second_node_alt_state,
249  SparseMatrixIndex const & first_node_orig_state_sparse_info,
250  SparseMatrixIndex const & second_node_alternate_state_sparse_info,
251  int second_node_alt_state_num_states_per_aatype,
252  int aa_neighbor_offset,
253  FArray1< core::PackerEnergy > & edge_energy_table
254  );
255 
256  static
257  inline
259  //int first_node_alt_state,
260  //int second_node_orig_state,
261  SparseMatrixIndex const & second_node_orig_state_sparse_info,
262  int first_node_state_offset_minus_1,
263  int second_node_curr_num_states_per_aatype,
264  int aa_neighbor_offset,
265  FArray1< core::PackerEnergy > & edge_energy_table,
266  core::PackerEnergy interaction_energy
267  );
268 
269 
270  static
271  inline
273  //int first_node_orig_state,
274  //int second_node_alt_state,
275  SparseMatrixIndex const & first_node_orig_state_sparse_info,
276  SparseMatrixIndex const & second_node_alternate_state_sparse_info,
277  int second_node_alt_state_num_states_per_aatype,
278  int aa_neighbor_offset,
279  FArray1< core::PackerEnergy > & edge_energy_table,
280  core::PackerEnergy interaction_energy
281  );
282 
283  inline
285  int substituted_node_index,
286  core::PackerEnergy const curr_state_energy,
287  int nodes_new_state,
288  SparseMatrixIndex const & nodes_new_state_sparse_info
289  );
290 
291  void set_edge_weight( Real weight );
292 
294  int get_two_body_table_size() const;
295 
296  void print_current_energy() const;
297 
298  bool build_sc_only_rotamer() { return true;}
299 
300  FArray2D_int const & get_offsets_for_aatypes( );
302 
303  ObjexxFCL::FArray2D< core::PackerEnergy >
305  int node1aa,
306  int node2aa
307  ) const;
308 
309  static core::PackerEnergy const NOT_YET_COMPUTED_ENERGY; //an energy lower than any RPE could ever be
310 
311  virtual unsigned int count_static_memory() const;
312  virtual unsigned int count_dynamic_memory() const;
313 
314 protected:
315 
316  //Hooks for SASAEdge< V, E, G > class
319  bool pd_edge_table_all_zeros() const { return false;}
320 
321 private:
323  int nodes_states[ 2 ],
324  SparseMatrixIndex sparse_matrix_indices[ 2 ]
325  );
326 
327  inline LazyNode const * get_lazy_node( int index ) const;
328  inline LazyNode * get_lazy_node( int index );
329  inline LazyInteractionGraph const * get_lazy_ig_owner() const;
331 
332  void
333  wipe_two_body_energies_for_node_state( int node, int state );
334 
339 
340  //no default constructor, uncopyable
341  LazyEdge();
342  LazyEdge( LazyEdge const & );
343  LazyEdge & operator = ( LazyEdge const & );
344 
345 };
346 
348 {
349 public:
350  LazyInteractionGraph( int numNodes );
351  virtual ~LazyInteractionGraph();
352 
353  //virtual methods inherited from InteractionGraphBase
354  virtual void blanket_assign_state_0();
355  virtual core::PackerEnergy set_state_for_node(int node_ind, int new_state);
356  virtual core::PackerEnergy set_network_state( FArray1_int & node_states);
357  virtual void consider_substitution(
358  int node_ind,
359  int new_state,
360  core::PackerEnergy & delta_energy,
361  core::PackerEnergy & prev_energy_for_node
362  );
365  virtual int get_edge_memory_usage() const;
366  virtual void print_current_state_assignment() const;
367  virtual void set_errorfull_deltaE_threshold( core::PackerEnergy deltaE );
368  virtual core::PackerEnergy get_energy_sum_for_vertex_group( int group_id );
369 
370  /// @brief Override the FixedBBInteractionGraph class's implementation of this function
371  /// to return 'true'.
372  virtual
373  bool
375 
376  virtual
378  int node_ind,
379  int node_state
380  ) const;
381 
382  virtual
383  ObjexxFCL::FArray2D< core::PackerEnergy >
385  int node1,
386  int node2,
387  int node1aa,
388  int node2aa
389  ) const;
390 
391  virtual unsigned int count_static_memory() const;
392  virtual unsigned int count_dynamic_memory() const;
393 
394 protected:
395 
396  virtual NodeBase* create_new_node( int node_index, int num_states);
397  virtual EdgeBase* create_new_edge( int index1, int index2);
398 
399  //Hooks for SASAInterationGraph< V, E, G >
402 
403  inline
404  LazyNode const * get_lazy_node(int index) const
405  {
406  return static_cast< LazyNode const * > (get_node( index ));
407  }
408 
409  inline
410  LazyNode * get_lazy_node(int index)
411  {
412  return static_cast< LazyNode * > (get_node( index ));
413  }
414 
415  inline
416  LazyEdge const * get_lazy_edge( int node1, int node2 ) const
417  {
418  return static_cast< LazyEdge const * > (find_edge( node1, node2 ));
419  }
420 
421  inline
422  LazyEdge * get_lazy_edge( int node1, int node2 )
423  {
424  return static_cast< LazyEdge * > (find_edge( node1, node2 ));
425  }
426 
427 private:
433 
434  static const int COMMIT_LIMIT_BETWEEN_UPDATES = 1024; // 2^10
435 
436  //no default constructor, uncopyable
440 
441 };
442 
443 inline
444 LazyEdge const * LazyNode::get_incident_lazy_edge( int index ) const
445 {
446  return static_cast< LazyEdge const * > (get_incident_edge( index ));
447 }
448 
449 inline
451 {
452  return static_cast< LazyEdge * > (get_incident_edge( index ));
453 }
454 
455 inline
456 LazyNode const * LazyNode::get_adjacent_lazy_node( int index ) const
457 {
458  return static_cast< LazyNode const * > (get_adjacent_node( index ));
459 }
460 
461 inline
463 {
464  return static_cast< LazyNode * > (get_adjacent_node( index ));
465 }
466 
467 inline
469 {
470  return static_cast< LazyInteractionGraph const * > (get_owner());
471 }
472 
473 inline
475 {
476  return static_cast< LazyInteractionGraph * > (get_owner());
477 }
478 
479 
480 inline
481 LazyNode const * LazyEdge::get_lazy_node( int index ) const
482 {
483  return static_cast< LazyNode const * > (get_node( index ));
484 }
485 
486 inline
488 {
489  return static_cast< LazyNode * > (get_node( index ));
490 }
491 
492 inline
494 {
495  return static_cast< LazyInteractionGraph const * > (get_owner());
496 }
497 
498 inline
500 {
501  return static_cast< LazyInteractionGraph * > (get_owner());
502 }
503 
504 ////////////////////////////////////////////////////////////////////////////////
505 /// @begin LazyEdge::acknowledge_substitution
506 ///
507 /// @brief
508 ///
509 /// @detailed
510 ///
511 /// @param
512 ///
513 /// @global_read
514 ///
515 /// @global_write
516 ///
517 /// @remarks
518 ///
519 /// @references
520 ///
521 /// @authors apl
522 ///
523 /// @last_modified
524 ////////////////////////////////////////////////////////////////////////////////
525 inline
526 void
528  int substituted_node_index,
529  core::PackerEnergy const curr_state_energy,
530  int nodes_new_state,
531  SparseMatrixIndex const & nodes_new_state_sparse_info
532 )
533 {
534  int node_substituted = substituted_node_index == get_node_index(0) ? 0 : 1;
535  int node_not_substituted = ! node_substituted;
536 
537  curr_state_energy_ = curr_state_energy;
538 
540  get_edges_position_in_nodes_edge_vector( node_not_substituted ),
542  nodes_new_state,
543  nodes_new_state_sparse_info
544  );
545 
546  return;
547 }
548 
549 ////////////////////////////////////////////////////////////////////////////////
550 /// @begin LazyNode::acknowledge_neighbors_state_substitution
551 ///
552 /// @brief
553 ///
554 /// @detailed
555 ///
556 /// @param
557 ///
558 /// @global_read
559 ///
560 /// @global_write
561 ///
562 /// @remarks
563 ///
564 /// @references
565 ///
566 /// @authors apl
567 ///
568 /// @last_modified
569 ////////////////////////////////////////////////////////////////////////////////
570 inline
571 void
573  int edge_to_altered_neighbor,
574  core::PackerEnergy new_edge_energy,
575  int other_node_new_state,
576  SparseMatrixIndex const & other_node_new_state_sparse_info
577 )
578 {
580  new_edge_energy - curr_state_two_body_energies_[edge_to_altered_neighbor];
581  curr_state_two_body_energies_[edge_to_altered_neighbor] = new_edge_energy;
582  neighbors_curr_state_[ edge_to_altered_neighbor ] = other_node_new_state;
583  neighbors_curr_state_sparse_info_[ edge_to_altered_neighbor ] =
584  other_node_new_state_sparse_info;
585  return;
586 }
587 
588 ////////////////////////////////////////////////////////////////////////////////
589 /// @begin LazyEdge::store_interaction_energy_first_node
590 ///
591 /// @brief
592 ///
593 /// @detailed
594 ///
595 /// @param
596 ///
597 /// @global_read
598 ///
599 /// @global_write
600 ///
601 /// @remarks
602 ///
603 /// @references
604 ///
605 /// @authors apl
606 ///
607 /// @last_modified
608 ////////////////////////////////////////////////////////////////////////////////
609 inline
610 void
612  SparseMatrixIndex const & second_node_orig_state_sparse_info,
613  int first_node_state_offset_minus_1,
614  int second_node_curr_num_states_per_aatype,
615  int aa_neighbor_offset,
616  FArray1< core::PackerEnergy > & edge_energy_table,
617  core::PackerEnergy interaction_energy
618 )
619 {
620 
621  //assert(first_node_alt_state != 0 && second_node_orig_state != 0);
623  second_node_orig_state_sparse_info,
624  first_node_state_offset_minus_1,
625  second_node_curr_num_states_per_aatype,
626  aa_neighbor_offset,
627  edge_energy_table,
628  interaction_energy);
629 }
630 
631 ////////////////////////////////////////////////////////////////////////////////
632 /// @begin LazyEdge::store_interaction_energy_second_node
633 ///
634 /// @brief
635 ///
636 /// @detailed
637 ///
638 /// @param
639 ///
640 /// @global_read
641 ///
642 /// @global_write
643 ///
644 /// @remarks
645 ///
646 /// @references
647 ///
648 /// @authors apl
649 ///
650 /// @last_modified
651 ////////////////////////////////////////////////////////////////////////////////
652 inline
653 void
655  SparseMatrixIndex const & first_node_orig_state_sparse_info,
656  SparseMatrixIndex const & second_node_alternate_state_sparse_info,
657  int second_node_alt_state_num_states_per_aatype,
658  int aa_neighbor_offset,
659  FArray1< core::PackerEnergy > & edge_energy_table,
660  core::PackerEnergy interaction_energy
661 )
662 {
663  //assert(first_node_orig_state != 0 && second_node_alt_state != 0);
665  first_node_orig_state_sparse_info,
666  second_node_alternate_state_sparse_info,
667  second_node_alt_state_num_states_per_aatype,
668  aa_neighbor_offset,
669  edge_energy_table,
670  interaction_energy);
671 }
672 
673 ////////////////////////////////////////////////////////////////////////////////
674 /// @begin LazyEdge::get_alternate_state_energy_second_node
675 ///
676 /// @brief
677 ///
678 /// @detailed
679 ///
680 /// @param
681 ///
682 /// @global_read
683 ///
684 /// @global_write
685 ///
686 /// @remarks
687 ///
688 /// @references
689 ///
690 /// @authors apl
691 ///
692 /// @last_modified
693 ////////////////////////////////////////////////////////////////////////////////
694 inline
697  int first_node_orig_state,
698  int second_node_alt_state,
699  SparseMatrixIndex const & first_node_orig_state_sparse_info,
700  SparseMatrixIndex const & second_node_alternate_state_sparse_info,
701  int second_node_alt_state_num_states_per_aatype,
702  int aa_neighbor_offset,
703  FArray1< core::PackerEnergy > & edge_energy_table
704 )
705 {
706 
707  if (first_node_orig_state == 0 || second_node_alt_state == 0) {
708  return core::PackerEnergy( 0.0 );
709  } else {
711  first_node_orig_state_sparse_info,
712  second_node_alternate_state_sparse_info,
713  second_node_alt_state_num_states_per_aatype,
714  aa_neighbor_offset,
715  edge_energy_table );
716  }
717 }
718 
719 ////////////////////////////////////////////////////////////////////////////////
720 /// @begin LazyNode::project_deltaE_for_substitution
721 ///
722 /// @brief
723 ///
724 /// @detailed
725 ///
726 /// @param
727 ///
728 /// @global_read
729 ///
730 /// @global_write
731 ///
732 /// @remarks
733 ///
734 /// @references
735 ///
736 /// @authors apl
737 ///
738 /// @last_modified
739 ////////////////////////////////////////////////////////////////////////////////
740 inline
743 (
744  int alternate_state,
745  core::PackerEnergy & prev_node_energy
746 )
747 {
748  alternate_state_is_being_considered_ = true;
749  //procrastinated_ = false;
750  //std::cout << "proj_deltaE: node - " << get_node_index()
751  // << " alt state " << alternate_state << "...";
752 
753  alternate_state_ = alternate_state;
754 
755  alt_state_sparse_mat_info_ = get_sparse_mat_info_for_state( alternate_state );
756  alternate_state_one_body_energy_ = get_one_body_energy( alternate_state );
757  alternate_state_total_energy_ = alternate_state_one_body_energy_;
758  prev_node_energy = curr_state_total_energy_;
759 
760  int aa_neighb_linear_index_offset = aa_offsets_for_edges_.
761  index(1, 1, alt_state_sparse_mat_info_.get_aa_type() ) - 1;
762 
763  int alt_state_num_states_per_aa_type =
764  get_num_states_for_aa_type( alt_state_sparse_mat_info_.get_aa_type() );
765  int alt_state_for_aa_type_minus_1 =
766  alt_state_sparse_mat_info_.get_state_ind_for_this_aa_type() - 1;
767  int nstates_offset =
768  num_states_for_aa_type_for_higher_indexed_neighbor_.index(1,1) - 1;
769 
770  for (int ii = 1; ii <= get_num_edges_to_smaller_indexed_nodes();
771  ++ii, aa_neighb_linear_index_offset += get_num_aa_types()) {
772 
773  alternate_state_two_body_energies_[ ii ] =
774  get_incident_lazy_edge(ii)->
775  get_alternate_state_energy_second_node(
776  neighbors_curr_state_[ii],
777  alternate_state_,
778  neighbors_curr_state_sparse_info_[ ii ],
779  alt_state_sparse_mat_info_,
780  alt_state_num_states_per_aa_type,
781  aa_offsets_for_edges_[
782  aa_neighb_linear_index_offset +
783  neighbors_curr_state_sparse_info_[ii].get_aa_type()
784  ],
785  edge_matrix_ptrs_[ii]
786  );
787  }
788 
789  for (int ii = get_num_edges_to_smaller_indexed_nodes() + 1;
790  ii <= get_num_incident_edges();
791  ++ii, aa_neighb_linear_index_offset += get_num_aa_types(),
792  nstates_offset += get_num_aa_types()) {
793  alternate_state_two_body_energies_[ ii ] =
794  get_incident_lazy_edge(ii)->
795  get_alternate_state_energy_first_node(
796  alternate_state_,
797  neighbors_curr_state_[ii],
798  neighbors_curr_state_sparse_info_[ii],
799  alt_state_for_aa_type_minus_1,
800  num_states_for_aa_type_for_higher_indexed_neighbor_[
801  nstates_offset +
802  neighbors_curr_state_sparse_info_[ii].get_aa_type()
803  ],
804  aa_offsets_for_edges_[
805  aa_neighb_linear_index_offset +
806  neighbors_curr_state_sparse_info_[ii].get_aa_type()
807  ],
808  edge_matrix_ptrs_[ii]
809  );
810  }
811 
812  bool all_energies_computed = true;
813  for ( int ii = 1; ii <= get_num_incident_edges(); ++ii ) {
814  alternate_state_total_energy_ += alternate_state_two_body_energies_[ ii ];
815  if ( alternate_state_two_body_energies_[ ii ] == LazyEdge::NOT_YET_COMPUTED_ENERGY ) {
816  all_energies_computed = false;
817  }
818  }
819  if ( all_energies_computed ) {
820  return alternate_state_total_energy_ - curr_state_total_energy_;
821  }
822 
823  aa_neighb_linear_index_offset = aa_offsets_for_edges_.
824  index(1, 1, alt_state_sparse_mat_info_.get_aa_type() ) - 1;
825  nstates_offset =
826  num_states_for_aa_type_for_higher_indexed_neighbor_.index(1,1) - 1;
827 
828  alternate_state_total_energy_ = alternate_state_one_body_energy_;
829 
830  for (int ii = 1; ii <= get_num_incident_edges(); ++ii, aa_neighb_linear_index_offset += get_num_aa_types()) {
831  if ( alternate_state_two_body_energies_[ ii ] == LazyEdge::NOT_YET_COMPUTED_ENERGY ) {
832 
833  alternate_state_two_body_energies_[ ii ] = compute_rotamer_pair_energy(
834  ii,
835  alternate_state_,
836  neighbors_curr_state_[ ii ]
837  );
838 
839  if ( ii <= get_num_edges_to_smaller_indexed_nodes() ) {
841  neighbors_curr_state_sparse_info_[ ii ],
842  alt_state_sparse_mat_info_,
843  alt_state_num_states_per_aa_type,
844  aa_offsets_for_edges_[
845  aa_neighb_linear_index_offset +
846  neighbors_curr_state_sparse_info_[ii].get_aa_type()
847  ],
848  edge_matrix_ptrs_[ii],
849  alternate_state_two_body_energies_[ii]
850  );
851  } else {
853  neighbors_curr_state_sparse_info_[ii],
854  alt_state_for_aa_type_minus_1,
855  num_states_for_aa_type_for_higher_indexed_neighbor_[
856  nstates_offset +
857  neighbors_curr_state_sparse_info_[ii].get_aa_type()
858  ],
859  aa_offsets_for_edges_[
860  aa_neighb_linear_index_offset +
861  neighbors_curr_state_sparse_info_[ii].get_aa_type()
862  ],
863  edge_matrix_ptrs_[ii],
864  alternate_state_two_body_energies_[ ii ]
865  );
866  }
867  }
868  alternate_state_total_energy_ += alternate_state_two_body_energies_[ ii ];
869  if ( ii > get_num_edges_to_smaller_indexed_nodes() ) {
870  nstates_offset += get_num_aa_types();
871  }
872  }
873 
874  //std::cout << " " << (double) num_rpe_calcs_this_sub / get_num_incident_edges();
875 
876  return alternate_state_total_energy_ - curr_state_total_energy_;
877 
878 }
879 
880 ////////////////////////////////////////////////////////////////////////////////
881 /// @begin LazyEdge::get_alternate_state_energy_first_node
882 ///
883 /// @brief
884 ///
885 /// @detailed
886 ///
887 /// @param
888 ///
889 /// @global_read
890 ///
891 /// @global_write
892 ///
893 /// @remarks
894 ///
895 /// @references
896 ///
897 /// @authors apl
898 ///
899 /// @last_modified
900 ////////////////////////////////////////////////////////////////////////////////
901 inline
904  int first_node_alt_state,
905  int second_node_orig_state,
906  SparseMatrixIndex const & second_node_orig_state_sparse_info,
907  int first_node_state_offset_minus_1,
908  int second_node_curr_num_states_per_aatype,
909  int aa_neighbor_offset,
910  FArray1< core::PackerEnergy > & edge_energy_table
911 
912 )
913 {
914  if ( first_node_alt_state == 0 || second_node_orig_state == 0 ) {
915  return core::PackerEnergy( 0.0 );
916  } else {
918  second_node_orig_state_sparse_info,
919  first_node_state_offset_minus_1,
920  second_node_curr_num_states_per_aatype,
921  aa_neighbor_offset,
922  edge_energy_table );
923  }
924 }
925 
926 ////////////////////////////////////////////////////////////////////////////////
927 /// @begin LazyNode::get_sparse_mat_info_for_curr_state
928 ///
929 /// @brief
930 ///
931 /// @detailed
932 ///
933 /// @param
934 ///
935 /// @global_read
936 ///
937 /// @global_write
938 ///
939 /// @remarks
940 ///
941 /// @references
942 ///
943 /// @authors apl
944 ///
945 /// @last_modified
946 ////////////////////////////////////////////////////////////////////////////////
947 inline
948 SparseMatrixIndex const &
950 {
952 }
953 
954 }
955 }
956 }
957 
958 #endif
959 
960