10 #ifndef ROL_TRUNCATEDMEANQUAD_HPP
11 #define ROL_TRUNCATEDMEANQUAD_HPP
24 std::string type = parlist.sublist(
"SOL").get(
"Type",
"Risk Averse");
25 ROL::ParameterList list;
26 if (type ==
"Risk Averse") {
27 list = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Truncated Mean");
29 else if (type ==
"Error") {
30 list = parlist.sublist(
"SOL").sublist(
"Error Measure").sublist(
"Huber");
32 else if (type ==
"Deviation") {
33 list = parlist.sublist(
"SOL").sublist(
"Deviation Measure").sublist(
"Truncated Mean");
35 else if (type ==
"Regret") {
36 list = parlist.sublist(
"SOL").sublist(
"Regret Measure").sublist(
"Truncated Mean");
38 beta_ = list.get<Real>(
"Threshold");
43 ROL_TEST_FOR_EXCEPTION((
beta_ <= zero), std::invalid_argument,
44 ">>> ERROR (ROL::TruncatedMeanQuadrangle): Threshold must be positive!");
60 Real
error(Real x,
int deriv = 0) {
61 bool inside = ( std::abs(x) <
beta_ ?
true : false );
62 Real err(0),
zero(0), half(0.5), one(1), two(2);
64 err = (inside ? half*std::pow(x,two)/
beta_ : std::abs(x)-half*
beta_);
77 Real X = ((deriv==0) ? x : ((deriv==1) ? one :
zero));
78 Real reg =
error(x,deriv) + X;
85 Real x =
beta_,
zero(0), one(1), two(2), p1(0.1);
91 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(beta) is correct? \n";
92 std::cout << std::right << std::setw(20) <<
"t"
93 << std::setw(20) <<
"v'(x)"
94 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
95 << std::setw(20) <<
"Error"
97 for (
int i = 0; i < 13; i++) {
100 diff = (vy-vx)/(two*t);
101 err = std::abs(diff-dv);
102 std::cout << std::scientific << std::setprecision(11) << std::right
103 << std::setw(20) << t
104 << std::setw(20) << dv
105 << std::setw(20) << diff
106 << std::setw(20) << err
119 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(-beta) is correct? \n";
120 std::cout << std::right << std::setw(20) <<
"t"
121 << std::setw(20) <<
"v'(x)"
122 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
123 << std::setw(20) <<
"Error"
125 for (
int i = 0; i < 13; i++) {
128 diff = (vy-vx)/(two*t);
129 err = std::abs(diff-dv);
130 std::cout << std::scientific << std::setprecision(11) << std::right
131 << std::setw(20) << t
132 << std::setw(20) << dv
133 << std::setw(20) << diff
134 << std::setw(20) << err
Provides a general interface for risk and error measures generated through the expectation risk quadr...
void checkInputs(void) const
TruncatedMeanQuadrangle(Real beta)
virtual void check(void)
Run default derivative tests for the scalar regret function.
Real error(Real x, int deriv=0)
Evaluate the scalar error function at x.
void check(void)
Run default derivative tests for the scalar regret function.
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
TruncatedMeanQuadrangle(ROL::ParameterList &parlist)
Real regret(Real x, int deriv=0)
Evaluate the scalar regret function at x.
void parseParameterList(ROL::ParameterList &parlist)