Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DoubleLazyInteractionGraph.cc
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/DoubleLazyInteractionGraph.cc
11 /// @brief Interaction graph that computes each rotamer pair energy at most once
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 /// Unit headers
16 
17 // Utility headers
18 #include <utility/in_place_list.hh>
19 
20 /// C++ headers
21 #include <iostream>
22 
23 #include <utility/vector0.hh>
24 #include <utility/vector1.hh>
25 
26 
27 namespace core {
28 namespace pack {
29 namespace interaction_graph {
30 
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// @begin DoubleLazyNode::(InteractionGraphBase *, int, int)
34 ///
35 /// @brief
36 /// main constructor, no default or copy constructors
37 ///
38 /// @detailed
39 ///
40 /// @param
41 ///
42 /// @global_read
43 ///
44 /// @global_write
45 ///
46 /// @remarks
47 ///
48 /// @references
49 ///
50 /// @authors apl
51 ///
52 /// @last_modified
53 ////////////////////////////////////////////////////////////////////////////////
55  InteractionGraphBase * owner,
56  int node_id,
57  int num_states
58 ) :
59  OnTheFlyNode( owner, node_id, num_states ),
60  current_state_( 0 ),
61  curr_state_one_body_energy_( 0.0f ),
62  curr_state_total_energy_( 0.0f ),
63  alternate_state_( 0 ),
64  alternate_state_one_body_energy_( 0 ),
65  alternate_state_total_energy_( 0 ),
66  alternate_state_is_being_considered_( false ),
67  procrastinated_( false )
68 {
69 }
70 
72 {}
73 
74 void
76 {
78  /*for (int ii = 1; ii <= get_num_states(); ++ii) {
79  mark_coordinates_current( ii ); /// What did this used to to?
80  }*/
81  return;
82 }
83 
84 void
86 {
87 
88  std::cout << "DoubleLazyNode " << get_node_index() << " with " << get_num_states() << " states" << std::endl;
89  std::cout << "curr_state " << current_state_ << " ";
90  std::cout << "curr_state_sparse_mat_info_ ";
91  std::cout << curr_state_sparse_mat_info_.get_aa_type() << " ";
93  std::cout << "Curr One Body Energy: " << curr_state_one_body_energy_ << std::endl;
94  std::cout << "Curr Two Body Energies:";
95  for (int ii = 1; ii <= get_num_incident_edges(); ++ii) {
96  std::cout << " " << get_index_of_adjacent_node(ii) << ":" << curr_state_two_body_energies_[ ii ];
97  }
98  std::cout << std::endl;
99 
100  if ( ! alternate_state_is_being_considered_ ) return;
101  std::cout << "Alt One Body Energy: " << alternate_state_one_body_energy_ << std::endl;
102  std::cout << "Alt Two Body Energies:";
103  for (int ii = 1; ii <= get_num_incident_edges(); ++ii) {
104  std::cout << " " << get_index_of_adjacent_node(ii) << ":" << alternate_state_two_body_energies_[ ii ];
105  }
106  std::cout << std::endl << "-----------------" << std::endl;
107 
108 
109 }
110 
111 ////////////////////////////////////////////////////////////////////////////////
112 /// @begin DoubleLazyNode::getMemoryUsageInBytes
113 ///
114 /// @brief
115 ///
116 /// @detailed
117 ///
118 /// @param
119 ///
120 /// @global_read
121 ///
122 /// @global_write
123 ///
124 /// @remarks
125 ///
126 /// @references
127 ///
128 /// @authors apl
129 ///
130 /// @last_modified
131 ////////////////////////////////////////////////////////////////////////////////
132 
133 unsigned int
135 {
136  return sizeof( DoubleLazyNode );
137 }
138 
139 unsigned int
141 {
142  unsigned int total_memory = OnTheFlyNode::count_dynamic_memory();
143 
144  total_memory += neighbors_curr_state_.size() * sizeof (int );
145 
146  //total_memory += aa_offsets_for_edges_.size() * sizeof( int );
147  //total_memory += num_states_for_aa_type_for_higher_indexed_neighbor_.size() * sizeof( int );
148  //total_memory += edge_matrix_ptrs_.size() * sizeof( FArray1Da< core::PackerEnergy > );
149  total_memory += neighbors_curr_state_.size() * sizeof( int );
150  total_memory += neighbors_curr_state_sparse_info_.size() * sizeof( SparseMatrixIndex );
151 
152  total_memory += curr_state_two_body_energies_.size() * sizeof( core::PackerEnergy );
153  total_memory += alternate_state_two_body_energies_.size() * sizeof( core::PackerEnergy );
154 
155  return total_memory;
156 }
157 
158 int
160 {
161  return get_sparse_mat_info_for_state( state ).get_aa_type();
162 }
163 
164 ////////////////////////////////////////////////////////////////////////////////
165 /// @begin DoubleLazyNode::assign_zero_state
166 ///
167 /// @brief
168 ///
169 /// @detailed
170 ///
171 /// @param
172 ///
173 /// @global_read
174 ///
175 /// @global_write
176 ///
177 /// @remarks
178 ///
179 /// @references
180 ///
181 /// @authors apl
182 ///
183 /// @last_modified
184 ////////////////////////////////////////////////////////////////////////////////
185 void
187 {
188  current_state_ = 0;
189  alternate_state_ = 0;
191 
193  //fills from [1] to end
194  std::vector< core::PackerEnergy >::iterator position1 = curr_state_two_body_energies_.begin();
195  ++position1;
196  std::fill( position1, curr_state_two_body_energies_.end(), core::PackerEnergy( 0.0 ));
198 
199  for (int ii = 1; ii <= get_num_incident_edges(); ++ii ) {
201  }
202 
203  return;
204 }
205 
206 ////////////////////////////////////////////////////////////////////////////////
207 /// @begin DoubleLazyNode::assign_state
208 ///
209 /// @brief
210 ///
211 /// @detailed
212 ///
213 /// @param
214 ///
215 /// @global_read
216 ///
217 /// @global_write
218 ///
219 /// @remarks
220 ///
221 /// @references
222 ///
223 /// @authors apl
224 ///
225 /// @last_modified
226 ////////////////////////////////////////////////////////////////////////////////
227 void
229 {
230  assert( new_state >= 0 && new_state <= get_num_states());
231 
232  if (new_state == 0) {
234  } else {
235  //std::cout << "assign_state: node - " << get_node_index() <<
236  // " new state " << new_state << "...";
237  current_state_ = new_state;
242 
243  for (int ii = 1; ii <= get_num_incident_edges(); ++ii ) {
245  get_node_index(),
249 
251  }
252  //std::cout<< "..done" << std::endl;
253  }
254  return;
255 }
256 
257 ////////////////////////////////////////////////////////////////////////////////
258 /// @begin DoubleLazyNode::partial_assign_state
259 ///
260 /// @brief
261 ///
262 /// @detailed
263 ///
264 /// @param
265 ///
266 /// @global_read
267 ///
268 /// @global_write
269 ///
270 /// @remarks
271 ///
272 /// @references
273 ///
274 /// @authors apl
275 ///
276 /// @last_modified
277 ////////////////////////////////////////////////////////////////////////////////
278 void
280 {
281  if (new_state == 0 ) {
283  return;
284  }
285 
286  current_state_ = new_state;
289  for (int ii = 1; ii <= get_num_incident_edges(); ++ii ) {
291  get_node_index(),
294  }
296 }
297 
298 
299 ////////////////////////////////////////////////////////////////////////////////
300 /// @begin DoubleLazyNode::complete_state_assignment
301 ///
302 /// @brief
303 ///
304 /// @detailed
305 ///
306 /// @param
307 ///
308 /// @global_read
309 ///
310 /// @global_write
311 ///
312 /// @remarks
313 ///
314 /// @references
315 ///
316 /// @authors apl
317 ///
318 /// @last_modified
319 ////////////////////////////////////////////////////////////////////////////////
321 {
322  if ( current_state_ == 0 ) return;
323 
326  for (int ii = 1; ii <= get_num_incident_edges(); ++ii) {
329  get_energy_following_partial_state_assignment();
331  }
332 }
333 
334 
335 
336 ////////////////////////////////////////////////////////////////////////////////
337 /// @begin DoubleLazyNode::commit_considered_substitution
338 ///
339 /// @brief
340 ///
341 /// @detailed
342 ///
343 /// @param
344 ///
345 /// @global_read
346 ///
347 /// @global_write
348 ///
349 /// @remarks
350 ///
351 /// @references
352 ///
353 /// @authors apl
354 ///
355 /// @last_modified
356 ////////////////////////////////////////////////////////////////////////////////
357 void
359 {
361 
366 
367  //copies from [1] to end
368  std::vector< core::PackerEnergy >::iterator alt_position1 = alternate_state_two_body_energies_.begin();
369  ++alt_position1;
370  std::vector< core::PackerEnergy >::iterator curr_position1 = curr_state_two_body_energies_.begin();
371  ++curr_position1;
372 
373  std::copy( alt_position1,
375  curr_position1 );
376 
377  //if ( procrastinated_ )
378  //{
379  // curr_state_total_energy_ = curr_state_one_body_energy_;
380  // for (int ii = 1; ii <= get_num_incident_edges(); ++ii)
381  // {
382  // if ( curr_state_two_body_energies_[ ii ] == DoubleLazyEdge::NOT_YET_COMPUTED_ENERGY )
383  // {
384  // curr_state_two_body_energies_[ ii ] = compute_pair_energy_for_current_state( ii );
385  // }
386  // curr_state_total_energy_ += curr_state_two_body_energies_[ ii ];
387  // }
388  // procrastinated_ = false;
389  // ++num_procrastinated_committed;
390  //}
391 
392 
393  for ( int ii = 1; ii <= get_num_incident_edges(); ++ii ) {
395  get_node_index(),
399  );
400  }
401 
403  return;
404 }
405 
406 ////////////////////////////////////////////////////////////////////////////////
407 /// @begin DoubleLazyNode::compute_pair_energy_for_current_state
408 ///
409 /// @brief
410 ///
411 /// @detailed
412 ///
413 /// @param
414 ///
415 /// @global_read
416 ///
417 /// @global_write
418 ///
419 /// @remarks
420 ///
421 /// @references
422 ///
423 /// @authors apl
424 ///
425 /// @last_modified
426 ////////////////////////////////////////////////////////////////////////////////
429  int edge_making_energy_request
430 )
431 {
432 
434  edge_making_energy_request,
436  neighbors_curr_state_[ edge_making_energy_request ]
437  );
438 }
439 
440 
441 ////////////////////////////////////////////////////////////////////////////////
442 /// @begin DoubleLazyNode::acknowledge_neighbors_partial_state_substitution
443 ///
444 /// @brief
445 ///
446 /// @detailed
447 ///
448 /// @param
449 ///
450 /// @global_read
451 ///
452 /// @global_write
453 ///
454 /// @remarks
455 ///
456 /// @references
457 ///
458 /// @authors apl
459 ///
460 /// @last_modified
461 ////////////////////////////////////////////////////////////////////////////////
462 void
464  int edge_to_altered_neighbor,
465  int other_node_new_state,
466  SparseMatrixIndex const & other_node_new_state_sparse_info
467 )
468 {
470  curr_state_two_body_energies_[ edge_to_altered_neighbor ] = 0;
471  neighbors_curr_state_[ edge_to_altered_neighbor ] = other_node_new_state;
472  neighbors_curr_state_sparse_info_[ edge_to_altered_neighbor ] =
473  other_node_new_state_sparse_info;
474 }
475 
476 
477 ////////////////////////////////////////////////////////////////////////////////
478 /// @begin DoubleLazyNode::print_internal_energies
479 ///
480 /// @brief
481 ///
482 /// @detailed
483 ///
484 /// @param
485 ///
486 /// @global_read
487 ///
488 /// @global_write
489 ///
490 /// @remarks
491 ///
492 /// @references
493 ///
494 /// @authors apl
495 ///
496 /// @last_modified
497 ////////////////////////////////////////////////////////////////////////////////
498 void
500 {
501  std::cout << "curr_state " << current_state_ << " ";
502  std::cout << "curr_state_sparse_mat_info_ ";
503  std::cout << curr_state_sparse_mat_info_.get_aa_type() << " ";
505  std::cout << "curr_state_one_body_energy_ ";
506  std::cout << curr_state_one_body_energy_ << " ";
507  std::cout << "curr_state_total_energy_" << curr_state_total_energy_ << " ";
508  for (int ii = 1; ii <= get_num_incident_edges(); ++ii) {
509  std::cout << "(" << curr_state_two_body_energies_[ ii ] << ") ";
510  }
511  std::cout << std::endl;
512 }
513 
514 ////////////////////////////////////////////////////////////////////////////////
515 /// @begin DoubleLazyNode::update_internal_energy_sums
516 ///
517 /// @brief
518 ///
519 /// @detailed
520 ///
521 /// @param
522 ///
523 /// @global_read
524 ///
525 /// @global_write
526 ///
527 /// @remarks
528 ///
529 /// @references
530 ///
531 /// @authors apl
532 ///
533 /// @last_modified
534 ////////////////////////////////////////////////////////////////////////////////
535 void
537 {
538  assert( get_edge_vector_up_to_date() );
540  for (int ii = 1; ii <= get_num_incident_edges(); ++ii) {
542  }
544  return;
545 }
546 
547 
548 ////////////////////////////////////////////////////////////////////////////////
549 /// @begin DoubleLazyNode::update_internal_vectors
550 ///
551 /// @brief
552 ///
553 /// @detailed
554 ///
555 /// @param
556 ///
557 /// @global_read
558 ///
559 /// @global_write
560 ///
561 /// @remarks
562 ///
563 /// @references
564 ///
565 /// @authors apl
566 ///
567 /// @last_modified
568 ////////////////////////////////////////////////////////////////////////////////
570 {
574 
575  for ( int ii = 1; ii <= get_num_incident_edges(); ++ii ) {
576  neighbors_curr_state_sparse_info_[ii].set_aa_type( 1 );
577  }
578 
581  return;
582 }
583 
584 // @ brief - allow derived class to "drive" through the deltaE calculation
585 void
586 DoubleLazyNode::calc_deltaEpd( int alternate_state )
587 {
588  core::PackerEnergy dummy(0.0f);
589  project_deltaE_for_substitution( alternate_state, dummy );
590 }
591 
592 
593 //-----------------------------------------------------------------//
594 
596 
597 ////////////////////////////////////////////////////////////////////////////////
598 /// @begin DoubleLazyEdge::DoubleLazyEdge
599 ///
600 /// @brief
601 ///
602 /// @detailed
603 ///
604 /// @param
605 ///
606 /// @global_read
607 ///
608 /// @global_write
609 ///
610 /// @remarks
611 ///
612 /// @references
613 ///
614 /// @authors apl
615 ///
616 /// @last_modified
617 ////////////////////////////////////////////////////////////////////////////////
619  InteractionGraphBase * owner,
620  int first_node_ind,
621  int second_node_ind
622 ):
623  OnTheFlyEdge( owner, first_node_ind, second_node_ind),
624  sparse_aa_neighbors_(
625  get_dlazy_ig_owner()->get_num_aatypes(),
626  get_dlazy_ig_owner()->get_num_aatypes(),
627  (unsigned char) 0 ),
628  two_body_energies_(
629  get_dlazy_ig_owner()->get_num_aatypes(),
630  get_dlazy_ig_owner()->get_num_aatypes(),
631  ( ObjexxFCL::FArray2D< core::PackerEnergy > * ) ( 0 ) ),
632  curr_state_energy_( 0.0f ),
633  partial_state_assignment_( false ),
634  ran_annealing_since_pair_energy_table_cleared_( false ),
635  // by default, do not use the memory-capping behavior of the DLIG;
636  // an index >= 0 means use memory-capping behavior
637  edge_index_( -1 )
638 {
639 }
640 
641 /// @details explicity deallocate the FArrays that were dynamically
642 /// allocated
644 {
645  for ( Size ii = 1; ii <= two_body_energies_.size2(); ++ii ) {
646  for ( Size jj = 1; jj <= two_body_energies_.size1(); ++jj ) {
647  delete two_body_energies_( jj, ii );
648  }
649  }
650 }
651 
652 void
654  FArray2_bool const & aa_neighbors
655 )
656 {
657  sparse_aa_neighbors_ = aa_neighbors;
658  for ( Size ii = 1; ii <= two_body_energies_.size2(); ++ii ) {
659  for ( Size jj = 1; jj <= two_body_energies_.size1(); ++jj ) {
660  if ( two_body_energies_( jj, ii ) && sparse_aa_neighbors_( jj, ii )) {
662  } else if ( two_body_energies_(jj,ii) ) {
663  delete two_body_energies_(jj,ii); two_body_energies_(jj,ii) = 0;
664  }
665  }
666  }
668 }
669 
670 /// @brief returns whether two amino acid types are represented as neighbors
671 bool DoubleLazyEdge::get_sparse_aa_info( int node1aa, int node2aa ) const
672 {
673  return sparse_aa_neighbors_( node2aa, node1aa );
674 }
675 
676 void DoubleLazyEdge::force_aa_neighbors(int node1aa, int node2aa)
677 {
678  sparse_aa_neighbors_( node2aa, node1aa ) = 1;
679 }
680 
682 {
685 }
686 
688  int const node1state,
689  int const node2state
690 ) const
691 {
692  SparseMatrixIndex node1info = get_otf_node(0)->get_sparse_mat_info_for_state( node1state );
693  SparseMatrixIndex node2info = get_otf_node(1)->get_sparse_mat_info_for_state( node2state );
694  return get_two_body_energy_smi( node1state, node2state, node1info, node2info );
695 }
696 
699  int const node1state,
700  int const node2state,
701  SparseMatrixIndex const & node1info,
702  SparseMatrixIndex const & node2info
703 ) const
704 {
705  if ( ! sparse_aa_neighbors_( node2info.get_aa_type(), node1info.get_aa_type() )) {
706  return 0.0;
707  }
708  prep_aa_submatrix( node1info.get_aa_type(), node2info.get_aa_type() );
709  core::PackerEnergy energy = read_aa_submatrix( node1info, node2info );
710 
711  if ( energy == NOT_YET_COMPUTED_ENERGY ) {
714  node1state, node2state ) * edge_weight();
715  set_aa_submatrix( node1info, node2info, energy );
716  }
717  return energy;
718 }
719 
720 /// @details -- const to be called within const functions; updates mutable data
721 void
723  int node1aa,
724  int node2aa
725 ) const
726 {
727  assert( sparse_aa_neighbors_( node2aa, node1aa ));
728 
729  if ( ! two_body_energies_( node2aa, node1aa ) ) {
730  two_body_energies_( node2aa, node1aa ) = new ObjexxFCL::FArray2D< core::PackerEnergy >(
734  if ( edge_index_ != -1 ) {
736  edge_index_, submatrix_index( node1aa, node2aa ), submatrix_size( node1aa, node2aa ));
737  }
738  }
739 }
740 
743  SparseMatrixIndex node1info,
744  SparseMatrixIndex node2info
745 ) const
746 {
747  assert( two_body_energies_( node2info.get_aa_type(), node1info.get_aa_type() ) );
748 
749  return (*two_body_energies_( node2info.get_aa_type(), node1info.get_aa_type() ))
751 }
752 
753 /// @details updates mutable data
754 void
756  SparseMatrixIndex node1info,
757  SparseMatrixIndex node2info,
758  core::PackerEnergy setting
759 ) const
760 {
761  assert( two_body_energies_( node2info.get_aa_type(), node1info.get_aa_type() ) );
762  (*two_body_energies_( node2info.get_aa_type(), node1info.get_aa_type() ))
763  ( node2info.get_state_ind_for_this_aa_type(), node1info.get_state_ind_for_this_aa_type() ) = setting;
764 }
765 
766 void
768 {}
769 
770 void
772 {
775  for ( Size ii = 1; ii <= sparse_aa_neighbors_.size2(); ++ii ) {
776  for ( Size jj = 1; jj <= sparse_aa_neighbors_.size1(); ++jj ) {
777  if ( sparse_aa_neighbors_( jj, ii ) ) {
778  return;
779  }
780  }
781  }
782  delete this;
783  }
784 }
785 
786 unsigned int
788 {
789  return sizeof( DoubleLazyEdge );
790 }
791 
792 /// @details add up all the submatrices
793 unsigned int
795 {
796  unsigned int total_memory = OnTheFlyEdge::count_dynamic_memory();
797  total_memory += sparse_aa_neighbors_.size() * sizeof( unsigned char );
798  total_memory += actual_twobody_memory_use();
799 
800  /// account for the memory use of all the pointers and the FArrays themselves (not their data)
801  total_memory += two_body_energies_.size() * sizeof( ObjexxFCL::FArray2D< core::PackerEnergy > * );
802  for ( Size ii = 1; ii <= two_body_energies_.size2(); ++ii ) {
803  for ( Size jj = 1; jj <= two_body_energies_.size1(); ++jj ) {
804  if ( two_body_energies_(jj,ii) ) {
805  total_memory += sizeof( ObjexxFCL::FArray2D< core::PackerEnergy > );
806  }
807  }
808  }
809  return total_memory;
810 }
811 
812 unsigned int
814 {
815  unsigned int total_memory( 0 );
816  for ( Size ii = 1; ii <= two_body_energies_.size2(); ++ii ) {
817  for ( Size jj = 1; jj <= two_body_energies_.size1(); ++jj ) {
818  if ( two_body_energies_(jj,ii) ) {
819  total_memory += two_body_energies_(jj,ii)->size() * sizeof( core::PackerEnergy );
820  }
821  }
822  }
823  return total_memory;
824 }
825 
826 
827 unsigned int
829 {
830  unsigned int total_memory( 0 );
831  for ( Size ii = 1; ii <= two_body_energies_.size2(); ++ii ) {
832  for ( Size jj = 1; jj <= two_body_energies_.size1(); ++jj ) {
833  if ( sparse_aa_neighbors_(jj,ii) ) {
834  total_memory +=
837  sizeof( core::PackerEnergy );
838  }
839  }
840  }
841  return total_memory;
842 }
843 
844 /// @details This function is only invoked if the graph is going to attempt to use
845 /// a memory-use cap. The edge_index_ serves to both identify that the memory-use
846 /// cap is in effect, and to allow efficient communication between the graph and
847 /// its edges.
848 void
850  int index
851 )
852 {
853  assert( index > -1 && edge_index_ == -1 ); // set this only once
854  edge_index_ = index;
855 }
856 
857 int
859  int submat_ind
860 ) const
861 {
862  std::pair< int, int > aainds = aa_indices_from_submatrix_index( submat_ind );
863  assert( two_body_energies_( aainds.second, aainds.first ) );
864  delete two_body_energies_( aainds.second, aainds.first ); two_body_energies_( aainds.second, aainds.first ) = 0;
865  return submatrix_size( aainds.first, aainds.second );
866 }
867 
868 
869 void
871 {
872  Real const scale_factor = weight / edge_weight();
873  for ( Size ii = 1; ii <= two_body_energies_.size2(); ++ii ) {
874  for ( Size jj = 1; jj <= two_body_energies_.size1(); ++jj ) {
875  if ( two_body_energies_(jj,ii) ) {
876  ObjexxFCL::FArray2D< core::PackerEnergy > & ii_jj_table( *two_body_energies_(jj,ii) );
877  for ( Size kk = 0; kk < ii_jj_table.size(); ++kk ) {
878  if ( ii_jj_table[ kk ] != NOT_YET_COMPUTED_ENERGY ) {
879  ii_jj_table[ kk ] *= scale_factor;
880  }
881  }
882  }
883  }
884  }
885  edge_weight( weight );
886 }
887 
888 
889 
890 ////////////////////////////////////////////////////////////////////////////////
891 /// @begin DoubleLazyEdge::get_current_two_body_energy
892 ///
893 /// @brief
894 ///
895 /// @detailed
896 ///
897 /// @param
898 ///
899 /// @global_read
900 ///
901 /// @global_write
902 ///
903 /// @remarks
904 ///
905 /// @references
906 ///
907 /// @authors apl
908 ///
909 /// @last_modified
910 ////////////////////////////////////////////////////////////////////////////////
913 {
914  return curr_state_energy_;
915 }
916 
917 ////////////////////////////////////////////////////////////////////////////////
918 /// @begin DoubleLazyEdge::acknowledge_state_change
919 ///
920 /// @brief
921 ///
922 /// @detailed
923 ///
924 /// @param
925 ///
926 /// @global_read
927 ///
928 /// @global_write
929 ///
930 /// @remarks
931 ///
932 /// @references
933 ///
934 /// @authors apl
935 ///
936 /// @last_modified
937 ////////////////////////////////////////////////////////////////////////////////
938 void
940  int node_ind,
941  int new_state,
942  SparseMatrixIndex const & new_state_sparse_info,
943  core::PackerEnergy & new_energy
944 )
945 {
946  int node_substituted = ( node_ind == get_node_index(0) ? 0 : 1);
947  int node_not_substituted = ! node_substituted;
948 
949  int nodes_curr_states[2];
950  SparseMatrixIndex nodes_curr_states_sparse_info[2];
951 
952  nodes_curr_states[ node_substituted ] = new_state;
953  nodes_curr_states_sparse_info[ node_substituted ] = new_state_sparse_info;
954 
955  nodes_curr_states[ node_not_substituted ] =
956  get_dlazy_node( node_not_substituted )->get_current_state();
957  nodes_curr_states_sparse_info[ node_not_substituted ] =
958  get_dlazy_node( node_not_substituted )->
959  get_sparse_mat_info_for_curr_state();
960 
961  get_energy_for_state_pair( nodes_curr_states, nodes_curr_states_sparse_info );
962  new_energy = curr_state_energy_;
963 
965  get_edges_position_in_nodes_edge_vector( node_not_substituted ),
967  new_state,
968  new_state_sparse_info
969  );
970 
971  return;
972 }
973 
974 ////////////////////////////////////////////////////////////////////////////////
975 /// @begin DoubleLazyEdge::acknowledge_state_zeroed
976 ///
977 /// @brief
978 ///
979 /// @detailed
980 ///
981 /// @param
982 ///
983 /// @global_read
984 ///
985 /// @global_write
986 ///
987 /// @remarks
988 ///
989 /// @references
990 ///
991 /// @authors apl
992 ///
993 /// @last_modified
994 ////////////////////////////////////////////////////////////////////////////////
995 void
997 {
998  int node_substituted = ( node_ind == get_node_index(0) ? 0 : 1);
999  int node_not_substituted = ! node_substituted;
1000 
1001  curr_state_energy_ = 0;
1002  SparseMatrixIndex dummy_sparse_info;
1003  dummy_sparse_info.set_aa_type( 1 );
1004  dummy_sparse_info.set_state_ind_for_this_aa_type(1);
1005 
1007  get_edges_position_in_nodes_edge_vector( node_not_substituted ),
1009  0,
1010  dummy_sparse_info
1011  );
1012  return;
1013 }
1014 
1015 ////////////////////////////////////////////////////////////////////////////////
1016 /// @begin DoubleLazyEdge::acknowledge_partial_state_change
1017 ///
1018 /// @brief
1019 ///
1020 /// @detailed
1021 ///
1022 /// @param
1023 ///
1024 /// @global_read
1025 ///
1026 /// @global_write
1027 ///
1028 /// @remarks
1029 ///
1030 /// @references
1031 ///
1032 /// @authors apl
1033 ///
1034 /// @last_modified
1035 ////////////////////////////////////////////////////////////////////////////////
1037  int node_ind,
1038  int new_state,
1039  SparseMatrixIndex const & new_state_sparse_info
1040 )
1041 {
1042  int node_substituted = ( node_ind == get_node_index(0) ? 0 : 1);
1043  int node_not_substituted = ! node_substituted;
1044 
1045  curr_state_energy_ = 0;
1046 
1048  get_edges_position_in_nodes_edge_vector( node_not_substituted ),
1049  new_state,
1050  new_state_sparse_info
1051  );
1053  return;
1054 }
1055 
1056 ////////////////////////////////////////////////////////////////////////////////
1057 /// @begin DoubleLazyEdge::get_energy_following_partial_state_assignment
1058 ///
1059 /// @brief
1060 ///
1061 /// @detailed
1062 ///
1063 /// @param
1064 ///
1065 /// @global_read
1066 ///
1067 /// @global_write
1068 ///
1069 /// @remarks
1070 ///
1071 /// @references
1072 ///
1073 /// @authors apl
1074 ///
1075 /// @last_modified
1076 ////////////////////////////////////////////////////////////////////////////////
1079 {
1081  int nodes_curr_states[2];
1082  SparseMatrixIndex nodes_curr_states_sparse_info[2];
1083 
1084  for (int ii = 0; ii < 2; ++ii) {
1085  nodes_curr_states[ ii ] =
1087  nodes_curr_states_sparse_info[ ii ] =
1089  }
1090  get_energy_for_state_pair( nodes_curr_states, nodes_curr_states_sparse_info );
1091  partial_state_assignment_ = false;
1092  }
1093  return curr_state_energy_;
1094 }
1095 
1096 
1097 ////////////////////////////////////////////////////////////////////////////////
1098 /// @begin DoubleLazyEdge::get_two_body_table_size
1099 ///
1100 /// @brief
1101 ///
1102 /// @detailed
1103 ///
1104 /// @param
1105 ///
1106 /// @global_read
1107 ///
1108 /// @global_write
1109 ///
1110 /// @remarks
1111 ///
1112 /// @references
1113 ///
1114 /// @authors apl
1115 ///
1116 /// @last_modified
1117 ////////////////////////////////////////////////////////////////////////////////
1119 {
1120  return 0; // TEMP!!! two_body_energies_.get_table_size();
1121 }
1122 
1123 
1124 ////////////////////////////////////////////////////////////////////////////////
1125 /// @begin DoubleLazyEdge::get_energy_for_state_pair
1126 ///
1127 /// @brief
1128 ///
1129 /// @detailed
1130 ///
1131 /// @param
1132 ///
1133 /// @global_read
1134 ///
1135 /// @global_write
1136 ///
1137 /// @remarks
1138 ///
1139 /// @references
1140 ///
1141 /// @authors apl
1142 ///
1143 /// @last_modified
1144 ////////////////////////////////////////////////////////////////////////////////
1145 void
1147  int nodes_states[ 2 ],
1148  SparseMatrixIndex sparse_matrix_indices[ 2 ]
1149 )
1150 {
1151  bool one_node_in_zero_state = ( nodes_states[0] == 0 || nodes_states[1] == 0 );
1152 
1153  if ( one_node_in_zero_state ) {
1154  curr_state_energy_ = 0;
1155  } else {
1156  if ( ! sparse_aa_neighbors_( sparse_matrix_indices[1].get_aa_type(), sparse_matrix_indices[0].get_aa_type() ) ) {
1157  curr_state_energy_ = 0;
1158  } else {
1160  nodes_states[0], nodes_states[1],
1161  sparse_matrix_indices[0], sparse_matrix_indices[1] );
1162  }
1163  }
1164 }
1165 
1166 ObjexxFCL::FArray2D< core::PackerEnergy >
1168  int node1aa,
1169  int node2aa
1170 ) const
1171 {
1172  if ( ! sparse_aa_neighbors_( node2aa, node1aa )) {
1173  ObjexxFCL::FArray2D< core::PackerEnergy > empty;
1174  return empty;
1175  }
1176 
1177  prep_aa_submatrix( node1aa, node2aa );
1178 
1179  assert( two_body_energies_( node2aa, node1aa ) );
1180  ObjexxFCL::FArray2D< core::PackerEnergy > submat( * two_body_energies_( node2aa, node1aa ));
1181  int const iioffset = get_dlazy_node(0)->get_state_offset_for_aatype( node1aa );
1182  int const jjoffset = get_dlazy_node(1)->get_state_offset_for_aatype( node2aa );
1183 
1184  for ( Size ii = 1; ii <= submat.size2(); ++ii ) {
1185  for ( Size jj = 1; jj <= submat.size1(); ++jj ) {
1186  if ( submat(jj,ii) == NOT_YET_COMPUTED_ENERGY ) {
1187  int const ii_state = ii + iioffset;
1188  int const jj_state = jj + jjoffset;
1191  ii_state, jj_state );
1192  (*two_body_energies_( node2aa, node1aa ))( jj, ii ) = iijjenergy;
1193  submat(jj,ii) = iijjenergy;
1194  }
1195  }
1196  }
1197 
1198  if ( edge_index_ != -1 ) {
1200  }
1201 
1202  return submat;
1203 }
1204 
1205 
1206 /*void
1207 DoubleLazyEdge::wipe_two_body_energies_for_node_state(
1208  int node,
1209  int state
1210 )
1211 {
1212  int other_node = node == 0 ? 1 : 0;
1213 
1214  SparseMatrixIndex states[ 2 ];
1215  states[ node ] = get_dlazy_node( node )->get_sparse_mat_info_for_state( state );
1216  int const other_node_num_states = get_dlazy_node( other_node )->get_num_states();
1217 
1218  for (int ii = 1; ii <= other_node_num_states; ++ii) {
1219  states[ other_node ] = get_dlazy_node( other_node )->get_sparse_mat_info_for_state( ii );
1220  two_body_energies_.set( states[ 0 ], states[ 1 ], NOT_YET_COMPUTED_ENERGY );
1221 
1222  }
1223 
1224 }*/
1225 
1226 void
1228 {
1229  std::cout << "DoubleLazyEdge: " << get_node_index( 0 ) << "/" << get_node_index( 1 );
1230  std::cout << " energy= " << curr_state_energy_ << std::endl;
1231 }
1232 
1233 /// @details -- node1aa and node2aa are both indexed from 1
1234 int
1235 DoubleLazyEdge::submatrix_index( int node1aa, int node2aa ) const
1236 {
1237  return ( node1aa - 1 ) * get_dlazy_ig_owner()->get_num_aatypes() + node2aa - 1;
1238 }
1239 
1240 int
1241 DoubleLazyEdge::submatrix_size( int node1aa, int node2aa ) const
1242 {
1243  return get_dlazy_node(1)->get_num_states_for_aa_types()[ node2aa ] *
1244  get_dlazy_node(0)->get_num_states_for_aa_types()[ node1aa ] * sizeof( core::PackerEnergy );
1245 }
1246 
1247 std::pair< int, int >
1249 {
1250  int node1aa = submat_ind / get_dlazy_ig_owner()->get_num_aatypes() + 1;
1251  int node2aa = submat_ind % get_dlazy_ig_owner()->get_num_aatypes() + 1;
1252  return std::make_pair( node1aa, node2aa );
1253 
1254 }
1255 
1256 
1257 //-------------------------------------------------------------------//
1258 
1259 ////////////////////////////////////////////////////////////////////////////////
1260 /// @begin DoubleLazyInteractionGraph::DoubleLazyInteractionGraph
1261 ///
1262 /// @brief
1263 ///
1264 /// @detailed
1265 ///
1266 /// @param
1267 ///
1268 /// @global_read
1269 ///
1270 /// @global_write
1271 ///
1272 /// @remarks
1273 ///
1274 /// @references
1275 ///
1276 /// @authors apl
1277 ///
1278 /// @last_modified
1279 ////////////////////////////////////////////////////////////////////////////////
1281  int numNodes
1282 ) :
1283  OnTheFlyInteractionGraph( numNodes ),
1284  memory_max_for_rpes_( 0 ),
1285  curr_memory_for_rpes_( 0 )
1286 {
1287 }
1288 
1289 ////////////////////////////////////////////////////////////////////////////////
1290 /// @begin DoubleLazyInteractionGraph::DoubleLazyInteractionGraph
1291 ///
1292 /// @brief
1293 ///
1294 /// @detailed
1295 ///
1296 /// @param
1297 ///
1298 /// @global_read
1299 ///
1300 /// @global_write
1301 ///
1302 /// @remarks
1303 ///
1304 /// @references
1305 ///
1306 /// @authors apl
1307 ///
1308 /// @last_modified
1309 ////////////////////////////////////////////////////////////////////////////////
1311 {
1312  unsigned int edge_potential_usage( 0 );
1313  unsigned int edge_actual_usage( 0 );
1314  for( std::list< EdgeBase* >::const_iterator eiter = get_edge_list_begin(),
1315  eiter_end = get_edge_list_end(); eiter != eiter_end; ++eiter ) {
1316  DoubleLazyEdge const * dledge = static_cast< DoubleLazyEdge const * > (* eiter );
1317  edge_potential_usage += dledge->potential_twobody_memory_use();
1318  edge_actual_usage += dledge->actual_twobody_memory_use();
1319  }
1320  std::cout << "~DoubleLazyIG: used " << edge_actual_usage << " bytes instead of " << edge_potential_usage << std::endl;
1321 }
1322 
1323 void
1325  rotamer_set::RotamerSetsBase const & rot_sets_base
1326 )
1327 {
1328  parent::initialize( rot_sets_base );
1330 }
1331 
1332 void
1334 {
1336 
1337  if ( memory_max_for_rpes_ == 0 ) return;
1338 
1339  /// Ok -- now allocate space for our in-place list of edge submatrix-access history information
1340  int const num_edges = get_num_edges();
1341  int const n_submatrices = num_edges * sqr_num_aa_types_;
1342  dlazy_edge_vector_.resize( num_edges );
1343  aa_submatrix_history_list_ = new utility::in_place_list< int >( n_submatrices );
1344 
1345  int count = 0; // index nodes from 0 -- makes module arithmetic easier
1346  for( std::list< EdgeBase* >::const_iterator eiter = get_edge_list_begin(),
1347  eiter_end = get_edge_list_end(); eiter != eiter_end; ++eiter ) {
1348  DoubleLazyEdge * dledge = static_cast< DoubleLazyEdge * > (* eiter );
1349  dledge->set_edge_index( count );
1350  dlazy_edge_vector_[ count ] = dledge;
1351  ++count;
1352  }
1353 }
1354 
1355 
1356 /// @detailed
1357 void
1359 {
1360  for ( int ii = 1; ii <= get_num_nodes(); ++ii ) {
1362  }
1364 }
1365 
1366 ////////////////////////////////////////////////////////////////////////////////
1367 /// @begin DoubleLazyInteractionGraph::set_state_for_node
1368 ///
1369 /// @brief
1370 ///
1371 /// @detailed
1372 ///
1373 /// @param
1374 ///
1375 /// @global_read
1376 ///
1377 /// @global_write
1378 ///
1379 /// @remarks
1380 ///
1381 /// @references
1382 ///
1383 /// @authors apl
1384 ///
1385 /// @last_modified
1386 ////////////////////////////////////////////////////////////////////////////////
1389 {
1390  get_dlazy_node( node_ind )->assign_state( new_state );
1393 }
1394 
1395 ////////////////////////////////////////////////////////////////////////////////
1396 /// @begin DoubleLazyInteractionGraph::set_network_state
1397 ///
1398 /// @brief
1399 ///
1400 /// @detailed
1401 ///
1402 /// @param
1403 ///
1404 /// @global_read
1405 ///
1406 /// @global_write
1407 ///
1408 /// @remarks
1409 ///
1410 /// @references
1411 ///
1412 /// @authors apl
1413 ///
1414 /// @last_modified
1415 ////////////////////////////////////////////////////////////////////////////////
1418 {
1419  for ( int ii = 1; ii <= get_num_nodes(); ++ii ) {
1420  get_dlazy_node( ii )->partial_assign_state( node_states( ii ) );
1421  }
1422  for ( int ii = 1; ii <= get_num_nodes(); ++ii ) {
1424  }
1426  //std::cout << "Set Network State Finished" << std::endl;
1427  //print_current_state_assignment();
1429 }
1430 
1431 ////////////////////////////////////////////////////////////////////////////////
1432 /// @begin DoubleLazyInteractionGraph::consider_substitution
1433 ///
1434 /// @brief
1435 ///
1436 /// @detailed
1437 ///
1438 /// @param
1439 ///
1440 /// @global_read
1441 ///
1442 /// @global_write
1443 ///
1444 /// @remarks
1445 ///
1446 /// @references
1447 ///
1448 /// @authors apl
1449 ///
1450 /// @last_modified
1451 ////////////////////////////////////////////////////////////////////////////////
1452 void
1454  int node_ind,
1455  int new_state,
1456  core::PackerEnergy & delta_energy,
1457  core::PackerEnergy & prev_energy_for_node
1458 )
1459 {
1460  node_considering_alt_state_ = node_ind;
1461 
1462  delta_energy = get_dlazy_node( node_ind )->
1463  project_deltaE_for_substitution( new_state, prev_energy_for_node );
1464 
1467 }
1468 
1469 ////////////////////////////////////////////////////////////////////////////////
1470 /// @begin DoubleLazyInteractionGraph::commit_considered_substitution
1471 ///
1472 /// @brief
1473 ///
1474 /// @detailed
1475 ///
1476 /// @param
1477 ///
1478 /// @global_read
1479 ///
1480 /// @global_write
1481 ///
1482 /// @remarks
1483 ///
1484 /// @references
1485 ///
1486 /// @authors apl
1487 ///
1488 /// @last_modified
1489 ////////////////////////////////////////////////////////////////////////////////
1492 {
1494 
1497 
1501  }
1502 
1504 }
1505 
1506 ////////////////////////////////////////////////////////////////////////////////
1507 /// @begin DoubleLazyInteractionGraph::get_energy_current_state_assignment
1508 ///
1509 /// @brief
1510 ///
1511 /// @detailed
1512 ///
1513 /// @param
1514 ///
1515 /// @global_read
1516 ///
1517 /// @global_write
1518 ///
1519 /// @remarks
1520 ///
1521 /// @references
1522 ///
1523 /// @authors apl
1524 ///
1525 /// @last_modified
1526 ////////////////////////////////////////////////////////////////////////////////
1529 {
1530  //std::cout << "Num rotamer pair energy calculations performed: " << DoubleLazyNode::num_rpe_calcs << std::endl;
1531  //std::cout << "Num procrastinated comps committed: " << DoubleLazyNode::num_procrastinated_committed << std::endl;
1534 }
1535 
1536 
1537 ////////////////////////////////////////////////////////////////////////////////
1538 /// @begin DoubleLazyInteractionGraph::get_edge_memory_usage
1539 ///
1540 /// @brief
1541 ///
1542 /// @detailed
1543 ///
1544 /// @param
1545 ///
1546 /// @global_read
1547 ///
1548 /// @global_write
1549 ///
1550 /// @remarks
1551 ///
1552 /// @references
1553 ///
1554 /// @authors apl
1555 ///
1556 /// @last_modified
1557 ////////////////////////////////////////////////////////////////////////////////
1558 int
1560 {
1561  int sum = 0;
1562  for (std::list< EdgeBase* >::const_iterator iter = get_edge_list_begin();
1563  iter != get_edge_list_end(); ++iter) {
1564  sum += ((DoubleLazyEdge*) *iter)->get_two_body_table_size();
1565  }
1566  return sum;
1567 }
1568 
1569 ////////////////////////////////////////////////////////////////////////////////
1570 /// @begin DoubleLazyInteractionGraph::print_current_state_assignment
1571 ///
1572 /// @brief
1573 ///
1574 /// @detailed
1575 ///
1576 /// @param
1577 ///
1578 /// @global_read
1579 ///
1580 /// @global_write
1581 ///
1582 /// @remarks
1583 ///
1584 /// @references
1585 ///
1586 /// @authors apl
1587 ///
1588 /// @last_modified
1589 ////////////////////////////////////////////////////////////////////////////////
1590 void
1592 {
1593  std::cout << "State Assignment: " << std::endl;
1594  for ( int ii = 1; ii <= get_num_nodes(); ++ii ) {
1595  std::cout << "Node " << ii << " state " << get_dlazy_node(ii)->get_current_state() << std::endl;
1596  get_dlazy_node(ii)->print();
1597  }
1598 
1599  for (std::list< EdgeBase* >::const_iterator iter = get_edge_list_begin();
1600  iter != get_edge_list_end(); ++iter) {
1601  ((DoubleLazyEdge*) (*iter))->print_current_energy();
1602  }
1603  std::cout << "Energy: " << total_energy_current_state_assignment_ << std::endl;
1604 }
1605 
1606 // @ brief O(1) total energy report. Protected read access for derived classes.
1608 {
1610 }
1611 
1612 
1613 ////////////////////////////////////////////////////////////////////////////////
1614 /// @begin DoubleLazyInteractionGraph::set_errorfull_deltaE_threshold
1615 ///
1616 /// @brief
1617 ///
1618 /// @detailed
1619 ///
1620 /// @param
1621 ///
1622 /// @global_read
1623 ///
1624 /// @global_write
1625 ///
1626 /// @remarks
1627 ///
1628 /// @references
1629 ///
1630 /// @authors apl
1631 ///
1632 /// @last_modified
1633 ////////////////////////////////////////////////////////////////////////////////
1634 void
1636 {}
1637 
1638 ////////////////////////////////////////////////////////////////////////////////
1639 /// @begin DoubleLazyInteractionGraph::get_energy_sum_for_vertex_group
1640 ///
1641 /// @brief
1642 ///
1643 /// @detailed
1644 ///
1645 /// @param
1646 ///
1647 /// @global_read
1648 ///
1649 /// @global_write
1650 ///
1651 /// @remarks
1652 ///
1653 /// @references
1654 ///
1655 /// @authors apl
1656 ///
1657 /// @last_modified
1658 ////////////////////////////////////////////////////////////////////////////////
1661 {
1662  core::PackerEnergy esum = 0;
1663  for ( int ii = 1; ii <= get_num_nodes(); ++ii ) {
1664  if ( get_vertex_member_of_energy_sum_group( ii, group_id ) ) {
1666  }
1667  }
1668 
1669  for ( std::list< EdgeBase* >::iterator edge_iter = get_edge_list_begin();
1670  edge_iter != get_edge_list_end(); ++edge_iter ) {
1671  int first_node_ind = (*edge_iter)->get_first_node_ind();
1672  int second_node_ind = (*edge_iter)->get_second_node_ind();
1673 
1674  if ( get_vertex_member_of_energy_sum_group( first_node_ind, group_id )
1675  && get_vertex_member_of_energy_sum_group( second_node_ind, group_id )) {
1676  esum += ((DoubleLazyEdge*) (*edge_iter))->get_current_two_body_energy();
1677  }
1678  }
1679 
1680  return esum;
1681 }
1682 
1683 /// @details DoubleLazyInteractionGraph will return aa submatrices as requested.
1684 bool
1686 {
1687  return true;
1688 }
1689 
1691  int node_ind,
1692  int node_state
1693 ) const
1694 {
1695  return get_dlazy_node(node_ind )->aatype_for_state( node_state );
1696 }
1697 
1698 ObjexxFCL::FArray2D< core::PackerEnergy >
1700  int node1,
1701  int node2,
1702  int node1aa,
1703  int node2aa
1704 ) const
1705 {
1706  return get_dlazy_edge( node1, node2 )->get_aa_submatrix_energies( node1aa, node2aa );
1707 }
1708 
1709 
1710 ////////////////////////////////////////////////////////////////////////////////
1711 /// @begin DoubleLazyInteractionGraph::getMemoryUsageInBytes()
1712 ///
1713 /// @brief
1714 ///
1715 /// @detailed
1716 ///
1717 /// @param
1718 ///
1719 /// @global_read
1720 ///
1721 /// @global_write
1722 ///
1723 /// @remarks
1724 ///
1725 /// @references
1726 ///
1727 /// @authors apl
1728 ///
1729 /// @last_modified
1730 ////////////////////////////////////////////////////////////////////////////////
1731 
1732 unsigned int
1734 {
1735  return sizeof( DoubleLazyInteractionGraph );
1736 }
1737 
1738 unsigned int
1740 {
1741  unsigned int total_memory = OnTheFlyInteractionGraph::count_dynamic_memory();
1742  return total_memory;
1743 }
1744 
1746 {
1747  memory_max_for_rpes_ = setting;
1748 }
1749 
1751  int edge_index,
1752  int submatrix_index, // count from 0 to make module arithmetic easier
1753  int submatrix_size // in bytes
1754 ) const
1755 {
1756  if ( memory_max_for_rpes_ == 0 ) return;
1757  curr_memory_for_rpes_ += submatrix_size;
1758  note_submatrix_accessed( edge_index, submatrix_index );
1759 
1761  int global_submatrix_index = aa_submatrix_history_list_->tail();
1762  assert( global_submatrix_index ); /// should never be zero if curr_memroy_for_rpes > memory_max_for_rpes_
1763  aa_submatrix_history_list_->remove( global_submatrix_index );
1764 
1765  --global_submatrix_index; // convert to a 0-based index for modular arithmetic
1766 
1767  int const edge_index = global_submatrix_index / sqr_num_aa_types_;
1768  int const local_submatrix_index = global_submatrix_index % sqr_num_aa_types_;
1769 
1770  int savings = dlazy_edge_vector_[ edge_index ]->drop_aa_submatrix( local_submatrix_index );
1771  //std::cout << "submatrix " << global_submatrix_index << " being deleted " << std::endl;
1772  curr_memory_for_rpes_ -= savings;
1773  }
1774 }
1775 
1777  int edge_index,
1778  int submatrix_index
1779 ) const
1780 {
1781  if ( memory_max_for_rpes_ == 0 ) return;
1782 
1783  int global_submatrix_index = edge_index * sqr_num_aa_types_ + submatrix_index + 1;
1784  aa_submatrix_history_list_->move_to_front( global_submatrix_index );
1785  //std::cout << "submatrix " << global_submatrix_index << " accessed " << std::endl;
1786 }
1787 
1788 ////////////////////////////////////////////////////////////////////////////////
1789 /// @begin DoubleLazyInteractionGraph::create_new_node( int node_index, int num_states)
1790 ///
1791 /// @brief
1792 ///
1793 /// @detailed
1794 ///
1795 /// @param
1796 ///
1797 /// @global_read
1798 ///
1799 /// @global_write
1800 ///
1801 /// @remarks
1802 ///
1803 /// @references
1804 ///
1805 /// @authors apl
1806 ///
1807 /// @last_modified
1808 ////////////////////////////////////////////////////////////////////////////////
1809 NodeBase*
1810 DoubleLazyInteractionGraph::create_new_node( int node_index, int num_states)
1811 {
1812  return new DoubleLazyNode( this, node_index, num_states );
1813 }
1814 
1815 ////////////////////////////////////////////////////////////////////////////////
1816 /// @begin DoubleLazyInteractionGraph::create_new_edge( int index1, int index2)
1817 ///
1818 /// @brief
1819 ///
1820 /// @detailed
1821 ///
1822 /// @param
1823 ///
1824 /// @global_read
1825 ///
1826 /// @global_write
1827 ///
1828 /// @remarks
1829 ///
1830 /// @references
1831 ///
1832 /// @authors apl
1833 ///
1834 /// @last_modified
1835 ////////////////////////////////////////////////////////////////////////////////
1836 EdgeBase*
1838 {
1839  return new DoubleLazyEdge( this, index1, index2 );
1840 }
1841 
1842 ////////////////////////////////////////////////////////////////////////////////
1843 /// @begin DoubleLazyInteractionGraph::update_internal_energy_totals
1844 ///
1845 /// @brief
1846 ///
1847 /// @detailed
1848 ///
1849 /// @param
1850 ///
1851 /// @global_read
1852 ///
1853 /// @global_write
1854 ///
1855 /// @remarks
1856 ///
1857 /// @references
1858 ///
1859 /// @authors apl
1860 ///
1861 /// @last_modified
1862 ////////////////////////////////////////////////////////////////////////////////
1863 void
1865 {
1867 
1868  for ( int ii = 1; ii <= get_num_nodes(); ++ii ) {
1870  get_one_body_energy_current_state();
1871  }
1872 
1873  for (std::list<EdgeBase*>::iterator iter = get_edge_list_begin();
1874  iter != get_edge_list_end(); ++iter ) {
1876  ((DoubleLazyEdge*) *iter)->get_current_two_body_energy();
1877  }
1878 
1880  return;
1881 }
1882 
1883 } //end namespace pack
1884 }
1885 }