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