44 #ifndef ROL_STOCHASTICPROBLEM_HPP 45 #define ROL_STOCHASTICPROBLEM_HPP 61 #include "Teuchos_ParameterList.hpp" 74 Teuchos::RCP<Objective<Real> >
obj_;
75 Teuchos::RCP<Vector<Real> >
vec_;
76 Teuchos::RCP<BoundConstraint<Real> >
bnd_;
89 obj_(Teuchos::null),
vec_(Teuchos::null),
bnd_(Teuchos::null),
96 obj_(Teuchos::null),
vec_(Teuchos::null),
bnd_(Teuchos::null),
99 parlist_ = Teuchos::rcpFromRef(parlist);
108 obj_(Teuchos::null),
vec_(Teuchos::null),
bnd_(Teuchos::null),
111 parlist_ = Teuchos::rcpFromRef(parlist);
124 obj_(Teuchos::null),
vec_(Teuchos::null),
bnd_(Teuchos::null),
127 parlist_ = Teuchos::rcpFromRef(parlist);
141 obj_(Teuchos::null),
vec_(Teuchos::null),
bnd_(Teuchos::null),
144 parlist_ = Teuchos::rcpFromRef(parlist);
157 obj_(Teuchos::null),
vec_(Teuchos::null),
bnd_(Teuchos::null),
160 parlist_ = Teuchos::rcpFromRef(parlist);
174 obj_(Teuchos::null),
vec_(Teuchos::null),
bnd_(Teuchos::null),
177 parlist_ = Teuchos::rcpFromRef(parlist);
192 obj_(Teuchos::null),
vec_(Teuchos::null),
bnd_(Teuchos::null),
195 parlist_ = Teuchos::rcpFromRef(parlist);
202 parlist_ = Teuchos::rcpFromRef(parlist);
237 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
238 ">>> ERROR (ROL::StochasticProblem): parameter list not set!");
243 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
244 ">>> ERROR (ROL::StochasticProblem): value sampler not set!");
248 std::string type =
parlist_->sublist(
"SOL").get(
"Stochastic Optimization Type",
"Risk Neutral");
249 if ( type ==
"Risk Neutral" ) {
250 bool storage =
parlist_->sublist(
"SOL").get(
"Store Sampled Value and Gradient",
true);
253 else if ( type ==
"Risk Averse" ) {
256 else if ( type ==
"BPOE" ) {
257 Real order =
parlist_->sublist(
"SOL").sublist(
"BPOE").get(
"Moment Order",1.);
258 Real threshold =
parlist_->sublist(
"SOL").sublist(
"BPOE").get(
"Threshold",0.);
261 else if ( type ==
"Mean Value" ) {
263 obj->setParameter(mean);
267 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
268 "Invalid stochastic optimization type" << type);
278 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
279 ">>> ERROR (ROL::StochasticProblem): parameter list not set!");
284 std::string type =
parlist_->sublist(
"SOL").get(
"Stochastic Optimization Type",
"Risk Neutral");
285 if ( type ==
"Risk Neutral" || type ==
"Mean Value" ) {
288 else if ( type ==
"Risk Averse" ) {
291 else if ( type ==
"BPOE" ) {
292 std::vector<Real> stat(1,1);
296 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
297 "Invalid stochastic optimization type" << type);
307 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
308 ">>> ERROR (ROL::StochasticProblem): parameter list not set!");
313 std::string type =
parlist_->sublist(
"SOL").get(
"Stochastic Optimization Type",
"Risk Neutral");
314 if ( type ==
"Risk Averse" || type ==
"BPOE" ) {
326 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
327 ">>> ERROR (ROL::StochasticProblem): parameter list not set!");
332 std::string type =
parlist_->sublist(
"SOL").get(
"Stochastic Optimization Type",
"Risk Neutral");
333 if ( type ==
"Risk Neutral" || type ==
"Mean Value" ) {
336 else if ( type ==
"Risk Averse" || type ==
"BPOE" ) {
340 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
341 "Invalid stochastic optimization type" << type);
360 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
361 ">>> ERROR (ROL::StochasticProblem): parameter list not set!");
367 std::string type =
parlist_->sublist(
"SOL").get(
"Stochastic Optimization Type",
"Risk Neutral");
369 if ( type ==
"Risk Averse" ) {
370 Teuchos::ParameterList &list
371 =
parlist_->sublist(
"SOL").sublist(
"Risk Measure");
372 std::string risk = list.get(
"Name",
"CVaR");
373 if ( risk ==
"Mixed-Quantile Quadrangle" ) {
374 Teuchos::ParameterList &MQQlist = list.sublist(
"Mixed-Quantile Quadrangle");
375 Teuchos::Array<Real> coeff
376 = Teuchos::getArrayFromStringParameter<Real>(MQQlist,
"Coefficient Array");
377 for (
int i = 0; i < coeff.size(); i++) {
381 else if ( risk ==
"Super Quantile Quadrangle" ) {
385 else if ( risk ==
"Chebyshev-Kusuoka" ) {
389 else if ( risk ==
"Spectral Risk" ) {
393 else if ( risk ==
"Quantile-Radius Quadrangle" ) {
406 catch (std::exception &e) {
413 const bool printToStream =
true,
414 std::ostream & outStream = std::cout,
416 const int order = 1 ) {
417 Teuchos::RCP<Vector<Real> > dp = d.
clone();
419 Real stat(5.1264386);
425 const bool printToStream =
true,
426 std::ostream & outStream = std::cout,
428 const int order = 1 ) {
429 Teuchos::RCP<Vector<Real> > vp = v.
clone();
431 Real stat(3.223468906);
439 int dim = sampler->getMyPoint(0).size(), nsamp = sampler->numMySamples();
440 std::vector<Real> loc(dim), mean(dim), pt(dim);
442 for (
int i = 0; i < nsamp; i++) {
443 pt = sampler->getMyPoint(i);
444 wt = sampler->getMyWeight(i);
445 for (
int j = 0; j < dim; j++) {
449 sampler->sumAll(&loc[0],&mean[0],dim);
455 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
456 ">>> ERROR (ROL::StochasticProblem): parameter list not set!");
460 std::string type =
parlist_->sublist(
"SOL").get(
"Stochastic Optimization Type",
"Risk Neutral");
461 if ( type ==
"Risk Neutral" || type ==
"Mean Value" ) {
464 else if ( type ==
"Risk Averse" ) {
467 else if ( type ==
"BPOE" ) {
468 std::vector<Real> statistic(1,stat);
472 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
473 "Invalid stochastic optimization type" << type);
Provides the interface to evaluate objective functions.
StochasticProblem(Teuchos::ParameterList &parlist, const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< SampleGenerator< Real > > &vsampler, const Teuchos::RCP< SampleGenerator< Real > > &gsampler, const Teuchos::RCP< SampleGenerator< Real > > &hsampler, const Teuchos::RCP< Vector< Real > > &vec)
virtual std::vector< std::vector< Real > > checkObjectiveGradient(const Vector< Real > &d, const bool printToStream=true, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
std::vector< Real > computeSampleMean(Teuchos::RCP< SampleGenerator< Real > > &sampler)
void setGradientSampleGenerator(const Teuchos::RCP< SampleGenerator< Real > > &gsampler)
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Real computeStatistic(const Vector< Real > &x) const
StochasticProblem(Teuchos::ParameterList &parlist, const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< SampleGenerator< Real > > &vsampler, const Teuchos::RCP< SampleGenerator< Real > > &gsampler, const Teuchos::RCP< SampleGenerator< Real > > &hsampler, const Teuchos::RCP< Vector< Real > > &vec, const Teuchos::RCP< BoundConstraint< Real > > &bnd)
Teuchos::RCP< BoundConstraint< Real > > bnd_
Defines the linear algebra or vector space interface.
void setHessVecSampleGenerator(const Teuchos::RCP< SampleGenerator< Real > > &hsampler)
StochasticProblem(Teuchos::ParameterList &parlist, const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< SampleGenerator< Real > > &sampler, const Teuchos::RCP< Vector< Real > > &vec)
Teuchos::RCP< SampleGenerator< Real > > vsampler_
StochasticProblem(Teuchos::ParameterList &parlist, const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< SampleGenerator< Real > > &sampler, const Teuchos::RCP< Vector< Real > > &vec, const Teuchos::RCP< BoundConstraint< Real > > &bnd)
void setObjective(const Teuchos::RCP< Objective< Real > > &obj)
Teuchos::RCP< BoundConstraint< Real > > ORIGINAL_bnd_
void setObjective(const Teuchos::RCP< Objective< Real > > &obj)
std::vector< std::vector< Real > > checkObjectiveGradient(const Vector< Real > &d, const bool printToStream=true, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
void setSolutionVector(const Teuchos::RCP< Vector< Real > > &sol)
void setStatistic(const Real stat)
Teuchos::RCP< Vector< Real > > ORIGINAL_vec_
void setParameterList(Teuchos::ParameterList &parlist)
Provides an interface for the risk measure associated with the super quantile quadrangle.
Provides an interface for spectral risk measures.
std::vector< std::vector< Real > > checkObjectiveHessVec(const Vector< Real > &v, const bool printToStream=true, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
StochasticProblem(Teuchos::ParameterList &parlist, const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< SampleGenerator< Real > > &vsampler, const Teuchos::RCP< SampleGenerator< Real > > &gsampler, const Teuchos::RCP< Vector< Real > > &vec, const Teuchos::RCP< BoundConstraint< Real > > &bnd)
Provides the interface to apply upper and lower bound constraints.
Teuchos::RCP< SampleGenerator< Real > > gsampler_
Teuchos::RCP< Vector< Real > > vec_
#define ROL_NUM_CHECKDERIV_STEPS
Number of steps for derivative checks.
Teuchos::RCP< Objective< Real > > ORIGINAL_obj_
Teuchos::RCP< Teuchos::ParameterList > parlist_
Teuchos::RCP< const StdVector< Real > > getStatistic(void) const
void setSolutionStatistic(const Real stat)
Teuchos::RCP< Vector< Real > > createVector(Teuchos::RCP< Vector< Real > > &vec, Real stat=1)
void setValueSampleGenerator(const Teuchos::RCP< SampleGenerator< Real > > &vsampler)
void setBoundConstraint(const Teuchos::RCP< BoundConstraint< Real > > &bnd)
void setBoundConstraint(const Teuchos::RCP< BoundConstraint< Real > > &bnd)
StochasticProblem(Teuchos::ParameterList &parlist)
void setSolutionVector(const Teuchos::RCP< Vector< Real > > &vec)
virtual std::vector< std::vector< Real > > checkObjectiveHessVec(const Vector< Real > &v, const bool printToStream=true, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
Real getSolutionStatistic(void)
Teuchos::RCP< Objective< Real > > obj_
StochasticProblem(Teuchos::ParameterList &parlist, const Teuchos::RCP< Objective< Real > > &obj, const Teuchos::RCP< SampleGenerator< Real > > &vsampler, const Teuchos::RCP< SampleGenerator< Real > > &gsampler, const Teuchos::RCP< Vector< Real > > &vec)
Provides an interface for the Chebyshev-Kusuoka risk measure.
Teuchos::RCP< SampleGenerator< Real > > hsampler_