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: LeastSq
10 //- Description: Abstract base class to logically represent a variety
11 //- of DAKOTA least squares objects in a generic fashion.
12 //- Owner: Mike Eldred
13 //- Version: $Id: DakotaLeastSq.hpp 6972 2010-09-17 22:18:50Z briadam $
14
15 #ifndef DAKOTA_LEAST_SQ_H
16 #define DAKOTA_LEAST_SQ_H
17
18 #include "DakotaMinimizer.hpp"
19
20
21 namespace Dakota {
22
23 /// Base class for the nonlinear least squares branch of the iterator hierarchy.
24
25 /** The LeastSq class provides common data and functionality for
26 least squares solvers (including NL2OL, NLSSOLLeastSq, and SNLLLeastSq. */
27
28 class LeastSq: public Minimizer
29 {
30 public:
31
32 protected:
33
34 //
35 //- Heading: Constructors and destructor
36 //
37
38 /// default constructor
39 LeastSq(std::shared_ptr<TraitsBase> traits);
40 /// standard constructor
41 LeastSq(ProblemDescDB& problem_db, Model& model, std::shared_ptr<TraitsBase> traits);
42 /// alternate "on the fly" constructor
43 LeastSq(unsigned short method_name, Model& model, std::shared_ptr<TraitsBase> traits);
44 /// destructor
45 ~LeastSq();
46
47 //
48 //- Heading: Virtual member function redefinitions
49 //
50
51 void initialize_run();
52 void post_run(std::ostream& s);
53 void finalize_run();
54 void print_results(std::ostream& s, short results_state = FINAL_RESULTS);
55
56 //
57 //- Heading: New virtual member functions
58 //
59
60 /// Calculate confidence intervals on estimated parameters
61 void get_confidence_intervals(const Variables& native_vars,
62 const Response& iter_resp);
63
64 //
65 //- Heading: Data
66 //
67
68 size_t numLeastSqTerms; ///< number of least squares terms
69
70 /// pointer to LeastSq instance used in static member functions
71 static LeastSq* leastSqInstance;
72 /// pointer containing previous value of leastSqInstance
73 LeastSq* prevLSqInstance;
74
75 /// flag indicating whether weighted least squares is active
76 bool weightFlag;
77 /// lower bounds for confidence intervals on calibration parameters
78 RealVector confBoundsLower;
79 /// upper bounds for confidence intervals on calibration parameters
80 RealVector confBoundsUpper;
81
82 /// storage for iterator best primary functions (which shouldn't be
83 /// stored in bestResponseArray when there are transformations)
84 RealVector bestIterPriFns;
85 /// whether final primary iterator space functions have been
86 /// retrieved (possibly by a derived class)
87 bool retrievedIterPriFns;
88
89 private:
90
91 //
92 //- Heading: Convenience/Helper functions
93 //
94
95 /// Wrap iteratedModel in a RecastModel that weights the residuals
96 void weight_model();
97
98 void archive_best_results();
99 /// Write the confidence intervals to the results output
100 // void archive_confidence_intervals();
101
102 //
103 //- Heading: Data
104 //
105 };
106
107
LeastSq(std::shared_ptr<TraitsBase> traits)108 inline LeastSq::LeastSq(std::shared_ptr<TraitsBase> traits) :
109 Minimizer(traits),
110 weightFlag(false)
111 { }
112
113
~LeastSq()114 inline LeastSq::~LeastSq()
115 { }
116
117
finalize_run()118 inline void LeastSq::finalize_run()
119 {
120 // Restore previous object instance in case of recursion.
121 leastSqInstance = prevLSqInstance;
122
123 Minimizer::finalize_run();
124 }
125
126 } // namespace Dakota
127
128 #endif
129