10#ifndef ROL_SEPARABLEOBJECTIVE_DEF_H
11#define ROL_SEPARABLEOBJECTIVE_DEF_H
15template<
typename Real>
17 :
obj_(obj), size_(obj.size()) {}
19template<
typename Real>
21 ROL_TEST_FOR_EXCEPTION( (size_ <= i ) , std::invalid_argument,
22 ">>> ERROR (ROL_SeparableObjective, get): "
23 "Dimension mismatch.");
27template<
typename Real>
30 ROL_TEST_FOR_EXCEPTION( (size_ != xp.
numVectors() ) , std::invalid_argument,
31 ">>> ERROR (ROL_SeparableObjective, update): "
32 "Dimension mismatch.");
33 for(
unsigned i = 0; i < size_; ++i)
obj_[i]->
update(*xp.
get(i),type,iter);
36template<
typename Real>
39 ROL_TEST_FOR_EXCEPTION( (size_ != xp.
numVectors() ) , std::invalid_argument,
40 ">>> ERROR (ROL_SeparableObjective, update): "
41 "Dimension mismatch.");
42 for(
unsigned i = 0; i < size_; ++i)
obj_[i]->
update(*xp.
get(i),flag,iter);
45template<
typename Real>
48 ROL_TEST_FOR_EXCEPTION( (size_ != xp.
numVectors() ) , std::invalid_argument,
49 ">>> ERROR (ROL_SeparableObjective, value): "
50 "Dimension mismatch.");
52 for(
unsigned i = 0; i < size_; ++i) val +=
obj_[i]->
value(*xp.
get(i),tol);
56template<
typename Real>
60 ROL_TEST_FOR_EXCEPTION( (size_ != gp.
numVectors() ) , std::invalid_argument,
61 ">>> ERROR (ROL_SeparableObjective, gradient): "
62 "Dimension mismatch.");
63 ROL_TEST_FOR_EXCEPTION( (size_ != xp.
numVectors() ) , std::invalid_argument,
64 ">>> ERROR (ROL_SeparableObjective, gradient): "
65 "Dimension mismatch.");
66 for(
unsigned i = 0; i < size_; ++i)
obj_[i]->gradient(*gp.
get(i),*xp.
get(i),tol);
69template<
typename Real>
74 ROL_TEST_FOR_EXCEPTION( (size_ != hvp.
numVectors() ) , std::invalid_argument,
75 ">>> ERROR (ROL_SeparableObjective, gradient): "
76 "Dimension mismatch.");
77 ROL_TEST_FOR_EXCEPTION( (size_ != vp.
numVectors() ) , std::invalid_argument,
78 ">>> ERROR (ROL_SeparableObjective, hessVec): "
79 "Dimension mismatch.");
80 ROL_TEST_FOR_EXCEPTION( (size_ != xp.
numVectors() ) , std::invalid_argument,
81 ">>> ERROR (ROL_SeparableObjective, hessVec): "
82 "Dimension mismatch.");
83 for(
unsigned i = 0; i < size_; ++i)
obj_[i]->hessVec(*hvp.
get(i),*vp.
get(i),*xp.
get(i),tol);
86template<
typename Real>
91 ROL_TEST_FOR_EXCEPTION( (size_ != hvp.
numVectors() ) , std::invalid_argument,
92 ">>> ERROR (ROL_SeparableObjective, gradient): "
93 "Dimension mismatch.");
94 ROL_TEST_FOR_EXCEPTION( (size_ != vp.
numVectors() ) , std::invalid_argument,
95 ">>> ERROR (ROL_SeparableObjective, hessVec): "
96 "Dimension mismatch.");
97 ROL_TEST_FOR_EXCEPTION( (size_ != xp.
numVectors() ) , std::invalid_argument,
98 ">>> ERROR (ROL_SeparableObjective, hessVec): "
99 "Dimension mismatch.");
100 for(
unsigned i = 0; i < size_; ++i)
obj_[i]->invHessVec(*hvp.
get(i),*vp.
get(i),*xp.
get(i),tol);
103template<
typename Real>
108 ROL_TEST_FOR_EXCEPTION( (size_ != hvp.
numVectors() ) , std::invalid_argument,
109 ">>> ERROR (ROL_SeparableObjective, gradient): "
110 "Dimension mismatch.");
111 ROL_TEST_FOR_EXCEPTION( (size_ != vp.
numVectors() ) , std::invalid_argument,
112 ">>> ERROR (ROL_SeparableObjective, hessVec): "
113 "Dimension mismatch.");
114 ROL_TEST_FOR_EXCEPTION( (size_ != xp.
numVectors() ) , std::invalid_argument,
115 ">>> ERROR (ROL_SeparableObjective, hessVec): "
116 "Dimension mismatch.");
117 for(
unsigned i = 0; i < size_; ++i)
obj_[i]->precond(*hvp.
get(i),*vp.
get(i),*xp.
get(i),tol);
120template<
typename Real>
Provides the interface to evaluate objective functions.
virtual void setParameter(const std::vector< Real > ¶m)
Defines the linear algebra of vector space on a generic partitioned vector.
ROL::Ptr< const Vector< Real > > get(size_type i) const
size_type numVectors() const
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Update objective function.
Real value(const Vector< Real > &x, Real &tol) override
Compute value.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
void precond(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply preconditioner to vector.
void setParameter(const std::vector< Real > ¶m) override
SeparableObjective(const std::vector< Ptr< Objective< Real > > > &obj)
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply Hessian approximation to vector.
void invHessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply inverse Hessian approximation to vector.
const Ptr< Objective< Real > > get(unsigned i) const
Defines the linear algebra or vector space interface.
void setParameter(ROL::ParameterList &parlist, const std::vector< std::string > &location, const std::vector< std::string >::iterator iter, ParameterType value)
ROL::Objective_SerialSimOpt Objective_SimOpt value(const V &u, const V &z, Real &tol) override
virtual void update(const Vector< Real > &u, const Vector< Real > &z, bool flag=true, int iter=-1) override