ROL
ROL_LineSearch_U_Types.hpp
Go to the documentation of this file.
1// @HEADER
2// ************************************************************************
3//
4// Rapid Optimization Library (ROL) Package
5// Copyright (2014) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact lead developers:
38// Drew Kouri (dpkouri@sandia.gov) and
39// Denis Ridzal (dridzal@sandia.gov)
40//
41// ************************************************************************
42// @HEADER
43
44#ifndef ROL_LINESEARCH_U_TYPES_H
45#define ROL_LINESEARCH_U_TYPES_H
46
47#include "ROL_Types.hpp"
48
49#include "ROL_ParameterList.hpp"
50#include "ROL_Ptr.hpp"
51
52namespace ROL {
53
72 };
73
74 inline std::string EDescentUToString(EDescentU tr) {
75 std::string retString;
76 switch(tr) {
77 case DESCENT_U_STEEPEST: retString = "Steepest Descent"; break;
78 case DESCENT_U_NONLINEARCG: retString = "Nonlinear CG"; break;
79 case DESCENT_U_SECANT: retString = "Quasi-Newton Method"; break;
80 case DESCENT_U_NEWTON: retString = "Newton's Method"; break;
81 case DESCENT_U_NEWTONKRYLOV: retString = "Newton-Krylov"; break;
82 case DESCENT_U_USERDEFINED: retString = "User Defined"; break;
83 case DESCENT_U_LAST: retString = "Last Type (Dummy)"; break;
84 default: retString = "INVALID EDescentU";
85 }
86 return retString;
87 }
88
95 return( (d == DESCENT_U_STEEPEST) ||
96 (d == DESCENT_U_NONLINEARCG) ||
97 (d == DESCENT_U_SECANT) ||
98 (d == DESCENT_U_NEWTON) ||
101 );
102 }
103
105 return type = static_cast<EDescentU>(type+1);
106 }
107
108 inline EDescentU operator++(EDescentU &type, int) {
109 EDescentU oldval = type;
110 ++type;
111 return oldval;
112 }
113
115 return type = static_cast<EDescentU>(type-1);
116 }
117
118 inline EDescentU operator--(EDescentU &type, int) {
119 EDescentU oldval = type;
120 --type;
121 return oldval;
122 }
123
124 inline EDescentU StringToEDescentU(std::string s) {
125 s = removeStringFormat(s);
126 for ( EDescentU des = DESCENT_U_STEEPEST; des < DESCENT_U_LAST; des++ ) {
127 if ( !s.compare(removeStringFormat(EDescentUToString(des))) ) {
128 return des;
129 }
130 }
131 return DESCENT_U_SECANT;
132 }
133
154 };
155
156 inline std::string ELineSearchUToString(ELineSearchU ls) {
157 std::string retString;
158 switch(ls) {
159 case LINESEARCH_U_ITERATIONSCALING: retString = "Iteration Scaling"; break;
160 case LINESEARCH_U_PATHBASEDTARGETLEVEL: retString = "Path-Based Target Level"; break;
161 case LINESEARCH_U_BACKTRACKING: retString = "Backtracking"; break;
162 case LINESEARCH_U_BISECTION: retString = "Bisection"; break;
163 case LINESEARCH_U_GOLDENSECTION: retString = "Golden Section"; break;
164 case LINESEARCH_U_CUBICINTERP: retString = "Cubic Interpolation"; break;
165 case LINESEARCH_U_BRENTS: retString = "Brent's"; break;
166 case LINESEARCH_U_USERDEFINED: retString = "User Defined"; break;
167 case LINESEARCH_U_LAST: retString = "Last Type (Dummy)"; break;
168 default: retString = "INVALID ELineSearchU";
169 }
170 return retString;
171 }
172
179 return( (ls == LINESEARCH_U_BACKTRACKING) ||
182 (ls == LINESEARCH_U_BISECTION) ||
184 (ls == LINESEARCH_U_CUBICINTERP) ||
185 (ls == LINESEARCH_U_BRENTS) ||
187 );
188 }
189
191 return type = static_cast<ELineSearchU>(type+1);
192 }
193
195 ELineSearchU oldval = type;
196 ++type;
197 return oldval;
198 }
199
201 return type = static_cast<ELineSearchU>(type-1);
202 }
203
205 ELineSearchU oldval = type;
206 --type;
207 return oldval;
208 }
209
210 inline ELineSearchU StringToELineSearchU(std::string s) {
211 s = removeStringFormat(s);
213 if ( !s.compare(removeStringFormat(ELineSearchUToString(ls))) ) {
214 return ls;
215 }
216 }
218 }
219
235 };
236
238 std::string retString;
239 switch(ls) {
240 case CURVATURECONDITION_U_WOLFE: retString = "Wolfe Conditions"; break;
241 case CURVATURECONDITION_U_STRONGWOLFE: retString = "Strong Wolfe Conditions"; break;
242 case CURVATURECONDITION_U_GENERALIZEDWOLFE: retString = "Generalized Wolfe Conditions"; break;
243 case CURVATURECONDITION_U_APPROXIMATEWOLFE: retString = "Approximate Wolfe Conditions"; break;
244 case CURVATURECONDITION_U_GOLDSTEIN: retString = "Goldstein Conditions"; break;
245 case CURVATURECONDITION_U_NULL: retString = "Null Curvature Condition"; break;
246 case CURVATURECONDITION_U_LAST: retString = "Last Type (Dummy)"; break;
247 default: retString = "INVALID ECurvatureConditionU";
248 }
249 return retString;
250 }
251
258 return( (ls == CURVATURECONDITION_U_WOLFE) ||
264 );
265 }
266
268 return type = static_cast<ECurvatureConditionU>(type+1);
269 }
270
272 ECurvatureConditionU oldval = type;
273 ++type;
274 return oldval;
275 }
276
278 return type = static_cast<ECurvatureConditionU>(type-1);
279 }
280
282 ECurvatureConditionU oldval = type;
283 --type;
284 return oldval;
285 }
286
288 s = removeStringFormat(s);
290 if ( !s.compare(removeStringFormat(ECurvatureConditionUToString(cc))) ) {
291 return cc;
292 }
293 }
295 }
296} // namespace ROL
297
298#endif
Contains definitions of custom data types in ROL.
int isValidCurvatureConditionU(ECurvatureConditionU ls)
Verifies validity of a CurvatureConditionU enum.
std::string removeStringFormat(std::string s)
Definition: ROL_Types.hpp:249
std::string ELineSearchUToString(ELineSearchU ls)
@ CURVATURECONDITION_U_APPROXIMATEWOLFE
@ CURVATURECONDITION_U_GOLDSTEIN
@ CURVATURECONDITION_U_GENERALIZEDWOLFE
@ CURVATURECONDITION_U_STRONGWOLFE
std::string ECurvatureConditionUToString(ECurvatureConditionU ls)
ECurvatureConditionU StringToECurvatureConditionU(std::string s)
@ LINESEARCH_U_PATHBASEDTARGETLEVEL
@ LINESEARCH_U_ITERATIONSCALING
int isValidDescentU(EDescentU d)
Verifies validity of a DescentU enum.
EPolyProjAlgo & operator--(EPolyProjAlgo &type)
EPolyProjAlgo & operator++(EPolyProjAlgo &type)
ELineSearchU StringToELineSearchU(std::string s)
int isValidLineSearchU(ELineSearchU ls)
Verifies validity of a LineSearchU enum.
std::string EDescentUToString(EDescentU tr)
EDescentU StringToEDescentU(std::string s)