/usr/include/trilinos/Isorropia_EpetraCostDescriber.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | //@HEADER
/*
************************************************************************
Isorropia: Partitioning and Load Balancing Package
Copyright (2006) Sandia Corporation
Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
license for use of this work by or on behalf of the U.S. Government.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
************************************************************************
*/
//@HEADER
#ifndef _Isorropia_EpetraCostDescriber_hpp_
#define _Isorropia_EpetraCostDescriber_hpp_
#include <Isorropia_ConfigDefs.hpp>
#include <Isorropia_CostDescriber.hpp>
#include <Teuchos_RCP.hpp>
#include <Teuchos_ParameterList.hpp>
#include <map>
#include <list>
#include <set>
#include <iostream>
#ifdef HAVE_EPETRA
class Epetra_Vector;
class Epetra_CrsMatrix;
namespace Isorropia {
/** The Isorropia::Epetra namespace implements a parallel partitioner
that operates on Epetra objects.
The objects to be partitioned may be the rows of an Epetra matrix
or linear system. There are two modes of operation.
In one, the user supplies
an Epetra object to Isorropia::Epetra::create_balanced_copy() and a
new, rebalanced Epetra object is returned.
In the other mode, the user supplies
an Epetra object to Isorropia::Epetra::create_partitioner() and a
Isorropia::Epetra::Partitioner object is returned. This Partitioner
object may be used to create an Isorropia::Epetra::Redistributor object.
Finally the "redistribute" method of the Redistributor object
may be used multiple times to redistribute Epetra objects with the
same distribution as the Epetra object given to create_partitioner().
In both cases, the application may supply row and edge weights with
an Isorropia::Epetra::CostDescriber and may supply parameters with
an Teuchos::ParameterList.
If Trilinos has been built with the Zoltan parallel dynamic load
balancing library (http://www.cs.sandia.gov/Zoltan),
then Isorropia will use Zoltan to partition the Epetra object.
The application can set Zoltan parameters with the ParameterList object.
If Zoltan is not available, or the application has set the parameter
"PARTITIONING_METHOD" to "SIMPLE_LINEAR", Isorropia will
perform a simple linear partitioning
of the object. If the application supplied vertex weights with a
CostDescriber, the linear partitioner will observe the vertex (row) weights.
Otherwise the linear partitioner will use the number of non-zeroes in
the row as the row weight. The linear partitioner does not
consider edge weights in the partitioning.
*/
class Operator;
namespace Epetra {
/** The CostDescriber class describes the vertex, edge and/or hyperedge weights.
It is instantiated by the application to define
weights, and then supplied to Isorropia with the
Isorropia::Epetra::create_balanced_copy method or the
Isorropia::Epetra::create_partitioner method.
The CostDescriber can hold vertex (row) weights.
For graph partitioning with Zoltan it may
also define graph edge (nonzero) weights. For hypergraph partitioning
with Zoltan it may describe hyperedge (column) weights.
If the application does not provide weights, reasonable defaults will
be used. Zoltan parameters (supplied with an Isorropia::Epetra::ParameterList)
are available to override those defaults.
*/
// Forward declarations of friends
namespace ZoltanLib{
class QueryObject;
}
class ZoltanLibClass;
class CostDescriber : public Isorropia::CostDescriber {
// public methods are part of API, private methods are used by different
// classes in isorropia
friend class Isorropia::Operator;
friend class Isorropia::Epetra::ZoltanLib::QueryObject;
friend class Isorropia::Epetra::ZoltanLibClass;
public:
/** Constructor */
CostDescriber();
/** Destructor */
~CostDescriber();
/** Overloaded << operator for CostDescriber object
*/
friend std::ostream& operator <<(std::ostream &, const Isorropia::Epetra::CostDescriber &cd);
/** setVertexWeights is called by a process to supply the
weight of each vertex (row) in the graph or hypergraph.
If the object to be partitioned is instead an Epetra_MultiVector
representing real
coordinates, then the weights represent the weight assigned to each coordinate.
\param[in] vwgts vector of weights, one for each vertex
*/
void setVertexWeights(Teuchos::RCP<const Epetra_Vector> vwgts);
/** setGraphEdgeWeights is called by a process to supply the weights for
each of the edges of its vertices. An edge corresponds to a non-zero
in the row representing the vertex.
This method is called only when performing graph partitioning with a
square symmetric matrix. For hypergraph partitioning call the equivalent
hypergraph method.
\param gewts an Epetra_CrsMatrix supplied by the application, each non-zero
represents a weight for an edge
*/
void setGraphEdgeWeights(Teuchos::RCP<const Epetra_CrsMatrix> gewts);
/** setHypergraphEdgeWeights is called by processes in an application to
supply weights for the hyperedges, which are represented by the columns
of the matrix. (A hyperedge can in general link more than one vertex.)
Matrices that represent hypergraphs are not in general square.
There may be more or fewer hyperedges (columns) than vertices (rows).
\param hgewts an Epetra_Vector containing the weights for each hyperedge.
*/
void setHypergraphEdgeWeights(Teuchos::RCP<const Epetra_Vector> hgewts);
/** setHypergraphEdgeWeights is called by processes in an application to
supply weights for the hyperedges, which are represented by the columns
of the matrix. (A hyperedge can in general link more than one vertex.)
Matrices that represent hypergraphs are not in general square.
There may be more or fewer hyperedges (columns) than vertices (rows).
More than one process can supply a weight for the same column. (So
there is no concept of a process owning a hyperedge.) Zoltan
combines these weights according to the setting of the
PHG_EDGE_WEIGHT_OPERATION parameter.
\param numHGedges the length of the hgGIDs and heEwgts arrays
\param hgGIDs the global ID for each hyperedge this process will supply a weight for
\param hgEwgts the hyperedge weight corresponding to each hyperedge listed in hgGIDs
*/
void setHypergraphEdgeWeights(int numHGedges, const int *hgGIDs, const float *hgEwgts);
/** \copydoc Isorropia::Epetra::CostDescriber::setHypergraphEdgeWeights(int numHGedges, const int *hgGIDs, const float *hgEwgts)
*/
void setHypergraphEdgeWeights(int numHGedges, const int *hgGIDs, const double *hgEwgts);
/** Get the contents of this CostDescriber
\param vertexWeights is set to a mapping from vertex global IDs to their weights
\param graphEdgeWeights is a mapping from vertex global IDs to a map from neighboring
IDs to edge weights
\param hypergraphEdgeWeights is a mapping from hyperedge (column) global IDs to hyperedge weights
*/
void getCosts(std::map<int, float > &vertexWeights,
std::map<int, std::map<int, float > > &graphEdgeWeights,
std::map<int, float > &hypergraphEdgeWeights) const;
/** Print out the contents of this CostDescriber
*/
void show_cd(std::ostream &) const;
private:
/** \copydoc Isorropia::CostDescriber::setParameters
*/
void setParameters(const Teuchos::ParameterList& paramlist);
/** \copydoc Isorropia::CostDescriber::haveVertexWeights
*/
bool haveVertexWeights() const;
/** \copydoc Isorropia::CostDescriber::getNumVertices
*/
int getNumVertices() const;
/** \copydoc Isorropia::CostDescriber::getVertexWeights
*/
void getVertexWeights(int numVertices,
int* global_ids, float* weights) const;
/** \copydoc Isorropia::CostDescriber::haveGraphEdgeWeights
*/
bool haveGraphEdgeWeights() const;
/** \copydoc Isorropia::CostDescriber::getNumGraphEdges
*/
int getNumGraphEdges(int vertex_global_id) const;
/** Get the set of global IDs for the vertices that we have edge information for.
\param gids will be set to the global IDs of the vertices for which neighbor and edge weight information have been provided
*/
int getGraphEdgeVertices(std::set<int> &gids) const;
/** \copydoc Isorropia::CostDescriber::getGraphEdgeWeights
*/
void getGraphEdgeWeights(int vertex_global_id,
int num_neighbors,
int* neighbor_global_ids,
float* weights) const;
/** \copydoc Isorropia::CostDescriber::haveHypergraphEdgeWeights
*/
bool haveHypergraphEdgeWeights() const;
/** \copydoc Isorropia::CostDescriber::getNumHypergraphEdgeWeights
*/
int getNumHypergraphEdgeWeights() const;
/** \copydoc Isorropia::CostDescriber::getHypergraphEdgeWeights
*/
void getHypergraphEdgeWeights(int numEdges,
int* global_ids,
float* weights) const;
/** Return the CostDescribers hypergraph edge weights as a map from hyperedge (column)
global ID to weight.
\param wgtMap will be set to a map from hyperedge global ID to hyperedge weight
*/
int getHypergraphEdgeWeights(std::map<int, float> &wgtMap) const;
/** Get vertex weights in the form of a map from vertex global ID to vertex weight.
\param wgtMap a map supplied by the caller, the vertex weights will be added to this map
\return the size of wgtMap
*/
int getVertexWeights(std::map<int, float> &wgtMap) const;
/** getGraphEdgeWeights is called to obtain
the graph edge weights for a given vertex (row).
\param vertex_global_id the global ID of the vertex the caller wants edge weights for
\param wgtMap a map from the global ID of each vertex neighbor to the weight of the edge formed by the vertex and this neighbor
\return the count of the neighbors of vertex_global_id
*/
int getGraphEdgeWeights(int vertex_global_id, std::map<int, float> &wgtMap) const;
/** haveGlobalVertexWeights returns true if any process in the application has
supplied vertex weights, it returns false otherwise.
*/
bool haveGlobalVertexWeights() const;
/** setNumGlobalVertexWeights may be used to set the count of the
global number of vertex weights supplied to the CostDescriber
*/
void setNumGlobalVertexWeights(int num);
/** haveGlobalGraphEdgeWeights returns true if any process in the application has
supplied graph edge weights, it returns false otherwise.
*/
bool haveGlobalGraphEdgeWeights() const;
/** setNumGlobalGraphEdgeWeights may be used to set the count of the
global number of graph edge weights supplied to the CostDescriber
*/
void setNumGlobalGraphEdgeWeights(int num);
/** haveGlobalHypergraphEdgeWeights returns true if any process in the application has
supplied hyperedge weights, it returns false otherwise.
*/
bool haveGlobalHypergraphEdgeWeights() const;
/** setNumGlobalHypergraphEdgeWeights may be used to set the count of the
global number of hyperedge weights supplied to the CostDescriber
*/
void setNumGlobalHypergraphEdgeWeights(int num);
/** Dynamically allocate storage for hypergraph edge weights.
*/
void allocate_hg_edge_weights_(int n);
/** Free storage used by hypergraph edge weights.
*/
void free_hg_edge_weights_();
Teuchos::RCP<const Epetra_Vector> vertex_weights_;
Teuchos::RCP<const Epetra_CrsMatrix> graph_edge_weights_;
std::set<int> graph_self_edges_;
Teuchos::ParameterList paramlist_;
int *hg_edge_gids_;
float *hg_edge_weights_;
int num_hg_edge_weights_;
int numGlobalVertexWeights_;
int numGlobalGraphEdgeWeights_;
int numGlobalHypergraphEdgeWeights_;
/** getEdges creates an array of the neighbors and edge weights for given vertex.
Self edges are not included.
\param vertexGID the global ID of the vertex (must be one owned by calling process)
\param len of preallocated nborGID and weights arrays
\param nborGID on return contains the global ID of each vertex neighboring vertexGID,
allocated by caller
\param weights on return contains the weight for each edge formed by the vertices in nborGID
\return the number of neighbors in nborGID is returned
*/
int getEdges(int vertexGID, int len, int *nborGID, float *weights) const;
};//class CostDescriber
}//namespace Epetra
}//namespace Isorropia
#endif //HAVE_EPETRA
#endif
|