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: NonLHSDEvidence
10 //- Description: Implementation code for NonDEvidence class
11 //- Owner: Laura Swiler
12 //- Checked by:
13 //- Version:
14
15 #include "NonDLHSEvidence.hpp"
16 #include "dakota_data_types.hpp"
17 #include "dakota_system_defs.hpp"
18
19 //#define DEBUG
20
21 namespace Dakota {
22
23
NonDLHSEvidence(ProblemDescDB & problem_db,Model & model)24 NonDLHSEvidence::NonDLHSEvidence(ProblemDescDB& problem_db, Model& model):
25 NonDLHSInterval(problem_db, model)
26 { }
27
28
~NonDLHSEvidence()29 NonDLHSEvidence::~NonDLHSEvidence()
30 { }
31
32
initialize()33 void NonDLHSEvidence::initialize()
34 { calculate_cells_and_bpas(); }
35
36
post_process_samples()37 void NonDLHSEvidence::post_process_samples()
38 {
39 // Construct a surrogate based on a set of LHS samples, and evaluate that
40 // sample a large number of times (default: 1 million) to sufficiently
41 // populate the belief intervals
42 // Use the sample set generated above to determine the maximum and minimum
43 // of each function within each input interval combination
44
45 const RealMatrix& all_samples = lhsSampler.all_samples();
46 const IntResponseMap& all_responses = lhsSampler.all_responses();
47
48 for (respFnCntr=0; respFnCntr<numFunctions; ++respFnCntr) {
49 // Use the max and mins to determine the cumulative distributions
50 // of plausibility and belief
51 RealVector& cell_fn_l_bnds = cellFnLowerBounds[respFnCntr];
52 RealVector& cell_fn_u_bnds = cellFnUpperBounds[respFnCntr];
53 for (size_t i=0; i <numCells; i++) {
54 cell_fn_l_bnds[i] = DBL_MAX;
55 cell_fn_u_bnds[i] = -DBL_MAX;
56 }
57 Cout << ">>>>> Identifying minimum and maximum samples for response "
58 << "function " << respFnCntr+1 << " within cells 1 through "
59 << numCells << '\n';
60 size_t i, j; IntRespMCIter it;
61 for (i=0, it=all_responses.begin(); i<numSamples; i++, ++it) {
62
63 const Real& fn_val = it->second.function_value(respFnCntr);
64 Variables vars = iteratedModel.current_variables().copy();
65 sample_to_variables(all_samples[i], vars);
66
67 const RealVector& c_vars = vars.continuous_variables();
68 const IntVector& di_vars = vars.discrete_int_variables();
69 const RealVector& dr_vars = vars.discrete_real_variables();
70
71 for (cellCntr=0; cellCntr<numCells; ++cellCntr) {
72 bool in_bounds = true;
73 for (j=0; j<numContIntervalVars; ++j)
74 if (c_vars[j] < cellContLowerBounds[cellCntr][j] ||
75 c_vars[j] > cellContUpperBounds[cellCntr][j])
76 { in_bounds = false; break; }
77 if (in_bounds)
78 for (j=0; j<numDiscIntervalVars; ++j)
79 if (di_vars[j] < cellIntRangeLowerBounds[cellCntr][j] ||
80 di_vars[j] > cellIntRangeUpperBounds[cellCntr][j]) // TO DO
81 { in_bounds = false; break; }
82 if (in_bounds)
83 for (j=0; j<numDiscSetIntUncVars; ++j)
84 if (di_vars[j+numDiscIntervalVars] != cellIntSetBounds[cellCntr][j]) // TO DO
85 { in_bounds = false; break; }
86 if (in_bounds)
87 for (j=0; j<numDiscSetRealUncVars; ++j)
88 if (dr_vars[j] != cellRealSetBounds[cellCntr][j]) // TO DO
89 { in_bounds = false; break; }
90
91 if (in_bounds) {
92 if (fn_val < cell_fn_l_bnds[cellCntr])
93 cell_fn_l_bnds[cellCntr] = fn_val;
94 if (fn_val > cell_fn_u_bnds[cellCntr])
95 cell_fn_u_bnds[cellCntr] = fn_val;
96 }
97 }
98 }
99 #ifdef DEBUG
100 for (i=0; i<numCells; i++) {
101 Cout << "CMAX " <<i<< " is " << cell_fn_u_bnds[i] << '\n' ;
102 Cout << "CMIN " <<i<< " is " << cell_fn_l_bnds[i] << '\n' ;
103 }
104 #endif //DEBUG
105
106 // replace with fortran free function to calculate CBF, CPF
107 calculate_cbf_cpf();
108 }
109
110 compute_evidence_statistics();
111 }
112
113 } // namespace Dakota
114