53 #define ROL_VALIDATE( A ) A
55 #define ROL_VALIDATE( A )
64 #include <type_traits>
65 #include <ROL_stacktrace.hpp>
67 #include <ROL_Ptr.hpp>
69 #include <ROL_config.h>
74 #define ROL_NUM_CHECKDERIV_STEPS 13
83 std::ostringstream ss;
105 inline Real
ROL_INF(
void) {
return 0.1*ROL_OVERFLOW<Real>(); }
108 inline Real
ROL_NINF(
void) {
return -ROL_INF<Real>(); }
127 std::string retString;
132 case EXITSTATUS_NAN: retString =
"Step and/or Gradient Returned NaN";
break;
135 default: retString =
"INVALID EExitStatus";
163 gnorm(std::numeric_limits<Real>::max()),
164 cnorm(std::numeric_limits<Real>::max()),
165 snorm(std::numeric_limits<Real>::max()),
178 value = ROL_INF<Real>();
180 gnorm = ROL_INF<Real>();
181 cnorm = ROL_INF<Real>();
182 snorm = ROL_INF<Real>();
222 void reset(
const Real searchSizeInput = 1.0) {
243 return (c ==
' ' || c ==
'-' || c ==
'(' || c ==
')' || c==
'\'' || c==
'\r' || c==
'\n' || c==
'\t');
248 std::string output = s;
250 std::transform( output.begin(), output.end(), output.begin(), ::tolower );
288 std::string retString;
299 case STEP_LAST: retString =
"Last Type (Dummy)";
break;
300 default: retString =
"INVALID EStep";
333 default: comp =
false;
339 std::string retString;
341 case TYPE_U: retString =
"Type-U";
break;
342 case TYPE_E: retString =
"Type-E";
break;
343 case TYPE_B: retString =
"Type-B";
break;
344 case TYPE_EB: retString =
"Type-EB";
break;
345 case TYPE_LAST: retString =
"Type-Last (Dummy)";
break;
346 default: retString =
"Invalid EProblem";
370 return type =
static_cast<EStep>(type+1);
380 return type =
static_cast<EStep>(type-1);
419 std::string retString;
426 case DESCENT_LAST: retString =
"Last Type (Dummy)";
break;
427 default: retString =
"INVALID ESecant";
447 return type =
static_cast<EDescent>(type+1);
457 return type =
static_cast<EDescent>(type-1);
494 std::string retString;
496 case SECANT_LBFGS: retString =
"Limited-Memory BFGS";
break;
497 case SECANT_LDFP: retString =
"Limited-Memory DFP";
break;
498 case SECANT_LSR1: retString =
"Limited-Memory SR1";
break;
501 case SECANT_LAST: retString =
"Last Type (Dummy)";
break;
502 default: retString =
"INVALID ESecant";
522 return type =
static_cast<ESecant>(type+1);
532 return type =
static_cast<ESecant>(type-1);
579 std::string retString;
592 default: retString =
"INVALID ENonlinearCG";
669 std::string retString;
680 default: retString =
"INVALID ELineSearch";
750 std::string retString;
759 default: retString =
"INVALID ECurvatureCondition";
830 std::string retString;
833 retString =
"Residual tolerance met";
836 retString =
"Iteration limit exceeded";
839 retString =
"Negative curvature detected";
842 retString =
"Trust-Region radius exceeded";
845 retString =
"Initial right hand side is zero";
848 retString =
"INVALID ECGFlag";
856 namespace Finite_Difference_Arrays {
859 const int shifts[4][4] = { { 1, 0, 0, 0 },
866 const double weights[4][5] = { { -1.0, 1.0, 0.0, 0.0, 0.0 },
867 { 0.0, -1.0/2.0, 1.0/2.0, 0.0, 0.0 },
868 { -1.0/2.0, -1.0/3.0, 1.0, -1.0/6.0, 0.0 },
869 { 0.0, -2.0/3.0, 1.0/12.0, 2.0/3.0, -1.0/12.0 }
876 template<
class Real,
class Element>
895 return static_cast<double>(val);
900 template<
class Element,
class Real>
910 namespace Exception {
915 std::logic_error(what_arg) {}
921 #if __cplusplus >= 201402L // using C++14
927 template<
bool B,
class T=
void>
std::string ECGFlagToString(ECGFlag cgf)
EStep StringToEStep(std::string s)
static Real ElementToReal(const Element &val)
int isValidSecant(ESecant s)
Verifies validity of a Secant enum.
Real ROL_THRESHOLD(void)
Tolerance for various equality tests.
const double weights[4][5]
ELineSearch StringToELineSearch(std::string s)
Real aggregateGradientNorm
EKrylov & operator++(EKrylov &type)
NotImplemented(const std::string &what_arg)
std::string removeStringFormat(std::string s)
ELineSearch
Enumeration of line-search types.
ESecant StringToESecant(std::string s)
std::string EDescentToString(EDescent tr)
static Real ElementToReal(const std::complex< Real > &val)
ECGFlag
Enumation of flags used by conjugate gradient methods.
ROL::Ptr< Vector< Real > > gradientVec
EDescent StringToEDescent(std::string s)
State for algorithm class. Will be used for restarts.
std::string NumberToString(T Number)
ENonlinearCG
Enumeration of nonlinear CG algorithms.
std::string ECurvatureConditionToString(ECurvatureCondition ls)
Real rol_cast(const Element &val)
std::string EExitStatusToString(EExitStatus tr)
typename std::enable_if< B, T >::type enable_if_t
EExitStatus
Enum for algorithm termination.
ESecant
Enumeration of secant update algorithms.
ROL::Ptr< Vector< Real > > constraintVec
ROL::Ptr< Vector< Real > > iterateVec
std::string ENonlinearCGToString(ENonlinearCG tr)
ENonlinearCG StringToENonlinearCG(std::string s)
int isValidDescent(EDescent d)
Verifies validity of a Secant enum.
std::string ELineSearchToString(ELineSearch ls)
Real ROL_OVERFLOW(void)
Platform-dependent maximum double.
int isValidLineSearch(ELineSearch ls)
Verifies validity of a LineSearch enum.
State for step class. Will be used for restarts.
std::string EProblemToString(EProblem p)
int isValidStep(EStep ls)
Verifies validity of a TrustRegion enum.
ROL::Ptr< Vector< Real > > descentVec
static double ElementToReal(const float &val)
int isValidCurvatureCondition(ECurvatureCondition ls)
Verifies validity of a CurvatureCondition enum.
ECurvatureCondition
Enumeration of line-search curvature conditions.
void reset(const Real searchSizeInput=1.0)
ROL::Ptr< Vector< Real > > lagmultVec
ECurvatureCondition StringToECurvatureCondition(std::string s)
EKrylov & operator--(EKrylov &type)
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.
ROL::Ptr< Vector< Real > > minIterVec
std::string ESecantToString(ESecant tr)
std::string EStepToString(EStep tr)
EStep
Enumeration of step types.
Real ROL_UNDERFLOW(void)
Platform-dependent minimum double.
int isValidNonlinearCG(ENonlinearCG s)
Verifies validity of a NonlinearCG enum.
EDescent
Enumeration of descent direction types.
bool isCompatibleStep(EProblem p, EStep s)