44 #ifndef ROL_MEANVARIANCEFROMTARGET_HPP 45 #define ROL_MEANVARIANCEFROMTARGET_HPP 67 target_.clear(); order_.clear(); coeff_.clear();
68 target_.push_back(target);
69 order_.push_back((order < 2.0) ? 2.0 : order);
70 coeff_.push_back((coeff < 0.0) ? 1.0 : coeff);
76 target_.clear(); order_.clear(); coeff_.clear();
77 if ( order.size() != target.size() ) {
78 target.resize(order.size(),0.0);
80 if ( order.size() != coeff.size() ) {
81 coeff.resize(order.size(),1.0);
83 for (
unsigned i = 0; i < order.size(); i++ ) {
84 target_.push_back(target[i]);
85 order_.push_back((order[i] < 2.0) ? 2.0 : order[i]);
86 coeff_.push_back((coeff[i] < 0.0) ? 1.0 : coeff[i]);
90 void update(
const Real val,
const Real weight) {
91 Real diff = 0.0, pf0 = 0.0;
93 for (
unsigned p = 0; p < order_.size(); p++ ) {
94 diff = val-target_[p];
95 pf0 = positiveFunction_->evaluate(diff,0);
101 Real diff = 0.0, pf0 = 0.0, pf1 = 0.0, c = 1.0;
102 for (
unsigned p = 0; p < order_.size(); p++ ) {
103 diff = val-target_[p];
104 pf0 = positiveFunction_->evaluate(diff,0);
105 pf1 = positiveFunction_->evaluate(diff,1);
106 c += order_[p]*coeff_[p]*std::pow(pf0,order_[p]-1.0)*pf1;
113 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;
114 for (
unsigned p = 0; p < order_.size(); p++ ) {
115 diff = val - target_[p];
116 pf0 = positiveFunction_->evaluate(diff,0);
117 pf1 = positiveFunction_->evaluate(diff,1);
118 pf2 = positiveFunction_->evaluate(diff,2);
120 p1 = std::pow(pf0,order_[p]-1.0);
121 p2 = std::pow(pf0,order_[p]-2.0);
122 cg += order_[p]*coeff_[p]*gv*( (order_[p]-1.0)*p2*pf1*pf1 + p1*pf2 );
123 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)
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)