45 #include "GlobiPack_GoldenQuadInterpBracket.hpp"
46 #include "GlobiPack_TestLagrPolyMeritFunc1D.hpp"
62 using GlobiPack::goldenQuadInterpBracket;
64 using GlobiPack::computePoint;
66 using Teuchos::inOutArg;
67 using Teuchos::outArg;
70 using Teuchos::rcpFromRef;
74 using Teuchos::parameterList;
77 template<
class Scalar>
78 inline Scalar sqr(
const Scalar &x) {
return x*x; }
82 template<
class Scalar>
83 const RCP<TestLagrPolyMeritFunc1D<Scalar> > quadPhi()
86 typedef typename ST::magnitudeType ScalarMag;
87 Array<Scalar> alphaPoints = tuple<Scalar>(0.0, 2.0, 4.0);
88 Array<ScalarMag> phiPoints = tuple<ScalarMag>(6.0, 3.0, 6.0);
89 return testLagrPolyMeritFunc1D<Scalar>(alphaPoints, phiPoints);
99 "tol", &g_tol,
"Floating point tolerance" );
119 const RCP<TestLagrPolyMeritFunc1D<Scalar> > phi = quadPhi<Scalar>();
121 RCP<GoldenQuadInterpBracket<Scalar> > bracket = goldenQuadInterpBracket<Scalar>();
123 bracket->setOStream(rcpFromRef(out));
125 const Array<Scalar> alpha =
127 1e-14, 1e-10, 1e-7, 1e-4, 0.1, 1.0, 1.1, 1.5,
128 1.9, 2.0, 2.1, 4.0, 8.0, 30.0);
130 for (
int i = 0; i < as<int>(alpha.size()); ++i ) {
132 PointEval1D<Scalar> p_l =
computePoint(*phi, ST::zero());
134 PointEval1D<Scalar> p_u;
137 if (alpha[i] > ST::eps()) {
139 const bool bracketResult = bracket->bracketMinimum(
140 *phi, inOutArg(p_l), inOutArg(p_m), outArg(p_u), outArg(numIters) );
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Teuchos_Conditions, NumberConditionSerialization, T)
const RCP< TestLagrPolyMeritFunc1D< Scalar > > testLagrPolyMeritFunc1D(const ArrayView< const Scalar > &alpha, const ArrayView< const Scalar > &phi)
static magnitudeType eps()
Simple concrete class that implements a 1D algorithm to bracket the minimum of a 1D merit function...
static CommandLineProcessor & getCLP()
Represents the evaluation point of the merit function phi(alpha) and/or is derivative Dphi(alpha)...
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
PointEval1D< Scalar > computePoint(const MeritFunc1DBase< Scalar > &phi, const Scalar &alpha, const bool compute_phi=true, const bool compute_Dphi=false)
Compute a point as an object.
TypeTo as(const TypeFrom &t)
TEST_ASSERT(castedDep1->getValuesAndValidators().size()==2)
#define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_REAL_SCALAR_TYPES(TEST_GROUP, TEST_NAME)
Lagrange Polynomial Merit Function used in testing.
#define TEST_COMPARE(v1, comp, v2)