ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
algorithm
TypeU
ROL_TypeU_AlgorithmFactory.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_TYPEU_ALGORITHM_FACTORY_H
11
#define ROL_TYPEU_ALGORITHM_FACTORY_H
12
13
#include "
ROL_TypeU_BundleAlgorithm.hpp
"
14
#include "
ROL_TypeU_LineSearchAlgorithm.hpp
"
15
#include "
ROL_TypeU_TrustRegionAlgorithm.hpp
"
16
#include "
ROL_Types.hpp
"
17
18
namespace
ROL
{
19
namespace
TypeU
{
20
28
enum
EAlgorithmU
{
29
ALGORITHM_U_BUNDLE
= 0,
30
ALGORITHM_U_LINESEARCH
,
31
ALGORITHM_U_TRUSTREGION
,
32
ALGORITHM_U_LAST
33
};
34
35
inline
std::string
EAlgorithmUToString
(
EAlgorithmU
alg) {
36
std::string retString;
37
switch
(alg) {
38
case
ALGORITHM_U_BUNDLE
: retString =
"Bundle"
;
break
;
39
case
ALGORITHM_U_LINESEARCH
: retString =
"Line Search"
;
break
;
40
case
ALGORITHM_U_TRUSTREGION
: retString =
"Trust Region"
;
break
;
41
case
ALGORITHM_U_LAST
: retString =
"Last Type (Dummy)"
;
break
;
42
default
: retString =
"INVALID EAlgorithmU"
;
43
}
44
return
retString;
45
}
46
52
inline
int
isValidAlgorithmU
(
EAlgorithmU
alg){
53
return
( (alg ==
ALGORITHM_U_BUNDLE
) ||
54
(alg ==
ALGORITHM_U_LINESEARCH
) ||
55
(alg ==
ALGORITHM_U_TRUSTREGION
) ||
56
(alg ==
ALGORITHM_U_LAST
)
57
);
58
}
59
60
inline
EAlgorithmU
&
operator++
(
EAlgorithmU
&type) {
61
return
type =
static_cast<
EAlgorithmU
>
(type+1);
62
}
63
64
inline
EAlgorithmU
operator++
(
EAlgorithmU
&type,
int
) {
65
EAlgorithmU
oldval = type;
66
++type;
67
return
oldval;
68
}
69
70
inline
EAlgorithmU
&
operator--
(
EAlgorithmU
&type) {
71
return
type =
static_cast<
EAlgorithmU
>
(type-1);
72
}
73
74
inline
EAlgorithmU
operator--
(
EAlgorithmU
&type,
int
) {
75
EAlgorithmU
oldval = type;
76
--type;
77
return
oldval;
78
}
79
80
inline
EAlgorithmU
StringToEAlgorithmU
(std::string s) {
81
s =
removeStringFormat
(s);
82
for
(
EAlgorithmU
alg =
ALGORITHM_U_BUNDLE
; alg <
ALGORITHM_U_LAST
; alg++ ) {
83
if
( !s.compare(
removeStringFormat
(
EAlgorithmUToString
(alg))) ) {
84
return
alg;
85
}
86
}
87
return
ALGORITHM_U_TRUSTREGION
;
88
}
89
90
template
<
typename
Real>
91
inline
Ptr<Algorithm<Real>>
AlgorithmFactory
(ParameterList &parlist,
const
Ptr<
Secant<Real>
> &secant = nullPtr) {
92
std::string stepType = parlist.sublist(
"Step"
).get(
"Type"
,
"Trust Region"
);
93
EAlgorithmU
ealg =
StringToEAlgorithmU
(stepType);
94
switch
(ealg) {
95
case
ALGORITHM_U_BUNDLE
:
return
makePtr<BundleAlgorithm<Real>>(parlist);
96
case
ALGORITHM_U_LINESEARCH
:
return
makePtr<LineSearchAlgorithm<Real>>(parlist,secant);
97
case
ALGORITHM_U_TRUSTREGION
:
return
makePtr<TrustRegionAlgorithm<Real>>(parlist,secant);
98
default
:
return
nullPtr;
99
}
100
}
101
102
}
// namespace TypeU
103
}
// namespace ROL
104
105
#endif
ROL_TypeU_BundleAlgorithm.hpp
ROL_TypeU_LineSearchAlgorithm.hpp
ROL_TypeU_TrustRegionAlgorithm.hpp
ROL_Types.hpp
Contains definitions of custom data types in ROL.
ROL::Secant
Provides interface for and implements limited-memory secant operators.
Definition
ROL_Secant.hpp:45
ROL::TypeU
Definition
ROL_TypeU_Algorithm.hpp:23
ROL::TypeU::operator--
EAlgorithmU & operator--(EAlgorithmU &type)
Definition
ROL_TypeU_AlgorithmFactory.hpp:70
ROL::TypeU::StringToEAlgorithmU
EAlgorithmU StringToEAlgorithmU(std::string s)
Definition
ROL_TypeU_AlgorithmFactory.hpp:80
ROL::TypeU::operator++
EAlgorithmU & operator++(EAlgorithmU &type)
Definition
ROL_TypeU_AlgorithmFactory.hpp:60
ROL::TypeU::isValidAlgorithmU
int isValidAlgorithmU(EAlgorithmU alg)
Verifies validity of a AlgorithmU enum.
Definition
ROL_TypeU_AlgorithmFactory.hpp:52
ROL::TypeU::EAlgorithmU
EAlgorithmU
Definition
ROL_TypeU_AlgorithmFactory.hpp:28
ROL::TypeU::ALGORITHM_U_LAST
@ ALGORITHM_U_LAST
Definition
ROL_TypeU_AlgorithmFactory.hpp:32
ROL::TypeU::ALGORITHM_U_LINESEARCH
@ ALGORITHM_U_LINESEARCH
Definition
ROL_TypeU_AlgorithmFactory.hpp:30
ROL::TypeU::ALGORITHM_U_TRUSTREGION
@ ALGORITHM_U_TRUSTREGION
Definition
ROL_TypeU_AlgorithmFactory.hpp:31
ROL::TypeU::ALGORITHM_U_BUNDLE
@ ALGORITHM_U_BUNDLE
Definition
ROL_TypeU_AlgorithmFactory.hpp:29
ROL::TypeU::EAlgorithmUToString
std::string EAlgorithmUToString(EAlgorithmU alg)
Definition
ROL_TypeU_AlgorithmFactory.hpp:35
ROL::TypeU::AlgorithmFactory
Ptr< Algorithm< Real > > AlgorithmFactory(ParameterList &parlist, const Ptr< Secant< Real > > &secant=nullPtr)
Definition
ROL_TypeU_AlgorithmFactory.hpp:91
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::removeStringFormat
std::string removeStringFormat(std::string s)
Definition
ROL_Types.hpp:215
Generated by
1.17.0