ROL
ROL_CompositeObjective.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_COMPOSITE_OBJECTIVE_H
11 #define ROL_COMPOSITE_OBJECTIVE_H
12 
13 #include "ROL_StdObjective.hpp"
14 
21 namespace ROL {
22 
23 template<typename Real>
24 class CompositeObjective : public Objective<Real> {
25 private:
26  const std::vector<Ptr<Objective<Real>>> obj_vec_;
27  const Ptr<StdObjective<Real>> std_obj_;
28 
29  Ptr<std::vector<Real>> obj_value_, obj_grad_, obj_gv_, obj_hess_;
31  std::vector<Ptr<Vector<Real>>> vec_grad_, vec_hess_;
32 
34 
35 public:
36  CompositeObjective(const std::vector<Ptr<Objective<Real>>> &obj_vec,
37  const Ptr<StdObjective<Real>> &std_obj);
38 
39  void update( const Vector<Real> &x, UpdateType type, int iter = -1 ) override;
40  void update( const Vector<Real> &x, bool flag = true, int iter = -1 ) override;
41  Real value( const Vector<Real> &x, Real &tol ) override;
42  void gradient( Vector<Real> &g, const Vector<Real> &x, Real &tol ) override;
43  void hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) override;
44 
45 // Definitions for parametrized (stochastic) objective functions
46 public:
47  void setParameter(const std::vector<Real> &param) override;
48 
49 private:
50  void initialize(const Vector<Real> &x);
51  void computeValue(const Vector<Real> &x, Real &tol);
52  void computeGradient(const Vector<Real> &x, Real &tol);
53  void computeHessVec(const Vector<Real> &v, const Vector<Real> &x, Real &tol);
54 };
55 
56 } // namespace ROL
57 
59 
60 #endif
Provides the interface to evaluate objective functions.
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply Hessian approximation to vector.
std::vector< Ptr< Vector< Real > > > vec_hess_
Ptr< StdVector< Real > > obj_hess_vec_
void computeValue(const Vector< Real > &x, Real &tol)
const std::vector< Ptr< Objective< Real > > > obj_vec_
Real value(const Vector< Real > &x, Real &tol) override
Compute value.
Ptr< std::vector< Real > > obj_gv_
void computeGradient(const Vector< Real > &x, Real &tol)
CompositeObjective(const std::vector< Ptr< Objective< Real >>> &obj_vec, const Ptr< StdObjective< Real >> &std_obj)
std::vector< Ptr< Vector< Real > > > vec_grad_
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
void initialize(const Vector< Real > &x)
Ptr< std::vector< Real > > obj_value_
Specializes the ROL::Objective interface for objective functions that operate on ROL::StdVector&#39;s.
Ptr< std::vector< Real > > obj_hess_
const Ptr< StdObjective< Real > > std_obj_
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
Ptr< StdVector< Real > > obj_value_vec_
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Update objective function.
Ptr< StdVector< Real > > obj_gv_vec_
Ptr< std::vector< Real > > obj_grad_
void computeHessVec(const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Ptr< StdVector< Real > > obj_grad_vec_
Provides the interface to evaluate composite objective functions.
void setParameter(const std::vector< Real > &param) override