ROL
ROL_StochasticProblem.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_STOCHASTICPROBLEM_HPP
11 #define ROL_STOCHASTICPROBLEM_HPP
12 
13 #include "ROL_Problem.hpp"
14 
18 
24 
25 #include "ROL_RiskVector.hpp"
29 
30 namespace ROL {
31 
32 template<typename Real>
33 class StochasticProblem : public Problem<Real> {
34 private:
35  Ptr<Objective<Real>> ORIGINAL_obj_;
36  Ptr<Vector<Real>> ORIGINAL_xprim_;
37  Ptr<Vector<Real>> ORIGINAL_xdual_;
38  Ptr<BoundConstraint<Real>> ORIGINAL_bnd_;
39  std::unordered_map<std::string,ConstraintData<Real>> ORIGINAL_con_;
40  std::unordered_map<std::string,ConstraintData<Real>> ORIGINAL_linear_con_;
41 
43  std::vector<bool> needRiskLessCon_;
44  Ptr<ParameterList> objList_;
45  std::unordered_map<std::string,std::pair<Ptr<ParameterList>,bool>> conList_;
46  std::unordered_map<std::string,size_t> statMap_;
47 
55 
56 public:
63  StochasticProblem(const Ptr<Objective<Real>> &obj,
64  const Ptr<Vector<Real>> &x,
65  const Ptr<Vector<Real>> &g = nullPtr);
66 
67  StochasticProblem(const Problem<Real> &problem) : Problem<Real>(problem) {}
68 
69  /***************************************************************************/
70  /*** Set and remove methods for constraints ********************************/
71  /***************************************************************************/
72 
73  void makeObjectiveStochastic(ParameterList &list,
74  const Ptr<SampleGenerator<Real>> &fsampler,
75  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
76  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr);
78  ParameterList &list,
79  const Ptr<SampleGenerator<Real>> &fsampler,
80  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
81  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr);
82  void makeConstraintStochastic(std::string name,
83  ParameterList &list,
84  const Ptr<SampleGenerator<Real>> &sampler,
85  const Ptr<BatchManager<Real>> &bman = nullPtr);
86  void makeLinearConstraintStochastic(std::string name,
87  ParameterList &list,
88  const Ptr<SampleGenerator<Real>> &sampler,
89  const Ptr<BatchManager<Real>> &bman = nullPtr);
90  void resetStochasticObjective(void);
91  void resetStochasticConstraint(std::string name);
92  void resetStochasticLinearConstraint(std::string name);
93  void resetStochastic(void);
94 
95  std::vector<Real> getObjectiveStatistic(void) const;
96  std::vector<Real> getConstraintStatistic(std::string name) const;
97  Real getSolutionStatistic(int comp = 0, std::string name = "") const;
98 
99  /***************************************************************************/
100  /*** Finalize and edit methods *********************************************/
101  /***************************************************************************/
102 
103  void finalize(bool lumpConstraints = false, bool printToStream = false,
104  std::ostream &outStream = std::cout) override;
105 
106  void edit(void) override;
107 
108 }; // class StochasticProblem
109 
110 } // namespace ROL
111 
113 
114 #endif // ROL_STOCHASTICPROBLEM_HPP
Provides the interface to evaluate objective functions.
void makeConstraintStochastic(std::string name, ParameterList &list, const Ptr< SampleGenerator< Real >> &sampler, const Ptr< BatchManager< Real >> &bman=nullPtr)
void resetStochasticLinearConstraint(std::string name)
std::unordered_map< std::string, size_t > statMap_
Ptr< Vector< Real > > ORIGINAL_xdual_
std::vector< Real > getConstraintStatistic(std::string name) const
Ptr< Objective< Real > > ORIGINAL_obj_
std::unordered_map< std::string, ConstraintData< Real > > ORIGINAL_linear_con_
StochasticProblem(const Ptr< Objective< Real >> &obj, const Ptr< Vector< Real >> &x, const Ptr< Vector< Real >> &g=nullPtr)
Default constructor for StochasticProblem.
Real getSolutionStatistic(int comp=0, std::string name="") const
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
std::vector< bool > needRiskLessCon_
std::unordered_map< std::string, std::pair< Ptr< ParameterList >, bool > > conList_
std::unordered_map< std::string, ConstraintData< Real > > ORIGINAL_con_
Ptr< BoundConstraint< Real > > ORIGINAL_bnd_
std::vector< Real > getObjectiveStatistic(void) const
StochasticProblem(const Problem< Real > &problem)
Ptr< ParameterList > objList_
void resetStochasticConstraint(std::string name)
Provides the interface to implement any functional that maps a random variable to a (extended) real n...
void edit(void) override
Resume editting optimization problem after finalize has been called.
void makeObjectiveStochastic(ParameterList &list, const Ptr< SampleGenerator< Real >> &fsampler, const Ptr< SampleGenerator< Real >> &gsampler=nullPtr, const Ptr< SampleGenerator< Real >> &hsampler=nullPtr)
void makeLinearConstraintStochastic(std::string name, ParameterList &list, const Ptr< SampleGenerator< Real >> &sampler, const Ptr< BatchManager< Real >> &bman=nullPtr)
void finalize(bool lumpConstraints=false, bool printToStream=false, std::ostream &outStream=std::cout) override
Tranform user-supplied constraints to consist of only bounds and equalities. Optimization problem can...
Ptr< Vector< Real > > ORIGINAL_xprim_