44 #ifndef ROL_TRUNCATEDMEANQUAD_HPP
45 #define ROL_TRUNCATEDMEANQUAD_HPP
58 std::string type = parlist.sublist(
"SOL").get(
"Stochastic Component Type",
"Risk Averse");
59 ROL::ParameterList list;
60 if (type ==
"Risk Averse") {
61 list = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Truncated Mean");
63 else if (type ==
"Error") {
64 list = parlist.sublist(
"SOL").sublist(
"Error Measure").sublist(
"Huber");
66 else if (type ==
"Deviation") {
67 list = parlist.sublist(
"SOL").sublist(
"Deviation Measure").sublist(
"Truncated Mean");
69 else if (type ==
"Regret") {
70 list = parlist.sublist(
"SOL").sublist(
"Regret Measure").sublist(
"Truncated Mean");
72 beta_ = list.get<Real>(
"Threshold");
77 ROL_TEST_FOR_EXCEPTION((
beta_ <= zero), std::invalid_argument,
78 ">>> ERROR (ROL::TruncatedMeanQuadrangle): Threshold must be positive!");
94 Real
error(Real x,
int deriv = 0) {
95 bool inside = ( std::abs(x) <
beta_ ?
true : false );
96 Real err(0),
zero(0), half(0.5), one(1), two(2);
98 err = (inside ? half*std::pow(x,two)/
beta_ : std::abs(x)-half*
beta_);
110 Real
zero(0), one(1);
111 Real X = ((deriv==0) ? x : ((deriv==1) ? one :
zero));
112 Real reg =
error(x,deriv) + X;
119 Real x =
beta_,
zero(0), one(1), two(2), p1(0.1);
125 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(beta) is correct? \n";
126 std::cout << std::right << std::setw(20) <<
"t"
127 << std::setw(20) <<
"v'(x)"
128 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
129 << std::setw(20) <<
"Error"
131 for (
int i = 0; i < 13; i++) {
134 diff = (vy-vx)/(two*t);
135 err = std::abs(diff-dv);
136 std::cout << std::scientific << std::setprecision(11) << std::right
137 << std::setw(20) << t
138 << std::setw(20) << dv
139 << std::setw(20) << diff
140 << std::setw(20) << err
153 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(-beta) is correct? \n";
154 std::cout << std::right << std::setw(20) <<
"t"
155 << std::setw(20) <<
"v'(x)"
156 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
157 << std::setw(20) <<
"Error"
159 for (
int i = 0; i < 13; i++) {
162 diff = (vy-vx)/(two*t);
163 err = std::abs(diff-dv);
164 std::cout << std::scientific << std::setprecision(11) << std::right
165 << std::setw(20) << t
166 << std::setw(20) << dv
167 << std::setw(20) << diff
168 << 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)