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<Objective<Real>> ORIGINAL_nobj_;
37  Ptr<Vector<Real>> ORIGINAL_xprim_;
38  Ptr<Vector<Real>> ORIGINAL_xdual_;
39  Ptr<BoundConstraint<Real>> ORIGINAL_bnd_;
40  std::unordered_map<std::string,ConstraintData<Real>> ORIGINAL_con_;
41  std::unordered_map<std::string,ConstraintData<Real>> ORIGINAL_linear_con_;
42 
44  std::vector<bool> needRiskLessCon_;
45  Ptr<ParameterList> objList_;
46  std::unordered_map<std::string,std::pair<Ptr<ParameterList>,bool>> conList_;
47  std::unordered_map<std::string,size_t> statMap_;
48 
57 
58 public:
65  StochasticProblem(const Ptr<Objective<Real>> &obj,
66  const Ptr<Vector<Real>> &x,
67  const Ptr<Vector<Real>> &g = nullPtr);
68 
69  StochasticProblem(const Problem<Real> &problem) : Problem<Real>(problem) {}
70 
71  /***************************************************************************/
72  /*** Set and remove methods for constraints ********************************/
73  /***************************************************************************/
74 
75  void makeObjectiveStochastic(ParameterList &list,
76  const Ptr<SampleGenerator<Real>> &fsampler,
77  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
78  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr);
80  ParameterList &list,
81  const Ptr<SampleGenerator<Real>> &fsampler,
82  const Ptr<SampleGenerator<Real>> &gsampler = nullPtr,
83  const Ptr<SampleGenerator<Real>> &hsampler = nullPtr);
84  void makeConstraintStochastic(std::string name,
85  ParameterList &list,
86  const Ptr<SampleGenerator<Real>> &sampler,
87  const Ptr<BatchManager<Real>> &bman = nullPtr);
88  void makeLinearConstraintStochastic(std::string name,
89  ParameterList &list,
90  const Ptr<SampleGenerator<Real>> &sampler,
91  const Ptr<BatchManager<Real>> &bman = nullPtr);
92  void resetStochasticObjective(void);
93  void resetStochasticConstraint(std::string name);
94  void resetStochasticLinearConstraint(std::string name);
95  void resetStochastic(void);
96 
97  std::vector<Real> getObjectiveStatistic(void) const;
98  std::vector<Real> getConstraintStatistic(std::string name) const;
99  Real getSolutionStatistic(int comp = 0, std::string name = "") const;
100 
101  /***************************************************************************/
102  /*** Finalize and edit methods *********************************************/
103  /***************************************************************************/
104 
105  void finalize(bool lumpConstraints = false, bool printToStream = false,
106  std::ostream &outStream = std::cout) override;
107 
108  void edit(void) override;
109 
110 }; // class StochasticProblem
111 
112 } // namespace ROL
113 
115 
116 #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)
Ptr< Objective< Real > > ORIGINAL_nobj_
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_