ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
sol
function
distribution
ROL_DistributionFactory.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Rapid Optimization Library (ROL) Package
4
//
5
// Copyright 2014 NTESS and the ROL contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef ROL_DISTRIBUTIONFACTORY_HPP
11
#define ROL_DISTRIBUTIONFACTORY_HPP
12
13
#include "ROL_ParameterList.hpp"
14
15
#include "
ROL_Dirac.hpp
"
16
#include "
ROL_Gaussian.hpp
"
17
#include "
ROL_TruncatedGaussian.hpp
"
18
#include "
ROL_Uniform.hpp
"
19
#include "
ROL_Logistic.hpp
"
20
#include "
ROL_Triangle.hpp
"
21
#include "
ROL_Parabolic.hpp
"
22
#include "
ROL_RaisedCosine.hpp
"
23
#include "
ROL_Laplace.hpp
"
24
#include "
ROL_Cauchy.hpp
"
25
#include "
ROL_Smale.hpp
"
26
#include "
ROL_Arcsine.hpp
"
27
#include "
ROL_Kumaraswamy.hpp
"
28
#include "
ROL_Exponential.hpp
"
29
#include "
ROL_TruncatedExponential.hpp
"
30
#include "
ROL_Gamma.hpp
"
31
#include "
ROL_Beta.hpp
"
32
33
namespace
ROL
{
34
35
enum
EDistribution
{
36
DISTRIBUTION_ARCSINE
= 0,
37
DISTRIBUTION_BETA
,
38
DISTRIBUTION_CAUCHY
,
39
DISTRIBUTION_DIRAC
,
40
DISTRIBUTION_EXPONENTIAL
,
41
DISTRIBUTION_GAMMA
,
42
DISTRIBUTION_GAUSSIAN
,
43
DISTRIBUTION_KUMARASWAMY
,
44
DISTRIBUTION_LAPLACE
,
45
DISTRIBUTION_LOGISTIC
,
46
DISTRIBUTION_PARABOLIC
,
47
DISTRIBUTION_RAISEDCOSINE
,
48
DISTRIBUTION_SMALE
,
49
DISTRIBUTION_TRIANGLE
,
50
DISTRIBUTION_TRUNCATEDEXPONENTIAL
,
51
DISTRIBUTION_TRUNCATEDGAUSSIAN
,
52
DISTRIBUTION_UNIFORM
,
53
DISTRIBUTION_LAST
54
};
55
56
inline
std::string
EDistributionToString
(
EDistribution
ed) {
57
std::string retString;
58
switch
(ed) {
59
case
DISTRIBUTION_ARCSINE
: retString =
"Arcsine"
;
break
;
60
case
DISTRIBUTION_BETA
: retString =
"Beta"
;
break
;
61
case
DISTRIBUTION_CAUCHY
: retString =
"Cauchy"
;
break
;
62
case
DISTRIBUTION_DIRAC
: retString =
"Dirac"
;
break
;
63
case
DISTRIBUTION_EXPONENTIAL
: retString =
"Exponential"
;
break
;
64
case
DISTRIBUTION_GAMMA
: retString =
"Gamma"
;
break
;
65
case
DISTRIBUTION_GAUSSIAN
: retString =
"Gaussian"
;
break
;
66
case
DISTRIBUTION_KUMARASWAMY
: retString =
"Kumaraswamy"
;
break
;
67
case
DISTRIBUTION_LAPLACE
: retString =
"Laplace"
;
break
;
68
case
DISTRIBUTION_LOGISTIC
: retString =
"Logistic"
;
break
;
69
case
DISTRIBUTION_PARABOLIC
: retString =
"Parabolic"
;
break
;
70
case
DISTRIBUTION_RAISEDCOSINE
: retString =
"Raised Cosine"
;
break
;
71
case
DISTRIBUTION_SMALE
: retString =
"Smale"
;
break
;
72
case
DISTRIBUTION_TRIANGLE
: retString =
"Triangle"
;
break
;
73
case
DISTRIBUTION_TRUNCATEDEXPONENTIAL
: retString =
"Truncated Exponential"
;
break
;
74
case
DISTRIBUTION_TRUNCATEDGAUSSIAN
: retString =
"Truncated Gaussian"
;
break
;
75
case
DISTRIBUTION_UNIFORM
: retString =
"Uniform"
;
break
;
76
case
DISTRIBUTION_LAST
: retString =
"Last Type (Dummy)"
;
break
;
77
default
: retString =
"INVALID EDistribution"
;
break
;
78
}
79
return
retString;
80
}
81
82
inline
int
isValidDistribution
(
EDistribution
ed) {
83
return
( (ed ==
DISTRIBUTION_DIRAC
) ||
84
(ed ==
DISTRIBUTION_BETA
) ||
85
(ed ==
DISTRIBUTION_GAMMA
) ||
86
(ed ==
DISTRIBUTION_GAUSSIAN
) ||
87
(ed ==
DISTRIBUTION_TRUNCATEDGAUSSIAN
) ||
88
(ed ==
DISTRIBUTION_UNIFORM
) ||
89
(ed ==
DISTRIBUTION_LOGISTIC
) ||
90
(ed ==
DISTRIBUTION_TRIANGLE
) ||
91
(ed ==
DISTRIBUTION_PARABOLIC
) ||
92
(ed ==
DISTRIBUTION_RAISEDCOSINE
) ||
93
(ed ==
DISTRIBUTION_LAPLACE
) ||
94
(ed ==
DISTRIBUTION_CAUCHY
) ||
95
(ed ==
DISTRIBUTION_SMALE
) ||
96
(ed ==
DISTRIBUTION_ARCSINE
) ||
97
(ed ==
DISTRIBUTION_KUMARASWAMY
) ||
98
(ed ==
DISTRIBUTION_EXPONENTIAL
) ||
99
(ed ==
DISTRIBUTION_TRUNCATEDEXPONENTIAL
) );
100
}
101
102
inline
EDistribution
&
operator++
(
EDistribution
&type) {
103
return
type =
static_cast<
EDistribution
>
(type+1);
104
}
105
106
inline
EDistribution
operator++
(
EDistribution
&type,
int
) {
107
EDistribution
oldval = type;
108
++type;
109
return
oldval;
110
}
111
112
inline
EDistribution
&
operator--
(
EDistribution
&type) {
113
return
type =
static_cast<
EDistribution
>
(type-1);
114
}
115
116
inline
EDistribution
operator--
(
EDistribution
&type,
int
) {
117
EDistribution
oldval = type;
118
--type;
119
return
oldval;
120
}
121
122
inline
EDistribution
StringToEDistribution
(std::string s) {
123
s =
removeStringFormat
(s);
124
for
(
EDistribution
tr =
DISTRIBUTION_ARCSINE
; tr <
DISTRIBUTION_LAST
; tr++ ) {
125
if
( !s.compare(
removeStringFormat
(
EDistributionToString
(tr))) ) {
126
return
tr;
127
}
128
}
129
return
DISTRIBUTION_UNIFORM
;
130
}
131
132
template
<
class
Real>
133
inline
ROL::Ptr<Distribution<Real> >
DistributionFactory
(ROL::ParameterList &parlist) {
134
std::string dist;
135
ROL::ParameterList sollist;
136
if
( parlist.isSublist(
"SOL"
) ) {
137
dist.assign(parlist.sublist(
"SOL"
).sublist(
"Distribution"
).get(
"Name"
,
"Dirac"
));
138
sollist = parlist;
139
}
140
else
{
141
dist.assign(parlist.sublist(
"Distribution"
).get(
"Name"
,
"Dirac"
));
142
sollist.sublist(
"SOL"
) = parlist;
143
}
144
EDistribution
ed =
StringToEDistribution
(dist);
145
switch
(ed) {
146
case
DISTRIBUTION_ARCSINE
:
return
ROL::makePtr<Arcsine<Real>>(sollist);
147
case
DISTRIBUTION_BETA
:
return
ROL::makePtr<Beta<Real>>(sollist);
148
case
DISTRIBUTION_CAUCHY
:
return
ROL::makePtr<Cauchy<Real>>(sollist);
149
case
DISTRIBUTION_DIRAC
:
return
ROL::makePtr<Dirac<Real>>(sollist);
150
case
DISTRIBUTION_EXPONENTIAL
:
return
ROL::makePtr<Exponential<Real>>(sollist);
151
case
DISTRIBUTION_GAMMA
:
return
ROL::makePtr<Gamma<Real>>(sollist);
152
case
DISTRIBUTION_GAUSSIAN
:
return
ROL::makePtr<Gaussian<Real>>(sollist);
153
case
DISTRIBUTION_KUMARASWAMY
:
return
ROL::makePtr<Kumaraswamy<Real>>(sollist);
154
case
DISTRIBUTION_LAPLACE
:
return
ROL::makePtr<Laplace<Real>>(sollist);
155
case
DISTRIBUTION_LOGISTIC
:
return
ROL::makePtr<Logistic<Real>>(sollist);
156
case
DISTRIBUTION_PARABOLIC
:
return
ROL::makePtr<Parabolic<Real>>(sollist);
157
case
DISTRIBUTION_RAISEDCOSINE
:
return
ROL::makePtr<RaisedCosine<Real>>(sollist);
158
case
DISTRIBUTION_SMALE
:
return
ROL::makePtr<Smale<Real>>(sollist);
159
case
DISTRIBUTION_TRIANGLE
:
return
ROL::makePtr<Triangle<Real>>(sollist);
160
case
DISTRIBUTION_TRUNCATEDEXPONENTIAL
:
return
ROL::makePtr<TruncatedExponential<Real>>(sollist);
161
case
DISTRIBUTION_TRUNCATEDGAUSSIAN
:
return
ROL::makePtr<TruncatedGaussian<Real>>(sollist);
162
case
DISTRIBUTION_UNIFORM
:
return
ROL::makePtr<Uniform<Real>>(sollist);
163
default
:
return
ROL::nullPtr;
164
}
165
}
166
}
167
#endif
ROL_Arcsine.hpp
ROL_Beta.hpp
ROL_Cauchy.hpp
ROL_Dirac.hpp
ROL_Exponential.hpp
ROL_Gamma.hpp
ROL_Gaussian.hpp
ROL_Kumaraswamy.hpp
ROL_Laplace.hpp
ROL_Logistic.hpp
ROL_Parabolic.hpp
ROL_RaisedCosine.hpp
ROL_Smale.hpp
ROL_Triangle.hpp
ROL_TruncatedExponential.hpp
ROL_TruncatedGaussian.hpp
ROL_Uniform.hpp
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::removeStringFormat
std::string removeStringFormat(std::string s)
Definition
ROL_Types.hpp:215
ROL::StringToEDistribution
EDistribution StringToEDistribution(std::string s)
Definition
ROL_DistributionFactory.hpp:122
ROL::DistributionFactory
ROL::Ptr< Distribution< Real > > DistributionFactory(ROL::ParameterList &parlist)
Definition
ROL_DistributionFactory.hpp:133
ROL::operator--
EPolyProjAlgo & operator--(EPolyProjAlgo &type)
Definition
ROL_PolyhedralProjectionFactory.hpp:81
ROL::EDistribution
EDistribution
Definition
ROL_DistributionFactory.hpp:35
ROL::DISTRIBUTION_SMALE
@ DISTRIBUTION_SMALE
Definition
ROL_DistributionFactory.hpp:48
ROL::DISTRIBUTION_TRIANGLE
@ DISTRIBUTION_TRIANGLE
Definition
ROL_DistributionFactory.hpp:49
ROL::DISTRIBUTION_UNIFORM
@ DISTRIBUTION_UNIFORM
Definition
ROL_DistributionFactory.hpp:52
ROL::DISTRIBUTION_EXPONENTIAL
@ DISTRIBUTION_EXPONENTIAL
Definition
ROL_DistributionFactory.hpp:40
ROL::DISTRIBUTION_RAISEDCOSINE
@ DISTRIBUTION_RAISEDCOSINE
Definition
ROL_DistributionFactory.hpp:47
ROL::DISTRIBUTION_LAPLACE
@ DISTRIBUTION_LAPLACE
Definition
ROL_DistributionFactory.hpp:44
ROL::DISTRIBUTION_GAMMA
@ DISTRIBUTION_GAMMA
Definition
ROL_DistributionFactory.hpp:41
ROL::DISTRIBUTION_LAST
@ DISTRIBUTION_LAST
Definition
ROL_DistributionFactory.hpp:53
ROL::DISTRIBUTION_GAUSSIAN
@ DISTRIBUTION_GAUSSIAN
Definition
ROL_DistributionFactory.hpp:42
ROL::DISTRIBUTION_BETA
@ DISTRIBUTION_BETA
Definition
ROL_DistributionFactory.hpp:37
ROL::DISTRIBUTION_LOGISTIC
@ DISTRIBUTION_LOGISTIC
Definition
ROL_DistributionFactory.hpp:45
ROL::DISTRIBUTION_DIRAC
@ DISTRIBUTION_DIRAC
Definition
ROL_DistributionFactory.hpp:39
ROL::DISTRIBUTION_TRUNCATEDEXPONENTIAL
@ DISTRIBUTION_TRUNCATEDEXPONENTIAL
Definition
ROL_DistributionFactory.hpp:50
ROL::DISTRIBUTION_TRUNCATEDGAUSSIAN
@ DISTRIBUTION_TRUNCATEDGAUSSIAN
Definition
ROL_DistributionFactory.hpp:51
ROL::DISTRIBUTION_CAUCHY
@ DISTRIBUTION_CAUCHY
Definition
ROL_DistributionFactory.hpp:38
ROL::DISTRIBUTION_PARABOLIC
@ DISTRIBUTION_PARABOLIC
Definition
ROL_DistributionFactory.hpp:46
ROL::DISTRIBUTION_ARCSINE
@ DISTRIBUTION_ARCSINE
Definition
ROL_DistributionFactory.hpp:36
ROL::DISTRIBUTION_KUMARASWAMY
@ DISTRIBUTION_KUMARASWAMY
Definition
ROL_DistributionFactory.hpp:43
ROL::operator++
EPolyProjAlgo & operator++(EPolyProjAlgo &type)
Definition
ROL_PolyhedralProjectionFactory.hpp:71
ROL::EDistributionToString
std::string EDistributionToString(EDistribution ed)
Definition
ROL_DistributionFactory.hpp:56
ROL::isValidDistribution
int isValidDistribution(EDistribution ed)
Definition
ROL_DistributionFactory.hpp:82
Generated by
1.17.0