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,
139 Real &tol)
override {
141 Real val = computeValue(obj,x,tol);
142 for (
int i = 0; i <
size_; i++) {
149 const std::vector<Real> &xstat,
152 sampler.
sumAll(&val_,&cvar,1);
153 for (
int i = 0; i <
size_; i++) {
154 cvar +=
coeff_[i]*xstat[i];
161 const std::vector<Real> &xstat,
162 Real &tol)
override {
163 Real pf(0), c(0), one(1);
164 Real val = computeValue(obj,x,tol);
165 for (
int i = 0; i <
size_; i++) {
170 computeGradient(*dualVector_,obj,x,tol);
171 g_->axpy(c,*dualVector_);
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,
193 Real &tol)
override {
194 Real pf1(0), pf2(0), c(0), one(1);
195 Real val = computeValue(obj,x,tol);
196 for (
int i = 0; i <
size_; i++) {
200 Real gv = computeGradVec(*dualVector_,obj,v,x,tol);
201 c = weight_*
coeff_[i]/(one-
prob_[i])*pf2*(gv-vstat[i]);
203 hv_->axpy(c,*dualVector_);
207 computeHessVec(*dualVector_,obj,v,x,tol);
214 std::vector<Real> &hvstat,
216 const std::vector<Real> &vstat,
218 const std::vector<Real> &xstat,
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0 zero)()
MixedCVaR(ROL::ParameterList &parlist)
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) override
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) override
void getGradient(Vector< Real > &g, std::vector< Real > &gstat, const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler) override
std::vector< Real > prob_
std::vector< Real > coeff_
MixedCVaR(const std::vector< Real > &prob, const std::vector< Real > &coeff, const ROL::Ptr< PlusFunction< Real > > &pf)
void initialize(const Vector< Real > &x) override
Real computeStatistic(const Ptr< const std::vector< Real > > &xstat) const override
void updateGradient(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol) override
Real getValue(const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler) override
void initializeMCVAR(void)
void updateValue(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol) override
ROL::Ptr< PlusFunction< Real > > plusFunction_
Provides the interface to evaluate objective functions.
Provides the interface to implement any functional that maps a random variable to a (extended) real n...
void sumAll(Real *input, Real *output, int dim) const
Defines the linear algebra or vector space interface.
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.