Container class for response functions and their derivatives. ResponseRep provides the body class. More...
Private Member Functions | |
ResponseRep () | |
default constructor | |
ResponseRep (const Variables &vars, const ProblemDescDB &problem_db) | |
standard constructor built from problem description database | |
ResponseRep (const ActiveSet &set) | |
alternate constructor using limited data | |
~ResponseRep () | |
destructor | |
void | read (std::istream &s) |
read a responseRep object from an std::istream | |
void | write (std::ostream &s) const |
write a responseRep object to an std::ostream | |
void | read_annotated (std::istream &s) |
read a responseRep object from an std::istream (annotated format) | |
void | write_annotated (std::ostream &s) const |
write a responseRep object to an std::ostream (annotated format) | |
void | read_tabular (std::istream &s) |
read functionValues from an std::istream (tabular format) | |
void | write_tabular (std::ostream &s) const |
write functionValues to an std::ostream (tabular format) | |
void | read (BiStream &s) |
read a responseRep object from a binary stream | |
void | write (BoStream &s) const |
write a responseRep object to a binary stream | |
void | read (MPIUnpackBuffer &s) |
read a responseRep object from a packed MPI buffer | |
void | write (MPIPackBuffer &s) const |
write a responseRep object to a packed MPI buffer | |
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 RealVector &source_fn_vals, const RealMatrix &source_fn_grads, const RealSymMatrixArray &source_fn_hessians, const ActiveSet &source_set) |
update this response object from components of another response object | |
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) |
partially update this response object partial components of another response object | |
void | reshape (const size_t &num_fns, const size_t &num_params, bool grad_flag, bool hess_flag) |
rehapes response data arrays | |
void | reset () |
resets all response data to zero | |
void | reset_inactive () |
resets all inactive response data to zero | |
void | active_set_request_vector (const ShortArray &asrv) |
set the active set request vector and verify consistent number of response functions | |
void | active_set_derivative_vector (const SizetArray &asdv) |
set the active set derivative vector and reshape functionGradients/functionHessians if needed | |
Private Attributes | |
int | referenceCount |
number of handle objects sharing responseRep | |
RealVector | functionValues |
abstract set of response functions | |
RealMatrix | functionGradients |
first derivatives of the response functions | |
RealSymMatrixArray | functionHessians |
second derivatives of the response functions | |
ActiveSet | responseActiveSet |
copy of the ActiveSet used by the Model to generate a Response instance | |
StringArray | functionLabels |
response function identifiers used to improve output readability | |
String | responsesId |
response identifier string from the input file | |
Friends | |
class | Response |
the handle class can access attributes of the body class directly | |
bool | operator== (const ResponseRep &rep1, const ResponseRep &rep2) |
equality operator |
Container class for response functions and their derivatives. ResponseRep provides the body class.
The ResponseRep class is the "representation" of the response container class. It is the "body" portion of the "handle-body idiom" (see Coplien "Advanced C++", p. 58). The handle class (Response) provides for memory efficiency in management of multiple response objects through reference counting and representation sharing. The body class (ResponseRep) actually contains the response data (functionValues, functionGradients, functionHessians, etc.). The representation is hidden in that an instance of ResponseRep may only be created by Response. Therefore, programmers create instances of the Response handle class, and only need to be aware of the handle/body mechanisms when it comes to managing shallow copies (shared representation) versus deep copies (separate representation used for history mechanisms).
ResponseRep | ( | const Variables & | vars, |
const ProblemDescDB & | problem_db | ||
) | [private] |
standard constructor built from problem description database
The standard constructor used by Dakota::ModelRep.
References Dakota::abort_handler(), Variables::continuous_variable_ids(), Variables::cv(), ActiveSet::derivative_vector(), ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionValues, ProblemDescDB::get_sizet(), ProblemDescDB::get_string(), ActiveSet::request_vector(), and ResponseRep::responseActiveSet.
ResponseRep | ( | const ActiveSet & | set | ) | [private] |
alternate constructor using limited data
Used for building a response object of the correct size on the fly (e.g., by slave analysis servers performing execute() on a local_response). functionLabels is not needed for this purpose since it's not passed in the MPI send/recv buffers. However, NPSOLOptimizer's user-defined functions option uses this constructor to build bestResponseArray.front() and bestResponseArray.front() needs functionLabels for I/O, so construction of functionLabels has been added.
References Dakota::build_labels(), ResponseRep::functionGradients, ResponseRep::functionHessians, and ResponseRep::functionLabels.
void read | ( | std::istream & | s | ) | [private] |
read a responseRep object from an std::istream
ASCII version of read needs capabilities for capturing data omissions or formatting errors (resulting from user error or asynch race condition) and analysis failures (resulting from nonconvergence, instability, etc.).
References ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionValues, Dakota::re_match(), Dakota::read_col_vector_trans(), ResponseRep::read_data(), ActiveSet::request_vector(), ResponseRep::reset(), and ResponseRep::responseActiveSet.
Referenced by Response::read().
void write | ( | std::ostream & | s | ) | const [private] |
write a responseRep object to an std::ostream
ASCII version of write.
References Dakota::abort_handler(), Dakota::array_write_annotated(), ActiveSet::derivative_vector(), ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionLabels, ResponseRep::functionValues, ActiveSet::request_vector(), ResponseRep::responseActiveSet, Dakota::write_col_vector_trans(), ResponseRep::write_data(), and Dakota::write_precision.
Referenced by Response::write().
void read_annotated | ( | std::istream & | s | ) | [private] |
read a responseRep object from an std::istream (annotated format)
read_annotated() is used for neutral file translation of restart files. Since objects are built solely from this data, annotations are used. This version closely mirrors the BiStream version.
References ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionLabels, ResponseRep::functionValues, Dakota::read_col_vector_trans(), ResponseRep::read_data(), ActiveSet::request_vector(), ResponseRep::reset(), ActiveSet::reshape(), ResponseRep::reshape(), and ResponseRep::responseActiveSet.
Referenced by Response::read_annotated().
void write_annotated | ( | std::ostream & | s | ) | const [private] |
write a responseRep object to an std::ostream (annotated format)
write_annotated() is used for neutral file translation of restart files. Since objects need to be build solely from this data, annotations are used. This version closely mirrors the BoStream version, with the exception of the use of white space between fields.
References Dakota::array_write_annotated(), ActiveSet::derivative_vector(), ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionLabels, ResponseRep::functionValues, ActiveSet::request_vector(), ResponseRep::responseActiveSet, ActiveSet::write_annotated(), Dakota::write_col_vector_trans(), and ResponseRep::write_data().
Referenced by Response::write_annotated().
void read_tabular | ( | std::istream & | s | ) | [private] |
read functionValues from an std::istream (tabular format)
read_tabular is used to read functionValues in tabular format. It is currently only used by ApproximationInterfaces in reading samples from a file. There is insufficient data in a tabular file to build complete response objects; rather, the response object must be constructed a priori and then its functionValues can be set.
References ResponseRep::functionValues.
Referenced by Response::read_tabular().
void write_tabular | ( | std::ostream & | s | ) | const [private] |
write functionValues to an std::ostream (tabular format)
write_tabular is used for output of functionValues in a tabular format for convenience in post-processing/plotting of DAKOTA results.
References ResponseRep::functionValues, ActiveSet::request_vector(), ResponseRep::responseActiveSet, and Dakota::write_precision.
Referenced by Response::write_tabular().
read a responseRep object from a binary stream
Binary version differs from ASCII version in 2 primary ways: (1) it lacks formatting. (2) the Response has not been sized a priori. In reading data from the binary restart file, a ParamResponsePair was constructed with its default constructor which called the Response default constructor. Therefore, we must first read sizing data and resize all of the arrays.
References ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionLabels, ResponseRep::functionValues, Dakota::read_col_vector_trans(), ResponseRep::read_data(), ActiveSet::request_vector(), ResponseRep::reset(), ResponseRep::reshape(), and ResponseRep::responseActiveSet.
write a responseRep object to a binary stream
Binary version differs from ASCII version in 2 primary ways: (1) It lacks formatting. (2) In reading data from the binary restart file, ParamResponsePairs are constructed with their default constructor which calls the Response default constructor. Therefore, we must first write sizing data so that ResponseRep::read(BoStream& s) can resize the arrays.
References ActiveSet::derivative_vector(), ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionLabels, ResponseRep::functionValues, ActiveSet::request_vector(), ResponseRep::responseActiveSet, Dakota::write_col_vector_trans(), and ResponseRep::write_data().
void read | ( | MPIUnpackBuffer & | s | ) | [private] |
read a responseRep object from a packed MPI buffer
UnpackBuffer version differs from BiStream version in the omission of functionLabels. Master processor retains labels and interface ids and communicates asv and response data only with slaves.
References ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionValues, Dakota::read_col_vector_trans(), ResponseRep::read_data(), ResponseRep::reset(), ResponseRep::reshape(), and ResponseRep::responseActiveSet.
void write | ( | MPIPackBuffer & | s | ) | const [private] |
write a responseRep object to a packed MPI buffer
MPIPackBuffer version differs from BoStream version only in the omission of functionLabels. The master processor retains labels and ids and communicates asv and response data only with slaves.
References ActiveSet::derivative_vector(), ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionValues, ActiveSet::request_vector(), ResponseRep::responseActiveSet, Dakota::write_col_vector_trans(), and ResponseRep::write_data().
void update | ( | const RealVector & | source_fn_vals, |
const RealMatrix & | source_fn_grads, | ||
const RealSymMatrixArray & | source_fn_hessians, | ||
const ActiveSet & | source_set | ||
) | [private] |
update this response object from components of another response object
Copy function values/gradients/Hessians data _only_. Prevents unwanted overwriting of responseActiveSet, functionLabels, etc. Also, care is taken to account for differences in derivative variable matrix sizing.
References Dakota::abort_handler(), ActiveSet::derivative_vector(), ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionValues, ActiveSet::request_vector(), ResponseRep::reset_inactive(), and ResponseRep::responseActiveSet.
Referenced by Response::update().
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 | ||
) | [private] |
partially update this response object partial components of another response object
Copy function values/gradients/Hessians data _only_. Prevents unwanted overwriting of responseActiveSet, functionLabels, etc. Also, care is taken to account for differences in derivative variable matrix sizing.
References Dakota::abort_handler(), ActiveSet::derivative_vector(), ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionValues, ActiveSet::request_vector(), ResponseRep::reset_inactive(), and ResponseRep::responseActiveSet.
Referenced by Response::update_partial().
void reshape | ( | const size_t & | num_fns, |
const size_t & | num_params, | ||
bool | grad_flag, | ||
bool | hess_flag | ||
) | [private] |
rehapes response data arrays
Reshape functionValues, functionGradients, and functionHessians according to num_fns, num_params, grad_flag, and hess_flag.
References Dakota::build_labels(), ActiveSet::derivative_vector(), ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionLabels, ResponseRep::functionValues, ActiveSet::request_vector(), ActiveSet::reshape(), and ResponseRep::responseActiveSet.
Referenced by ResponseRep::active_set_derivative_vector(), ResponseRep::read(), ResponseRep::read_annotated(), and Response::reshape().
void reset | ( | ) | [private] |
resets all response data to zero
Reset all numerical response data (not labels, ids, or active set) to zero.
References ResponseRep::functionGradients, ResponseRep::functionHessians, and ResponseRep::functionValues.
Referenced by ResponseRep::read(), ResponseRep::read_annotated(), and Response::reset().
void reset_inactive | ( | ) | [private] |
resets all inactive response data to zero
Used to clear out any inactive data left over from previous evaluations.
References ResponseRep::functionGradients, ResponseRep::functionHessians, ResponseRep::functionValues, ActiveSet::request_vector(), and ResponseRep::responseActiveSet.
Referenced by Response::reset_inactive(), ResponseRep::update(), and ResponseRep::update_partial().
RealMatrix functionGradients [private] |
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 ResponseRep::active_set_derivative_vector(), Response::copy(), Response::function_gradient(), Response::function_gradient_copy(), Response::function_gradient_view(), Response::function_gradients(), Response::function_gradients_view(), Dakota::operator==(), ResponseRep::overlay(), ResponseRep::read(), ResponseRep::read_annotated(), ResponseRep::read_data(), ResponseRep::reset(), ResponseRep::reset_inactive(), ResponseRep::reshape(), ResponseRep::ResponseRep(), ResponseRep::update(), ResponseRep::update_partial(), ResponseRep::write(), ResponseRep::write_annotated(), and ResponseRep::write_data().