ROL
ROL_QuasiNewton_U.hpp
Go to the documentation of this file.
1// @HEADER
2// ************************************************************************
3//
4// Rapid Optimization Library (ROL) Package
5// Copyright (2014) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact lead developers:
38// Drew Kouri (dpkouri@sandia.gov) and
39// Denis Ridzal (dridzal@sandia.gov)
40//
41// ************************************************************************
42// @HEADER
43
44#ifndef ROL_QUASINEWTON_U_H
45#define ROL_QUASINEWTON_U_H
46
48
49#include "ROL_Types.hpp"
50#include "ROL_SecantFactory.hpp"
51
57
58namespace ROL {
59
60template<typename Real>
61class QuasiNewton_U : public DescentDirection_U<Real> {
62private:
63
64 Ptr<Secant<Real>> secant_;
66 std::string secantName_;
67
68public:
69
79 QuasiNewton_U( ParameterList &parlist,
80 const Ptr<Secant<Real>> &secant = nullPtr)
81 : secant_(secant), esec_(SECANT_USERDEFINED) {
82 // Initialize secant object
83 if ( secant == nullPtr ) {
84 secantName_ = parlist.sublist("General").sublist("Secant").get("Type","Limited-Memory BFGS");
87 }
88 else {
89 secantName_ = parlist.sublist("General").sublist("Secant").get("User Defined Secant Name",
90 "Unspecified User Defined Secant Method");
91 }
92 }
93
94 void compute( Vector<Real> &s, Real &snorm, Real &sdotg, int &iter, int &flag,
95 const Vector<Real> &x, const Vector<Real> &g, Objective<Real> &obj) override {
96 secant_->applyH(s,g);
97 //sdotg = -s.dot(g.dual());
98 sdotg = -s.apply(g);
99 if (sdotg >= static_cast<Real>(0)) {
100 s.set(g.dual());
101 //sdotg = -s.dot(g.dual());
102 sdotg = -s.apply(g);
103 }
104 s.scale(static_cast<Real>(-1));
105 snorm = s.norm();
106 iter = 0;
107 flag = 0;
108 }
109
110 void update(const Vector<Real> &x, const Vector<Real> &s,
111 const Vector<Real> &gold, const Vector<Real> &gnew,
112 const Real snorm, const int iter) override {
113 // Update Secant Information
114 secant_->updateStorage(x,gnew,gold,s,snorm,iter+1);
115 }
116
117 std::string printName(void) const override {
118 std::stringstream name;
119 name << "Quasi-Newton Method with " << secantName_;
120 return name.str();
121 }
122}; // class ROL::QuasiNewton_U
123
124} // namespace ROL
125
126#endif
Contains definitions of custom data types in ROL.
Provides the interface to compute unconstrained optimization steps for line search.
Provides the interface to evaluate objective functions.
void update(const Vector< Real > &x, const Vector< Real > &s, const Vector< Real > &gold, const Vector< Real > &gnew, const Real snorm, const int iter) override
void compute(Vector< Real > &s, Real &snorm, Real &sdotg, int &iter, int &flag, const Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj) override
std::string printName(void) const override
QuasiNewton_U(ParameterList &parlist, const Ptr< Secant< Real > > &secant=nullPtr)
Constructor.
Ptr< Secant< Real > > secant_
Secant object (used for quasi-Newton)
std::string secantName_
Secant name.
ESecant esec_
Secant type.
Provides interface for and implements limited-memory secant operators.
Defines the linear algebra or vector space interface.
virtual Real apply(const Vector< Real > &x) const
Apply to a dual vector. This is equivalent to the call .
virtual Real norm() const =0
Returns where .
virtual void set(const Vector &x)
Set where .
virtual void scale(const Real alpha)=0
Compute where .
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis,...
ESecant StringToESecant(std::string s)
@ SECANT_USERDEFINED
ROL::Ptr< Secant< Real > > SecantFactory(ROL::ParameterList &parlist, ESecantMode mode=SECANTMODE_BOTH)