ROL
ROL_StdObjective.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_STDOBJECTIVE_H
11 #define ROL_STDOBJECTIVE_H
12 
13 #include "ROL_Objective.hpp"
14 #include "ROL_StdVector.hpp"
15 
23 namespace ROL {
24 
25 template<typename Real>
26 class StdObjective : public virtual Objective<Real> {
27 public:
28  virtual void update( const std::vector<Real> &x, bool flag = true, int iter = -1 ) {}
29 
31  void update( const Vector<Real> &x, bool flag = true, int iter = -1 ) override;
32 
33  virtual void update( const std::vector<Real> &x, UpdateType type, int iter = -1 ) {}
34 
35  void update( const Vector<Real> &x, UpdateType type, int iter = -1 ) override;
36 
37  virtual Real value( const std::vector<Real> &x, Real &tol ) = 0;
38 
40  Real value( const Vector<Real> &x, Real &tol ) override;
41 
42  virtual void gradient( std::vector<Real> &g, const std::vector<Real> &x, Real &tol );
43 
45  void gradient( Vector<Real> &g, const Vector<Real> &x, Real &tol ) override;
46 
47  virtual Real dirDeriv( const std::vector<Real> &x, const std::vector<Real> &d, Real &tol );
48 
50  Real dirDeriv( const Vector<Real> &x, const Vector<Real> &d, Real &tol ) override;
51 
52  virtual void hessVec( std::vector<Real> &hv, const std::vector<Real> &v, const std::vector<Real> &x, Real &tol );
53 
55  void hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) override;
56 
57  virtual void invHessVec( std::vector<Real> &hv, const std::vector<Real> &v, const std::vector<Real> &x, Real &tol );
58 
60  void invHessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) override;
61 
62  virtual void precond( std::vector<Real> &Pv, const std::vector<Real> &v, const std::vector<Real> &x, Real &tol );
63 
65  void precond( Vector<Real> &Pv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) override;
66 
67 private:
68  Real sgn(Real x) const;
69 
70 };
71 
72 } // namespace ROL
73 
74 #include "ROL_StdObjective_Def.hpp"
75 
76 #endif
virtual Real value(const std::vector< Real > &x, Real &tol)=0
Provides the interface to evaluate objective functions.
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
virtual void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
virtual void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)
Specializes the ROL::Objective interface for objective functions that operate on ROL::StdVector&#39;s.
virtual void invHessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Real sgn(Real x) const
virtual void update(const std::vector< Real > &x, bool flag=true, int iter=-1)
virtual void precond(std::vector< Real > &Pv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
virtual Real dirDeriv(const std::vector< Real > &x, const std::vector< Real > &d, Real &tol)
virtual void update(const std::vector< Real > &x, UpdateType type, int iter=-1)