ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
algorithm
TypeE
ROL_TypeE_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_TYPEE_ALGORITHMFACTORY_H
11
#define ROL_TYPEE_ALGORITHMFACTORY_H
12
13
#include "
ROL_TypeE_AugmentedLagrangianAlgorithm.hpp
"
14
#include "
ROL_TypeE_FletcherAlgorithm.hpp
"
15
#include "
ROL_TypeE_CompositeStepAlgorithm.hpp
"
16
#include "
ROL_TypeE_StabilizedLCLAlgorithm.hpp
"
17
#include "
ROL_Types.hpp
"
18
19
namespace
ROL
{
20
namespace
TypeE
{
21
25
enum
EAlgorithmE
{
26
ALGORITHM_E_AUGMENTEDLAGRANGIAN
= 0,
27
ALGORITHM_E_FLETCHER
,
28
ALGORITHM_E_COMPOSITESTEP
,
29
ALGORITHM_E_STABILIZEDLCL
,
30
ALGORITHM_E_LAST
31
};
32
33
inline
std::string
EAlgorithmEToString
(
EAlgorithmE
alg) {
34
std::string retString;
35
switch
(alg) {
36
case
ALGORITHM_E_AUGMENTEDLAGRANGIAN
: retString =
"Augmented Lagrangian"
;
break
;
37
case
ALGORITHM_E_FLETCHER
: retString =
"Fletcher"
;
break
;
38
case
ALGORITHM_E_COMPOSITESTEP
: retString =
"Composite Step"
;
break
;
39
case
ALGORITHM_E_STABILIZEDLCL
: retString =
"Stabilized LCL"
;
break
;
40
case
ALGORITHM_E_LAST
: retString =
"Last Type (Dummy)"
;
break
;
41
default
: retString =
"INVALID EAlgorithmE"
;
42
}
43
return
retString;
44
}
45
51
inline
int
isValidAlgorithmE
(
EAlgorithmE
alg){
52
return
( (alg ==
ALGORITHM_E_AUGMENTEDLAGRANGIAN
) ||
53
(alg ==
ALGORITHM_E_FLETCHER
) ||
54
(alg ==
ALGORITHM_E_COMPOSITESTEP
) ||
55
(alg ==
ALGORITHM_E_STABILIZEDLCL
) ||
56
(alg ==
ALGORITHM_E_LAST
)
57
);
58
}
59
60
inline
EAlgorithmE
&
operator++
(
EAlgorithmE
&type) {
61
return
type =
static_cast<
EAlgorithmE
>
(type+1);
62
}
63
64
inline
EAlgorithmE
operator++
(
EAlgorithmE
&type,
int
) {
65
EAlgorithmE
oldval = type;
66
++type;
67
return
oldval;
68
}
69
70
inline
EAlgorithmE
&
operator--
(
EAlgorithmE
&type) {
71
return
type =
static_cast<
EAlgorithmE
>
(type-1);
72
}
73
74
inline
EAlgorithmE
operator--
(
EAlgorithmE
&type,
int
) {
75
EAlgorithmE
oldval = type;
76
--type;
77
return
oldval;
78
}
79
80
inline
EAlgorithmE
StringToEAlgorithmE
(std::string s) {
81
s =
removeStringFormat
(s);
82
for
(
EAlgorithmE
alg =
ALGORITHM_E_AUGMENTEDLAGRANGIAN
; alg <
ALGORITHM_E_LAST
; alg++ ) {
83
if
( !s.compare(
removeStringFormat
(
EAlgorithmEToString
(alg))) ) {
84
return
alg;
85
}
86
}
87
return
ALGORITHM_E_AUGMENTEDLAGRANGIAN
;
88
}
89
90
template
<
typename
Real>
91
inline
Ptr<TypeE::Algorithm<Real>>
AlgorithmFactory
(ParameterList &parlist,
const
Ptr<
Secant<Real>
> &secant = nullPtr) {
92
std::string stepType = parlist.sublist(
"Step"
).get(
"Type"
,
"Augmented Lagrangian"
);
93
EAlgorithmE
ealg =
StringToEAlgorithmE
(stepType);
94
switch
(ealg) {
95
case
ALGORITHM_E_AUGMENTEDLAGRANGIAN
:
return
makePtr<TypeE::AugmentedLagrangianAlgorithm<Real>>(parlist,secant);
96
case
ALGORITHM_E_FLETCHER
:
return
makePtr<TypeE::FletcherAlgorithm<Real>>(parlist,secant);
97
case
ALGORITHM_E_COMPOSITESTEP
:
return
makePtr<TypeE::CompositeStepAlgorithm<Real>>(parlist);
98
case
ALGORITHM_E_STABILIZEDLCL
:
return
makePtr<TypeE::StabilizedLCLAlgorithm<Real>>(parlist,secant);
99
default
:
return
nullPtr;
100
}
101
}
102
103
}
// namespace TypeE
104
}
// namespace ROL
105
106
#endif
ROL_TypeE_AugmentedLagrangianAlgorithm.hpp
ROL_TypeE_CompositeStepAlgorithm.hpp
ROL_TypeE_FletcherAlgorithm.hpp
ROL_TypeE_StabilizedLCLAlgorithm.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::TypeE
Definition
ROL_TypeE_Algorithm.hpp:23
ROL::TypeE::AlgorithmFactory
Ptr< TypeE::Algorithm< Real > > AlgorithmFactory(ParameterList &parlist, const Ptr< Secant< Real > > &secant=nullPtr)
Definition
ROL_TypeE_AlgorithmFactory.hpp:91
ROL::TypeE::EAlgorithmE
EAlgorithmE
Definition
ROL_TypeE_AlgorithmFactory.hpp:25
ROL::TypeE::ALGORITHM_E_AUGMENTEDLAGRANGIAN
@ ALGORITHM_E_AUGMENTEDLAGRANGIAN
Definition
ROL_TypeE_AlgorithmFactory.hpp:26
ROL::TypeE::ALGORITHM_E_LAST
@ ALGORITHM_E_LAST
Definition
ROL_TypeE_AlgorithmFactory.hpp:30
ROL::TypeE::ALGORITHM_E_STABILIZEDLCL
@ ALGORITHM_E_STABILIZEDLCL
Definition
ROL_TypeE_AlgorithmFactory.hpp:29
ROL::TypeE::ALGORITHM_E_FLETCHER
@ ALGORITHM_E_FLETCHER
Definition
ROL_TypeE_AlgorithmFactory.hpp:27
ROL::TypeE::ALGORITHM_E_COMPOSITESTEP
@ ALGORITHM_E_COMPOSITESTEP
Definition
ROL_TypeE_AlgorithmFactory.hpp:28
ROL::TypeE::operator++
EAlgorithmE & operator++(EAlgorithmE &type)
Definition
ROL_TypeE_AlgorithmFactory.hpp:60
ROL::TypeE::EAlgorithmEToString
std::string EAlgorithmEToString(EAlgorithmE alg)
Definition
ROL_TypeE_AlgorithmFactory.hpp:33
ROL::TypeE::isValidAlgorithmE
int isValidAlgorithmE(EAlgorithmE alg)
Verifies validity of a AlgorithmE enum.
Definition
ROL_TypeE_AlgorithmFactory.hpp:51
ROL::TypeE::operator--
EAlgorithmE & operator--(EAlgorithmE &type)
Definition
ROL_TypeE_AlgorithmFactory.hpp:70
ROL::TypeE::StringToEAlgorithmE
EAlgorithmE StringToEAlgorithmE(std::string s)
Definition
ROL_TypeE_AlgorithmFactory.hpp:80
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::removeStringFormat
std::string removeStringFormat(std::string s)
Definition
ROL_Types.hpp:215
Generated by
1.17.0