Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
core::pack::interaction_graph::PDEdge Class Reference

#include <PDInteractionGraph.hh>

Inheritance diagram for core::pack::interaction_graph::PDEdge:
Inheritance graph
[legend]
Collaboration diagram for core::pack::interaction_graph::PDEdge:
Collaboration graph
[legend]

Public Member Functions

 PDEdge (InteractionGraphBase *owner, int first_node_ind, int second_node_ind)
 main constructor - no default nor copy constructors provided More...
 
virtual ~PDEdge ()
 destructor More...
 
virtual void set_sparse_aa_info (ObjexxFCL::FArray2_bool const &sparse_conn_info)
 allocates two-body energy table based on amino-acid neighbor relationships and initializes the table to 0. More...
 
virtual void force_aa_neighbors (int node1aa, int node2aa)
 re-allocates two-body energy table after forcing a pair of amino acids to become neighbors that were not initially declared to be neighbors More...
 
virtual void force_all_aa_neighbors ()
 re-allocates two-body energy table after forcing a pair of amino acids to become neighbors that were not initially declared to be neighbors More...
 
virtual bool get_sparse_aa_info (int node1aa, int node2aa) const
 returns whether two amino acid types are represented as neighbors More...
 
virtual void add_to_two_body_energy (int const, int const, core::PackerEnergy const)
 adds the input energy to the two body energy for state1 on the node with the smaller index and state2 on the node with the larger index so long as the amion acid types of those states have been previously declared amino acid neighbors. Any energies for non-neighboring states are ignored. More...
 
virtual void add_to_two_body_energies (ObjexxFCL::FArray2< core::PackerEnergy > const &res_res_energy_array)
 Adds all the energies stored in the oversized_res_res_energy array to the two body energy table for those states whose amion acid types were previoudsly declared to be amino-acid neighbors. The res-res array should have the dimension (node1->get_num_states() x node2->get_num_states());. More...
 
virtual void set_two_body_energy (int const, int const, core::PackerEnergy const)
 Sets the two-body energy for a pair of states. That is, it overwrites whatever two-body energy there was previously for that state pair with a new energy. Ignores non-neighboring state pairs. More...
 
virtual void clear_two_body_energy (int const, int const)
 Sets the two-body energy for a pair of states. That is, it overwrites whatever two-body energy there was previously for that state pair with a new energy. Ignores non-neighboring state pairs. More...
 
virtual core::PackerEnergy get_two_body_energy (int const, int const ) const
 returns the two body energy for a pair of states: 0 if those states are not neighbors More...
 
virtual void declare_energies_final ()
 When all the energies that are going to be stored in an edge have been placed in it, the edge may save some memory by shrinking its AminoAcidNeighborSparseMatrix. This method instructs the edge to do so. More...
 
virtual void prepare_for_simulated_annealing ()
 reduces the size of the pair-energy table if any amino-acid-neighbor submatrices hold nothing but 0's More...
 
core::PackerEnergy get_current_two_body_energy ()
 returns the two body energy corresponding to the current states assigned to the nodes this edge is incident upon. More...
 
void acknowledge_state_change (int node_ind, int new_state, SparseMatrixIndex const &new_state_sparse_info, core::PackerEnergy &new_energy)
 updates bookkeeping information when one of the two nodes changes its state More...
 
void acknowledge_state_zeroed (int node_ind)
 updates bookkeeping information when one of the two nodes enters its "unassigned" state. More...
 
void acknowledge_substitution (int substituted_node_index, core::PackerEnergy const curr_state_energy, int nodes_new_state, SparseMatrixIndex const &nodes_new_state_sparse_info)
 update bookkeeping information when one of the nodes an edge is incident upon changes state More...
 
ObjexxFCL::FArray2D_int const & get_offsets_for_aatypes ()
 Returns the array of offsets into the sparse two-body energy table for amino-acid neighbors. Used in transferring information from edges onto nodes for cache efficiency. More...
 
utility::vector1< int > const & get_second_node_num_states_per_aa ()
 returns an FArray of the number of states for each amino acid type for the higher-indexed node More...
 
int get_two_body_table_size () const
 returns the memory usage of the two body energy table for this edge More...
 
core::PackerEnergyget_edge_table_ptr ()
 Returns a reference to the first element in the sparse two-body energy table. Used to create a proxy array on the nodes for cache efficiency. More...
 
virtual unsigned int count_static_memory () const
 
virtual unsigned int count_dynamic_memory () const
 
ObjexxFCL::FArray2D
< core::PackerEnergy
get_aa_submatrix_energies (int node1aa, int node2aa) const
 
virtual void set_edge_weight (Real weight)
 
- Public Member Functions inherited from core::pack::interaction_graph::PrecomputedPairEnergiesEdge
virtual ~PrecomputedPairEnergiesEdge ()
 
 PrecomputedPairEnergiesEdge (InteractionGraphBase *owner, int first_node_ind, int second_node_ind)
 
- Public Member Functions inherited from core::pack::interaction_graph::FixedBBEdge
virtual ~FixedBBEdge ()
 
 FixedBBEdge (InteractionGraphBase *owner, int first_node_ind, int second_node_ind)
 
- Public Member Functions inherited from core::pack::interaction_graph::EdgeBase
virtual ~EdgeBase ()
 copy constructor, do not use More...
 
 EdgeBase (InteractionGraphBase *owner, int first_node_ind, int second_node_ind)
 main constructor for edge, no default nor copy constructors More...
 
int get_other_ind (int callers_index) const
 returns the index of the other node that the edge is incident upon More...
 
NodeBaseget_other_node (int callers_index) const
 returns a pointer to the other node that the edge is incident upon More...
 
int get_first_node_ind () const
 returns the index of the smaller-indexed node More...
 
int get_second_node_ind () const
 returns the index of the larger-indexed node More...
 
void set_pos_in_owners_list (std::list< EdgeBase * >::iterator edge_iterator)
 edge keeps iterator to its position in it's owner's edge list More...
 
void set_pos_in_node_edgevector (int callers_index, int position)
 edge keeps index it has in node_ind's edge vector More...
 
bool same_edge (int node1, int node2) const
 returns true if this edge connects nodes of index node1 and node2 the order of node1 and node2 is not important More...
 
Real edge_weight () const
 
InteractionGraphBase const * get_owner () const
 
InteractionGraphBaseget_owner ()
 

Static Public Member Functions

static core::PackerEnergy get_alternate_state_energy_first_node (int first_node_alt_state, int second_node_orig_state, SparseMatrixIndex const &second_node_orig_state_sparse_info, int first_node_state_offset_minus_1, int second_node_curr_num_states_per_aatype, int aa_neighbor_offset, ObjexxFCL::FArray1< core::PackerEnergy > &edge_energy_table)
 static method that looks up the two body energy when the node with the smaller index on an edge is considering an alternate state More...
 
static core::PackerEnergy get_alternate_state_energy_second_node (int first_node_orig_state, int second_node_alt_state, SparseMatrixIndex const &first_node_orig_state_sparse_info, SparseMatrixIndex const &second_node_alternate_state_sparse_info, int second_node_alt_state_num_states_per_aatype, int aa_neighbor_offset, ObjexxFCL::FArray1< core::PackerEnergy > &edge_energy_table)
 static method that looks up the two body energy when the node with the larger index on an edge is considering an alternate state More...
 

Protected Member Functions

void declare_energies_final_no_deletion ()
 allow derived class to prep this class for simA, but guarantee no call to delete this; More...
 
void prepare_for_simulated_annealing_no_deletion ()
 
  • allow derived class to prep this class for simA, but guarantee no call to delete this;
More...
 
bool pd_edge_table_all_zeros () const
  More...
 

Private Member Functions

PDNode const * get_pd_node (int index) const
 
PDNodeget_pd_node (int index)
 
PDInteractionGraph const * get_pdig_owner () const
 
PDInteractionGraphget_pdig_owner ()
 
void drop_small_submatrices_where_possible (core::PackerEnergy epsilon)
 drops any amino-acid neighbor submatrix of the two-body energy table when the magnitudes of the energies stored in that submatrix do not exceed the input parameter, epsilon. Dropping submatrices that contain zero energies is a special case of this function where epsilon == 0. More...
 
void drop_zero_submatrices_where_possible ()
 drops amino-acid neighbor submatrices when they do not contain any non-zero entries. Represents a special case of drop_small_submatrices_where_possible More...
 
 PDEdge ()
 
 PDEdge (PDEdge const &)
 
PDEdgeoperator= (PDEdge const &)
 

Private Attributes

AminoAcidNeighborSparseMatrix
< core::PackerEnergy
two_body_energies_
 
core::PackerEnergy curr_state_energy_
 
bool energies_updated_since_last_prep_for_simA_
 

Constructor & Destructor Documentation

core::pack::interaction_graph::PDEdge::PDEdge ( InteractionGraphBase owner,
int  first_node_ind,
int  second_node_ind 
)

main constructor - no default nor copy constructors provided

Parameters
owner- [in] - pointer to the graph that created this node
first_node_ind- [in] - the index of the smaller-indexed node
second_node_ind- [in] - the index of the larger-indexed node
core::pack::interaction_graph::PDEdge::~PDEdge ( )
virtual

destructor

core::pack::interaction_graph::PDEdge::PDEdge ( )
private

Referenced by count_static_memory().

core::pack::interaction_graph::PDEdge::PDEdge ( PDEdge const &  )
private

Member Function Documentation

void core::pack::interaction_graph::PDEdge::acknowledge_state_change ( int  node_ind,
int  new_state,
SparseMatrixIndex const &  new_state_sparse_info,
core::PackerEnergy new_energy 
)

updates bookkeeping information when one of the two nodes changes its state

Parameters
node_ind- [in] - the index of the node that changed its state
node_state- [in] - the index of the new state it assumed
new_state_spare_info- [in] - the sparse-matrix information for the state
new_energy- [out] - the two body energy produced by the new state and the current state on the other node

Referenced by core::pack::interaction_graph::PDNode::assign_state().

void core::pack::interaction_graph::PDEdge::acknowledge_state_zeroed ( int  node_ind)
void core::pack::interaction_graph::PDEdge::acknowledge_substitution ( int  substituted_node_index,
core::PackerEnergy const  curr_state_energy,
int  nodes_new_state,
SparseMatrixIndex const &  nodes_new_state_sparse_info 
)
inline

update bookkeeping information when one of the nodes an edge is incident upon changes state

Parameters
substituted_node_index- [in] - index of the node that chagned its state
curr_state_energy- [in] - the two body energy given the new state
nodes_new_state- [in] - the state the node just transitioned into
nodes_new_state_sparse_info- [in] - sparse matrix info for the new state

References curr_state_energy_, core::pack::interaction_graph::EdgeBase::get_edges_position_in_nodes_edge_vector(), core::pack::interaction_graph::EdgeBase::get_node_index(), and get_pd_node().

Referenced by core::pack::interaction_graph::PDNode::commit_considered_substitution().

void core::pack::interaction_graph::PDEdge::add_to_two_body_energies ( ObjexxFCL::FArray2< core::PackerEnergy > const &  res_res_energy_array)
virtual

Adds all the energies stored in the oversized_res_res_energy array to the two body energy table for those states whose amion acid types were previoudsly declared to be amino-acid neighbors. The res-res array should have the dimension (node1->get_num_states() x node2->get_num_states());.

Parameters
res_res_energy_array- [in] - an array containing the state pair energies

Implements core::pack::interaction_graph::PrecomputedPairEnergiesEdge.

void core::pack::interaction_graph::PDEdge::add_to_two_body_energy ( int const  state1,
int const  state2,
core::PackerEnergy const  energy 
)
virtual

adds the input energy to the two body energy for state1 on the node with the smaller index and state2 on the node with the larger index so long as the amion acid types of those states have been previously declared amino acid neighbors. Any energies for non-neighboring states are ignored.

Implements core::pack::interaction_graph::PrecomputedPairEnergiesEdge.

void core::pack::interaction_graph::PDEdge::clear_two_body_energy ( int const  state1,
int const  state2 
)
virtual

Sets the two-body energy for a pair of states. That is, it overwrites whatever two-body energy there was previously for that state pair with a new energy. Ignores non-neighboring state pairs.

Parameters
state1- [in] - state index for the node with the smaller index
state2- [in] - state index for the node with the larger index
energy- [in] - the energy which replaces the old two-body energy

Implements core::pack::interaction_graph::PrecomputedPairEnergiesEdge.

unsigned int core::pack::interaction_graph::PDEdge::count_dynamic_memory ( ) const
virtual
unsigned int core::pack::interaction_graph::PDEdge::count_static_memory ( ) const
virtual
void core::pack::interaction_graph::PDEdge::declare_energies_final ( )
virtual

When all the energies that are going to be stored in an edge have been placed in it, the edge may save some memory by shrinking its AminoAcidNeighborSparseMatrix. This method instructs the edge to do so.

Implements core::pack::interaction_graph::EdgeBase.

References prepare_for_simulated_annealing().

void core::pack::interaction_graph::PDEdge::declare_energies_final_no_deletion ( )
protected

allow derived class to prep this class for simA, but guarantee no call to delete this;

References prepare_for_simulated_annealing_no_deletion().

void core::pack::interaction_graph::PDEdge::drop_small_submatrices_where_possible ( core::PackerEnergy  epsilon)
private

drops any amino-acid neighbor submatrix of the two-body energy table when the magnitudes of the energies stored in that submatrix do not exceed the input parameter, epsilon. Dropping submatrices that contain zero energies is a special case of this function where epsilon == 0.

Parameters
epsilon- [in] - the magnitude threshold for keeping amino-acid neighbor submatrices.

References core::pack::interaction_graph::AminoAcidNeighborSparseMatrix< T >::drop_small_submatrices_where_possible(), and two_body_energies_.

Referenced by drop_zero_submatrices_where_possible().

void core::pack::interaction_graph::PDEdge::drop_zero_submatrices_where_possible ( )
private

drops amino-acid neighbor submatrices when they do not contain any non-zero entries. Represents a special case of drop_small_submatrices_where_possible

References drop_small_submatrices_where_possible().

void core::pack::interaction_graph::PDEdge::force_aa_neighbors ( int  node1aa,
int  node2aa 
)
virtual

re-allocates two-body energy table after forcing a pair of amino acids to become neighbors that were not initially declared to be neighbors

Parameters
node1aa- [in] - the amino acid type for the node with the smaller index
node2aa- [in] - the amino acid type for the node with the larger index

Implements core::pack::interaction_graph::FixedBBEdge.

References energies_updated_since_last_prep_for_simA_, core::pack::interaction_graph::AminoAcidNeighborSparseMatrix< T >::force_aa_neighbors(), and two_body_energies_.

void core::pack::interaction_graph::PDEdge::force_all_aa_neighbors ( )
virtual

re-allocates two-body energy table after forcing a pair of amino acids to become neighbors that were not initially declared to be neighbors

Parameters
node1aa- [in] - the amino acid type for the node with the smaller index
node2aa- [in] - the amino acid type for the node with the larger index

Implements core::pack::interaction_graph::FixedBBEdge.

References energies_updated_since_last_prep_for_simA_, core::pack::interaction_graph::AminoAcidNeighborSparseMatrix< T >::force_all_aa_neighbors(), and two_body_energies_.

Referenced by core::pack::interaction_graph::PDInteractionGraph::add_edge().

ObjexxFCL::FArray2D< core::PackerEnergy > core::pack::interaction_graph::PDEdge::get_aa_submatrix_energies ( int  node1aa,
int  node2aa 
) const
float core::pack::interaction_graph::PDEdge::get_alternate_state_energy_first_node ( int  first_node_alt_state,
int  second_node_orig_state,
SparseMatrixIndex const &  second_node_orig_state_sparse_info,
int  first_node_state_offset_minus_1,
int  second_node_curr_num_states_per_aatype,
int  aa_neighbor_offset,
ObjexxFCL::FArray1< core::PackerEnergy > &  edge_energy_table 
)
inlinestatic

static method that looks up the two body energy when the node with the smaller index on an edge is considering an alternate state

Parameters
first_node_alt_state- [in] - the alternate state for the lower-indexed node
second_node_orig_state- [in] - the current state for the higher-indexed node
second_node_orig_state_sparse_info- [in] - the sparse matrix info for the higher-indexed node
first_node_state_offset_minus_1- [in] - part of the sparse matrix info for the lower-indexed node where 1 is subtracted from the state offset.
second_node_num_states_per_aatype- [in] - number of states with current aa type for node 2
aa_neighbor_offset- [in] - offset for the amino-acid neighbor pair for the sparse two-body energy table
edge_energy_table- [in] - the proxy FArray pointing at the edge table connecting the two nodes.

References core::pack::interaction_graph::AminoAcidNeighborSparseMatrix< T >::get().

float core::pack::interaction_graph::PDEdge::get_alternate_state_energy_second_node ( int  first_node_orig_state,
int  second_node_alt_state,
SparseMatrixIndex const &  first_node_orig_state_sparse_info,
SparseMatrixIndex const &  second_node_alternate_state_sparse_info,
int  second_node_alt_state_num_states_per_aatype,
int  aa_neighbor_offset,
ObjexxFCL::FArray1< core::PackerEnergy > &  edge_energy_table 
)
inlinestatic

static method that looks up the two body energy when the node with the larger index on an edge is considering an alternate state

Parameters
first_node_orig_state- [in] - the current state for the lower-indexed node
second_node_alt_state- [in] - the alt state for the higher-indexed node
first_node_orig_state_sparse_info- [in] - the sparse matrix info for the lower-indexed node
second_node_alt_state_sparse_info- [in] - the sparse matrix info for the higher-indexed node
first_node_state_offset_minus_1- [in] - part of the sparse matrix info for the lower-indexed node where 1 is subtracted from the state offset.
second_node_alt_state_num_states_per_aatype- [in] - number of states with alternate aa type for node 2
aa_neighbor_offset- [in] - offset for the amino-acid neighbor pair for the sparse two-body energy table
edge_energy_table- [in] - the proxy FArray pointing at the edge table connecting the two nodes.

References core::pack::interaction_graph::AminoAcidNeighborSparseMatrix< T >::get().

float core::pack::interaction_graph::PDEdge::get_current_two_body_energy ( )

returns the two body energy corresponding to the current states assigned to the nodes this edge is incident upon.

References curr_state_energy_.

Referenced by core::pack::interaction_graph::PDNode::update_internal_energy_sums().

float & core::pack::interaction_graph::PDEdge::get_edge_table_ptr ( )

Returns a reference to the first element in the sparse two-body energy table. Used to create a proxy array on the nodes for cache efficiency.

References core::pack::interaction_graph::AminoAcidNeighborSparseMatrix< T >::getMatrixPointer(), and two_body_energies_.

Referenced by core::pack::interaction_graph::PDNode::update_internal_vectors().

FArray2D_int const & core::pack::interaction_graph::PDEdge::get_offsets_for_aatypes ( )

Returns the array of offsets into the sparse two-body energy table for amino-acid neighbors. Used in transferring information from edges onto nodes for cache efficiency.

References core::pack::interaction_graph::AminoAcidNeighborSparseMatrix< T >::getAANeighborOffsets(), and two_body_energies_.

Referenced by core::pack::interaction_graph::PDNode::update_internal_vectors().

PDNode const * core::pack::interaction_graph::PDEdge::get_pd_node ( int  index) const
inlineprivate
PDNode * core::pack::interaction_graph::PDEdge::get_pd_node ( int  index)
inlineprivate
PDInteractionGraph const * core::pack::interaction_graph::PDEdge::get_pdig_owner ( ) const
inlineprivate
PDInteractionGraph * core::pack::interaction_graph::PDEdge::get_pdig_owner ( )
inlineprivate
utility::vector1< int > const & core::pack::interaction_graph::PDEdge::get_second_node_num_states_per_aa ( )

returns an FArray of the number of states for each amino acid type for the higher-indexed node

References core::pack::interaction_graph::PDNode::get_num_states_for_aa_types(), and get_pd_node().

Referenced by core::pack::interaction_graph::PDNode::update_internal_vectors().

bool core::pack::interaction_graph::PDEdge::get_sparse_aa_info ( int  node1aa,
int  node2aa 
) const
virtual

returns whether two amino acid types are represented as neighbors

Implements core::pack::interaction_graph::FixedBBEdge.

References core::pack::interaction_graph::AminoAcidNeighborSparseMatrix< T >::get_sparse_aa_info(), and two_body_energies_.

float core::pack::interaction_graph::PDEdge::get_two_body_energy ( int const  state1,
int const  state2 
) const
virtual

returns the two body energy for a pair of states: 0 if those states are not neighbors

Parameters
state1- [in] - state index for the node with the smaller index
state2- [in] - state index for the node with the larger index

Implements core::pack::interaction_graph::FixedBBEdge.

References core::pack::interaction_graph::AminoAcidNeighborSparseMatrix< T >::get(), get_pd_node(), and two_body_energies_.

Referenced by protocols::enzdes::EnzdesFlexibleRegion::calculate_rotamer_set_design_targets_partition_sum().

int core::pack::interaction_graph::PDEdge::get_two_body_table_size ( ) const
PDEdge& core::pack::interaction_graph::PDEdge::operator= ( PDEdge const &  )
private
bool core::pack::interaction_graph::PDEdge::pd_edge_table_all_zeros ( ) const
protected
void core::pack::interaction_graph::PDEdge::prepare_for_simulated_annealing ( )
virtual

reduces the size of the pair-energy table if any amino-acid-neighbor submatrices hold nothing but 0's

since the drop_zero_submatrices_where_possible() method of the AANSM is somewhat time consuming, and since it can only reduce memory use / simA running time on the first execution following an update to the two-body energies, the PDEdge member variable energies_updated_since_last_prep_ for_simA ensures that the AANSM method is only called once following the update of any RPEs.

Implements core::pack::interaction_graph::EdgeBase.

References core::pack::interaction_graph::AminoAcidNeighborSparseMatrix< T >::get_table_size(), prepare_for_simulated_annealing_no_deletion(), and two_body_energies_.

Referenced by declare_energies_final().

void core::pack::interaction_graph::PDEdge::prepare_for_simulated_annealing_no_deletion ( )
protected
void core::pack::interaction_graph::PDEdge::set_edge_weight ( Real  weight)
virtual

DANGER: If for some reason one were to reweight edges during simulated annealing then some of the cached energies in the adjacent nodes would be out-of-date; data integrity would be violated an all hell would break loose. The same thing is true if one were to change the energies on any edge during simulated annealing. One simple solution: call blanket_assign_state0 to wipe all cahced energies stored on nodes and then assign_network_state to the state just before the reweighting. Of course, since the annealer itself is tracking the "best" network state, one would have to worry about its data integrity as well. General advice: don't change energies during simA.

Implements core::pack::interaction_graph::EdgeBase.

References core::pack::interaction_graph::EdgeBase::edge_weight(), core::pack::interaction_graph::AminoAcidNeighborSparseMatrix< T >::scale(), and two_body_energies_.

void core::pack::interaction_graph::PDEdge::set_sparse_aa_info ( ObjexxFCL::FArray2_bool const &  sparse_conn_info)
virtual

allocates two-body energy table based on amino-acid neighbor relationships and initializes the table to 0.

Parameters
sparse_conn_info- [in] - a MAX_AA x MAX_AA 2D array where each "true" entry means that the corresponding amino acid pair are neighbors.
Remarks
idea borrowed from energy2b implementation

Implements core::pack::interaction_graph::FixedBBEdge.

References energies_updated_since_last_prep_for_simA_, core::pack::interaction_graph::AminoAcidNeighborSparseMatrix< T >::set_sparse_aa_info(), and two_body_energies_.

void core::pack::interaction_graph::PDEdge::set_two_body_energy ( int const  state1,
int const  state2,
core::PackerEnergy const  energy 
)
virtual

Sets the two-body energy for a pair of states. That is, it overwrites whatever two-body energy there was previously for that state pair with a new energy. Ignores non-neighboring state pairs.

Parameters
state1- [in] - state index for the node with the smaller index
state2- [in] - state index for the node with the larger index
energy- [in] - the energy which replaces the old two-body energy

Implements core::pack::interaction_graph::PrecomputedPairEnergiesEdge.

Member Data Documentation

core::PackerEnergy core::pack::interaction_graph::PDEdge::curr_state_energy_
private
bool core::pack::interaction_graph::PDEdge::energies_updated_since_last_prep_for_simA_
private
AminoAcidNeighborSparseMatrix< core::PackerEnergy > core::pack::interaction_graph::PDEdge::two_body_energies_
private

The documentation for this class was generated from the following files: