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()),
180 value = ROL_INF<Real>();
182 gnorm = ROL_INF<Real>();
183 cnorm = ROL_INF<Real>();
184 snorm = ROL_INF<Real>();
224 void reset(
const Real searchSizeInput = 1.0) {
245 return (c ==
' ' || c ==
'-' || c ==
'(' || c ==
')' || c==
'\'' || c==
'\r' || c==
'\n' || c==
'\t');
250 std::string output = s;
252 std::transform( output.begin(), output.end(), output.begin(), ::tolower );
290 std::string retString;
301 case STEP_LAST: retString =
"Last Type (Dummy)";
break;
302 default: retString =
"INVALID EStep";
335 default: comp =
false;
341 std::string retString;
343 case TYPE_U: retString =
"Type-U";
break;
344 case TYPE_E: retString =
"Type-E";
break;
345 case TYPE_B: retString =
"Type-B";
break;
346 case TYPE_EB: retString =
"Type-EB";
break;
347 case TYPE_LAST: retString =
"Type-Last (Dummy)";
break;
348 default: retString =
"Invalid EProblem";
372 return type =
static_cast<EStep>(type+1);
382 return type =
static_cast<EStep>(type-1);
421 std::string retString;
428 case DESCENT_LAST: retString =
"Last Type (Dummy)";
break;
429 default: retString =
"INVALID ESecant";
449 return type =
static_cast<EDescent>(type+1);
459 return type =
static_cast<EDescent>(type-1);
496 std::string retString;
498 case SECANT_LBFGS: retString =
"Limited-Memory BFGS";
break;
499 case SECANT_LDFP: retString =
"Limited-Memory DFP";
break;
500 case SECANT_LSR1: retString =
"Limited-Memory SR1";
break;
503 case SECANT_LAST: retString =
"Last Type (Dummy)";
break;
504 default: retString =
"INVALID ESecant";
524 return type =
static_cast<ESecant>(type+1);
534 return type =
static_cast<ESecant>(type-1);
581 std::string retString;
594 default: retString =
"INVALID ENonlinearCG";
671 std::string retString;
682 default: retString =
"INVALID ELineSearch";
752 std::string retString;
761 default: retString =
"INVALID ECurvatureCondition";
832 std::string retString;
835 retString =
"Residual tolerance met";
838 retString =
"Iteration limit exceeded";
841 retString =
"Negative curvature detected";
844 retString =
"Trust-Region radius exceeded";
847 retString =
"Initial right hand side is zero";
850 retString =
"INVALID ECGFlag";
858 namespace Finite_Difference_Arrays {
861 const int shifts[4][4] = { { 1, 0, 0, 0 },
868 const double weights[4][5] = { { -1.0, 1.0, 0.0, 0.0, 0.0 },
869 { 0.0, -1.0/2.0, 1.0/2.0, 0.0, 0.0 },
870 { -1.0/2.0, -1.0/3.0, 1.0, -1.0/6.0, 0.0 },
871 { 0.0, -2.0/3.0, 1.0/12.0, 2.0/3.0, -1.0/12.0 }
878 template<
class Real,
class Element>
897 return static_cast<double>(val);
902 template<
class Element,
class Real>
912 namespace Exception {
917 std::logic_error(what_arg) {}
923 #if __cplusplus >= 201402L // using C++14
929 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]
EPolyProjAlgo & operator++(EPolyProjAlgo &type)
ELineSearch StringToELineSearch(std::string s)
virtual ~AlgorithmState()
Real aggregateGradientNorm
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
EPolyProjAlgo & operator--(EPolyProjAlgo &type)
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)
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)