44 #ifndef ROL_MEANDEVIATION_HPP 45 #define ROL_MEANDEVIATION_HPP 52 #include "Teuchos_ParameterList.hpp" 53 #include "Teuchos_Array.hpp" 83 typedef typename std::vector<Real>::size_type
uint;
158 TEUCHOS_TEST_FOR_EXCEPTION((oSize!=cSize),std::invalid_argument,
159 ">>> ERROR (ROL::MeanDeviation): Order and coefficient arrays have different sizes!");
160 Real zero(0), two(2);
161 for (
int i = 0; i < oSize; i++) {
162 TEUCHOS_TEST_FOR_EXCEPTION((
order_[i] < two), std::invalid_argument,
163 ">>> ERROR (ROL::MeanDeviation): Element of order array out of range!");
164 TEUCHOS_TEST_FOR_EXCEPTION((
coeff_[i] < zero), std::invalid_argument,
165 ">>> ERROR (ROL::MeanDeviation): Element of coefficient array out of range!");
167 TEUCHOS_TEST_FOR_EXCEPTION(
positiveFunction_ == Teuchos::null, std::invalid_argument,
168 ">>> ERROR (ROL::MeanDeviation): PositiveFunction pointer is null!");
201 const std::vector<Real> &coeff,
205 for (
uint i = 0; i < order.size(); i++ ) {
206 order_.push_back(order[i]);
208 for (
uint i = 0; i < coeff.size(); i++ ) {
209 coeff_.push_back(coeff[i]);
229 Teuchos::ParameterList &list
230 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Mean Plus Deviation");
232 Teuchos::Array<Real> order
233 = Teuchos::getArrayFromStringParameter<double>(list,
"Orders");
234 order_ = order.toVector();
235 Teuchos::Array<Real> coeff
236 = Teuchos::getArrayFromStringParameter<double>(list,
"Coefficients");
237 coeff_ = coeff.toVector();
239 std::string type = list.get<std::string>(
"Deviation Type");
240 if ( type ==
"Upper" ) {
243 else if ( type ==
"Absolute" ) {
247 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
248 ">>> (ROL::MeanDeviation): Deviation type is not recoginized!");
274 void update(
const Real val,
const Real weight) {
285 typename std::vector<Teuchos::RCP<Vector<Real> > >::iterator it =
gradient_storage_.end();
299 typename std::vector<Teuchos::RCP<Vector<Real> > >::iterator it =
gradient_storage_.end();
313 sampler.
sumAll(&val,&ev,1);
315 Real diff(0), pf0(0), dev(0), one(1);
334 sampler.
sumAll(&val,&ev,1);
336 Real diff(0), pf0(0), pf1(0), c(0), one(1), zero(0);
358 if (
dev0_[p] > zero ) {
372 std::vector<Real> myval(2), val(2);
375 sampler.
sumAll(&myval[0],&val[0],2);
376 Real ev = val[0], egv = val[1];
378 Real diff(0), pf0(0), pf1(0), pf2(0), zero(0), one(1), two(2);
379 Real cg(0), ch(0), diff1(0), diff2(0), diff3(0);
426 if (
dev0_[p] > zero ) {
Real getValue(SampleGenerator< Real > &sampler)
Return risk measure value.
std::vector< Real > dev2_
std::vector< Real > gvs3_
std::vector< Real > dev0_
std::vector< Real >::size_type uint
std::vector< Real > dev3_
void sumAll(Real *input, Real *output, int dim) const
Teuchos::RCP< Vector< Real > > dualVector2_
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
std::vector< Real > des0_
MeanDeviation(const std::vector< Real > &order, const std::vector< Real > &coeff, const Teuchos::RCP< PositiveFunction< Real > > &pf)
Constructor.
Defines the linear algebra or vector space interface.
Teuchos::RCP< const Vector< Real > > getVector(void) const
void getGradient(Vector< Real > &g, SampleGenerator< Real > &sampler)
Return risk measure (sub)gradient.
Provides an interface for the mean plus a sum of arbitrary order deviations.
void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x, Teuchos::RCP< Vector< Real > > &v0, const Vector< Real > &v)
Reset internal risk measure storage. Called for Hessian-times-a-vector computation.
std::vector< Real > gvp3_
std::vector< Real > order_
MeanDeviation(Teuchos::ParameterList &parlist)
Constructor.
MeanDeviation(const Real order, const Real coeff, const Teuchos::RCP< PositiveFunction< Real > > &pf)
Constructor.
std::vector< Real > gvp2_
std::vector< Real > value_storage_
std::vector< Teuchos::RCP< Vector< Real > > > gradient_storage_
std::vector< Real > des3_
std::vector< Real > dev1_
std::vector< Real > gradvec_storage_
Teuchos::RCP< Vector< Real > > dualVector1_
std::vector< Real > des2_
std::vector< Real > devp_
void update(const Real val, const Real weight)
Update internal risk measure storage for value computation.
std::vector< Real > gvs2_
void update(const Real val, const Vector< Real > &g, const Real gv, const Vector< Real > &hv, const Real weight)
Update internal risk measure storage for Hessian-time-a-vector computation.
void update(const Real val, const Vector< Real > &g, const Real weight)
Update internal risk measure storage for gradient computation.
virtual void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x)
Reset internal risk measure storage. Called for value and gradient computation.
void checkInputs(void) const
Provides the interface to implement risk measures.
Teuchos::RCP< PositiveFunction< Real > > positiveFunction_
std::vector< Real > des1_
std::vector< Real > gvp1_
void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x)
Reset internal risk measure storage. Called for value and gradient computation.
std::vector< Real > weights_
std::vector< Real > coeff_
std::vector< Teuchos::RCP< Vector< Real > > > hessvec_storage_
void getHessVec(Vector< Real > &hv, SampleGenerator< Real > &sampler)
Return risk measure Hessian-times-a-vector.
std::vector< Real > gvs1_