Dakota  Version 6.20
Explore and Predict with Confidence
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
Response Class Reference

Container class for response functions and their derivatives.
Response provides the enveloper base class. More...

Inheritance diagram for Response:
ExperimentResponse SimulationResponse

Public Member Functions

 Response ()
 default constructor
 
 Response (short type, const Variables &vars, const ProblemDescDB &problem_db)
 standard constructor built from problem description database
 
 Response (const SharedResponseData &srd, const ActiveSet &set)
 alternate constructor that shares response data
 
 Response (short type, const ActiveSet &set)
 alternate constructor using limited data without sharing
 
 Response (const SharedResponseData &srd)
 alternate constructor using limited data (explicit disallows implicit type conversion)
 
 Response (const Response &response)
 copy constructor
 
virtual ~Response ()
 destructor
 
Response operator= (const Response &response)
 assignment operator
 
const SharedResponseDatashared_data () const
 return sharedRespData
 
SharedResponseDatashared_data ()
 return sharedRespData
 
size_t num_functions () const
 return the number of response functions
 
const ActiveSetactive_set () const
 return the active set
 
void active_set (const ActiveSet &set)
 set the active set
 
const ShortArray & active_set_request_vector () const
 return the active set request vector
 
ShortArray & active_set_request_vector ()
 return the active set request vector
 
void active_set_request_vector (const ShortArray &asrv)
 set the active set request vector and verify consistent number of response functions
 
const SizetArray & active_set_derivative_vector () const
 return the active set derivative vector
 
SizetArray & active_set_derivative_vector ()
 return the active set derivative vector
 
void active_set_derivative_vector (const SizetArray &asdv)
 set the active set derivative vector and reshape functionGradients/functionHessians if needed
 
void active_set_derivative_vector (SizetMultiArrayConstView asdv)
 set the active set derivative vector and reshape functionGradients/functionHessians if needed
 
const Real & function_value (size_t i) const
 return a function value
 
Real & function_value_view (size_t i)
 return a "view" of a function value for updating in place
 
const RealVector & function_values () const
 return all function values
 
RealVector function_values_view ()
 return all function values as a view for updating in place
 
RealVector function_values_view () const
 return all function values as a view for accessing the function values vector from a const response
 
void function_value (const Real &fn_val, size_t i)
 set a function value
 
void function_values (const RealVector &fn_vals)
 set all function values
 
const Real * function_gradient (int i) const
 return the i-th function gradient as a const Real*
 
RealVector function_gradient_view (int i)
 return the i-th function gradient as a SerialDenseVector view (shallow copy) for updating in place
 
RealVector function_gradient_view (int i) const
 return the i-th function gradient as a SerialDenseVector view (shallow copy) for accessing a column vector from a const matrix
 
RealVector function_gradient_copy (int i) const
 return the i-th function gradient as a SerialDenseVector Teuchos::Copy (deep copy)
 
const RealMatrix & function_gradients () const
 return all function gradients
 
RealMatrix function_gradients_view ()
 return all function gradients as a view for updating in place
 
RealMatrix function_gradients_view () const
 return all function gradients as a view for updating in place
 
void function_gradient (const RealVector &assign_grad, int fn_index)
 set a function gradient
 
void function_gradient (const RealVector &assign_grad, int fn_index, const SizetArray &assign_indices, const SizetArray &curr_indices)
 set a function gradient, managing dissimilar DVV
 
void function_gradient (const RealVector &assign_grad, int fn_index, const SizetArray &assign_dvv)
 set a function gradient, managing dissimilar DVV
 
void function_gradients (const RealMatrix &fn_grads)
 set all function gradients
 
const RealSymMatrix & function_hessian (size_t i) const
 return the i-th function Hessian
 
RealSymMatrix function_hessian_view (size_t i)
 return the i-th function Hessian as a Teuchos::View (shallow copy) for updating in place
 
RealSymMatrix function_hessian_view (size_t i) const
 return the i-th function Hessian as a Teuchos::View (shallow copy) for accessing the i-th matrix within a const matrix array
 
const RealSymMatrixArray & function_hessians () const
 return all function Hessians
 
RealSymMatrixArray function_hessians_view ()
 return all function Hessians as Teuchos::Views (shallow copies) for updating in place
 
RealSymMatrixArray function_hessians_view () const
 return all function Hessians as Teuchos::Views (shallow copies) for updating in place
 
void function_hessian (const RealSymMatrix &assign_hessian, size_t fn_index)
 set a function Hessian
 
void function_hessian (const RealSymMatrix &assign_hessian, size_t fn_index, const SizetArray &assign_indices, const SizetArray &curr_indices)
 set a function Hessian, using DVV index mappings
 
void function_hessian (const RealSymMatrix &assign_hessian, size_t fn_index, const SizetArray &assign_dvv)
 set a function Hessian, managing dissimilar DVV
 
void function_hessians (const RealSymMatrixArray &fn_hessians)
 set all function Hessians
 
void map_dvv_indices (const SizetArray &assign_dvv, SizetArray &assign_indices, SizetArray &curr_indices)
 define source and target indices for updating derivatives by matching assign_dvv against the current DVV
 
const IntVector & field_lengths () const
 return the field lengths (from SharedResponseData)
 
void field_lengths (const IntVector &field_lens)
 set the field lengths (within SharedResponseData)
 
RealVector field_values_view (size_t i) const
 return const field values for the i-th field
 
RealVector field_values_view (size_t i)
 return a "view" of the i-th field values for updating in place
 
void field_values (const RealVector &field_val, size_t i)
 set the values for the i-th field
 
RealMatrix field_gradients_view (size_t i) const
 return a view of the gradients of each element of the i-th field
 
RealSymMatrixArray field_hessians_view (size_t i) const
 return a view of the hessians of each element of the i-th field
 
RealMatrix field_coords_view (size_t i)
 return a "view" of the i-th field's coordinates
 
const RealMatrix field_coords_view (size_t i) const
 return a const "view" of the i-th field's coordinates
 
void field_coords (const RealMatrix &field_coords, size_t i)
 set the i-th field's coordinates
 
const IntVector & num_coords_per_field () const
 return the number of coordinates each field has (from SharedResponseData)
 
const StringArray & function_labels () const
 return the fine-grained (unrolled) response function identifier strings from sharedRespData
 
void function_labels (const StringArray &labels)
 set the fine-grained (unrolled) response function identifier strings within sharedRespData
 
const StringArray & field_group_labels ()
 return the user-provided field group labels instead of the unrolled labels available through function_labels()
 
const std::vector< RespMetadataT > & metadata () const
 get the (possibly empty) response metadata; (get labels through shared_data())
 
RespMetadataT metadata (size_t index) const
 get a single entry from the response metadata
 
void metadata (const std::vector< RespMetadataT > &md)
 set the response metadata (set labels through shared_data())
 
void metadata (const std::vector< RespMetadataT > &md, size_t start)
 set a portion of the response metadata starting from given position
 
void read (std::istream &s, const unsigned short format=FLEXIBLE_RESULTS)
 read a response object of specified format from a std::istream
 
void write (std::ostream &s) const
 write a response object to a std::ostream
 
void read_annotated (std::istream &s)
 read a response object in annotated format from a std::istream
 
void write_annotated (std::ostream &s) const
 write a response object in annotated format to a std::ostream
 
void read_tabular (std::istream &s)
 read responseRep::functionValues in tabular format from a std::istream
 
void write_tabular (std::ostream &s, bool eol=true) const
 write responseRep::functionValues in tabular format to a std::ostream
 
void write_tabular_partial (std::ostream &s, size_t start_index, size_t num_items) const
 write portion of responseRep::functionValues in tabular format to a std::ostream
 
void write_tabular_labels (std::ostream &s, bool eol=true) const
 write the response labels in tabular format to a std::ostream
 
void read (MPIUnpackBuffer &s)
 read a response object from a packed MPI buffer
 
void write (MPIPackBuffer &s) const
 write a response object to a packed MPI buffer
 
Response copy (bool deep_srd=false) const
 return a deep response copy of the contained responseRep for use in history mechanisms (SharedResponseData uses a shallow copy by default)
 
int data_size ()
 return the number of doubles active in response. Used for sizing double* response_data arrays passed into read_data and write_data.
 
void read_data (double *response_data)
 read from an incoming double* array
 
void write_data (double *response_data)
 write to an incoming double* array
 
void overlay (const Response &response)
 add incoming response to functionValues/Gradients/Hessians
 
void update (const Response &response, bool pull_metadata=false)
 Used in place of operator= when only results data updates are desired (functionValues/functionGradients/functionHessians are updated, ASV/labels/id's/etc. are not). Care is taken to allow different derivative array sizing between the two response objects.
 
void update (const RealVector &source_fn_vals, const RealMatrix &source_fn_grads, const RealSymMatrixArray &source_fn_hessians, const ActiveSet &source_set)
 Overloaded form which allows update from components of a response object. Care is taken to allow different derivative array sizing.
 
void update_partial (size_t start_index_target, size_t num_items, const Response &response, size_t start_index_source)
 partial update of this response object from another response object. The response objects may have different numbers of response functions.
 
void update_partial (size_t start_index_target, size_t num_items, const RealVector &source_fn_vals, const RealMatrix &source_fn_grads, const RealSymMatrixArray &source_fn_hessians, const ActiveSet &source_set, size_t start_index_source)
 Overloaded form which allows partial update from components of a response object. The response objects may have different numbers of response functions.
 
void reshape (size_t num_fns, size_t num_params, bool grad_flag, bool hess_flag)
 rehapes response data arrays
 
void reshape_metadata (size_t num_meta)
 rehapes response metadata arrays
 
void reset ()
 resets all response data to zero
 
void reset_inactive ()
 resets all inactive response data to zero
 
bool is_null () const
 function to check responseRep (does this handle contain a body)
 
virtual void set_scalar_covariance (RealVector &scalars)
 method to set the covariance matrix defined for ExperimentResponse
 
virtual const ExperimentCovariance & experiment_covariance () const
 retrieve the ExperimentCovariance structure
 
virtual void set_full_covariance (std::vector< RealMatrix > &matrices, std::vector< RealVector > &diagonals, RealVector &scalars, IntVector matrix_map_indices, IntVector diagonal_map_indices, IntVector scalar_map_indices)
 method to set the full covariance matrices for ExperimentResponse
 
virtual Real apply_covariance (const RealVector &residuals) const
 method to compute the triple product v'*inv(C)*v.
 
virtual void apply_covariance_inv_sqrt (const RealVector &residuals, RealVector &weighted_residuals) const
 method to compute (v'*inv(C)^1/2), to compute weighted residual
 
virtual void apply_covariance_inv_sqrt (const RealMatrix &gradients, RealMatrix &weighted_gradients) const
 
virtual void apply_covariance_inv_sqrt (const RealSymMatrixArray &hessians, RealSymMatrixArray &weighted_hessians) const
 
virtual void get_covariance_diagonal (RealVector &diagonal) const
 
virtual Real covariance_determinant () const
 covariance determinant for one experiment (default 1.0)
 
virtual Real log_covariance_determinant () const
 log of covariance determinant for one experiment (default 0.0)
 

Protected Member Functions

 Response (BaseConstructor, const Variables &vars, const ProblemDescDB &problem_db)
 constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139)
 
 Response (BaseConstructor, const SharedResponseData &srd, const ActiveSet &set)
 constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139)
 
 Response (BaseConstructor, const ActiveSet &set)
 constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139)
 
 Response (BaseConstructor, const SharedResponseData &srd)
 constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139)
 
virtual void copy_rep (std::shared_ptr< Response > source_resp_rep)
 Implementation of data copy for Response letters (specialized by some derived letter types); pulls base class data from source_resp_rep into the this object.

 

Protected Attributes

SharedResponseData sharedRespData
 reference-counted instance of shared response data: id's, labels
 
RealVector functionValues
 Abstract set of response functions. Ordered: [primary_scalar, primary_field, nonlinear_inequality, nonlinear_equality].
 
RealMatrix functionGradients
 first derivatives of the response functions More...
 
RealSymMatrixArray functionHessians
 second derivatives of the response functions
 
IntRealMatrixMap fieldCoords
 coordinates (independent vars like x,t) on which field values depend
 
ActiveSet responseActiveSet
 copy of the ActiveSet used by the Model to generate a Response instance
 
std::vector< RespMetadataT > metaData
 metadata storage
 

Private Member Functions

template<class Archive , typename OrdinalType , typename ScalarType >
void write_sdm_col (Archive &ar, int col, const Teuchos::SerialDenseMatrix< OrdinalType, ScalarType > &sdm) const
 write a column of a SerialDenseMatrix
 
template<class Archive , typename OrdinalType , typename ScalarType >
void read_sdm_col (Archive &ar, int col, Teuchos::SerialDenseMatrix< OrdinalType, ScalarType > &sdm)
 read a column of a SerialDenseMatrix
 
template<class Archive >
void load (Archive &ar, const unsigned int version)
 read a Response from an archive<class Archive>
 
template<class Archive >
void load_rep (Archive &ar, const unsigned int version)
 read a Response letter object from an archive
 
template<class Archive >
void save (Archive &ar, const unsigned int version) const
 write a Response to an archive
 
template<class Archive >
void save_rep (Archive &ar, const unsigned int version) const
 write a Response letter object to an archive
 
BOOST_SERIALIZATION_SPLIT_MEMBER() std std::shared_ptr< Responseget_response (const SharedResponseData &srd, const ActiveSet &set) const
 Used by standard envelope constructor to instantiate a new letter class. More...
 
std::shared_ptr< Responseget_response (short type, const ActiveSet &set) const
 Used by alternate envelope constructor to instantiate a new letter class.
 
std::shared_ptr< Responseget_response (const SharedResponseData &srd) const
 Used by copy() to instantiate a new letter class.
 
std::shared_ptr< Responseget_response (short type) const
 Used by read functions to instantiate a new letter class.
 
void read_annotated_rep (std::istream &s)
 read a letter object in annotated format from a std::istream
 
void write_annotated_rep (std::ostream &s) const
 write a letter object in annotated format to a std::ostream
 
void read_rep (MPIUnpackBuffer &s)
 read a letter object from a packed MPI buffer
 
void write_rep (MPIPackBuffer &s) const
 write a letter object to a packed MPI buffer
 
void shape_rep (const ActiveSet &set, bool initialize=true)
 resizes the representation's containers
 
void reshape_rep (size_t num_fns, size_t num_params, bool grad_flag, bool hess_flag)
 resizes the representation's containers
 
void reshape_active_derivs (size_t num_deriv_vars)
 reshape function{Gradients,Hessians} if needed to sync with DVV
 
void read_core (std::istream &s, const unsigned short formats, std::ostringstream &errors)
 
bool expect_derivatives (const ShortArray &asv)
 
void read_gradients (std::istream &s, const ShortArray &asv, bool expect_metadata, std::ostringstream &error)
 Read gradients from a freeform stream. Insert error messages.
 
void read_hessians (std::istream &s, const ShortArray &asv, bool expect_metadata, std::ostringstream &error)
 Read Hessians from a freeform stream. Insert error messages.
 
void read_labeled_fn_vals (std::istream &s, const ShortArray &asv, size_t num_metadata, std::ostringstream &errors)
 Read function values from an annotated stream. Insert error messages.
 
void read_flexible_fn_vals (std::istream &s, const ShortArray &asv, size_t num_metadata, std::ostringstream &errors)
 Read function values from a stream in a "flexible" way – ignoring any labels. Insert error messages into errors stream.
 
bool failure_reported (std::istream &s)
 Check for FAIL in stream.
 

Private Attributes

std::shared_ptr< ResponseresponseRep
 pointer to the body (handle-body idiom)
 

Friends

class boost::serialization::access
 
bool operator== (const Response &resp1, const Response &resp2)
 equality operator
 
bool operator!= (const Response &resp1, const Response &resp2)
 inequality operator
 

Detailed Description

Container class for response functions and their derivatives.
Response provides the enveloper base class.

The Response class is a container class for an abstract set of functions (functionValues) and their first (functionGradients) and second (functionHessians) derivatives. The functions may involve objective and constraint functions (optimization data set), least squares terms (parameter estimation data set), or generic response functions (uncertainty quantification data set). When field responses are present, the stored response elements are ordered: [primary_scalar, primary_field, nonlinear_inequality, nonlinear_equality].

For memory efficiency, it employs the "letter-envelope idiom" approach to reference counting and representation sharing (see Coplien "Advanced C++"), for which the base Response class serves as the envelope and one of its derived classes serves as the letter.

Member Function Documentation

◆ get_response()

BOOST_SERIALIZATION_SPLIT_MEMBER () std std::shared_ptr<Response> get_response ( const SharedResponseData srd,
const ActiveSet set 
) const
private

Used by standard envelope constructor to instantiate a new letter class.

Used by alternate envelope constructor to instantiate a new letter class

Member Data Documentation

◆ functionGradients

RealMatrix functionGradients
protected

first derivatives of the response functions

the gradient vectors (plural) are column vectors in the matrix (singular) with (row, col) = (variable index, response fn index).

Referenced by Response::field_gradients_view(), Response::function_gradient(), Response::function_gradient_copy(), Response::function_gradient_view(), Response::function_gradients(), and Response::function_gradients_view().


The documentation for this class was generated from the following file: