$extrastylesheet
Dakota
Version 6.2
|
Base class for the approximation class hierarchy. More...
Public Member Functions | |
Approximation () | |
default constructor | |
Approximation (ProblemDescDB &problem_db, const SharedApproxData &shared_data) | |
standard constructor for envelope | |
Approximation (const SharedApproxData &shared_data) | |
alternate constructor | |
Approximation (const Approximation &approx) | |
copy constructor | |
virtual | ~Approximation () |
destructor | |
Approximation | operator= (const Approximation &approx) |
assignment operator | |
virtual void | build () |
builds the approximation from scratch | |
virtual void | rebuild () |
rebuilds the approximation incrementally | |
virtual void | pop (bool save_data) |
removes entries from end of SurrogateData::{vars,resp}Data (last points appended, or as specified in args) | |
virtual void | restore () |
restores state prior to previous append() | |
virtual void | finalize () |
finalize approximation by applying all remaining trial sets | |
virtual void | store () |
store current approximation for later combination | |
virtual void | combine (short corr_type) |
combine current approximation with previously stored approximation | |
virtual Real | value (const Variables &vars) |
retrieve the approximate function value for a given parameter vector | |
virtual const RealVector & | gradient (const Variables &vars) |
retrieve the approximate function gradient for a given parameter vector | |
virtual const RealSymMatrix & | hessian (const Variables &vars) |
retrieve the approximate function Hessian for a given parameter vector | |
virtual Real | prediction_variance (const Variables &vars) |
retrieve the variance of the predicted value for a given parameter vector | |
virtual Real | value (const RealVector &c_vars) |
retrieve the approximate function value for a given parameter vector | |
virtual const RealVector & | gradient (const RealVector &c_vars) |
retrieve the approximate function gradient for a given parameter vector | |
virtual const RealSymMatrix & | hessian (const RealVector &c_vars) |
retrieve the approximate function Hessian for a given parameter vector | |
virtual Real | prediction_variance (const RealVector &c_vars) |
retrieve the variance of the predicted value for a given parameter vector | |
virtual bool | diagnostics_available () |
check if diagnostics are available for this approximation type | |
virtual Real | diagnostic (const String &metric_type) |
retrieve a single diagnostic metric for the diagnostic type specified | |
virtual void | primary_diagnostics (int fn_index) |
compute and print all requested diagnostics and cross-validation | |
virtual void | challenge_diagnostics (const RealMatrix &challenge_points, int fn_index) |
compute and print all requested diagnostics for user provided challenge pts | |
virtual RealVector | approximation_coefficients (bool normalized) const |
return the coefficient array computed by build()/rebuild() | |
virtual void | approximation_coefficients (const RealVector &approx_coeffs, bool normalized) |
set the coefficient array from external sources, rather than computing with build()/rebuild() | |
virtual void | coefficient_labels (std::vector< std::string > &coeff_labels) const |
print the coefficient array computed in build()/rebuild() | |
virtual void | print_coefficients (std::ostream &s, bool normalized) |
print the coefficient array computed in build()/rebuild() | |
virtual int | min_coefficients () const |
return the minimum number of samples (unknowns) required to build the derived class approximation type in numVars dimensions | |
virtual int | recommended_coefficients () const |
return the recommended number of samples (unknowns) required to build the derived class approximation type in numVars dimensions | |
virtual int | num_constraints () const |
return the number of constraints to be enforced via an anchor point | |
virtual void | clear_current () |
clear current build data in preparation for next build | |
int | min_points (bool constraint_flag) const |
return the minimum number of points required to build the approximation type in numVars dimensions. Uses *_coefficients() and num_constraints(). | |
int | recommended_points (bool constraint_flag) const |
return the recommended number of samples to build the approximation type in numVars dimensions (default same as min_points) | |
const Pecos::SurrogateData & | approximation_data () const |
return approxData | |
void | add (const Pecos::SurrogateDataVars &sdv, bool anchor_flag) |
append to SurrogateData::varsData or assign to SurrogateData::anchorVars | |
void | add (const Variables &vars, bool anchor_flag, bool deep_copy) |
extract the relevant vectors from Variables and invoke add(RealVector&, IntVector&, RealVector&) | |
void | add (const Real *sample_c_vars, bool anchor_flag, bool deep_copy) |
create a RealVector view and invoke add(RealVector&, empty, empty) | |
void | add (const RealVector &c_vars, const IntVector &di_vars, const RealVector &dr_vars, bool anchor_flag, bool deep_copy) |
shared code among add(Variables&) and add(Real*); adds a new data point by either appending to SurrogateData::varsData or assigning to SurrogateData::anchorVars, as dictated by anchor_flag. Uses add_point() and add_anchor(). | |
void | add (const Pecos::SurrogateDataResp &sdr, bool anchor_flag) |
append to SurrogateData::respData or assign to SurrogateData::anchorResp | |
void | add (const Response &response, int fn_index, bool anchor_flag, bool deep_copy) |
adds a new data point by either appending to SurrogateData::respData or assigning to SurrogateData::anchorResp, as dictated by anchor_flag. Uses add_point() and add_anchor(). | |
void | pop_count (size_t count) |
appends to popCountStack (number of entries to pop from end of SurrogateData::{vars,resp}Data, based on size of last data set appended) | |
void | clear_all () |
clear all build data (current and history) to restore original state | |
void | clear_anchor () |
clear SurrogateData::anchor{Vars,Resp} | |
void | clear_data () |
clear SurrogateData::{vars,resp}Data | |
void | clear_saved () |
clear popCountStack and SurrogateData::saved{Vars,Resp}Trials | |
void | set_bounds (const RealVector &c_l_bnds, const RealVector &c_u_bnds, const IntVector &di_l_bnds, const IntVector &di_u_bnds, const RealVector &dr_l_bnds, const RealVector &dr_u_bnds) |
set approximation lower and upper bounds (currently only used by graphics) | |
Approximation * | approx_rep () const |
returns approxRep for access to derived class member functions that are not mapped to the top Approximation level | |
Protected Member Functions | |
Approximation (BaseConstructor, const ProblemDescDB &problem_db, const SharedApproxData &shared_data) | |
constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139) | |
Approximation (NoDBBaseConstructor, const SharedApproxData &shared_data) | |
constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139) | |
Protected Attributes | |
RealVector | approxGradient |
gradient of the approximation returned by gradient() | |
RealSymMatrix | approxHessian |
Hessian of the approximation returned by hessian() | |
Pecos::SurrogateData | approxData |
contains the variables/response data for constructing a single approximation model (one response function) | |
SharedApproxData * | sharedDataRep |
contains the approximation data that is shared among the response set | |
Private Member Functions | |
Approximation * | get_approx (ProblemDescDB &problem_db, const SharedApproxData &shared_data) |
Used only by the standard envelope constructor to initialize approxRep to the appropriate derived type. | |
Approximation * | get_approx (const SharedApproxData &shared_data) |
Used only by the alternate envelope constructor to initialize approxRep to the appropriate derived type. | |
Private Attributes | |
SizetArray | popCountStack |
a stack managing the number of points previously added by calls to append() that can be removed by calls to pop() | |
Approximation * | approxRep |
pointer to the letter (initialized only for the envelope) | |
int | referenceCount |
number of objects sharing approxRep |
Base class for the approximation class hierarchy.
The Approximation class is the base class for the response data fit approximation class hierarchy in DAKOTA. One instance of an Approximation must be created for each function to be approximated (a vector of Approximations is contained in ApproximationInterface). For memory efficiency and enhanced polymorphism, the approximation hierarchy employs the "letter/envelope idiom" (see Coplien "Advanced C++", p. 133), for which the base class (Approximation) serves as the envelope and one of the derived classes (selected in Approximation::get_approx()) serves as the letter.
Approximation | ( | ) |
default constructor
The default constructor is used in Array<Approximation> instantiations and by the alternate envelope constructor. approxRep is NULL in this case (problem_db is needed to build a meaningful Approximation object). This makes it necessary to check for NULL in the copy constructor, assignment operator, and destructor.
Approximation | ( | ProblemDescDB & | problem_db, |
const SharedApproxData & | shared_data | ||
) |
standard constructor for envelope
Envelope constructor only needs to extract enough data to properly execute get_approx, since Approximation(BaseConstructor, problem_db) builds the actual base class data for the derived approximations.
References Dakota::abort_handler(), Approximation::approxRep, and Approximation::get_approx().
Approximation | ( | const SharedApproxData & | shared_data | ) |
alternate constructor
This is the alternate envelope constructor for instantiations on the fly. Since it does not have access to problem_db, it utilizes the NoDBBaseConstructor constructor chain.
References Dakota::abort_handler(), Approximation::approxRep, and Approximation::get_approx().
Approximation | ( | const Approximation & | approx | ) |
copy constructor
Copy constructor manages sharing of approxRep and incrementing of referenceCount.
References Approximation::approxRep, and Approximation::referenceCount.
~Approximation | ( | ) | [virtual] |
destructor
Destructor decrements referenceCount and only deletes approxRep when referenceCount reaches zero.
References Approximation::approxRep, and Approximation::referenceCount.
Approximation | ( | BaseConstructor | , |
const ProblemDescDB & | problem_db, | ||
const SharedApproxData & | shared_data | ||
) | [protected] |
constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139)
This constructor is the one which must build the base class data for all derived classes. get_approx() instantiates a derived class letter and the derived constructor selects this base class constructor in its initialization list (to avoid recursion in the base class constructor calling get_approx() again). Since the letter IS the representation, its rep pointer is set to NULL (an uninitialized pointer causes problems in ~Approximation).
Approximation | ( | NoDBBaseConstructor | , |
const SharedApproxData & | shared_data | ||
) | [protected] |
constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139)
This constructor is the one which must build the base class data for all derived classes. get_approx() instantiates a derived class letter and the derived constructor selects this base class constructor in its initialization list (to avoid recursion in the base class constructor calling get_approx() again). Since the letter IS the representation, its rep pointer is set to NULL (an uninitialized pointer causes problems in ~Approximation).
Approximation operator= | ( | const Approximation & | approx | ) |
assignment operator
Assignment operator decrements referenceCount for old approxRep, assigns new approxRep, and increments referenceCount for new approxRep.
References Approximation::approxRep, and Approximation::referenceCount.
void build | ( | ) | [virtual] |
builds the approximation from scratch
This is the common base class portion of the virtual fn and is insufficient on its own; derived implementations should explicitly invoke (or reimplement) this base class contribution.
Reimplemented in PecosApproximation, VPSApproximation, GaussProcApproximation, SurfpackApproximation, TaylorApproximation, and TANA3Approximation.
References Dakota::abort_handler(), Approximation::approxData, Approximation::approxRep, Approximation::build(), Approximation::min_points(), SharedApproxData::numVars, and Approximation::sharedDataRep.
Referenced by Approximation::build(), and Approximation::rebuild().
void rebuild | ( | ) | [virtual] |
rebuilds the approximation incrementally
This is the common base class portion of the virtual fn and is insufficient on its own; derived implementations should explicitly invoke (or reimplement) this base class contribution.
Reimplemented in PecosApproximation.
References Approximation::approxRep, Approximation::build(), and Approximation::rebuild().
Referenced by Approximation::rebuild().
void pop | ( | bool | save_data | ) | [virtual] |
removes entries from end of SurrogateData::{vars,resp}Data (last points appended, or as specified in args)
This is the common base class portion of the virtual fn and is insufficient on its own; derived implementations should explicitly invoke (or reimplement) this base class contribution.
Reimplemented in PecosApproximation.
References Dakota::abort_handler(), Approximation::approxData, Approximation::approxRep, Approximation::pop(), and Approximation::popCountStack.
Referenced by Approximation::pop().
void restore | ( | ) | [virtual] |
restores state prior to previous append()
This is the common base class portion of the virtual fn and is insufficient on its own; derived implementations should explicitly invoke (or reimplement) this base class contribution.
Reimplemented in PecosApproximation.
References Approximation::approxData, Approximation::approxRep, Approximation::popCountStack, SharedApproxData::restoration_index(), Approximation::restore(), and Approximation::sharedDataRep.
Referenced by Approximation::restore().
void finalize | ( | ) | [virtual] |
finalize approximation by applying all remaining trial sets
This is the common base class portion of the virtual fn and is insufficient on its own; derived implementations should explicitly invoke (or reimplement) this base class contribution.
Reimplemented in PecosApproximation.
References Approximation::approxData, Approximation::approxRep, Approximation::clear_saved(), SharedApproxData::finalization_index(), Approximation::finalize(), and Approximation::sharedDataRep.
Referenced by Approximation::finalize().
void clear_current | ( | ) | [inline, virtual] |
clear current build data in preparation for next build
Redefined by TANA3Approximation to clear current data but preserve history.
Reimplemented in TANA3Approximation.
References Approximation::approxRep, Approximation::clear_all(), and Approximation::clear_current().
Referenced by Approximation::clear_current().
void clear_all | ( | ) | [inline] |
clear all build data (current and history) to restore original state
Clears out any history (e.g., TANA3Approximation use for a different response function in NonDReliability).
References Approximation::approxData, Approximation::approxRep, and Approximation::clear_all().
Referenced by Approximation::clear_all(), and Approximation::clear_current().
Approximation * get_approx | ( | ProblemDescDB & | problem_db, |
const SharedApproxData & | shared_data | ||
) | [private] |
Used only by the standard envelope constructor to initialize approxRep to the appropriate derived type.
Used only by the envelope constructor to initialize approxRep to the appropriate derived type.
References SharedApproxData::approxType, SharedApproxData::data_rep(), ProblemDescDB::get_bool(), and Dakota::strends().
Referenced by Approximation::Approximation().
Approximation * get_approx | ( | const SharedApproxData & | shared_data | ) | [private] |
Used only by the alternate envelope constructor to initialize approxRep to the appropriate derived type.
Used only by the envelope constructor to initialize approxRep to the appropriate derived type.
References SharedApproxData::approxType, SharedApproxData::data_rep(), and Dakota::strends().