ROL
ROL_IterationScaling.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_H
11#define ROL_ITERATIONSCALING_H
12
17#include "ROL_LineSearch.hpp"
18
19namespace ROL {
20
21template<class Real>
22class IterationScaling : public LineSearch<Real> {
23private:
25 ROL::Ptr<Vector<Real> > xnew_;
26
27public:
28
29 virtual ~IterationScaling() {}
30
31 // Constructor
32 IterationScaling( ROL::ParameterList &parlist ) : LineSearch<Real>(parlist), algo_iter_(0) {}
33
36 LineSearch<Real>::initialize(x,s,g,obj,con);
37 xnew_ = x.clone();
38 }
39
40 // Run Iteration scaled line search
41 void run( Real &alpha, Real &fval, int &ls_neval, int &ls_ngrad,
42 const Real &gs, const Vector<Real> &s, const Vector<Real> &x,
44 Real tol = std::sqrt(ROL_EPSILON<Real>());
45 ls_neval = 0;
46 ls_ngrad = 0;
47 // Get line search parameter
48 algo_iter_++;
49 alpha = LineSearch<Real>::getInitialAlpha(ls_neval,ls_ngrad,fval,gs,x,s,obj,con)/static_cast<Real>(algo_iter_);
50 // Update iterate
52 // Compute objective function value
53 obj.update(*xnew_);
54 fval = obj.value(*xnew_,tol);
55 ls_neval++;
56 }
57};
58
59}
60
61#endif
Provides the interface to apply upper and lower bound constraints.
Provides an implementation of iteration scaled line search.
ROL::Ptr< Vector< Real > > xnew_
void initialize(const ROL::Vector< Real > &x, const ROL::Vector< Real > &s, const ROL::Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &con)
IterationScaling(ROL::ParameterList &parlist)
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, BoundConstraint< Real > &con)
Provides interface for and implements line searches.
void updateIterate(Vector< Real > &xnew, const Vector< Real > &x, const Vector< Real > &s, Real alpha, BoundConstraint< Real > &con)
virtual void initialize(const Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &con)
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, BoundConstraint< Real > &con)
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.