Zoltan2
Toggle main menu visibility
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
48
49
#ifndef ZOLTAN2_GRAPHCMETRICS_HPP
50
#define ZOLTAN2_GRAPHCMETRICS_HPP
51
52
#include <
Zoltan2_BaseClassMetrics.hpp
>
53
#include <
Zoltan2_GraphModel.hpp
>
54
#include <
Zoltan2_MetricUtility.hpp
>
55
56
#define GRAPH_METRICS_TYPE_NAME "GraphMetrics"
57
58
namespace
Zoltan2
{
59
61
template
<
typename
scalar_t>
62
class
GraphMetrics
:
public
BaseClassMetrics
<scalar_t> {
63
64
public
:
66
GraphMetrics
(std::string mname) :
BaseClassMetrics
<
scalar_t
>(
static_metricNames_
.size(), mname) {}
67
69
GraphMetrics
() :
BaseClassMetrics
<
scalar_t
>(
static_metricNames_
.size()) {}
70
72
virtual
const
std::string &
getMetricType
()
const
{
return
GraphMetrics<scalar_t>::static_metricTypeName_
; }
73
75
static
void
printHeader
(std::ostream &os);
76
78
virtual
void
printLine
(std::ostream &os)
const
;
79
81
void
setGlobalSum
(
scalar_t
x) { this->
setMetricValue
(
"global sum"
, x);}
82
84
void
setGlobalMax
(
scalar_t
x) { this->
setValue
(
"global maximum"
, x);}
85
87
scalar_t
getGlobalSum
()
const
{
return
this->
getMetricValue
(
"global sum"
);}
88
90
scalar_t
getGlobalMax
()
const
{
return
this->
getMetricValue
(
"global maximum"
);}
91
93
virtual
const
std::vector<std::string> &
getMetrics
()
const
{
return
GraphMetrics<scalar_t>::static_metricNames_
; }
94
96
static
std::vector<std::string>
static_metricNames_
;
97
99
static
std::string
static_metricTypeName_
;
100
};
// end class
101
103
template
<
typename
scalar_t>
104
std::string
GraphMetrics<scalar_t>::static_metricTypeName_
=
GRAPH_METRICS_TYPE_NAME
;
105
107
template
<
typename
scalar_t>
108
std::vector<std::string>
GraphMetrics<scalar_t>::static_metricNames_
= {
109
"global sum"
,
110
"global maximum"
111
};
112
113
template
<
typename
scalar_t>
114
void
GraphMetrics<scalar_t>::printHeader
(std::ostream &os)
115
{
116
os << std::setw(20) <<
" "
;
117
os << std::setw(12) <<
"total"
<< std::setw(12) <<
"max"
;
118
os << std::endl;
119
}
120
121
template
<
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
Zoltan2_BaseClassMetrics.hpp
GRAPH_METRICS_TYPE_NAME
#define GRAPH_METRICS_TYPE_NAME
Definition
Zoltan2_GraphMetrics.hpp:56
Zoltan2_GraphModel.hpp
Defines the GraphModel interface.
Zoltan2_MetricUtility.hpp
Zoltan2::BaseClassMetrics::setMetricValue
void setMetricValue(const std::string &metric_name, scalar_t value) const
Definition
Zoltan2_BaseClassMetrics.hpp:146
Zoltan2::BaseClassMetrics::setValue
void setValue(int enumIndex, scalar_t value)
Definition
Zoltan2_BaseClassMetrics.hpp:86
Zoltan2::BaseClassMetrics::getMetricValue
scalar_t getMetricValue(const std::string &metric_name) const
Definition
Zoltan2_BaseClassMetrics.hpp:137
Zoltan2::BaseClassMetrics::BaseClassMetrics
BaseClassMetrics()
Constructor - for compiling but not used.
Definition
Zoltan2_BaseClassMetrics.hpp:91
Zoltan2::BaseClassMetrics::getName
const std::string & getName() const
Get the name of the item measured.
Definition
Zoltan2_BaseClassMetrics.hpp:126
Zoltan2::GraphMetrics::printHeader
static void printHeader(std::ostream &os)
Print a standard header.
Definition
Zoltan2_GraphMetrics.hpp:114
Zoltan2::GraphMetrics::getGlobalSum
scalar_t getGlobalSum() const
Get the global sum of edge cuts for all parts.
Definition
Zoltan2_GraphMetrics.hpp:87
Zoltan2::GraphMetrics::static_metricTypeName_
static std::string static_metricTypeName_
Definition
Zoltan2_GraphMetrics.hpp:99
Zoltan2::GraphMetrics::getMetricType
virtual const std::string & getMetricType() const
Get the class type of the metric.
Definition
Zoltan2_GraphMetrics.hpp:72
Zoltan2::GraphMetrics::setGlobalMax
void setGlobalMax(scalar_t x)
Set the global maximum across parts.
Definition
Zoltan2_GraphMetrics.hpp:84
Zoltan2::GraphMetrics::setGlobalSum
void setGlobalSum(scalar_t x)
Set the global sum.
Definition
Zoltan2_GraphMetrics.hpp:81
Zoltan2::GraphMetrics::printLine
virtual void printLine(std::ostream &os) const
Print a standard line of data that fits under the header.
Definition
Zoltan2_GraphMetrics.hpp:122
Zoltan2::GraphMetrics::getMetrics
virtual const std::vector< std::string > & getMetrics() const
Definition
Zoltan2_GraphMetrics.hpp:93
Zoltan2::GraphMetrics::getGlobalMax
scalar_t getGlobalMax() const
Get the global maximum of edge cuts per part across all parts.
Definition
Zoltan2_GraphMetrics.hpp:90
Zoltan2::GraphMetrics::static_metricNames_
static std::vector< std::string > static_metricNames_
Definition
Zoltan2_GraphMetrics.hpp:96
Zoltan2::GraphMetrics::GraphMetrics
GraphMetrics()
Constructor.
Definition
Zoltan2_GraphMetrics.hpp:69
Zoltan2::GraphMetrics::GraphMetrics
GraphMetrics(std::string mname)
Constructor.
Definition
Zoltan2_GraphMetrics.hpp:66
Zoltan2
Created by mbenlioglu on Aug 31, 2020.
Definition
Zoltan2_AlgHybrid2GL.hpp:38
Zoltan2::scalar_t
core
src
util
Zoltan2_GraphMetrics.hpp
Generated by
1.17.0