44 #ifndef ROL_FDIVERGENCE_HPP 45 #define ROL_FDIVERGENCE_HPP 109 TEUCHOS_TEST_FOR_EXCEPTION((thresh_ <= zero), std::invalid_argument,
110 ">>> ERROR (ROL::FDivergence): Threshold must be positive!");
119 xlam_(0), xmu_(0), vlam_(0), vmu_(0), valLam_(0), valMu_(0),
133 xlam_(0), xmu_(0), vlam_(0), vmu_(0), valLam_(0), valMu_(0),
135 Teuchos::ParameterList &list
136 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"F-Divergence");
137 thresh_ = list.get<Real>(
"Threshold");
148 virtual Real
Fprimal(Real x,
int deriv = 0) = 0;
162 virtual Real
Fdual(Real x,
int deriv = 0) = 0;
167 xmu_ = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getStatistic(1);
169 dualVector_ = (x0->dual()).clone();
173 valLam_ = 0; valLam2_ = 0; valMu_ = 0; valMu2_ = 0;
182 vmu_ = Teuchos::dyn_cast<
const RiskVector<Real> >(v).getStatistic(1);
186 void update(
const Real val,
const Real weight) {
187 Real r =
Fdual((val-xmu_)/xlam_,0);
193 sampler.
sumAll(&val,&gval,1);
194 return xlam_*(thresh_ + gval) + xmu_;
199 Real x = (val-
xmu_)/xlam_;
203 valLam_ -= weight * r1 * x;
204 valMu_ -= weight * r1;
212 std::vector<Real> mygval(3), gval(3);
216 sampler.
sumAll(&mygval[0],&gval[0],3);
218 std::vector<Real> stat(2);
219 stat[0] = thresh_ + gval[0] + gval[1];
220 stat[1] = (Real)1 + gval[2];
229 Real x = (val-
xmu_)/xlam_;
232 valLam_ += weight * r2 * x * x;
233 valLam2_ -= weight * r2 * gv * x;
234 valMu_ += weight * r2;
235 valMu2_ -= weight * r2 * gv;
243 std::vector<Real> myhval(5), hval(5);
249 sampler.
sumAll(&myhval[0],&hval[0],5);
251 std::vector<Real> stat(2);
252 stat[0] = (vlam_ * hval[1] + vmu_ * hval[0] + hval[2])/xlam_;
253 stat[1] = (vlam_ * hval[0] + vmu_ * hval[3] + hval[4])/xlam_;
void checkInputs(void) const
Contains definitions of custom data types in ROL.
void sumAll(Real *input, Real *output, int dim) const
void update(const Real val, const Vector< Real > &g, const Real weight)
Update internal risk measure storage for gradient computation.
void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x)
Reset internal risk measure storage. Called for value and gradient computation.
Defines the linear algebra or vector space interface.
void getHessVec(Vector< Real > &hv, SampleGenerator< Real > &sampler)
Return risk measure Hessian-times-a-vector.
void update(const Real val, const Real weight)
Update internal risk measure storage for value computation.
void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x, Teuchos::RCP< Vector< Real > > &v0, const Vector< Real > &v)
Reset internal risk measure storage. Called for Hessian-times-a-vector computation.
void setVector(const Vector< Real > &vec)
void update(const Real val, const Vector< Real > &g, const Real gv, const Vector< Real > &hv, const Real weight)
Update internal risk measure storage for Hessian-time-a-vector computation.
Teuchos::RCP< Vector< Real > > dualVector_
void setStatistic(const Real stat)
FDivergence(Teuchos::ParameterList &parlist)
Constructor.
virtual Real Fdual(Real x, int deriv=0)=0
Implementation of the scalar dual F function.
FDivergence(const Real thresh)
Constructor.
virtual Real Fprimal(Real x, int deriv=0)=0
Implementation of the scalar primal F function.
Real getValue(SampleGenerator< Real > &sampler)
Return risk measure value.
Provides a general interface for the F-divergence distributionally robust expectation.
virtual void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x)
Reset internal risk measure storage. Called for value and gradient computation.
void getGradient(Vector< Real > &g, SampleGenerator< Real > &sampler)
Return risk measure (sub)gradient.
Provides the interface to implement risk measures.