10 #ifndef ROL_MIXEDQUANTILEQUADRANGLE_HPP
11 #define ROL_MIXEDQUANTILEQUADRANGLE_HPP
16 #include "ROL_ParameterList.hpp"
83 ROL_TEST_FOR_EXCEPTION((pSize!=cSize),std::invalid_argument,
84 ">>> ERROR (ROL::MixedCVaR): Probability and coefficient arrays have different sizes!");
85 Real sum(0),
zero(0), one(1);
86 for (
int i = 0; i < pSize; i++) {
87 ROL_TEST_FOR_EXCEPTION((
prob_[i]>one ||
prob_[i]<
zero), std::invalid_argument,
88 ">>> ERROR (ROL::MixedCVaR): Element of probability array out of range!");
89 ROL_TEST_FOR_EXCEPTION((
coeff_[i]>one ||
coeff_[i]<
zero), std::invalid_argument,
90 ">>> ERROR (ROL::MixedCVaR): Element of coefficient array out of range!");
93 ROL_TEST_FOR_EXCEPTION((std::abs(sum-one) > std::sqrt(ROL_EPSILON<Real>())),std::invalid_argument,
94 ">>> ERROR (ROL::MixedCVaR): Coefficients do not sum to one!");
95 ROL_TEST_FOR_EXCEPTION(
plusFunction_ == ROL::nullPtr, std::invalid_argument,
96 ">>> ERROR (ROL::MixedCVaR): PlusFunction pointer is null!");
104 ROL::ParameterList &list
105 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Mixed CVaR");
107 prob_ = ROL::getArrayFromStringParameter<Real>(list,
"Probability Array");
108 coeff_ = ROL::getArrayFromStringParameter<Real>(list,
"Coefficient Array");
115 const std::vector<Real> &coeff,
128 if (xstat != nullPtr) {
129 for (
int i = 0; i <
size_; ++i) {
130 stat =
coeff_[i]*(*xstat)[i];
138 const std::vector<Real> &xstat,
142 for (
int i = 0; i <
size_; i++) {
149 const std::vector<Real> &xstat,
153 for (
int i = 0; i <
size_; i++) {
154 cvar +=
coeff_[i]*xstat[i];
161 const std::vector<Real> &xstat,
163 Real pf(0), c(0), one(1);
165 for (
int i = 0; i <
size_; i++) {
168 if (std::abs(c) >= ROL_EPSILON<Real>()) {
177 std::vector<Real> &gstat,
179 const std::vector<Real> &xstat,
182 for (
int i = 0; i <
size_; i++) {
190 const std::vector<Real> &vstat,
192 const std::vector<Real> &xstat,
194 Real pf1(0), pf2(0), c(0), one(1);
196 for (
int i = 0; i <
size_; i++) {
199 if (std::abs(pf2) >= ROL_EPSILON<Real>()) {
205 if (std::abs(pf1) >= ROL_EPSILON<Real>()) {
214 std::vector<Real> &hvstat,
216 const std::vector<Real> &vstat,
218 const std::vector<Real> &xstat,
Provides the interface to evaluate objective functions.
MixedCVaR(ROL::ParameterList &parlist)
void computeHessVec(Vector< Real > &hv, Objective< Real > &obj, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Real computeValue(Objective< Real > &obj, const Vector< Real > &x, Real &tol)
Ptr< Vector< Real > > hv_
void updateGradient(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal risk measure storage for gradient computation.
ROL::Ptr< PlusFunction< Real > > plusFunction_
void updateHessVec(Objective< Real > &obj, const Vector< Real > &v, const std::vector< Real > &vstat, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal risk measure storage for Hessian-time-a-vector computation.
Ptr< Vector< Real > > dualVector_
std::vector< Real > coeff_
Defines the linear algebra or vector space interface.
void sumAll(Real *input, Real *output, int dim) const
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
Real getValue(const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler)
Return risk measure value.
Provides an interface for a convex combination of conditional value-at-risks.
void getHessVec(Vector< Real > &hv, std::vector< Real > &hvstat, const Vector< Real > &v, const std::vector< Real > &vstat, const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler)
Return risk measure Hessian-times-a-vector.
void initialize(const Vector< Real > &x)
Initialize temporary variables.
MixedCVaR(const std::vector< Real > &prob, const std::vector< Real > &coeff, const ROL::Ptr< PlusFunction< Real > > &pf)
void computeGradient(Vector< Real > &g, Objective< Real > &obj, const Vector< Real > &x, Real &tol)
Real computeGradVec(Vector< Real > &g, Objective< Real > &obj, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Provides the interface to implement any functional that maps a random variable to a (extended) real n...
void initializeMCVAR(void)
std::vector< Real > prob_
void updateValue(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal storage for value computation.
void getGradient(Vector< Real > &g, std::vector< Real > &gstat, const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler)
Return risk measure (sub)gradient.
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.
Real computeStatistic(const Ptr< const std::vector< Real >> &xstat) const override
Compute statistic.