ROL
Toggle main menu visibility
Loading...
Searching...
No Matches
src
algorithm
TypeG
ROL_TypeG_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_TYPEG_ALGORITHMFACTORY_H
11
#define ROL_TYPEG_ALGORITHMFACTORY_H
12
13
#include "
ROL_TypeG_AugmentedLagrangianAlgorithm.hpp
"
14
#include "
ROL_TypeG_MoreauYosidaAlgorithm.hpp
"
15
#include "
ROL_TypeG_InteriorPointAlgorithm.hpp
"
16
#include "
ROL_TypeG_StabilizedLCLAlgorithm.hpp
"
17
#include "
ROL_Types.hpp
"
18
19
namespace
ROL
{
20
namespace
TypeG
{
21
30
enum
EAlgorithmG
{
31
ALGORITHM_G_AUGMENTEDLAGRANGIAN
= 0,
32
ALGORITHM_G_MOREAUYOSIDA
,
33
ALGORITHM_G_INTERIORPOINT
,
34
ALGORITHM_G_STABILIZEDLCL
,
35
ALGORITHM_G_LAST
36
};
37
38
inline
std::string
EAlgorithmGToString
(
EAlgorithmG
alg) {
39
std::string retString;
40
switch
(alg) {
41
case
ALGORITHM_G_AUGMENTEDLAGRANGIAN
: retString =
"Augmented Lagrangian"
;
break
;
42
case
ALGORITHM_G_MOREAUYOSIDA
: retString =
"Moreau-Yosida"
;
break
;
43
case
ALGORITHM_G_INTERIORPOINT
: retString =
"Interior Point"
;
break
;
44
case
ALGORITHM_G_STABILIZEDLCL
: retString =
"Stabilized LCL"
;
break
;
45
case
ALGORITHM_G_LAST
: retString =
"Last Type (Dummy)"
;
break
;
46
default
: retString =
"INVALID EAlgorithmG"
;
47
}
48
return
retString;
49
}
50
56
inline
int
isValidAlgorithmG
(
EAlgorithmG
alg){
57
return
( (alg ==
ALGORITHM_G_AUGMENTEDLAGRANGIAN
) ||
58
(alg ==
ALGORITHM_G_MOREAUYOSIDA
) ||
59
(alg ==
ALGORITHM_G_INTERIORPOINT
) ||
60
(alg ==
ALGORITHM_G_STABILIZEDLCL
) ||
61
(alg ==
ALGORITHM_G_LAST
)
62
);
63
}
64
65
inline
EAlgorithmG
&
operator++
(
EAlgorithmG
&type) {
66
return
type =
static_cast<
EAlgorithmG
>
(type+1);
67
}
68
69
inline
EAlgorithmG
operator++
(
EAlgorithmG
&type,
int
) {
70
EAlgorithmG
oldval = type;
71
++type;
72
return
oldval;
73
}
74
75
inline
EAlgorithmG
&
operator--
(
EAlgorithmG
&type) {
76
return
type =
static_cast<
EAlgorithmG
>
(type-1);
77
}
78
79
inline
EAlgorithmG
operator--
(
EAlgorithmG
&type,
int
) {
80
EAlgorithmG
oldval = type;
81
--type;
82
return
oldval;
83
}
84
85
inline
EAlgorithmG
StringToEAlgorithmG
(std::string s) {
86
s =
removeStringFormat
(s);
87
for
(
EAlgorithmG
alg =
ALGORITHM_G_AUGMENTEDLAGRANGIAN
; alg <
ALGORITHM_G_LAST
; alg++ ) {
88
if
( !s.compare(
removeStringFormat
(
EAlgorithmGToString
(alg))) ) {
89
return
alg;
90
}
91
}
92
return
ALGORITHM_G_AUGMENTEDLAGRANGIAN
;
93
}
94
95
template
<
typename
Real>
96
inline
Ptr<TypeG::Algorithm<Real>>
AlgorithmFactory
(ParameterList &parlist,
const
Ptr<
Secant<Real>
> &secant = nullPtr) {
97
std::string stepType = parlist.sublist(
"Step"
).get(
"Type"
,
"Augmented Lagrangian"
);
98
EAlgorithmG
ealg =
StringToEAlgorithmG
(stepType);
99
switch
(ealg) {
100
case
ALGORITHM_G_AUGMENTEDLAGRANGIAN
:
return
makePtr<TypeG::AugmentedLagrangianAlgorithm<Real>>(parlist,secant);
101
case
ALGORITHM_G_MOREAUYOSIDA
:
return
makePtr<TypeG::MoreauYosidaAlgorithm<Real>>(parlist,secant);
102
case
ALGORITHM_G_INTERIORPOINT
:
return
makePtr<TypeG::InteriorPointAlgorithm<Real>>(parlist,secant);
103
case
ALGORITHM_G_STABILIZEDLCL
:
return
makePtr<TypeG::StabilizedLCLAlgorithm<Real>>(parlist,secant);
104
default
:
return
nullPtr;
105
}
106
}
107
}
// namespace TypeG
108
}
// namespace ROL
109
110
#endif
ROL_TypeG_AugmentedLagrangianAlgorithm.hpp
ROL_TypeG_InteriorPointAlgorithm.hpp
ROL_TypeG_MoreauYosidaAlgorithm.hpp
ROL_TypeG_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::TypeG
Definition
ROL_TypeG_Algorithm.hpp:25
ROL::TypeG::StringToEAlgorithmG
EAlgorithmG StringToEAlgorithmG(std::string s)
Definition
ROL_TypeG_AlgorithmFactory.hpp:85
ROL::TypeG::EAlgorithmG
EAlgorithmG
Definition
ROL_TypeG_AlgorithmFactory.hpp:30
ROL::TypeG::ALGORITHM_G_INTERIORPOINT
@ ALGORITHM_G_INTERIORPOINT
Definition
ROL_TypeG_AlgorithmFactory.hpp:33
ROL::TypeG::ALGORITHM_G_AUGMENTEDLAGRANGIAN
@ ALGORITHM_G_AUGMENTEDLAGRANGIAN
Definition
ROL_TypeG_AlgorithmFactory.hpp:31
ROL::TypeG::ALGORITHM_G_MOREAUYOSIDA
@ ALGORITHM_G_MOREAUYOSIDA
Definition
ROL_TypeG_AlgorithmFactory.hpp:32
ROL::TypeG::ALGORITHM_G_LAST
@ ALGORITHM_G_LAST
Definition
ROL_TypeG_AlgorithmFactory.hpp:35
ROL::TypeG::ALGORITHM_G_STABILIZEDLCL
@ ALGORITHM_G_STABILIZEDLCL
Definition
ROL_TypeG_AlgorithmFactory.hpp:34
ROL::TypeG::operator++
EAlgorithmG & operator++(EAlgorithmG &type)
Definition
ROL_TypeG_AlgorithmFactory.hpp:65
ROL::TypeG::operator--
EAlgorithmG & operator--(EAlgorithmG &type)
Definition
ROL_TypeG_AlgorithmFactory.hpp:75
ROL::TypeG::EAlgorithmGToString
std::string EAlgorithmGToString(EAlgorithmG alg)
Definition
ROL_TypeG_AlgorithmFactory.hpp:38
ROL::TypeG::isValidAlgorithmG
int isValidAlgorithmG(EAlgorithmG alg)
Verifies validity of a AlgorithmG enum.
Definition
ROL_TypeG_AlgorithmFactory.hpp:56
ROL::TypeG::AlgorithmFactory
Ptr< TypeG::Algorithm< Real > > AlgorithmFactory(ParameterList &parlist, const Ptr< Secant< Real > > &secant=nullPtr)
Definition
ROL_TypeG_AlgorithmFactory.hpp:96
ROL
Definition
ROL_ElementwiseVector.hpp:27
ROL::removeStringFormat
std::string removeStringFormat(std::string s)
Definition
ROL_Types.hpp:215
Generated by
1.17.0