10 #ifndef ROL_LINEARCOMBINATIONOBJECTIVE_DEF_H
11 #define ROL_LINEARCOMBINATIONOBJECTIVE_DEF_H
15 template<
typename Real>
18 xdual_(nullPtr), initialized_(false) {
23 template<
typename Real>
26 :
Objective<Real>(),
obj_(obj), weights_(weights), size_(weights.size()),
27 xdual_(nullPtr), initialized_(false) {}
29 template<
typename Real>
31 for (
size_t i=0; i<size_; ++i) {
32 obj_[i]->update(x,type,iter);
36 template<
typename Real>
38 for (
size_t i=0; i<size_; ++i) {
39 obj_[i]->update(x,flag,iter);
43 template<
typename Real>
46 for (
size_t i = 0; i < size_; i++) {
47 val += weights_[i]*
obj_[i]->value(x,tol);
52 template<
typename Real>
59 for (
size_t i = 0; i < size_; i++) {
60 obj_[i]->gradient(*xdual_,x,tol);
61 g.
axpy(weights_[i],*xdual_);
65 template<
typename Real>
72 for (
size_t i = 0; i < size_; i++) {
73 obj_[i]->hessVec(*xdual_,v,x,tol);
74 hv.
axpy(weights_[i],*xdual_);
78 template<
typename Real>
81 for (
size_t i = 0; i < size_; ++i) {
82 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.