Zoltan2
Loading...
Searching...
No Matches
Zoltan2_GraphMetrics.hpp
Go to the documentation of this file.
1// @HEADER
2//
3// ***********************************************************************
4//
5// Zoltan2: A package of combinatorial algorithms for scientific computing
6// Copyright 2012 Sandia Corporation
7//
8// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9// the U.S. Government retains certain rights in this software.
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//
18// 2. Redistributions in binary form must reproduce the above copyright
19// notice, this list of conditions and the following disclaimer in the
20// documentation and/or other materials provided with the distribution.
21//
22// 3. Neither the name of the Corporation nor the names of the
23// contributors may be used to endorse or promote products derived from
24// this software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact Karen Devine (kddevin@sandia.gov)
39// Erik Boman (egboman@sandia.gov)
40// Siva Rajamanickam (srajama@sandia.gov)
41//
42// ***********************************************************************
43//
44// @HEADER
45
49#ifndef ZOLTAN2_GRAPHCMETRICS_HPP
50#define ZOLTAN2_GRAPHCMETRICS_HPP
51
55
56#define GRAPH_METRICS_TYPE_NAME "GraphMetrics"
57
58namespace Zoltan2{
59
61template <typename scalar_t>
62 class GraphMetrics : public BaseClassMetrics<scalar_t> {
63
64public:
66GraphMetrics(std::string mname) : BaseClassMetrics<scalar_t>(static_metricNames_.size(), mname) {}
67
70
72virtual const std::string & getMetricType() const { return GraphMetrics<scalar_t>::static_metricTypeName_; }
73
75static void printHeader(std::ostream &os);
76
78virtual void printLine(std::ostream &os) const;
79
81void setGlobalSum(scalar_t x) { this->setMetricValue("global sum", x);}
82
84void setGlobalMax(scalar_t x) { this->setValue("global maximum", x);}
85
87scalar_t getGlobalSum() const { return this->getMetricValue("global sum");}
88
90scalar_t getGlobalMax() const { return this->getMetricValue("global maximum");}
91
93virtual const std::vector<std::string> & getMetrics() const { return GraphMetrics<scalar_t>::static_metricNames_; }
94
96static std::vector<std::string> static_metricNames_;
97
99static std::string static_metricTypeName_;
100}; // end class
101
103template <typename scalar_t>
105
107template <typename scalar_t>
108std::vector<std::string> GraphMetrics<scalar_t>::static_metricNames_ = {
109 "global sum",
110 "global maximum"
111};
112
113template <typename scalar_t>
115{
116 os << std::setw(20) << " ";
117 os << std::setw(12) << "total" << std::setw(12) << "max";
118 os << std::endl;
119}
120
121template <typename scalar_t>
122 void GraphMetrics<scalar_t>::printLine(std::ostream &os) const
123{
124 std::string label( this->getName() );
125
126 os << std::setw(20) << label;
127 os << std::setw(12) << std::setprecision(4) << this->getMetricValue("global sum");
128 os << std::setw(12) << std::setprecision(4) << this->getMetricValue("global maximum");
129
130 os << std::endl;
131}
132
133} //namespace Zoltan2
134#endif
#define GRAPH_METRICS_TYPE_NAME
Defines the GraphModel interface.
void setMetricValue(const std::string &metric_name, scalar_t value) const
void setValue(int enumIndex, scalar_t value)
scalar_t getMetricValue(const std::string &metric_name) const
static void printHeader(std::ostream &os)
Print a standard header.
scalar_t getGlobalSum() const
Get the global sum of edge cuts for all parts.
static std::string static_metricTypeName_
virtual const std::string & getMetricType() const
Get the class type of the metric.
void setGlobalMax(scalar_t x)
Set the global maximum across parts.
void setGlobalSum(scalar_t x)
Set the global sum.
virtual void printLine(std::ostream &os) const
Print a standard line of data that fits under the header.
static std::vector< std::string > static_metricNames_
virtual const std::vector< std::string > & getMetrics() const
scalar_t getGlobalMax() const
Get the global maximum of edge cuts per part across all parts.
GraphMetrics(std::string mname)
Constructor.
Created by mbenlioglu on Aug 31, 2020.