44 #ifndef ROL_BPOEOBJECTIVE_HPP 45 #define ROL_BPOEOBJECTIVE_HPP 47 #include "Teuchos_RCP.hpp" 108 const std::vector<Real> ¶m, Real &tol) {
116 value_storage_.insert(std::pair<std::vector<Real>,Real>(param,val));
122 const std::vector<Real> ¶m, Real &tol) {
130 Teuchos::RCP<Vector<Real> > tmp = g.
clone();
138 const std::vector<Real> ¶m, Real &tol) {
147 const Real order,
const Real threshold,
151 const bool storage =
true )
160 const Real order,
const Real threshold,
163 const bool storage =
true )
172 const Real order,
const Real threshold,
174 const bool storage =
true )
183 Teuchos::RCP<Vector<Real> > xvec; Real xvar = 0.0;
200 Teuchos::RCP<Vector<Real> > xvec; Real xvar = 0.0;
203 std::vector<Real> point;
204 Real weight = 0.0, myval = 0.0, pval = 0.0, val = 0.0, bp = 0.0;
206 for (
int i = start; i < end; i++ ) {
214 myval += weight*((
order_==1.0) ? bp
221 return ((
order_==1.0) ? val : std::pow(val,1.0/
order_));
225 Teuchos::RCP<Vector<Real> > xvec; Real xvar = 0.0;
230 std::vector<Real> point, val(2,0.0), myval(2,0.0);
231 Real weight = 0.0, pval = 0.0, pvalp0 = 0.0, pvalp1 = 0.0, bp = 0.0;
233 for (
int i = start; i < end; i++ ) {
241 pvalp0 = ((
order_==1.0) ? bp
243 pvalp1 = ((
order_==1.0) ? 1.0
245 : std::pow(bp,
order_-1.0)));
247 myval[0] += weight*pvalp0;
259 if ( std::abs(val[0]) >= ROL_EPSILON<Real>()) {
272 Teuchos::RCP<Vector<Real> > xvec; Real xvar = 0.0;
274 Teuchos::RCP<Vector<Real> > vvec; Real vvar = 0.0;
281 std::vector<Real> point, val(5,0.0), myval(5,0.0);
282 Real pval = 0.0, pvalp0 = 0.0, pvalp1 = 0.0, pvalp2 = 0.0;
283 Real weight = 0.0, gv = 0.0, bp = 0.0;
285 for (
int i = start; i < end; i++ ) {
294 pvalp0 = ((
order_==1.0) ? bp
296 pvalp1 = ((
order_==1.0) ? 1.0
298 : std::pow(bp,
order_-1.0)));
299 pvalp2 = ((
order_==1.0) ? 0.0
302 : std::pow(bp,
order_-2.0))));
304 myval[0] += weight*pvalp0;
311 myval[3] += weight*pvalp1*gv;
312 myval[4] += weight*pvalp2*(pval-
threshold_)*gv;
325 if ( std::abs(val[0]) >= ROL_EPSILON<Real>() ) {
331 Real norm0 = ((
order_==1.0) ? 1.0
332 : ((
order_==2.0) ? std::sqrt(val[0])
334 Real norm1 = ((
order_==1.0) ? val[0]
336 hvar = (
order_-1.0)*((val[2]/norm0 - val[1]*val[1]/norm1)*vvar
337 +xvar*(val[4]/norm0 - val[3]*val[1]/norm1))
340 Real coeff = -(
order_-1.0)*xvar*(xvar*val[3]+vvar*val[1])/norm1+vvar/norm0;
Provides the interface to evaluate objective functions.
Teuchos::RCP< Vector< Real > > gradient1_
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
void unwrap_const_CVaR_vector(Teuchos::RCP< Vector< Real > > &xvec, Real &xvar, const Vector< Real > &x)
Teuchos::RCP< SampleGenerator< Real > > HessianSampler_
Teuchos::RCP< Vector< Real > > pointGrad_
Teuchos::RCP< Vector< Real > > sumGrad1_
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
void initialize(const Vector< Real > &x)
void getGradient(Vector< Real > &g, const Vector< Real > &x, const std::vector< Real > ¶m, Real &tol)
BPOEObjective(const Teuchos::RCP< Objective< Real > > &pObj, const Real order, const Real threshold, const Teuchos::RCP< SampleGenerator< Real > > &vsampler, const Teuchos::RCP< SampleGenerator< Real > > &gsampler, const Teuchos::RCP< SampleGenerator< Real > > &hsampler, const bool storage=true)
Teuchos::RCP< Vector< Real > > sumGrad0_
virtual void precond(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply preconditioner to vector.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
void getValue(Real &val, const Vector< Real > &x, const std::vector< Real > ¶m, Real &tol)
Teuchos::RCP< Vector< Real > > pointHess_
std::map< std::vector< Real >, Real > value_storage_
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
std::map< std::vector< Real >, Teuchos::RCP< Vector< Real > > > gradient_storage_
void setVector(const Vector< Real > &vec)
Teuchos::RCP< SampleGenerator< Real > > ValueSampler_
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
BPOEObjective(const Teuchos::RCP< Objective< Real > > &pObj, const Real order, const Real threshold, const Teuchos::RCP< SampleGenerator< Real > > &sampler, const bool storage=true)
void setStatistic(const Real stat)
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
Teuchos::RCP< Vector< Real > > gradient2_
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Teuchos::RCP< Vector< Real > > sumHess_
Teuchos::RCP< Vector< Real > > sumGrad2_
Teuchos::RCP< Objective< Real > > ParametrizedObjective_
Teuchos::RCP< Vector< Real > > gradient0_
BPOEObjective(const Teuchos::RCP< Objective< Real > > &pObj, const Real order, const Real threshold, const Teuchos::RCP< SampleGenerator< Real > > &vsampler, const Teuchos::RCP< SampleGenerator< Real > > &gsampler, const bool storage=true)
virtual void set(const Vector &x)
Set where .
void getHessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, const std::vector< Real > ¶m, Real &tol)
Teuchos::RCP< SampleGenerator< Real > > GradientSampler_
Teuchos::RCP< Vector< Real > > hessvec_