44 #ifndef ROL_MEANVARIANCEFROMTARGET_HPP 45 #define ROL_MEANVARIANCEFROMTARGET_HPP 52 #include "Teuchos_ParameterList.hpp" 53 #include "Teuchos_Array.hpp" 79 typedef typename std::vector<Real>::size_type
uint;
90 int oSize = order_.size(), cSize = coeff_.size();
91 TEUCHOS_TEST_FOR_EXCEPTION((oSize!=cSize),std::invalid_argument,
92 ">>> ERROR (ROL::MeanVarianceFromTarget): Order and coefficient arrays have different sizes!");
94 for (
int i = 0; i < oSize; i++) {
95 TEUCHOS_TEST_FOR_EXCEPTION((order_[i] < two), std::invalid_argument,
96 ">>> ERROR (ROL::MeanVarianceFromTarget): Element of order array out of range!");
97 TEUCHOS_TEST_FOR_EXCEPTION((coeff_[i] < zero), std::invalid_argument,
98 ">>> ERROR (ROL::MeanVarianceFromTarget): Element of coefficient array out of range!");
100 TEUCHOS_TEST_FOR_EXCEPTION(positiveFunction_ == Teuchos::null, std::invalid_argument,
101 ">>> ERROR (ROL::MeanVarianceFromTarget): PositiveFunction pointer is null!");
118 target_.clear(); target_.push_back(target);
119 order_.clear(); order_.push_back(order);
120 coeff_.clear(); coeff_.push_back(coeff);
122 NumMoments_ = order_.size();
136 const std::vector<Real> &order,
137 const std::vector<Real> &coeff,
140 target_.clear(); order_.clear(); coeff_.clear();
141 for ( uint i = 0; i < target.size(); i++ ) {
142 target_.push_back(target[i]);
144 for ( uint i = 0; i < order.size(); i++ ) {
145 order_.push_back(order[i]);
147 for ( uint i = 0; i < coeff.size(); i++ ) {
148 coeff_.push_back(coeff[i]);
151 NumMoments_ = order_.size();
168 Teuchos::ParameterList &list
169 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Mean Plus Variance From Target");
171 Teuchos::Array<Real> target
172 = Teuchos::getArrayFromStringParameter<double>(list,
"Targets");
173 target_ = target.toVector();
174 Teuchos::Array<Real> order
175 = Teuchos::getArrayFromStringParameter<double>(list,
"Orders");
176 order_ = order.toVector();
177 Teuchos::Array<Real> coeff
178 = Teuchos::getArrayFromStringParameter<double>(list,
"Coefficients");
179 coeff_ = coeff.toVector();
181 std::string type = list.get<std::string>(
"Deviation Type");
182 if ( type ==
"Upper" ) {
185 else if ( type ==
"Absolute" ) {
189 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
190 ">>> (ROL::MeanDeviation): Deviation type is not recoginized!");
194 NumMoments_ = order.size();
197 void update(
const Real val,
const Real weight) {
198 Real diff(0), pf0(0);
201 diff = val-target_[p];
202 pf0 = positiveFunction_->evaluate(diff,0);
208 Real diff(0), pf0(0), pf1(0), c(1), one(1);
210 diff = val-target_[p];
211 pf0 = positiveFunction_->evaluate(diff,0);
212 pf1 = positiveFunction_->evaluate(diff,1);
213 c += order_[p]*coeff_[p]*std::pow(pf0,order_[p]-one)*pf1;
220 Real diff(0), pf0(0), pf1(0), pf2(0), p1(0), p2(0), ch(1), cg(0), one(1), two(2);
222 diff = val - target_[p];
223 pf0 = positiveFunction_->evaluate(diff,0);
224 pf1 = positiveFunction_->evaluate(diff,1);
225 pf2 = positiveFunction_->evaluate(diff,2);
227 p1 = std::pow(pf0,order_[p]-one);
228 p2 = std::pow(pf0,order_[p]-two);
229 cg += order_[p]*coeff_[p]*gv*( (order_[p]-one)*p2*pf1*pf1 + p1*pf2 );
230 ch += order_[p]*coeff_[p]*p1*pf1;
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.
MeanVarianceFromTarget(Teuchos::ParameterList &parlist)
Constructor.
Defines the linear algebra or vector space interface.
std::vector< Real > target_
MeanVarianceFromTarget(const std::vector< Real > &target, const std::vector< Real > &order, const std::vector< Real > &coeff, const Teuchos::RCP< PositiveFunction< Real > > &pf)
Constructor.
Teuchos::RCP< PositiveFunction< Real > > positiveFunction_
std::vector< Real > order_
Provides an interface for the mean plus a sum of arbitrary order variances from targets.
std::vector< Real > coeff_
void update(const Real val, const Real weight)
Update internal risk measure storage for value computation.
std::vector< Real >::size_type uint
Provides the interface to implement risk measures.
MeanVarianceFromTarget(const Real target, const Real order, const Real coeff, const Teuchos::RCP< PositiveFunction< Real > > &pf)
Constructor.
void checkInputs(void) const