44 #ifndef GLOBIPACK_POLY_INTERP_LINE_SEARCH_DEF_HPP
45 #define GLOBIPACK_POLY_INTERP_LINE_SEARCH_DEF_HPP
58 template<
typename Scalar>
60 : eta_(ArmijoPolyInterpLineSearchUtils::
eta_default),
69 template<
typename Scalar>
76 template<
typename Scalar>
83 template<
typename Scalar>
90 template<
typename Scalar>
97 template<
typename Scalar>
104 template<
typename Scalar>
114 template<
class Scalar>
120 namespace AQLSU = ArmijoPolyInterpLineSearchUtils;
121 using Teuchos::getParameter;
130 TEUCHOS_ASSERT_INEQUALITY( eta_, <, ST::one() );
131 TEUCHOS_ASSERT_INEQUALITY( minFrac_, >=, ST::zero() );
132 TEUCHOS_ASSERT_INEQUALITY( minFrac_, <, maxFrac_ );
133 TEUCHOS_ASSERT_INEQUALITY( minIters_, >=, 0 );
134 TEUCHOS_ASSERT_INEQUALITY( minIters_, <=, maxIters_ );
135 setMyParamList(paramList);
139 template<
class Scalar>
143 namespace AQLSU = ArmijoPolyInterpLineSearchUtils;
163 template<
typename Scalar>
170 template<
typename Scalar>
177 template<
typename Scalar>
187 using Teuchos::ptrFromRef;
193 #endif // TEUCHOS_DEBUG
199 *out <<
"\nStarting Armijo Quadratic interpolation linesearch ...\n";
209 #endif // TEUCHOS_DEBUG
211 const Scalar phi_k = point_k.
phi;
212 Scalar &alpha_k = point_kp1->alpha;
213 Scalar &phi_kp1 = point_kp1->phi;
217 const Scalar Dphi_k = point_k.
Dphi;
222 <<
"\nDphi_k = " << Dphi_k
223 <<
"\nphi_k = " << phi_k
226 *out <<
"\nminIters == " << minIters_ <<
"\n";
228 *out <<
"\ndoMaxIters == true, maxing out maxIters = "
229 <<maxIters_<<
" iterations!\n";
232 TabularOutputter tblout(out);
234 tblout.pushFieldSpec(
"itr", TO::INT);
235 tblout.pushFieldSpec(
"alpha_k", TO::DOUBLE);
236 tblout.pushFieldSpec(
"phi_kp1", TO::DOUBLE);
237 tblout.pushFieldSpec(
"phi_kp1-frac_phi", TO::DOUBLE);
238 tblout.pushFieldSpec(
"alpha_interp", TO::DOUBLE);
239 tblout.pushFieldSpec(
"alpha_min", TO::DOUBLE);
240 tblout.pushFieldSpec(
"alpha_max", TO::DOUBLE);
242 tblout.outputHeader();
246 "ArmijoPolyInterpLineSearch::doLineSearch(): "
247 "The given descent direction for the given "
248 "phi Dphi_k="<<Dphi_k<<
" >= 0!" );
251 Scalar best_alpha = alpha_k;
252 Scalar best_phi = phi_kp1;
255 bool success =
false;
257 for ( ; numIters < maxIters_; ++numIters ) {
261 Scalar frac_phi = phi_k + eta_ * alpha_k * Dphi_k;
262 tblout.outputField(numIters);
263 tblout.outputField(alpha_k);
264 tblout.outputField(phi_kp1);
265 tblout.outputField(((phi_kp1)-frac_phi));
267 if (ST::isnaninf(phi_kp1)) {
270 alpha_k = minFrac_ * alpha_k;
271 best_alpha = ST::zero();
277 if (phi_kp1 < frac_phi) {
280 if (numIters < minIters_) {
283 else if ( !doMaxIters_ || ( doMaxIters_ && numIters == maxIters_ - 1 ) ) {
284 tblout.nextRow(
true);
301 ( -as<Scalar>(0.5) * Dphi_k * alpha_k * alpha_k )
303 ( (phi_kp1) - phi_k - alpha_k * Dphi_k );
305 tblout.outputField(alpha_quad);
310 const Scalar alpha_min = minFrac_ * alpha_k;
311 const Scalar alpha_max = maxFrac_ * alpha_k;
313 tblout.outputField(alpha_min);
314 tblout.outputField(alpha_max);
318 max(alpha_min, alpha_quad),
324 tblout.nextRow(
true);
329 phi_kp1 = computeValue<Scalar>(phi, alpha_k);
332 if (phi_kp1 < best_phi) {
334 best_alpha = alpha_k;
340 *numIters_out = numIters;
343 *out <<
"\nLine search success!\n";
349 alpha_k = best_alpha;
350 phi_kp1 = computeValue<Scalar>(phi, best_alpha);
351 *out <<
"\nLine search failure!\n";
360 #endif // GLOBIPACK_POLY_INTERP_LINE_SEARCH_DEF_HPP
const std::string maxIters_name
Scalar phi
The value of the merit function phi(alpha).
bool is_null(const boost::shared_ptr< T > &p)
Scalar Dphi
The value of the derivative of the merit function Dphi(alpha).
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
const double maxFrac_default
#define TEUCHOS_ASSERT_INEQUALITY(val1, comp, val2)
const std::string doMaxIters_name
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
RCP< const ParameterList > getValidParameters() const
Thrown if search direction not a descent direction for the merit function.
const std::string eta_name
const int maxIters_default
const std::string maxFrac_name
virtual bool doLineSearch(const MeritFunc1DBase< Scalar > &phi, const PointEval1D< Scalar > &point_k, const Ptr< PointEval1D< Scalar > > &point_kp1, const Ptr< int > &numIters) const
Scalar alpha
The value of the unknown alpha.
Represents the evaluation point of the merit function phi(alpha) and/or is derivative Dphi(alpha)...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
const bool doMaxIters_default
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
void setParameterList(RCP< ParameterList > const ¶mList)
TypeTo as(const TypeFrom &t)
virtual bool requiresDerivEvals() const
Returns false.
const std::string minFrac_name
const int minIters_default
ArmijoPolyInterpLineSearch()
Construct with default parameters.
Base class for 1D merit fucntions used in globalization methods.
const std::string minIters_name
const double minFrac_default
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
virtual bool requiresBaseDeriv() const
Returns true.