ROL
ROL_IterationScaling_U.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Rapid Optimization Library (ROL) Package
4//
5// Copyright 2014 NTESS and the ROL contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef ROL_ITERATIONSCALING_U_H
11#define ROL_ITERATIONSCALING_U_H
12
17#include "ROL_LineSearch_U.hpp"
18
19namespace ROL {
20
21template<typename Real>
22class IterationScaling_U : public LineSearch_U<Real> {
23private:
25 Ptr<Vector<Real>> xnew_;
26
28
29public:
30
31 IterationScaling_U( ParameterList &parlist ) : LineSearch_U<Real>(parlist), algo_iter_(0) {}
32
33 void initialize(const Vector<Real> &x, const Vector<Real> &g) override {
35 xnew_ = x.clone();
36 }
37
38 // Run Iteration scaled line search
39 void run( Real &alpha, Real &fval, int &ls_neval, int &ls_ngrad,
40 const Real &gs, const Vector<Real> &s, const Vector<Real> &x,
41 Objective<Real> &obj ) override {
42 Real tol = std::sqrt(ROL_EPSILON<Real>());
43 ls_neval = 0;
44 ls_ngrad = 0;
45 // Get line search parameter
46 algo_iter_++;
47 alpha = getInitialAlpha(ls_neval,ls_ngrad,fval,gs,x,s,obj)/static_cast<Real>(algo_iter_);
48 // Update iterate
49 xnew_->set(x); xnew_->axpy(alpha,s);
50 // Compute objective function value
52 fval = obj.value(*xnew_,tol);
53 ls_neval++;
54 }
55}; // class ROL::IterationScaling_U
56
57} // namespace ROL
58
59#endif
Provides an implementation of iteration scaled line search.
void initialize(const Vector< Real > &x, const Vector< Real > &g) override
void run(Real &alpha, Real &fval, int &ls_neval, int &ls_ngrad, const Real &gs, const Vector< Real > &s, const Vector< Real > &x, Objective< Real > &obj) override
IterationScaling_U(ParameterList &parlist)
Provides interface for and implements line searches.
virtual Real getInitialAlpha(int &ls_neval, int &ls_ngrad, const Real fval, const Real gs, const Vector< Real > &x, const Vector< Real > &s, Objective< Real > &obj)
virtual void initialize(const Vector< Real > &x, const Vector< Real > &g)
Provides the interface to evaluate objective functions.
virtual Real value(const Vector< Real > &x, Real &tol)=0
Compute value.
virtual void update(const Vector< Real > &x, UpdateType type, int iter=-1)
Update objective function.
Defines the linear algebra or vector space interface.
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.