Isorropia: Partitioning, Load Balancing and more

ispatest is the namespace that contains isorropia's testutilities. More...
Functions  
int  fill_matrix (Epetra_CrsMatrix &matrix, int numNonzerosPerRow, bool verbose) 
Fill a matrix with the specified number of nonzeros per row, using matrix.InsertGlobalValues.  
int  fill_graph (Epetra_CrsGraph &graph, int numNonzerosPerRow, bool verbose) 
Fill a graph with the specified number of nonzeros per row.  
bool  test_matrix_vector_multiply (Epetra_CrsMatrix &A) 
Verify that a matrix is a valid Epetra_CrsMatrix by attempting to multiply with it.  
bool  test_row_matrix_vector_multiply (Epetra_RowMatrix &R) 
Verify that a matrix is a valid Epetra_RowMatrix by attempting to multiply with it.  
bool  test_matrix_vector_multiply (Epetra_CrsGraph &G) 
Verify that a matrix is a valid Epetra_CrsGraph by attempting to multiply with it.  
bool  test_matrix_vector_multiply (Epetra_LinearProblem &LP) 
Verify that the Epetra_RowMatrix in a Epetra_LinearProblem is valid by attempting to multiply with it.  
Epetra_Map *  map_from_blockmap (const Epetra_BlockMap &b) 
Method to create an Epetra_Map from an Epetra_BlockMap, when using methods that require an Epetra_Map but you only have an Epetra_BlockMap.  
int  readCoordFile (const std::string &fname, std::vector< double > &x, std::vector< double > &y, std::vector< double > &z) 
Read in the file "fname".  
Epetra_MultiVector *  makeWeights (const Epetra_BlockMap &map, double(*wFunc)(const int, const int, const int, const int)) 
Create a multivector of 1 dimensional weights with the same distribution as the supplied map.  
double  unitWeights (const int id, const int me, const int nids, const int nprocs) 
A function for makeWeights, returns 1.0 for the object's weight.  
double  veeWeights (const int id, const int me, const int nids, const int nprocs) 
A function for makeWeights, weight is based on global ID, lower in the middle and higher at both ends.  
double  alternateWeights (const int id, const int me, const int nids, const int nprocs) 
A function for makeWeights, weights alternate 1.0, 2.0, 1.0, etc.  
Epetra_MultiVector *  file2multivector (const Epetra_Comm &comm, const std::string &fname) 
Read in a file of 1, 2 or 3 dimensional coordinates and create a multivector with a standard linear distribution.  
int  printMultiVector (const Epetra_MultiVector &mv, std::ostream &os, const char *s, int max=1000) 
Print out the contents of the multivector by process, with optional title.  
int  printRowMatrix (const Epetra_RowMatrix &m, std::ostream &os, const char *s, bool withGraphCuts, int max=1000) 
Print out the contents of a small Epetra_RowMatrix, with optional title.  
int  compute_balance (const Epetra_Vector &wgts, double myGoalWeight, double &min, double &max, double &avg) 
Given an Epetra_Vector of weights, compute the weight imbalance on each process.  
int  compute_hypergraph_metrics (const Epetra_CrsGraph &graph, Isorropia::Epetra::CostDescriber &costs, double &myGoalWeight, double &balance, double &cutn, double &cutl) 
Compute Zoltanstyle hypergraph metrics given a partitioned CrsGraph and a CostDescriber (weight) object.  
int  compute_hypergraph_metrics (const Epetra_RowMatrix &matrix, Isorropia::Epetra::CostDescriber &costs, double &myGoalWeight, double &balance, double &cutn, double &cutl) 
Compute Zoltanstyle hypergraph metrics given a partitioned RowMatrix and a CostDescriber (weight) object.  
int  compute_graph_metrics (const Epetra_RowMatrix &matrix, Isorropia::Epetra::CostDescriber &costs, double &myGoalWeight, double &balance, int &numCuts, double &cutWgt, double &cutn, double &cutl) 
Compute graph metrics given an Epetra_RowMatrix.  
int  compute_graph_metrics (const Epetra_CrsGraph &graph, Isorropia::Epetra::CostDescriber &costs, double &myGoalWeight, double &balance, int &numCuts, double &cutWgt, double &cutn, double &cutl) 
Compute graph metrics given an Epetra_CrsGraph.  
void  show_matrix (const char *txt, const Epetra_RowMatrix &matrix, const Epetra_Comm &comm) 
Print out a distributed RowMatrix.  
void  show_matrix (const char *txt, const Epetra_CrsGraph &graph, const Epetra_Comm &comm) 
Print out a distributed CrsGraph.  
void  show_matrix (const char *txt, const Epetra_LinearProblem &problem, const Epetra_Comm &comm) 
Print out a distributed LinearProblem.  
void  read_distribution (const char *filename, std::vector< int > &rows, std::vector< int > &cols, std::vector< int > &partitions) 
Read a matrix distribution from a file.  
bool  set_verbose (int localProc, int argc, char **argv) 
return a bool that's true if v appears in the commandline arguments. 
ispatest is the namespace that contains isorropia's testutilities.
These testutilities are for internal testing, and are not generally expected to be seen or used by external users.
int ispatest::fill_matrix  (  Epetra_CrsMatrix &  matrix, 
int  numNonzerosPerRow,  
bool  verbose  
) 
Fill a matrix with the specified number of nonzeros per row, using matrix.InsertGlobalValues.
Call FillComplete on the matrix before returning. If any negative error code is returned by an Epetra method, that will be the return value of this function.
int ispatest::fill_graph  (  Epetra_CrsGraph &  graph, 
int  numNonzerosPerRow,  
bool  verbose  
) 
Fill a graph with the specified number of nonzeros per row.
Call FillComplete on the graph before returning. If any nonzero error code is returned by an Epetra method, that will be the return value of this function.
bool ispatest::test_matrix_vector_multiply  (  Epetra_CrsMatrix &  A  ) 
Verify that a matrix is a valid Epetra_CrsMatrix by attempting to multiply with it.
Return true if successful, false otherwise.
A is the input matrix, and "x" and "y" will be created and then y = Ax will be computed.
"x" will be created with the domain map of the "A", "y" will be created with the range map.
Return true if successful, false otherwise.
bool ispatest::test_row_matrix_vector_multiply  (  Epetra_RowMatrix &  R  ) 
Verify that a matrix is a valid Epetra_RowMatrix by attempting to multiply with it.
Return true if successful, false otherwise.
y = Rx will be calculated, where "y" will be created with the OperatorRangeMap() of "R" and "x" will be created with the OperatorDomainMap() of "R".
Return true if successful, false otherwise.
bool ispatest::test_matrix_vector_multiply  (  Epetra_CrsGraph &  G  ) 
Verify that a matrix is a valid Epetra_CrsGraph by attempting to multiply with it.
Return true if successful, false otherwise.
An Epetra_CrsMatrix (A) will be created from the input graph G, and then y = Ax will be computed.
"x" will be created with the domain map of "G", and "y" will be created with the range map of "G".
Return true if successful, false otherwise.
bool ispatest::test_matrix_vector_multiply  (  Epetra_LinearProblem &  LP  ) 
Verify that the Epetra_RowMatrix in a Epetra_LinearProblem is valid by attempting to multiply with it.
An Epetra_RowMatrix (R) will be extracted from the linear problem, and then y = Rx will be computed.
"y" will be created with the OperatorRangeMap() of "R" and "x" will be created with the OperatorDomainMap() of "R".
This test does not use the vectors in the linear problem, it uses a made up vector. (Maybe it should use rhs and lhs?)
Return true if successful, false otherwise.
Epetra_Map* ispatest::map_from_blockmap  (  const Epetra_BlockMap &  b  ) 
Method to create an Epetra_Map from an Epetra_BlockMap, when using methods that require an Epetra_Map but you only have an Epetra_BlockMap.
Caller should delete the returned map when done with it.
int ispatest::readCoordFile  (  const std::string &  fname, 
std::vector< double > &  x,  
std::vector< double > &  y,  
std::vector< double > &  z  
) 
Read in the file "fname".
It should be a text file with a list of 1, 2 or 3dimensional floating point coordinates. Each is on one line of the file, and coordinates are separated by white space. Blank lines are allowed.
Fill the vectors x, y, and z with the x, y and z coordinates. (z will have size 0 for 1 and 2 dimensional coordinates, y will have size 0 for 1 dimensional coordinates.)
Return the dimension of the coordinates, or 0 if none could be read.
Epetra_MultiVector* ispatest::makeWeights  (  const Epetra_BlockMap &  map, 
double(*)(const int, const int, const int, const int)  wFunc  
) 
Create a multivector of 1 dimensional weights with the same distribution as the supplied map.
The weight for each object will be computed with the supplied function. The arguments for the supplied function are the global ID of the object, the rank of the calling process, the global number of objects, and the number of processes.
double ispatest::unitWeights  (  const int  id, 
const int  me,  
const int  nids,  
const int  nprocs  
) 
A function for makeWeights, returns 1.0 for the object's weight.
double ispatest::veeWeights  (  const int  id, 
const int  me,  
const int  nids,  
const int  nprocs  
) 
A function for makeWeights, weight is based on global ID, lower in the middle and higher at both ends.
Graph of weights for IDs would be "v" shaped.
double ispatest::alternateWeights  (  const int  id, 
const int  me,  
const int  nids,  
const int  nprocs  
) 
A function for makeWeights, weights alternate 1.0, 2.0, 1.0, etc.
by process ID.
Epetra_MultiVector* ispatest::file2multivector  (  const Epetra_Comm &  comm, 
const std::string &  fname  
) 
Read in a file of 1, 2 or 3 dimensional coordinates and create a multivector with a standard linear distribution.
int ispatest::printMultiVector  (  const Epetra_MultiVector &  mv, 
std::ostream &  os,  
const char *  s,  
int  max = 1000 

) 
Print out the contents of the multivector by process, with optional title.
This is more compact the Epetra_MultiVector::Print().
int ispatest::printRowMatrix  (  const Epetra_RowMatrix &  m, 
std::ostream &  os,  
const char *  s,  
bool  withGraphCuts,  
int  max = 1000 

) 
Print out the contents of a small Epetra_RowMatrix, with optional title.
There is no Epetra_RowMatrix::Print. If m is symmetric, we can view it as a graph and show graph cuts if "withGraphCuts" is true.
int ispatest::compute_balance  (  const Epetra_Vector &  wgts, 
double  myGoalWeight,  
double &  min,  
double &  max,  
double &  avg  
) 
Given an Epetra_Vector of weights, compute the weight imbalance on each process.
Set the minimum imbalance across all processes, the maximum, and the average. myShare is between 0 and 1, and usually would be 1.0/numProc.
int ispatest::compute_hypergraph_metrics  (  const Epetra_CrsGraph &  graph, 
Isorropia::Epetra::CostDescriber &  costs,  
double &  myGoalWeight,  
double &  balance,  
double &  cutn,  
double &  cutl  
) 
Compute Zoltanstyle hypergraph metrics given a partitioned CrsGraph and a CostDescriber (weight) object.
If the CostDescriber has no weights in it, reasonable defaults will be used.
int ispatest::compute_hypergraph_metrics  (  const Epetra_RowMatrix &  matrix, 
Isorropia::Epetra::CostDescriber &  costs,  
double &  myGoalWeight,  
double &  balance,  
double &  cutn,  
double &  cutl  
) 
Compute Zoltanstyle hypergraph metrics given a partitioned RowMatrix and a CostDescriber (weight) object.
If the CostDescriber has no weights in it, reasonable defaults will be used.
int ispatest::compute_graph_metrics  (  const Epetra_RowMatrix &  matrix, 
Isorropia::Epetra::CostDescriber &  costs,  
double &  myGoalWeight,  
double &  balance,  
int &  numCuts,  
double &  cutWgt,  
double &  cutn,  
double &  cutl  
) 
Compute graph metrics given an Epetra_RowMatrix.
A CostDescriber object may provide vertex (row) and/or edge (nonzeroes) weights, or it may be an initialized object with no weights. If no vertex weights are provided, each vertex is assumed to be weight 1. If no edge weights are provided, each edge is assumed to be weight 1.
The goal weight for a process is the proportion of the total vertex (row) weights that were to be assigned to this process under repartitioning. If all processes are to get an equal proportion of the weight, set this value to (1.0 / # processes). This value is needed in order to compute how close the repartitioning is to being perfectly balanced.
If the CostDescriber has no weights in it, reasonable defaults will be used.
int ispatest::compute_graph_metrics  (  const Epetra_CrsGraph &  graph, 
Isorropia::Epetra::CostDescriber &  costs,  
double &  myGoalWeight,  
double &  balance,  
int &  numCuts,  
double &  cutWgt,  
double &  cutn,  
double &  cutl  
) 
Compute graph metrics given an Epetra_CrsGraph.
A CostDescriber object may provide vertex (row) and/or edge (nonzeroes) weights, or it may be an initialized object with no weights. If no vertex weights are provided, each vertex is assumed to be weight 1. If no edge weights are provided, each edge is assumed to be weight 1.
The goal weight for a process is the proportion of the total vertex (row) weights that were to be assigned to this process under repartitioning. If all processes are to get an equal proportion of the weight, set this value to (1.0 / # processes). This value is needed in order to compute how close the repartitioning is to being perfectly balanced.
If the CostDescriber has no weights in it, reasonable defaults will be used.
void ispatest::show_matrix  (  const char *  txt, 
const Epetra_RowMatrix &  matrix,  
const Epetra_Comm &  comm  
) 
Print out a distributed RowMatrix.
This only works for small test matrices of 1s and 0s, and 10 or fewer processes.
void ispatest::show_matrix  (  const char *  txt, 
const Epetra_CrsGraph &  graph,  
const Epetra_Comm &  comm  
) 
Print out a distributed CrsGraph.
This only works for small test matrices of 1s and 0s and 10 or fewer processes.
void ispatest::show_matrix  (  const char *  txt, 
const Epetra_LinearProblem &  problem,  
const Epetra_Comm &  comm  
) 
Print out a distributed LinearProblem.
This only works for small test matrices of 1s and 0s and 10 or fewer processes.
void ispatest::read_distribution  (  const char *  filename, 
std::vector< int > &  rows,  
std::vector< int > &  cols,  
std::vector< int > &  partitions  
) 
Read a matrix distribution from a file.
The file is expected to follow a very simple format where each line corresponds to a single nonzero of the matrix, and each line contains 3 numbers which specify a row number, a columnnumber, and a partition number. When this function returns, each of the three vectors should have the same length, which is the number of nonzeros.
bool ispatest::set_verbose  (  int  localProc, 
int  argc,  
char **  argv  
) 
return a bool that's true if v appears in the commandline arguments.