44 #ifndef ROL_LINEARCOMBINATIONOBJECTIVE_DEF_H
45 #define ROL_LINEARCOMBINATIONOBJECTIVE_DEF_H
49 template<
typename Real>
52 xdual_(nullPtr), initialized_(false) {
57 template<
typename Real>
60 :
Objective<Real>(),
obj_(obj), weights_(weights), size_(weights.size()),
61 xdual_(nullPtr), initialized_(false) {}
63 template<
typename Real>
65 for (
size_t i=0; i<size_; ++i) {
66 obj_[i]->update(x,type,iter);
70 template<
typename Real>
72 for (
size_t i=0; i<size_; ++i) {
73 obj_[i]->update(x,flag,iter);
77 template<
typename Real>
80 for (
size_t i = 0; i < size_; i++) {
81 val += weights_[i]*
obj_[i]->value(x,tol);
86 template<
typename Real>
93 for (
size_t i = 0; i < size_; i++) {
94 obj_[i]->gradient(*xdual_,x,tol);
95 g.
axpy(weights_[i],*xdual_);
99 template<
typename Real>
106 for (
size_t i = 0; i < size_; i++) {
107 obj_[i]->hessVec(*xdual_,v,x,tol);
108 hv.
axpy(weights_[i],*xdual_);
112 template<
typename Real>
115 for (
size_t i = 0; i < size_; ++i) {
116 obj_[i]->setParameter(param);
Provides the interface to evaluate objective functions.
const std::vector< Ptr< Objective< Real > > > obj_
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
const double weights[4][5]
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
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.
LinearCombinationObjective(const std::vector< Ptr< Objective< Real >>> &obj)
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
void setParameter(const std::vector< Real > ¶m) override
virtual void setParameter(const std::vector< Real > ¶m)
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply Hessian approximation to vector.
std::vector< Real > weights_
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Update objective function.