44 #ifndef ROL_MIXEDQUANTILEQUADRANGLE_HPP 45 #define ROL_MIXEDQUANTILEQUADRANGLE_HPP 51 #include "Teuchos_Array.hpp" 52 #include "Teuchos_ParameterList.hpp" 78 Teuchos::ParameterList &list
79 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Mixed-Quantile Quadrangle");
81 prob_ = Teuchos::getArrayFromStringParameter<Real>(list,
"Probability Array");
82 coeff_ = Teuchos::getArrayFromStringParameter<Real>(list,
"Coefficient Array");
84 int pSize = prob_.size(), cSize = coeff_.size();
85 TEUCHOS_TEST_FOR_EXCEPTION((pSize!=cSize),std::invalid_argument,
86 ">>> ERROR (ROL::MixedQuantileQuadrangle): Probability and coefficient arrays have different sizes!");
90 for (
int i = 0; i <
size_; i++) {
91 TEUCHOS_TEST_FOR_EXCEPTION((prob_[i]>1. || prob_[i]<0.), std::invalid_argument,
92 ">>> ERROR (ROL::MixedQuantileQuadrangle): Element of probability array out of range!");
93 TEUCHOS_TEST_FOR_EXCEPTION((coeff_[i]>1. || coeff_[i]<0.), std::invalid_argument,
94 ">>> ERROR (ROL::MixedQuantileQuadrangle): Element of coefficient array out of range!");
97 TEUCHOS_TEST_FOR_EXCEPTION((std::abs(sum-1.) > std::sqrt(
ROL_EPSILON)),std::invalid_argument,
98 ">>> ERROR (ROL::MixedQuantileQuadrangle): Coefficients do not sum to one!");
102 xvar_.clear(); xvar_.resize(size_,0.0);
103 vvar_.clear(); vvar_.resize(size_,0.0);
104 vec_.clear(); vec_.resize(size_,0.0);
108 const std::vector<Real> &coeff,
110 :
RiskMeasure<Real>(), plusFunction_(pf), firstReset_(true) {
111 prob_.clear(); coeff_.clear();
113 int pSize = prob.size(), cSize = coeff.size();
114 TEUCHOS_TEST_FOR_EXCEPTION((pSize!=cSize),std::invalid_argument,
115 ">>> ERROR (ROL::MixedQuantileQuadrangle): Probability and coefficient arrays have different sizes!");
119 for (
int i = 0; i <
size_; i++) {
120 TEUCHOS_TEST_FOR_EXCEPTION((prob[i]>1. || prob[i]<0.), std::invalid_argument,
121 ">>> ERROR (ROL::MixedQuantileQuadrangle): Element of probability array out of range!");
122 TEUCHOS_TEST_FOR_EXCEPTION((coeff[i]>1. || coeff[i]<0.), std::invalid_argument,
123 ">>> ERROR (ROL::MixedQuantileQuadrangle): Element of coefficient array out of range!");
124 prob_.push_back(prob_[i]);
125 coeff_.push_back(coeff_[i]);
128 TEUCHOS_TEST_FOR_EXCEPTION((std::abs(sum-1.) > std::sqrt(
ROL_EPSILON)),std::invalid_argument,
129 ">>> ERROR (ROL::MixedQuantileQuadrangle): Coefficients do not sum to one!");
131 xvar_.clear(); xvar_.resize(size_,0.0);
132 vvar_.clear(); vvar_.resize(size_,0.0);
133 vec_.clear(); vec_.resize(size_,0.0);
138 for (
int i = 0; i <
size_; i++) {
144 dualVector_ = (x0->dual()).clone();
155 for (
int i = 0; i <
size_; i++) {
161 void update(
const Real val,
const Real weight) {
163 for (
int i = 0; i <
size_; i++) {
164 pf = plusFunction_->evaluate(val-xvar_[i],0);
170 Real pf = 0.0, c = 0.0;
171 for (
int i = 0; i <
size_; i++) {
172 pf = plusFunction_->evaluate(val-xvar_[i],1);
173 c = weight*coeff_[i]/(1.0-prob_[i])*pf;
181 Real pf1 = 0.0, pf2 = 0.0, c = 0.0;
182 for (
int i = 0; i <
size_; i++) {
183 pf1 = plusFunction_->evaluate(val-xvar_[i],1);
184 pf2 = plusFunction_->evaluate(val-xvar_[i],2);
185 c = weight*coeff_[i]/(1.0-prob_[i])*pf2*(gv-vvar_[i]);
189 c = weight*coeff_[i]/(1.0-prob_[i])*pf1;
197 sampler.
sumAll(&val,&cvar,1);
198 for (
int i = 0; i <
size_; i++) {
199 cvar += coeff_[i]*xvar_[i];
206 std::vector<Real> var(size_,0.0);
207 sampler.
sumAll(&vec_[0],&var[0],size_);
210 for (
int i = 0; i <
size_; i++) {
219 std::vector<Real> var(size_,0.0);
220 sampler.
sumAll(&vec_[0],&var[0],size_);
MixedQuantileQuadrangle(Teuchos::ParameterList &parlist)
void getHessVec(Vector< Real > &hv, SampleGenerator< Real > &sampler)
const Real getStatistic(const int i=0) const
void getGradient(Vector< Real > &g, SampleGenerator< Real > &sampler)
Defines the linear algebra or vector space interface.
void sumAll(Real *input, Real *output, int dim) const
void setVector(const Vector< Real > &vec)
Teuchos::RCP< const Vector< Real > > getVector() const
void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x)
void setStatistic(const Real stat)
void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x, Teuchos::RCP< Vector< Real > > &v0, const Vector< Real > &v)
void update(const Real val, const Real weight)
std::vector< Real > vvar_
MixedQuantileQuadrangle(const std::vector< Real > &prob, const std::vector< Real > &coeff, const Teuchos::RCP< PlusFunction< Real > > &pf)
Teuchos::RCP< Vector< Real > > dualVector_
void update(const Real val, const Vector< Real > &g, const Real gv, const Vector< Real > &hv, const Real weight)
Teuchos::Array< Real > prob_
Teuchos::Array< Real > coeff_
void update(const Real val, const Vector< Real > &g, const Real weight)
virtual void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x)
Real getValue(SampleGenerator< Real > &sampler)
std::vector< Real > xvar_
Teuchos::RCP< PlusFunction< Real > > plusFunction_
static const double ROL_EPSILON
Platform-dependent machine epsilon.