Dakota  Version 6.13
Explore and Predict with Confidence
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
HierarchSurrModel Class Reference

Derived model class within the surrogate model branch for managing hierarchical surrogates (models of varying fidelity). More...

Inheritance diagram for HierarchSurrModel:
SurrogateModel Model

Public Member Functions

 HierarchSurrModel (ProblemDescDB &problem_db)
 constructor
 
 ~HierarchSurrModel ()
 destructor
 
const unsigned short correction_mode () const
 return correctionMode
 
void correction_mode (unsigned short corr_mode)
 set correctionMode
 

Protected Member Functions

size_t qoi () const
 return number of unique response functions (managing any aggregations)
 
DiscrepancyCorrectiondiscrepancy_correction ()
 return the DiscrepancyCorrection object used by SurrogateModels
 
short correction_type ()
 return the correction type from the DiscrepancyCorrection object used by SurrogateModels
 
void correction_type (short corr_type)
 set the correction type from the DiscrepancyCorrection object used by SurrogateModels
 
bool initialize_mapping (ParLevLIter pl_iter)
 
bool finalize_mapping ()
 
void nested_variable_mappings (const SizetArray &c_index1, const SizetArray &di_index1, const SizetArray &ds_index1, const SizetArray &dr_index1, const ShortArray &c_target2, const ShortArray &di_target2, const ShortArray &ds_target2, const ShortArray &dr_target2)
 set primaryA{C,DI,DS,DR}VarMapIndices, secondaryA{C,DI,DS,DR}VarMapTargets (coming from a higher-level NestedModel context to inform derivative est.)
 
const SizetArray & nested_acv1_indices () const
 return primaryACVarMapIndices
 
const ShortArray & nested_acv2_targets () const
 return secondaryACVarMapTargets
 
short query_distribution_parameter_derivatives () const
 calculate and return derivative composition of final results w.r.t. distribution parameters (none, all, or mixed)
 
void check_submodel_compatibility (const Model &sub_model)
 verify compatibility between SurrogateModel attributes and attributes of the submodel (DataFitSurrModel::actualModel or HierarchSurrModel::highFidelityModel)
 
void derived_evaluate (const ActiveSet &set)
 
void derived_evaluate_nowait (const ActiveSet &set)
 
const IntResponseMap & derived_synchronize ()
 
const IntResponseMap & derived_synchronize_nowait ()
 
Modelsurrogate_model ()
 return the active low fidelity model
 
const Modelsurrogate_model () const
 return the active low fidelity model
 
Modeltruth_model ()
 return the active high fidelity model
 
const Modeltruth_model () const
 return the active high fidelity model
 
void active_model_key (const UShortArray &key)
 define the active model key and associated {truth,surr}ModelKey pairing
 
void derived_subordinate_models (ModelList &ml, bool recurse_flag)
 return orderedModels and, optionally, their sub-model recursions
 
void resize_from_subordinate_model (size_t depth=std::numeric_limits< size_t >::max())
 resize currentResponse if needed when one of the subordinate models has been resized
 
void update_from_subordinate_model (size_t depth=std::numeric_limits< size_t >::max())
 update currentVariables using non-active data from the passed model (one of the ordered models)
 
void primary_response_fn_weights (const RealVector &wts, bool recurse_flag=true)
 set the relative weightings for multiple objective functions or least squares terms and optionally recurses into LF/HF models
 
void surrogate_response_mode (short mode)
 set responseMode and pass any bypass request on to the high fidelity model for any lower-level surrogate recursions
 
void surrogate_function_indices (const IntSet &surr_fn_indices)
 (re)set the surrogate index set in SurrogateModel::surrogateFnIndices
 
void build_approximation ()
 use the high fidelity model to compute the truth values needed for correction of the low fidelity model results
 
void component_parallel_mode (short mode)
 update component parallel mode for supporting parallelism in the low ad high fidelity models
 
IntIntPair estimate_partition_bounds (int max_eval_concurrency)
 estimate the minimum and maximum partition sizes that can be utilized by this Model
 
void derived_init_communicators (ParLevLIter pl_iter, int max_eval_concurrency, bool recurse_flag=true)
 set up parallel operations for the array of ordered model fidelities
 
void derived_init_serial ()
 set up serial operations for the array of ordered model fidelities
 
void derived_set_communicators (ParLevLIter pl_iter, int max_eval_concurrency, bool recurse_flag=true)
 set active parallel configuration within the current low and high fidelity models identified by {low,high}FidelityKey
 
void derived_free_communicators (ParLevLIter pl_iter, int max_eval_concurrency, bool recurse_flag=true)
 deallocate communicator partitions for the HierarchSurrModel (request forwarded to the the array of ordered model fidelities)
 
void serve_run (ParLevLIter pl_iter, int max_eval_concurrency)
 Service the low and high fidelity model job requests received from the master; completes when termination message received from stop_servers().
 
void stop_servers ()
 Executed by the master to terminate the low and high fidelity model server operations when iteration on the HierarchSurrModel is complete.
 
void inactive_view (short view, bool recurse_flag=true)
 update the Model's inactive view based on higher level (nested) context and optionally recurse into
 
bool evaluation_cache (bool recurse_flag=true) const
 if recurse_flag, return true if orderedModels evaluation cache usage
 
bool restart_file (bool recurse_flag=true) const
 if recurse_flag, return true if orderedModels restart file usage
 
void set_evaluation_reference ()
 set the evaluation counter reference points for the HierarchSurrModel (request forwarded to the low and high fidelity models)
 
void fine_grained_evaluation_counters ()
 request fine-grained evaluation reporting within the low and high fidelity models
 
void print_evaluation_summary (std::ostream &s, bool minimal_header=false, bool relative_count=true) const
 print the evaluation summary for the HierarchSurrModel (request forwarded to the low and high fidelity models)
 
void warm_start_flag (const bool flag)
 set the warm start flag, including the orderedModels
 
- Protected Member Functions inherited from SurrogateModel
 SurrogateModel (ProblemDescDB &problem_db)
 constructor
 
 SurrogateModel (ProblemDescDB &problem_db, ParallelLibrary &parallel_lib, const SharedVariablesData &svd, bool share_svd, const SharedResponseData &srd, bool share_srd, const ActiveSet &set, short corr_type, short output_level)
 alternate constructor
 
 ~SurrogateModel ()
 destructor
 
Pecos::ProbabilityTransformation & probability_transformation ()
 return probability transformation employed by the Model (forwarded along to ProbabilityTransformModel recasting)
 
void activate_distribution_parameter_derivatives ()
 activate derivative setting w.r.t. distribution parameters
 
void deactivate_distribution_parameter_derivatives ()
 deactivate derivative setting w.r.t. distribution parameters
 
void trans_grad_X_to_U (const RealVector &fn_grad_x, RealVector &fn_grad_u, const RealVector &x_vars)
 transform x-space gradient vector to u-space
 
void trans_grad_U_to_X (const RealVector &fn_grad_u, RealVector &fn_grad_x, const RealVector &x_vars)
 transform u-space gradient vector to x-space
 
void trans_grad_X_to_S (const RealVector &fn_grad_x, RealVector &fn_grad_s, const RealVector &x_vars)
 transform x-space gradient vector to gradient with respect to inserted distribution parameters
 
void trans_hess_X_to_U (const RealSymMatrix &fn_hess_x, RealSymMatrix &fn_hess_u, const RealVector &x_vars, const RealVector &fn_grad_x)
 transform x-space Hessian matrix to u-space
 
Modelsubordinate_model ()
 return truth_model()
 
void active_model_key (const UShortArray &key)
 set the active multi-index key within surrogate data, grid driver, and approximation classes that support the management of multiple approximation states within surrogate models
 
short surrogate_response_mode () const
 return responseMode
 
int derived_evaluation_id () const
 return the current evaluation id for this Model More...
 
size_t mi_parallel_level_index () const
 return miPLIndex
 
virtual void asv_split (const ShortArray &orig_asv, ShortArray &actual_asv, ShortArray &approx_asv, bool build_flag)
 distributes the incoming orig_asv among actual_asv and approx_asv
 
void extract_model_keys (const UShortArray &active_key, UShortArray &truth_key, UShortArray &surr_key)
 define truth and surrogate keys from incoming active key
 
unsigned short surrogate_level_index () const
 return the level index from active low fidelity model key
 
unsigned short truth_level_index () const
 return the level index from active high fidelity model key
 
void check_key (int key1, int key2) const
 check for consistency in response map keys
 
bool force_rebuild ()
 evaluate whether a rebuild of the approximation should be forced based on changes in the inactive data More...
 
void asv_combine (const ShortArray &actual_asv, const ShortArray &approx_asv, ShortArray &combined_asv)
 reconstitutes a combined_asv from actual_asv and approx_asv
 
void response_combine (const Response &actual_response, const Response &approx_response, Response &combined_response)
 overlays actual_response and approx_response to update combined_response
 
void aggregate_response (const Response &hf_resp, const Response &lf_resp, Response &agg_resp)
 aggregate {HF,LF} response data to create a new response with 2x size
 
- Protected Member Functions inherited from Model
 Model (BaseConstructor, ProblemDescDB &problem_db)
 constructor initializing the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139) More...
 
 Model (LightWtBaseConstructor, ProblemDescDB &problem_db, ParallelLibrary &parallel_lib, const SharedVariablesData &svd, bool share_svd, const SharedResponseData &srd, bool share_srd, const ActiveSet &set, short output_level)
 constructor initializing base class for derived model class instances constructed on the fly
 
 Model (LightWtBaseConstructor, ProblemDescDB &problem_db, ParallelLibrary &parallel_lib)
 constructor initializing base class for recast model instances More...
 
void initialize_distribution (Pecos::MultivariateDistribution &mv_dist, bool active_only=false)
 initialize distribution types from problemDescDB More...
 
void initialize_distribution_parameters (Pecos::MultivariateDistribution &mv_dist, bool active_only=false)
 initialize distribution parameters from problemDescDB
 
void set_ie_asynchronous_mode (int max_eval_concurrency)
 default logic for defining asynchEvalFlag and evaluationCapacity based on ie_pl settings
 
void assign_max_strings (const Pecos::MultivariateDistribution &mv_dist, Variables &vars)
 assign all of the longest possible string values into vars
 
SSCIter max_string (const StringSet &ss)
 return iterator for longest string value found in string set
 
SRMCIter max_string (const StringRealMap &srm)
 return iterator for longest string value found in string map
 
SizetMultiArrayConstView initialize_x0_bounds (const SizetArray &original_dvv, bool &active_derivs, bool &inactive_derivs, RealVector &x0, RealVector &fd_lb, RealVector &fd_ub) const
 Initialize data needed for computing finite differences (active/inactive, center point, and bounds)
 
Real forward_grad_step (size_t num_deriv_vars, size_t xj_index, Real x0_j, Real lb_j, Real ub_j)
 Compute the forward step for a finite difference gradient; updates shortStep.
 
EvaluationsDBState evaluations_db_state (const Interface &interface)
 Return the interface flag for the EvaluationsDB state.
 
EvaluationsDBState evaluations_db_state (const Model &model)
 Return the model flag for the EvaluationsDB state.
 
void asynch_eval_store (const Interface &interface, const int &id, const Response &response)
 Store the response portion of an interface evaluation. Called from rekey_response_map.
 
void asynch_eval_store (const Model &model, const int &id, const Response &response)
 Exists to support storage of interface evaluations. No-op so that rekey_response_map<Model> can be generated.
 
template<typename MetaType >
void rekey_response_map (MetaType &meta_object, const IntResponseMap &resp_map, IntIntMap &id_map, IntResponseMap &resp_map_rekey, bool deep_copy_resp=false)
 rekey returned jobs matched in id_map into resp_map_rekey; unmatched jobs are cached within the meta_object
 
template<typename MetaType >
void rekey_synch (MetaType &meta_object, bool block, IntIntMap &id_map, IntResponseMap &resp_map_rekey, bool deep_copy_resp=false)
 synchronize via meta_object and rekey returned jobs matched in id_map into resp_map_rekey; unmatched jobs are cached within the meta_object
 

Private Member Functions

void key_updates (unsigned short model_index, unsigned short soln_lev_index)
 utility for propagating new key values
 
void check_model_interface_instance ()
 update sameInterfaceInstance based on interface ids for models identified by current {low,high}FidelityKey
 
void init_model (Model &model)
 update the passed model (one of the ordered models) with data that could change once per set of evaluations (e.g., an outer iterator execution), including active variable labels, inactive variable values/bounds/labels, and linear/nonlinear constraint coeffs/bounds
 
void update_model (Model &model)
 update the passed model (one of the ordered models) with data that could change per function evaluation (active variable values/bounds)
 
void update_from_model (Model &model)
 update currentVariables using non-active data from the passed model (one of the ordered models)
 
void derived_synchronize_sequential (IntResponseMap &hf_resp_map_rekey, IntResponseMap &lf_resp_map_rekey, bool block)
 called from derived_synchronize() and derived_synchronize_nowait() to extract and rekey response maps using blocking or nonblocking synchronization on the LF and HF models
 
void derived_synchronize_competing ()
 called from derived_synchronize() for case of distinct models/interfaces with competing LF/HF job queues
 
void derived_synchronize_combine (const IntResponseMap &hf_resp_map, IntResponseMap &lf_resp_map, IntResponseMap &combined_resp_map)
 combine the HF and LF response maps into a combined response map
 
void derived_synchronize_combine_nowait (const IntResponseMap &hf_resp_map, IntResponseMap &lf_resp_map, IntResponseMap &combined_resp_map)
 combine the available components from HF and LF response maps into a combined response map
 
void resize_response (bool use_virtual_counts=true)
 resize currentResponse based on responseMode
 
void compute_apply_delta (IntResponseMap &lf_resp_map)
 helper function used in the AUTO_CORRECTED_SURROGATE responseMode for computing a correction and applying it to lf_resp_map
 
void single_apply (const Variables &vars, Response &resp, const UShortArray &paired_key)
 helper function for applying a single response correction corresponding to deltaCorr[paired_key]
 
void recursive_apply (const Variables &vars, Response &resp)
 helper function for applying a correction across a sequence of model forms or discretization levels
 
void stop_model (size_t ordered_model_index)
 stop the servers for the orderedModels instance identified by the passed index
 

Private Attributes

std::map< UShortArray,
DiscrepancyCorrection
deltaCorr
 manages construction and application of correction functions that are applied to a surrogate model (DataFitSurr or HierarchSurr) in order to reproduce high fidelity data.
 
short corrOrder
 order of correction: 0, 1, or 2
 
unsigned short correctionMode
 
ModelArray orderedModels
 Ordered sequence (low to high) of model fidelities. Models are of arbitrary type and supports recursions.
 
bool sameModelInstance
 flag indicating that the {low,high}FidelityKey correspond to the same model instance, requiring modifications to updating and evaluation scheduling processes
 
bool sameInterfaceInstance
 flag indicating that the models identified by {low,high}FidelityKey employ the same interface instance, requiring modifications to evaluation scheduling processes
 
UShortArray componentParallelKey
 store {LF,HF} model key that is active in component_parallel_mode()
 
std::map< UShortArray, ResponsetruthResponseRef
 map of reference truth (high fidelity) responses computed in build_approximation() and used for calculating corrections
 
IntResponseMap cachedTruthRespMap
 map of truth (high-fidelity) responses retrieved in derived_synchronize_nowait() that could not be returned since corresponding low-fidelity response portions were still pending
 

Additional Inherited Members

- Static Public Member Functions inherited from Model
static void active_variables (const RealVector &config_vars, Model &model)
 set the specified configuration to the Model's inactive vars, converting from real to integer or through index to string value as needed More...
 
static void inactive_variables (const RealVector &config_vars, Model &model)
 set the specified configuration to the Model's inactive vars, converting from real to integer or through index to string value as needed More...
 
static void inactive_variables (const RealVector &config_vars, Model &model, Variables &updated_vars)
 
static void evaluate (const RealMatrix &samples_matrix, Model &model, RealMatrix &resp_matrix)
 Bulk synchronously evaluate the model for each column in the samples matrix and return as columns of the response matrix.
 
- Static Protected Member Functions inherited from Model
static String user_auto_id ()
 return the next available model ID for no-ID user methods More...
 
static String no_spec_id ()
 return the next available model ID for on-the-fly methods More...
 
- Protected Attributes inherited from SurrogateModel
IntSet surrogateFnIndices
 for mixed response sets, this array specifies the response function subset that is approximated
 
short responseMode
 an enumeration that controls the response calculation mode in {DataFit,Hierarch}SurrModel approximate response computations More...
 
UShortArray activeKey
 array of indices that identify the currently active model key
 
UShortArray surrModelKey
 array of indices that identify the surrogate (e.g., low fidelity) model (trailing portion of activeKey, if aggregated models)
 
UShortArray truthModelKey
 array of indices that identify the truth (e.g., high fidelity) model (leading portion of activeKey, if aggregated models)
 
short corrType
 type of correction: additive, multiplicative, or combined
 
IntIntMap truthIdMap
 map from actualModel/highFidelityModel evaluation ids to DataFitSurrModel/HierarchSurrModel ids
 
IntIntMap surrIdMap
 map from approxInterface/lowFidelityModel evaluation ids to DataFitSurrModel/HierarchSurrModel ids
 
int surrModelEvalCntr
 counter for calls to derived_evaluate()/derived_evaluate_nowait(); used to key response maps from SurrogateModels
 
IntResponseMap surrResponseMap
 map of surrogate responses returned by derived_synchronize() and derived_synchronize_nowait()
 
IntResponseMap cachedApproxRespMap
 map of approximate responses retrieved in derived_synchronize_nowait() that could not be returned since corresponding truth model response portions were still pending.
 
IntVariablesMap rawVarsMap
 map of raw continuous variables used by apply_correction(). Model::varsList cannot be used for this purpose since it does not contain lower level variables sets from finite differencing.
 
size_t approxBuilds
 number of calls to build_approximation() More...
 
size_t miPLIndex
 the index of the active metaiterator-iterator parallelism level (corresponding to ParallelConfiguration::miPLIters) used at runtime
 
RealVector referenceCLBnds
 stores a reference copy of active continuous lower bounds when the approximation is built; used to detect when a rebuild is required.
 
RealVector referenceCUBnds
 stores a reference copy of active continuous upper bounds when the approximation is built; used to detect when a rebuild is required.
 
IntVector referenceDILBnds
 stores a reference copy of active discrete int lower bounds when the approximation is built; used to detect when a rebuild is required.
 
IntVector referenceDIUBnds
 stores a reference copy of active discrete int upper bounds when the approximation is built; used to detect when a rebuild is required.
 
RealVector referenceDRLBnds
 stores a reference copy of active discrete real lower bounds when the approximation is built; used to detect when a rebuild is required.
 
RealVector referenceDRUBnds
 stores a reference copy of active discrete real upper bounds when the approximation is built; used to detect when a rebuild is required.
 
RealVector referenceICVars
 stores a reference copy of the inactive continuous variables when the approximation is built using a Distinct view; used to detect when a rebuild is required.
 
IntVector referenceIDIVars
 stores a reference copy of the inactive discrete int variables when the approximation is built using a Distinct view; used to detect when a rebuild is required.
 
StringMultiArray referenceIDSVars
 stores a reference copy of the inactive discrete string variables when the approximation is built using a Distinct view; used to detect when a rebuild is required.
 
RealVector referenceIDRVars
 stores a reference copy of the inactive discrete real variables when the approximation is built using a Distinct view; used to detect when a rebuild is required.
 

Detailed Description

Derived model class within the surrogate model branch for managing hierarchical surrogates (models of varying fidelity).

The HierarchSurrModel class manages hierarchical models of varying fidelity. The class contains an ordered array of model forms (fidelity ordered from low to high), where each model form may also contain a set of solution levels (space/time discretization, convergence tolerances, etc.). At run time, one of these combinations is activated as the low fidelity model and used to perform approximate function evaluations, while another of these combinations is activated as the high fidelity model and used to provide truth evaluations for computing corrections to the low fidelity results.

Member Function Documentation

bool initialize_mapping ( ParLevLIter  pl_iter)
protectedvirtual

Inactive variables must be propagated when a HierarchSurrModel is employed by a sub-iterator (e.g., OUU with MLMC or MLPCE). In current use cases, this can occur once per sub-iterator execution within Model::initialize_mapping().

Reimplemented from Model.

References HierarchSurrModel::init_model(), Model::initialize_mapping(), and HierarchSurrModel::orderedModels.

bool finalize_mapping ( )
protectedvirtual

Inactive variables must be propagated when a HierarchSurrModel is employed by a sub-iterator (e.g., OUU with MLMC or MLPCE). In current use cases, this can occur once per sub-iterator execution within Model::initialize_mapping().

Reimplemented from Model.

References Model::finalize_mapping(), and HierarchSurrModel::orderedModels.

void derived_evaluate ( const ActiveSet set)
protectedvirtual
void derived_evaluate_nowait ( const ActiveSet set)
protectedvirtual
const IntResponseMap & derived_synchronize ( )
protectedvirtual

Blocking retrieval of asynchronous evaluations from LF model, HF model, or both (mixed case). For the LF model portion, apply correction (if active) to each response in the array. derived_synchronize() is designed for the general case where derived_evaluate_nowait() may be inconsistent in its use of low fidelity evaluations, high fidelity evaluations, or both.

Reimplemented from Model.

References HierarchSurrModel::derived_synchronize_combine(), HierarchSurrModel::derived_synchronize_competing(), HierarchSurrModel::derived_synchronize_sequential(), HierarchSurrModel::sameInterfaceInstance, HierarchSurrModel::sameModelInstance, SurrogateModel::surrIdMap, SurrogateModel::surrResponseMap, and SurrogateModel::truthIdMap.

const IntResponseMap & derived_synchronize_nowait ( )
protectedvirtual

Nonblocking retrieval of asynchronous evaluations from LF model, HF model, or both (mixed case). For the LF model portion, apply correction (if active) to each response in the map. derived_synchronize_nowait() is designed for the general case where derived_evaluate_nowait() may be inconsistent in its use of actual evals, approx evals, or both.

Reimplemented from Model.

References HierarchSurrModel::derived_synchronize_combine_nowait(), HierarchSurrModel::derived_synchronize_sequential(), and SurrogateModel::surrResponseMap.

Referenced by HierarchSurrModel::derived_synchronize_competing().


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