44 #ifndef ROL_MEANVARIANCEFROMTARGET_HPP 45 #define ROL_MEANVARIANCEFROMTARGET_HPP 52 #include "Teuchos_ParameterList.hpp" 53 #include "Teuchos_Array.hpp" 59 typedef typename std::vector<Real>::size_type
uint;
74 target_.clear(); order_.clear(); coeff_.clear();
75 target_.push_back(target);
76 order_.push_back((order < 2.0) ? 2.0 : order);
77 coeff_.push_back((coeff < 0.0) ? 1.0 : coeff);
78 NumMoments_ = order_.size();
84 NumMoments_ = order.size();
85 target_.clear(); order_.clear(); coeff_.clear();
86 if ( NumMoments_ != target.size() ) {
87 target.resize(NumMoments_,0.0);
89 if ( NumMoments_ != coeff.size() ) {
90 coeff.resize(NumMoments_,1.0);
93 target_.push_back(target[i]);
94 order_.push_back((order[i] < 2.0) ? 2.0 : order[i]);
95 coeff_.push_back((coeff[i] < 0.0) ? 1.0 : coeff[i]);
101 Teuchos::ParameterList &list
102 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Mean Plus Variance From Target");
104 Teuchos::Array<Real> target
105 = Teuchos::getArrayFromStringParameter<double>(list,
"Targets");
106 Teuchos::Array<Real> order
107 = Teuchos::getArrayFromStringParameter<double>(list,
"Orders");
108 Teuchos::Array<Real> coeff
109 = Teuchos::getArrayFromStringParameter<double>(list,
"Coefficients");
111 NumMoments_ = order.size();
112 target_.clear(); order_.clear(); coeff_.clear();
113 if ( NumMoments_ != static_cast<uint>(target.size()) ) {
114 target.resize(NumMoments_,0.0);
116 if ( NumMoments_ != static_cast<uint>(coeff.size()) ) {
117 coeff.resize(NumMoments_,1.0);
120 target_.push_back(target[i]);
121 order_.push_back((order[i] < 2.0) ? 2.0 : order[i]);
122 coeff_.push_back((coeff[i] < 0.0) ? 1.0 : coeff[i]);
125 if ( list.get(
"Deviation Type",
"Upper") ==
"Upper" ) {
133 void update(
const Real val,
const Real weight) {
134 Real diff = 0.0, pf0 = 0.0;
137 diff = val-target_[p];
138 pf0 = positiveFunction_->evaluate(diff,0);
144 Real diff = 0.0, pf0 = 0.0, pf1 = 0.0, c = 1.0;
146 diff = val-target_[p];
147 pf0 = positiveFunction_->evaluate(diff,0);
148 pf1 = positiveFunction_->evaluate(diff,1);
149 c += order_[p]*coeff_[p]*std::pow(pf0,order_[p]-1.0)*pf1;
156 Real diff = 0.0, pf0 = 0.0, pf1 = 0.0, pf2 = 0.0, p1 = 0.0, p2 = 0.0, ch = 1.0, cg = 0.0;
158 diff = val - target_[p];
159 pf0 = positiveFunction_->evaluate(diff,0);
160 pf1 = positiveFunction_->evaluate(diff,1);
161 pf2 = positiveFunction_->evaluate(diff,2);
163 p1 = std::pow(pf0,order_[p]-1.0);
164 p2 = std::pow(pf0,order_[p]-2.0);
165 cg += order_[p]*coeff_[p]*gv*( (order_[p]-1.0)*p2*pf1*pf1 + p1*pf2 );
166 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)
void update(const Real val, const Vector< Real > &g, const Real weight)
MeanVarianceFromTarget(Teuchos::ParameterList &parlist)
Defines the linear algebra or vector space interface.
MeanVarianceFromTarget(Real target, Real order, Real coeff, Teuchos::RCP< PositiveFunction< Real > > &pf)
std::vector< Real > target_
MeanVarianceFromTarget(std::vector< Real > &target, std::vector< Real > &order, std::vector< Real > &coeff, Teuchos::RCP< PositiveFunction< Real > > &pf)
Teuchos::RCP< PositiveFunction< Real > > positiveFunction_
std::vector< Real > order_
std::vector< Real > coeff_
void update(const Real val, const Real weight)
std::vector< Real >::size_type uint