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