ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
sol
function
randvarfunctional
risk
spectral
ROL_ChebyshevSpectral.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_CHEBYSHEVKUSUOKA_HPP
11
#define ROL_CHEBYSHEVKUSUOKA_HPP
12
13
#include "
ROL_SpectralRisk.hpp
"
14
#include "ROL_GaussChebyshev1Quadrature.hpp"
15
#include "ROL_GaussChebyshev2Quadrature.hpp"
16
#include "ROL_GaussChebyshev3Quadrature.hpp"
17
59
60
namespace
ROL
{
61
62
template
<
class
Real>
63
class
ChebyshevSpectral
:
public
SpectralRisk
<Real> {
64
private
:
65
ROL::Ptr<PlusFunction<Real> >
plusFunction_
;
66
67
Real
lower_
,
upper_
;
68
int
nQuad_
;
69
int
wType_
;
70
71
std::vector<Real>
wts_
;
72
std::vector<Real>
pts_
;
73
74
void
checkInputs
(
void
)
const
{
75
ROL_TEST_FOR_EXCEPTION(
lower_
>
upper_
, std::invalid_argument,
76
">>> ERROR (ROL::ChebyshevSpectral): Lower bound exceeds upper!"
);
77
ROL_TEST_FOR_EXCEPTION(
lower_
<
static_cast<
Real
>
(0), std::invalid_argument,
78
">>> ERROR (ROL::ChebyshevSpectral): Lower bound is less than zero!"
);
79
ROL_TEST_FOR_EXCEPTION(
static_cast<
Real
>
(1) <
upper_
, std::invalid_argument,
80
">>> ERROR (ROL::ChebyshevSpectral): Upper bound is greater than one!"
);
81
ROL_TEST_FOR_EXCEPTION((
wType_ < 1 || wType_ >
3), std::invalid_argument,
82
">>> ERROR (ROL::ChebyshevSpectral): Weight must be 1, 2 or 3!"
);
83
ROL_TEST_FOR_EXCEPTION(
plusFunction_
== ROL::nullPtr, std::invalid_argument,
84
">>> ERROR (ROL::ChebyshevSpectral): PlusFunction pointer is null!"
);
85
}
86
87
void
initializeQuad
(
void
) {
88
ROL::Ptr<Quadrature1D<Real> > quad;
89
if
(
wType_
== 1 ) {
90
quad = ROL::makePtr<GaussChebyshev1Quadrature<Real>>(
nQuad_
);
91
}
92
else
if
(
wType_
== 2 ) {
93
quad = ROL::makePtr<GaussChebyshev2Quadrature<Real>>(
nQuad_
);
94
}
95
else
if
(
wType_
== 3 ) {
96
quad = ROL::makePtr<GaussChebyshev3Quadrature<Real>>(
nQuad_
);
97
}
98
// quad->test();
99
quad->get(
pts_
,
wts_
);
100
Real sum(0), half(0.5), one(1);
101
for
(
int
i = 0; i <
nQuad_
; ++i) {
102
sum +=
wts_
[i];
103
}
104
for
(
int
i = 0; i <
nQuad_
; ++i) {
105
wts_
[i] /= sum;
106
pts_
[i] =
lower_
+ (
upper_
-
lower_
)*half*(
pts_
[i] + one);
107
}
108
SpectralRisk<Real>::buildMixedQuantile
(
pts_
,
wts_
,
plusFunction_
);
109
}
110
111
public
:
124
ChebyshevSpectral
( ROL::ParameterList &parlist )
125
:
SpectralRisk
<Real>() {
126
ROL::ParameterList &list
127
= parlist.sublist(
"SOL"
).sublist(
"Risk Measure"
).sublist(
"Chebyshev Spectral Risk"
);
128
// Grab confidence level and quadrature order
129
lower_
= list.get(
"Lower Bound"
,0.0);
130
upper_
= list.get(
"Upper Bound"
,1.0);
131
nQuad_
= list.get(
"Number of Quadrature Points"
,5);
132
wType_
= list.get(
"Weight Type"
,1);
133
plusFunction_
= ROL::makePtr<PlusFunction<Real>>(list);
134
// Check inputs
135
checkInputs
();
136
initializeQuad
();
137
}
138
147
ChebyshevSpectral
(
const
Real lower,
const
Real upper,
148
const
int
nQuad,
const
int
wType,
149
const
ROL::Ptr<
PlusFunction<Real>
> &pf)
150
:
SpectralRisk
<Real>(),
plusFunction_
(pf),
151
lower_
(lower),
upper_
(upper),
nQuad_
(nQuad),
wType_
(wType) {
152
// Check inputs
153
checkInputs
();
154
initializeQuad
();
155
}
156
};
157
158
}
159
160
#endif
ROL_SpectralRisk.hpp
ROL::ChebyshevSpectral::checkInputs
void checkInputs(void) const
Definition
ROL_ChebyshevSpectral.hpp:74
ROL::ChebyshevSpectral::plusFunction_
ROL::Ptr< PlusFunction< Real > > plusFunction_
Definition
ROL_ChebyshevSpectral.hpp:65
ROL::ChebyshevSpectral::nQuad_
int nQuad_
Definition
ROL_ChebyshevSpectral.hpp:68
ROL::ChebyshevSpectral::upper_
Real upper_
Definition
ROL_ChebyshevSpectral.hpp:67
ROL::ChebyshevSpectral::wType_
int wType_
Definition
ROL_ChebyshevSpectral.hpp:69
ROL::ChebyshevSpectral::pts_
std::vector< Real > pts_
Definition
ROL_ChebyshevSpectral.hpp:72
ROL::ChebyshevSpectral::lower_
Real lower_
Definition
ROL_ChebyshevSpectral.hpp:67
ROL::ChebyshevSpectral::ChebyshevSpectral
ChebyshevSpectral(const Real lower, const Real upper, const int nQuad, const int wType, const ROL::Ptr< PlusFunction< Real > > &pf)
Constructor.
Definition
ROL_ChebyshevSpectral.hpp:147
ROL::ChebyshevSpectral::wts_
std::vector< Real > wts_
Definition
ROL_ChebyshevSpectral.hpp:71
ROL::ChebyshevSpectral::ChebyshevSpectral
ChebyshevSpectral(ROL::ParameterList &parlist)
Constructor.
Definition
ROL_ChebyshevSpectral.hpp:124
ROL::ChebyshevSpectral::initializeQuad
void initializeQuad(void)
Definition
ROL_ChebyshevSpectral.hpp:87
ROL::PlusFunction
Definition
ROL_PlusFunction.hpp:21
ROL::SpectralRisk::SpectralRisk
SpectralRisk(void)
Definition
ROL_SpectralRisk.hpp:132
ROL::SpectralRisk::buildMixedQuantile
void buildMixedQuantile(const std::vector< Real > &pts, const std::vector< Real > &wts, const ROL::Ptr< PlusFunction< Real > > &pf)
Definition
ROL_SpectralRisk.hpp:77
ROL
Definition
ROL_ElementwiseVector.hpp:27
Generated by
1.17.0