44 #ifndef ROL_MEANVALUEOBJECTIVE_DEF_HPP
45 #define ROL_MEANVALUEOBJECTIVE_DEF_HPP
49 template<
typename Real>
53 obj_->setParameter(param);
56 template<
typename Real>
58 obj_->update(x,type,iter);
61 template<
typename Real>
63 obj_->update(x,flag,iter);
66 template<
typename Real>
68 return obj_->value(x,tol);
71 template<
typename Real>
73 obj_->gradient(g,x,tol);
76 template<
typename Real>
79 obj_->hessVec(hv,v,x,tol);
82 template<
typename Real>
85 obj_->precond(Pv,v,x,tol);
88 template<
typename Real>
91 int dim = sampler->getMyPoint(0).size(), nsamp = sampler->numMySamples();
92 std::vector<Real> loc(dim), mean(dim), pt(dim);
94 for (
int i = 0; i < nsamp; i++) {
95 pt = sampler->getMyPoint(i);
96 wt = sampler->getMyWeight(i);
97 for (
int j = 0; j <
dim; j++) {
101 sampler->sumAll(&loc[0],&mean[0],dim);
Provides the interface to evaluate objective functions.
MeanValueObjective(const Ptr< Objective< Real >> &obj, const Ptr< SampleGenerator< Real >> &sampler)
void precond(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply preconditioner to vector.
Defines the linear algebra or vector space interface.
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Update objective function.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol) override
Compute gradient.
std::vector< Real > computeSampleMean(const Ptr< SampleGenerator< Real >> &sampler) const
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply Hessian approximation to vector.
Real value(const Vector< Real > &x, Real &tol) override
Compute value.
const Ptr< Objective< Real > > obj_