1 /* _______________________________________________________________________
2
3 DAKOTA: Design Analysis Kit for Optimization and Terascale Applications
4 Copyright 2014-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
5 This software is distributed under the GNU Lesser General Public License.
6 For more information, see the README file in the top Dakota directory.
7 _______________________________________________________________________ */
8
9 //- Class: NonDGlobalReliability
10 //- Description: Class for local reliability methods within DAKOTA/UQ
11 //- Owner: Mike Eldred
12 //- Checked by:
13 //- Version:
14
15 #ifndef NOND_GLOBAL_RELIABILITY_H
16 #define NOND_GLOBAL_RELIABILITY_H
17
18 #include "NonDReliability.hpp"
19 #include "ProbabilityTransformation.hpp"
20
21 namespace Dakota {
22
23
24 /// Class for global reliability methods within DAKOTA/UQ
25
26 /** The NonDGlobalReliability class implements EGO/SKO for global MPP
27 search, which maximizes an expected improvement function derived
28 from Gaussian process models. Once the limit state has been
29 characterized, a multimodal importance sampling approach is used
30 to compute probabilities. */
31
32 class NonDGlobalReliability: public NonDReliability
33 {
34 public:
35
36 //
37 //- Heading: Constructors and destructor
38 //
39
40 /// constructor
41 NonDGlobalReliability(ProblemDescDB& problem_db, Model& model);
42 /// destructor
43 ~NonDGlobalReliability();
44
45 //
46 //- Heading: Virtual function redefinitions
47 //
48
49 bool resize();
50 void derived_init_communicators(ParLevLIter pl_iter);
51 void derived_set_communicators(ParLevLIter pl_iter);
52 void derived_free_communicators(ParLevLIter pl_iter);
53
54 void pre_run();
55 void core_run();
56 void print_results(std::ostream& s, short results_state = FINAL_RESULTS);
57
58 private:
59
60 //
61 //- Heading: Convenience functions
62 //
63
64 /// construct the GP using EGO/SKO
65 void optimize_gaussian_process();
66
67 /// perform multimodal adaptive importance sampling on the GP
68 void importance_sampling();
69
70 /// determine current best solution from among sample data for expected
71 /// imporovement function in Performance Measure Approach (PMA)
72 void get_best_sample();
73
74 /// calculate the penalty to be applied to the PMA constraint value
75 Real constraint_penalty(const Real& constraint,
76 const RealVector& c_variables);
77
78 /// expected improvement function for the GP
79 Real expected_improvement(const RealVector& expected_values,
80 const Variables& recast_vars);
81
82 /// expected feasibility function for the GP
83 Real expected_feasibility(const RealVector& expected_values,
84 const Variables& recast_vars);
85
86 /// evaluate iteratedModel at current point to collect x-space truth data
87 void x_truth_evaluation(short mode);
88 /// evaluate iteratedModel at specified point to collect x-space truth data
89 void x_truth_evaluation(const RealVector& c_vars_u, short mode);
90 /// evaluate uSpaceModel in BYPASS_SURROGATE mode to collect u-space
91 /// truth data at specified point
92 void u_truth_evaluation(const RealVector& c_vars_u, short mode);
93 /// evaluate uSpaceModel to collect u-space surrogate data at specified point
94 void u_evaluation(const RealVector& c_vars_u, short mode);
95
96 //
97 //- Heading: Objective/constraint evaluators passed to RecastModel
98 //
99
100 /// static function used as the objective function in the
101 /// Expected Improvement (EIF) problem formulation for PMA
102 static void EIF_objective_eval(const Variables& sub_model_vars,
103 const Variables& recast_vars,
104 const Response& sub_model_response,
105 Response& recast_response);
106
107 /// static function used as the objective function in the
108 /// Expected Feasibility (EFF) problem formulation for RIA
109 static void EFF_objective_eval(const Variables& sub_model_vars,
110 const Variables& recast_vars,
111 const Response& sub_model_response,
112 Response& recast_response);
113
114 //
115 //- Heading: Data members
116 //
117
118 /// pointer to the active object instance used within the static evaluator
119 /// functions in order to avoid the need for static data
120 static NonDGlobalReliability* nondGlobRelInstance;
121
122 /// minimum penalized response from among true function evaluations
123 Real fnStar;
124
125 /// type of merit function used to penalize sample data
126 short meritFunctionType;
127
128 /// Lagrange multiplier for standard Lagrangian merit function
129 Real lagrangeMult;
130
131 /// Lagrange multiplier for augmented Lagrangian merit function
132 Real augLagrangeMult;
133
134 /// penalty parameter for augmented Lagrangian merit funciton
135 Real penaltyParameter;
136
137 /// constraint violation at last iteration, used to determine if the
138 /// current iterate should be accepted (must reduce violation)
139 Real lastConstraintViolation;
140
141 /// flag to determine if last iterate was accepted
142 /// this controls update of parameters for augmented Lagrangian merit fn
143 bool lastIterateAccepted;
144
145 /// order of the data used for surrogate construction, in ActiveSet
146 /// request vector 3-bit format; user may override responses spec
147 short dataOrder;
148
149 };
150
151
x_truth_evaluation(short mode)152 inline void NonDGlobalReliability::x_truth_evaluation(short mode)
153 {
154 uSpaceModel.component_parallel_mode(TRUTH_MODEL_MODE); // Recast forwards
155
156 ActiveSet set = iteratedModel.current_response().active_set();
157 set.request_values(0); set.request_value(mode, respFnCount);
158 iteratedModel.evaluate(set);
159
160 // Not currently necessary as surrogate mode does not employ parallelism:
161 //uSpaceModel.component_parallel_mode(SURROGATE_MODEL_MODE); // restore
162 }
163
164
165 inline void NonDGlobalReliability::
x_truth_evaluation(const RealVector & c_vars_u,short mode)166 x_truth_evaluation(const RealVector& c_vars_u, short mode)
167 {
168 RealVector c_vars_x;
169 uSpaceModel.probability_transformation().trans_U_to_X(c_vars_u, c_vars_x);
170 iteratedModel.continuous_variables(c_vars_x);
171
172 x_truth_evaluation(mode);
173 }
174
175
176 inline void NonDGlobalReliability::
u_truth_evaluation(const RealVector & c_vars_u,short mode)177 u_truth_evaluation(const RealVector& c_vars_u, short mode)
178 {
179 uSpaceModel.component_parallel_mode(TRUTH_MODEL_MODE); // Recast forwards
180 uSpaceModel.surrogate_response_mode(BYPASS_SURROGATE); // Recast forwards
181
182 uSpaceModel.continuous_variables(c_vars_u);
183 ActiveSet set = uSpaceModel.current_response().active_set();
184 set.request_values(0); set.request_value(mode, respFnCount);
185 uSpaceModel.evaluate(set);
186
187 uSpaceModel.surrogate_response_mode(UNCORRECTED_SURROGATE); // restore
188 // Not currently necessary as surrogate mode does not employ parallelism:
189 //uSpaceModel.component_parallel_mode(SURROGATE_MODEL_MODE); // restore
190 }
191
192
193 inline void NonDGlobalReliability::
u_evaluation(const RealVector & c_vars_u,short mode)194 u_evaluation(const RealVector& c_vars_u, short mode)
195 {
196 uSpaceModel.continuous_variables(c_vars_u);
197 ActiveSet set = uSpaceModel.current_response().active_set();
198 set.request_values(0); set.request_value(mode, respFnCount);
199 uSpaceModel.evaluate(set);
200 }
201
202 } // namespace Dakota
203
204 #endif
205