44 #ifndef ROL_MEANVARIANCE_HPP
45 #define ROL_MEANVARIANCE_HPP
70 order_.push_back((order < 2.0) ? 2.0 : order);
72 coeff_.push_back((coeff < 0.0) ? 1.0 : coeff);
78 if ( order.size() != coeff.size() ) {
79 coeff.resize(order.size(),1.0);
81 for (
unsigned i = 0; i < order.size(); i++ ) {
82 order_.push_back((order[i] < 2.0) ? 2.0 : order[i]);
83 coeff_.push_back((coeff[i] < 0.0) ? 1.0 : coeff[i]);
111 x0 = Teuchos::rcp(&
const_cast<Vector<Real> &
>(x),
false);
112 v0 = Teuchos::rcp(&
const_cast<Vector<Real> &
>(v),
false);
115 void update(
const Real val,
const Real weight) {
126 typename std::vector<Teuchos::RCP<Vector<Real> > >::iterator it = (this->
gradient_storage_).end();
140 typename std::vector<Teuchos::RCP<Vector<Real> > >::iterator it = (this->
gradient_storage_).end();
155 sampler.
sumAll(&val,&ev,1);
158 Real diff = 0.0, pf0 = 0.0, var = 0.0;
159 for (
unsigned i = 0; i < this->
weights_.size(); i++ ) {
162 for (
unsigned p = 0; p < this->
order_.size(); p++ ) {
166 sampler.
sumAll(&val,&var,1);
176 sampler.
sumAll(&val,&ev,1);
179 Teuchos::RCP<Vector<Real> > gs = g.
clone(); gs->zero();
180 Teuchos::RCP<Vector<Real> > gtmp = g.
clone(); gtmp->zero();
181 Real diff = 0.0, pf0 = 0.0, pf1 = 0.0, c = 0.0, ec = 0.0, ecs = 0.0;
182 for (
unsigned i = 0; i < this->
weights_.size(); i++ ) {
187 for (
unsigned p = 0; p < this->
order_.size(); p++ ) {
193 sampler.
sumAll(&ec,&ecs,1);
195 sampler.
sumAll(*gtmp,*gs);
204 sampler.
sumAll(&val,&ev,1);
207 sampler.
sumAll(&gv,&egv,1);
208 Teuchos::RCP<Vector<Real> > g = hv.
clone();
212 Real diff = 0.0, pf0 = 0.0, pf1 = 0.0, pf2 = 0.0;
213 Real cg = 0.0, ecg = 0.0, ecgs = 0.0, ch = 0.0, ech = 0.0, echs = 0.0;
214 Teuchos::RCP<Vector<Real> > htmp = hv.
clone(); htmp->zero();
215 Teuchos::RCP<Vector<Real> > hs = hv.
clone(); hs->zero();
216 for (
unsigned i = 0; i < this->
weights_.size(); i++ ) {
223 for (
unsigned p = 0; p < this->
order_.size(); p++ ) {
225 ((this->
order_[p]-1.0)*std::pow(pf0,this->
order_[p]-2.0)*pf1*pf1+
226 std::pow(pf0,this->
order_[p]-1.0)*pf2);
234 sampler.
sumAll(&ech,&echs,1);
236 sampler.
sumAll(&ecg,&ecgs,1);
238 sampler.
sumAll(*htmp,*hs);
Real getValue(SampleGenerator< Real > &sampler)
std::vector< Teuchos::RCP< Vector< Real > > > gradient_storage_
virtual void scale(const Real alpha)=0
Compute where .
MeanVariance(Real order, Real coeff, Teuchos::RCP< PositiveFunction< Real > > &pf)
std::vector< Real > gradvec_storage_
virtual void plus(const Vector &x)=0
Compute , where .
Teuchos::RCP< PositiveFunction< Real > > positiveFunction_
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x)
void update(const Real val, const Real weight)
std::vector< Real > order_
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
std::vector< Real > weights_
MeanVariance(std::vector< Real > &order, std::vector< Real > &coeff, Teuchos::RCP< PositiveFunction< Real > > &pf)
virtual void zero()
Set to zero vector.
std::vector< Real > coeff_
Defines the linear algebra or vector space interface.
void update(const Real val, const Vector< Real > &g, const Real gv, const Vector< Real > &hv, const Real weight)
void sumAll(Real *input, Real *output, int dim) const
void update(const Real val, const Vector< Real > &g, const Real weight)
void getGradient(Vector< Real > &g, SampleGenerator< Real > &sampler)
std::vector< Teuchos::RCP< Vector< Real > > > hessvec_storage_
void getHessVec(Vector< Real > &hv, SampleGenerator< Real > &sampler)
void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x, Teuchos::RCP< Vector< Real > > &v0, const Vector< Real > &v)
std::vector< Real > value_storage_