Biorithm
1.1
|
This is an abstract class for reconciliation algorithms. More...
#include <reconciliation-algorithms.h>
Public Member Functions | |
AbstractSingleReconciliation (MyGraph &graph, MyPointSet &weights, double q, double maxIters, double epsilon, string outputPrefix) | |
AbstractSingleReconciliation (vector< MyGraph > &graphs, double q, double maxIters, double epsilon, string outputPrefix) | |
virtual | ~AbstractSingleReconciliation () |
Destructor. | |
virtual string | getName () |
Return the name of the algorithm. | |
virtual void | run () |
Run the algorithm on each sample in _weights. | |
void | setCurrGraphA (MyGraph &g) |
void | setCurrSampleA (unsigned int n) |
Protected Member Functions | |
virtual void | _initialiseNodeWeights (map< MyNodeId, double > &initial, map< MyNodeId, double > ¤t, map< MyNodeId, double > &previous, MyGraph &graph, const MyPointSet &weights, unsigned int sample, bool normalize=true) |
Initialize the node weights for the given sample. | |
virtual void | _initialiseNodeWeights (map< MyNodeId, double > &initial, map< MyNodeId, double > ¤t, map< MyNodeId, double > &previous, MyGraph &graph) |
Initialize each node's weight to 1/N, where N is the number of nodes in the graph. | |
virtual void | _initialiseNodeWeights (map< MyNodeId, double > &initial, map< MyNodeId, double > ¤t, map< MyNodeId, double > &previous, MyGraph &graph, double val) |
Initialize each node's weight to the given value. | |
virtual void | _runAlgorithmOnceA () |
Run the algorithm once for the current sample. | |
virtual bool | _checkFinished (unsigned int iters, double maxDiff) |
Check if we have reached convergence criteria. Return true if converged, false otherwise. | |
virtual void | _updateNodeWeightA (MyNode node)=0 |
This virtual method is unique for each reconciliation algorithm. | |
virtual void | _printNodeWeights (ofstream &ostr) |
Pretty print the node weights to _outputStream. | |
virtual void | _runForWeights () |
Run the reconciliation algorithm for the case where a single network and one or more samples of node weights are provided. | |
virtual void | _runForGraphs () |
Run the reconciliation algorithm for the case where multiple networks are provided. | |
virtual pair< double, double > | _computeEnergy () |
A method to compute the node summation and edge summation in the energy functions for each algorithm. | |
Protected Attributes | |
vector< MyGraph > | _graphs |
The set of graphs on which this algorithm will be run. | |
MyGraph | _currGraphA |
The current graph on which the algorithm is operating. | |
MyPointSet | _weights |
The matrix of node weights, which may contain multiple samples. | |
double | _q |
The parameter q used by many of the reconciliation algorithm to balance network influence with initial node weights. | |
unsigned int | _MAX_ITERS |
The maximum number of iterations to run the iterative reconciliation algorithms. | |
double | _EPSILON |
A small value used to determine when the reconciliation algorithm has converged. | |
unsigned int | _currSampleA |
The index of the current sample on which the algorithm is operating. | |
string | _outputPrefix |
The string to preprend to all generated output files. | |
map< MyNodeId, double > | _initialNodeWeightsA |
The initial node weights for the current run of the reconciliation algorithm. | |
map< MyNodeId, double > | _currNodeWeightsA |
The node weights in the current run of the reconciliation algorithm. | |
map< MyNodeId, double > | _prevNodeWeightsA |
The node weights in the previous run of the reconciliation algorithm. |
This is an abstract class for reconciliation algorithms.
This abstract base class serves as a skeleton to provide methods that each reconciliation algorithm must implement.
AbstractSingleReconciliation::AbstractSingleReconciliation | ( | MyGraph & | graph, |
MyPointSet & | weights, | ||
double | q, | ||
double | maxIters, | ||
double | epsilon, | ||
string | outputPrefix | ||
) | [inline] |
Constructor for running the algorithm on a single network with multiple initial weights samples.
[in] | graph | The network on which to operate. |
[in] | weights | The samples containing initial node weights. |
[in] | q | The parameter q used by the algorithm. |
[in] | maxIters | The maximum number of iterations to run the iterative reconciliation algorithms. |
[in] | epsilon | A small value that defines part of the convergence criteria. |
[in] | outputPrefix | A string to prepend to all output files. |
AbstractSingleReconciliation::AbstractSingleReconciliation | ( | vector< MyGraph > & | graphs, |
double | q, | ||
double | maxIters, | ||
double | epsilon, | ||
string | outputPrefix | ||
) | [inline] |
Constructor for running the algorithm on multiple networks with no initial weights.
[in] | graphs | The networks on which to operate. |
[in] | q | The parameter q used by the algorithm. |
[in] | maxIters | The maximum number of iterations to run the iterative reconciliation algorithms. |
[in] | epsilon | A small value that defines part of the convergence criteria. |
[in] | outputPrefix | A string to prepend to all output files. |
bool AbstractSingleReconciliation::_checkFinished | ( | unsigned int | iters, |
double | maxDiff | ||
) | [protected, virtual] |
Check if we have reached convergence criteria. Return true if converged, false otherwise.
[in] | iters | Current number of iterations that have elapsed. If this value is greater than or equal to MAX_ITERS, return true. |
[in] | maxDiff | The maximum difference of any node's value between the current iteration and previous iteration. If this value is smaller than _EPSILON, return true. |
Reimplemented in HeatKernel.
void AbstractSingleReconciliation::_initialiseNodeWeights | ( | map< MyNodeId, double > & | initial, |
map< MyNodeId, double > & | current, | ||
map< MyNodeId, double > & | previous, | ||
MyGraph & | graph, | ||
const MyPointSet & | weights, | ||
unsigned int | sample, | ||
bool | normalize = true |
||
) | [protected, virtual] |
Initialize the node weights for the given sample.
[out] | intitial | The data structure to hold initial node weights. |
[out] | current | The data structure to hold current node weights. |
[out] | previous | The data structure to hold previous node weights. |
[in] | graph | The network on which we will run the reconciliation algorithm. |
[in] | weights | The instance of MyPointSet containing the node weights. |
[in] | sample | An index to the sample to use for the node weights. |
[in] | normalize | A boolean that specifies whether to normalize the initial node weights to sum to 1. |
void AbstractSingleReconciliation::_initialiseNodeWeights | ( | map< MyNodeId, double > & | initial, |
map< MyNodeId, double > & | current, | ||
map< MyNodeId, double > & | previous, | ||
MyGraph & | graph | ||
) | [protected, virtual] |
Initialize each node's weight to 1/N, where N is the number of nodes in the graph.
[out] | intitial | The data structure to hold initial node weights. |
[out] | current | The data structure to hold current node weights. |
[out] | previous | The data structure to hold previous node weights. |
[in] | graph | The network on which we will run the reconciliation algorithm. |
void AbstractSingleReconciliation::_initialiseNodeWeights | ( | map< MyNodeId, double > & | initial, |
map< MyNodeId, double > & | current, | ||
map< MyNodeId, double > & | previous, | ||
MyGraph & | graph, | ||
double | val | ||
) | [protected, virtual] |
Initialize each node's weight to the given value.
[out] | intitial | The data structure to hold initial node weights. |
[out] | current | The data structure to hold current node weights. |
[out] | previous | The data structure to hold previous node weights. |
[in] | graph | The network on which we will run the reconciliation algorithm. |
[in] | val | The value for every node's initial weight. |
void AbstractSingleReconciliation::setCurrGraphA | ( | MyGraph & | g | ) | [inline] |
Set the current sraph
[in] | g | The graph to set _currGraphA to. |
void AbstractSingleReconciliation::setCurrSampleA | ( | unsigned int | n | ) | [inline] |
Set the current sample.
[in] | n | The index of the current sample. |