45 #include "GlobiPack_TestLagrPolyMeritFunc1D.hpp"
46 #include "GlobiPack_ArmijoPolyInterpLineSearch.hpp"
65 using GlobiPack::armijoQuadraticLineSearch;
66 using GlobiPack::computeValue;
68 using Teuchos::inOutArg;
69 using Teuchos::outArg;
72 using Teuchos::rcpFromRef;
76 using Teuchos::parameterList;
85 "tol", &g_tol,
"Floating point tolerance" );
101 typedef typename ST::magnitudeType ScalarMag;
102 namespace AQLSU = GlobiPack::ArmijoPolyInterpLineSearchUtils;
103 RCP<ArmijoPolyInterpLineSearch<Scalar> > linesearch =
104 armijoQuadraticLineSearch<Scalar>();
119 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArmijoPolyInterpLineSearch, parseParams, Scalar )
122 namespace AQLSU = GlobiPack::ArmijoPolyInterpLineSearchUtils;
123 ECHO(RCP<ArmijoPolyInterpLineSearch<Scalar> > linesearch =
124 armijoQuadraticLineSearch<Scalar>());
125 const double eta = 0.99999;
126 const double minFrac = 4.0;
127 const double maxFrac = 5.0;
128 const int minIters = 5;
129 const int maxIters = 100;
130 const bool doMaxIters =
true;
131 ECHO(
const RCP<ParameterList> pl = parameterList());
132 ECHO(pl->set(
"Armijo Slope Fraction", eta));
133 ECHO(pl->set(
"Min Backtrack Fraction", minFrac));
134 ECHO(pl->set(
"Max Backtrack Fraction", maxFrac));
135 ECHO(pl->set(
"Min Num Iterations", minIters));
136 ECHO(pl->set(
"Max Num Iterations", maxIters));
137 ECHO(pl->set(
"Do Max Iterations", doMaxIters));
138 ECHO(linesearch->setParameterList(pl));
139 const Scalar tol = ST::eps();
173 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArmijoPolyInterpLineSearch, quadExact, Scalar )
177 typedef typename ST::magnitudeType ScalarMag;
179 const RCP<TestLagrPolyMeritFunc1D<Scalar> > phi = quadPhi<Scalar>();
181 RCP<ArmijoPolyInterpLineSearch<Scalar> > linesearch =
182 armijoQuadraticLineSearch<Scalar>();
184 linesearch->setOStream(rcpFromRef(out));
186 const PointEval1D<Scalar> point_k =
computePoint(*phi, ST::zero(),
true,
true);
187 PointEval1D<Scalar> point_kp1 =
computePoint(*phi, as<Scalar>(5.0));
190 const bool linesearchResult = linesearch->doLineSearch(
191 *phi, point_k, inOutArg(point_kp1), outArg(numIters) );
208 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArmijoPolyInterpLineSearch, noEval, Scalar )
214 const RCP<TestLagrPolyMeritFunc1D<Scalar> > phi = quadPhi<Scalar>();
216 RCP<ArmijoPolyInterpLineSearch<Scalar> > linesearch =
217 armijoQuadraticLineSearch<Scalar>();
219 linesearch->setOStream(rcpFromRef(out));
221 const Scalar alpha_k_init = as<Scalar>(2.1);
222 const PointEval1D<Scalar> point_k =
computePoint(*phi, ST::zero(),
true,
true);
223 PointEval1D<Scalar> point_kp1 =
computePoint(*phi, alpha_k_init);
226 const bool linesearchResult = linesearch->doLineSearch(
227 *phi, point_k, inOutArg(point_kp1), outArg(numIters) );
243 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( ArmijoPolyInterpLineSearch, minIters, Scalar )
247 typedef typename ST::magnitudeType ScalarMag;
249 const RCP<TestLagrPolyMeritFunc1D<Scalar> > phi = quadPhi<Scalar>();
251 RCP<ArmijoPolyInterpLineSearch<Scalar> > linesearch =
252 armijoQuadraticLineSearch<Scalar>();
254 const RCP<ParameterList> pl = parameterList();
255 pl->set(
"Max Backtrack Fraction", 1.0);
256 pl->set(
"Min Num Iterations", 1);
257 linesearch->setParameterList(pl);
259 linesearch->setOStream(rcpFromRef(out));
261 const Scalar alpha_k_init = as<Scalar>(2.1);
262 const PointEval1D<Scalar> point_k =
computePoint(*phi, ST::zero(),
true,
true);
263 PointEval1D<Scalar> point_kp1 =
computePoint(*phi, alpha_k_init);
266 const bool linesearchResult = linesearch->doLineSearch(
267 *phi, point_k, inOutArg(point_kp1), 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()
static CommandLineProcessor & getCLP()
const double maxFrac_default
Linesearch subclass implementing a backtracking-only line search using an Armijo cord test condition ...
const int maxIters_default
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.
const bool doMaxIters_default
TypeTo as(const TypeFrom &t)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
TEST_ASSERT(castedDep1->getValuesAndValidators().size()==2)
#define TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT_REAL_SCALAR_TYPES(TEST_GROUP, TEST_NAME)
const double minFrac_default
Lagrange Polynomial Merit Function used in testing.
TEST_EQUALITY(rcp_dynamic_cast< const EnhancedNumberValidator< double > >(castedDep1->getValuesAndValidators().find("val1") ->second, true) ->getMax(), double1Vali->getMax())
ScalarTraits< Scalar >::magnitudeType computeValue(const MeritFunc1DBase< Scalar > &phi, const Scalar &alpha)
Compute the value of the merit function phi(alpha).