44 #ifndef ROL_RISKNEUTRALOBJECTIVE_HPP
45 #define ROL_RISKNEUTRALOBJECTIVE_HPP
47 #include "Teuchos_RefCountPtr.hpp"
58 Teuchos::RCP<ParametrizedObjective<Real> >
pObj_;
73 pObj_ = Teuchos::rcp(&pObj,
false);
74 vsampler_ = Teuchos::rcp(&vsampler,
false);
75 gsampler_ = Teuchos::rcp(&gsampler,
false);
83 pObj_ = Teuchos::rcp(&pObj,
false);
93 pObj_->update(x,flag,iter);
104 Real myval = 0.0, ptval = 0.0, val = 0.0, error = 2.0*tol + 1.0;
105 std::vector<Real> ptvals;
106 while ( error > tol ) {
110 ptval =
pObj_->value(x,tol);
111 myval +=
vsampler_->getMyWeight(i)*ptval;
112 ptvals.push_back(ptval);
134 Teuchos::RCP<Vector<Real> > ptg = g.
clone(); ptg->zero();
135 Teuchos::RCP<Vector<Real> > myg = g.
clone(); myg->zero();
136 std::vector<Teuchos::RCP<Vector<Real> > > ptgs;
137 Real error = 2.0*tol + 1.0;
138 while ( error > tol ) {
142 pObj_->gradient(*ptg,x,tol);
143 myg->axpy(
gsampler_->getMyWeight(i),*ptg);
144 ptgs.push_back(x.
clone());
145 (ptgs.back())->set(*ptg);
166 Teuchos::RCP<Vector<Real> > pth = hv.
clone(); pth->zero();
167 Teuchos::RCP<Vector<Real> > myh = hv.
clone(); myh->zero();
168 for (
int i = 0; i <
gsampler_->numMySamples(); i++ ) {
170 pObj_->hessVec(*pth,v,x,tol);
171 myh->axpy(
gsampler_->getMyWeight(i),*pth);
Provides the interface to evaluate objective functions.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
RiskNeutralObjective(ParametrizedObjective< Real > &pObj, SampleGenerator< Real > &vsampler, SampleGenerator< Real > &gsampler)
virtual void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
Teuchos::RCP< Vector< Real > > gradient_
virtual ~RiskNeutralObjective()
RiskNeutralObjective(ParametrizedObjective< Real > &pObj, SampleGenerator< Real > &sampler)
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
virtual void precond(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply preconditioner to vector.
Teuchos::RCP< SampleGenerator< Real > > gsampler_
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
virtual Real value(const Vector< Real > &x, Real &tol)
Compute value.
virtual void set(const Vector &x)
Set where .
Teuchos::RCP< SampleGenerator< Real > > vsampler_
Teuchos::RCP< ParametrizedObjective< Real > > pObj_