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
23namespace ROL {
24
25template<typename Real>
26class StdObjective : public virtual Objective<Real> {
27public:
28 virtual void update( const std::vector<Real> &x, bool flag = true, int iter = -1 ) {}
29
30 using Objective<Real>::update;
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
39 using Objective<Real>::value;
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
44 using Objective<Real>::gradient;
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
49 using Objective<Real>::dirDeriv;
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
54 using Objective<Real>::hessVec;
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
59 using Objective<Real>::invHessVec;
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
64 using Objective<Real>::precond;
65 void precond( Vector<Real> &Pv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) override;
66
67private:
68 Real sgn(Real x) const;
69
70};
71
72} // namespace ROL
73
75
76#endif
Provides the interface to evaluate objective functions.
Specializes the ROL::Objective interface for objective functions that operate on ROL::StdVector's.
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)
virtual void invHessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
virtual void precond(std::vector< Real > &Pv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
virtual void update(const std::vector< Real > &x, bool flag=true, int iter=-1)
virtual void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
virtual Real value(const std::vector< Real > &x, Real &tol)=0
virtual void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)
Defines the linear algebra or vector space interface.