Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
NestedModel Class Reference

Derived model class which performs a complete sub-iterator execution within every evaluation of the model. More...

Inheritance diagram for NestedModel:
Model

List of all members.

Public Member Functions

 NestedModel (ProblemDescDB &problem_db)
 constructor
 ~NestedModel ()
 destructor

Protected Member Functions

void derived_compute_response (const ActiveSet &set)
 portion of compute_response() specific to NestedModel
void derived_asynch_compute_response (const ActiveSet &set)
 portion of asynch_compute_response() specific to NestedModel
Iteratorsubordinate_iterator ()
 return subIterator
Modelsubordinate_model ()
 return subModel
void derived_subordinate_models (ModelList &ml, bool recurse_flag)
 return subModel
Interfaceinterface ()
 return optionalInterface
void surrogate_response_mode (bool mode)
 pass a bypass request on to the subModel for any lower-level surrogates
void component_parallel_mode (short mode)
 update component parallel mode for supporting parallelism in optionalInterface and subModel
bool derived_master_overload () const
 flag which prevents overloading the master with a multiprocessor evaluation (forwarded to optionalInterface)
void derived_init_communicators (const int &max_iterator_concurrency, bool recurse_flag=true)
 set up optionalInterface and subModel for parallel operations
void derived_init_serial ()
 set up optionalInterface and subModel for serial operations.
void derived_set_communicators (const int &max_iterator_concurrency, bool recurse_flag=true)
 set active parallel configuration within subModel
void derived_free_communicators (const int &max_iterator_concurrency, bool recurse_flag=true)
 deallocate communicator partitions for the NestedModel (forwarded to optionalInterface and subModel)
void serve ()
 Service optionalInterface and subModel job requests received from the master. Completes when a termination message is received from stop_servers().
void stop_servers ()
 Executed by the master to terminate server operations for subModel and optionalInterface when iteration on the NestedModel is complete.
const Stringinterface_id () const
 return the optionalInterface identifier
int evaluation_id () const
 Return the current evaluation id for the NestedModel.
void set_evaluation_reference ()
 set the evaluation counter reference points for the NestedModel (request forwarded to optionalInterface and subModel)
void fine_grained_evaluation_counters ()
 request fine-grained evaluation reporting within optionalInterface and subModel
void print_evaluation_summary (std::ostream &s, bool minimal_header=false, bool relative_count=true) const
 print the evaluation summary for the NestedModel (request forwarded to optionalInterface and subModel)

Private Member Functions

void resolve_real_variable_mapping (const String &map1, const String &map2, size_t curr_index, short &inactive_sm_view)
 for a named real mapping, resolve primary index and secondary target
void resolve_integer_variable_mapping (const String &map1, const String &map2, size_t curr_index, short &inactive_sm_view)
 for a named integer mapping, resolve primary index and secondary target
size_t sm_acv_index_map (size_t pacvm_index, short sacvm_target)
 offset pacvm_index based on sacvm_target to create mapped_index
size_t sm_adiv_index_map (size_t padivm_index, short sadivm_target)
 offset padivm_index based on sadivm_target to create mapped_index
size_t sm_adrv_index_map (size_t padrvm_index, short sadrvm_target)
 offset padrvm_index based on sadrvm_target to create mapped_index
size_t cv_index_map (size_t cv_index)
 offset cv_index to create index into aggregated primary/secondary arrays
size_t div_index_map (size_t div_index)
 offset div_index to create index into aggregated primary/secondary arrays
size_t drv_index_map (size_t drv_index)
 offset drv_index to create index into aggregated primary/secondary arrays
size_t ccv_index_map (size_t ccv_index)
 offset active complement ccv_index to create index into all continuous arrays
size_t cdiv_index_map (size_t cdiv_index)
 offset active complement cdiv_index to create index into all discrete int arrays
size_t cdrv_index_map (size_t cdrv_index)
 offset active complement cdrv_index to create index into all discrete real arrays
void real_variable_mapping (const Real &r_var, size_t mapped_index, short svm_target)
 insert r_var into appropriate recipient
void integer_variable_mapping (const int &i_var, size_t mapped_index, short svm_target)
 insert i_var into appropriate recipient
void set_mapping (const ActiveSet &mapped_set, ActiveSet &interface_set, bool &opt_interface_map, ActiveSet &sub_iterator_set, bool &sub_iterator_map)
 define the evaluation requirements for the optionalInterface (interface_set) and the subIterator (sub_iterator_set) from the total model evaluation requirements (mapped_set)
void response_mapping (const Response &interface_response, const Response &sub_iterator_response, Response &mapped_response)
 combine the response from the optional interface evaluation with the response from the sub-iteration using the primaryCoeffs/secondaryCoeffs mappings to create the total response for the model
void update_inactive_view (short new_view, short &view)
 update inactive variables view for subIterator based on new_view
void update_inactive_view (unsigned short type, short &view)
 update inactive variables view for subIterator based on type
void update_sub_model ()
 update subModel with current variable values/bounds/labels

Private Attributes

int nestedModelEvalCntr
 number of calls to derived_compute_response()/ derived_asynch_compute_response()
Iterator subIterator
 the sub-iterator that is executed on every evaluation of this model
Model subModel
 the sub-model used in sub-iterator evaluations
size_t numSubIterFns
 number of sub-iterator response functions prior to mapping
size_t numSubIterMappedIneqCon
 number of top-level inequality constraints mapped from the sub-iteration results
size_t numSubIterMappedEqCon
 number of top-level equality constraints mapped from the sub-iteration results
Interface optionalInterface
 the optional interface contributes nonnested response data to the total model response
String optInterfacePointer
 the optional interface pointer from the nested model specification
Response optInterfaceResponse
 the response object resulting from optional interface evaluations
size_t numOptInterfPrimary
 number of primary response functions (objective/least squares/generic functions) resulting from optional interface evaluations
size_t numOptInterfIneqCon
 number of inequality constraints resulting from optional interface evaluations
size_t numOptInterfEqCon
 number of equality constraints resulting from the optional interface evaluations
SizetArray active1ACVarMapIndices
 "primary" variable mappings for inserting active continuous currentVariables within all continuous subModel variables. If there are no secondary mappings defined, then the insertions replace the subModel variable values.
SizetArray active1ADIVarMapIndices
 "primary" variable mappings for inserting active discrete int currentVariables within all discrete int subModel variables. No secondary mappings are defined for discrete int variables, so the insertions replace the subModel variable values.
SizetArray active1ADRVarMapIndices
 "primary" variable mappings for inserting active discrete real currentVariables within all discrete real subModel variables. No secondary mappings are defined for discrete real variables, so the insertions replace the subModel variable values.
ShortArray active2ACVarMapTargets
 "secondary" variable mappings for inserting active continuous currentVariables into sub-parameters (e.g., distribution parameters for uncertain variables or bounds for continuous design/state variables) within all continuous subModel variables.
ShortArray active2ADIVarMapTargets
 "secondary" variable mappings for inserting active discrete int currentVariables into sub-parameters (e.g., bounds for discrete design/state variables) within all discrete int subModel variables.
ShortArray active2ADRVarMapTargets
 "secondary" variable mappings for inserting active discrete real currentVariables into sub-parameters (e.g., bounds for discrete design/state variables) within all discrete real subModel variables.
SizetArray complement1ACVarMapIndices
 "primary" variable mappings for inserting the complement of the active continuous currentVariables within all continuous subModel variables
SizetArray complement1ADIVarMapIndices
 "primary" variable mappings for inserting the complement of the active discrete int currentVariables within all discrete int subModel variables
SizetArray complement1ADRVarMapIndices
 "primary" variable mappings for inserting the complement of the active discrete real currentVariables within all discrete real subModel variables
BoolDeque extraCVarsData
 flags for updating subModel continuous bounds and labels, one for each active continuous variable in currentVariables
BoolDeque extraDIVarsData
 flags for updating subModel discrete int bounds and labels, one for each active discrete int variable in currentVariables
BoolDeque extraDRVarsData
 flags for updating subModel discrete real bounds and labels, one for each active discrete real variable in currentVariables
RealMatrix primaryRespCoeffs
 "primary" response_mapping matrix applied to the sub-iterator response functions. For OUU, the matrix is applied to UQ statistics to create contributions to the top-level objective functions/least squares/ generic response terms.
RealMatrix secondaryRespCoeffs
 "secondary" response_mapping matrix applied to the sub-iterator response functions. For OUU, the matrix is applied to UQ statistics to create contributions to the top-level inequality and equality constraints.

Detailed Description

Derived model class which performs a complete sub-iterator execution within every evaluation of the model.

The NestedModel class nests a sub-iterator execution within every model evaluation. This capability is most commonly used for optimization under uncertainty, in which a nondeterministic iterator is executed on every optimization function evaluation. The NestedModel also contains an optional interface, for portions of the model evaluation which are independent from the sub-iterator, and a set of mappings for combining sub-iterator and optional interface data into a top level response for the model.


Member Function Documentation

void derived_compute_response ( const ActiveSet set) [protected, virtual]
void derived_asynch_compute_response ( const ActiveSet set) [protected, virtual]
bool derived_master_overload ( ) const [inline, protected, virtual]

flag which prevents overloading the master with a multiprocessor evaluation (forwarded to optionalInterface)

Derived master overload for subModel is handled separately in subModel.compute_response() within subIterator.run().

Reimplemented from Model.

References Interface::iterator_eval_dedicated_master_flag(), Interface::multi_proc_eval_flag(), NestedModel::optInterfacePointer, and NestedModel::optionalInterface.

void derived_init_communicators ( const int &  max_iterator_concurrency,
bool  recurse_flag = true 
) [inline, protected, virtual]

set up optionalInterface and subModel for parallel operations

Asynchronous flags need to be initialized for the subModel. In addition, max_iterator_concurrency is the outer level iterator concurrency, not the subIterator concurrency that subModel will see, and recomputing the message_lengths on the subModel is probably not a bad idea either. Therefore, recompute everything on subModel using init_communicators().

Reimplemented from Model.

References Interface::init_communicators(), Model::init_communicators(), Iterator::maximum_concurrency(), Model::messageLengths, NestedModel::optInterfacePointer, NestedModel::optionalInterface, NestedModel::subIterator, and NestedModel::subModel.

int evaluation_id ( ) const [inline, protected, virtual]

Return the current evaluation id for the NestedModel.

return the top level nested evaluation count. To get the lower level eval count, the subModel must be explicitly queried. This is consistent with the eval counter definitions in surrogate models.

Reimplemented from Model.

References NestedModel::nestedModelEvalCntr.

size_t cv_index_map ( size_t  cv_index) [private]

offset cv_index to create index into aggregated primary/secondary arrays

maps index within active continuous variables to index within aggregated active continuous/discrete-int/discrete-real variables.

References Model::currentVariables, Variables::variables_components_totals(), and Variables::view().

Referenced by NestedModel::NestedModel(), and NestedModel::update_sub_model().

size_t div_index_map ( size_t  div_index) [private]

offset div_index to create index into aggregated primary/secondary arrays

maps index within active discrete int variables to index within aggregated active continuous/discrete-int/discrete-real variables.

References Model::currentVariables, Variables::cv(), Variables::variables_components_totals(), and Variables::view().

Referenced by NestedModel::NestedModel(), and NestedModel::update_sub_model().

size_t drv_index_map ( size_t  drv_index) [private]

offset drv_index to create index into aggregated primary/secondary arrays

maps index within active discrete real variables to index within aggregated active continuous/discrete-int/discrete-real variables.

References Model::currentVariables, Variables::cv(), Variables::div(), Variables::variables_components_totals(), and Variables::view().

Referenced by NestedModel::NestedModel(), and NestedModel::update_sub_model().

size_t ccv_index_map ( size_t  ccv_index) [private]

offset active complement ccv_index to create index into all continuous arrays

maps index within complement of active continuous variables to index within all continuous variables.

References Dakota::abort_handler(), Model::currentVariables, Variables::variables_components_totals(), and Variables::view().

Referenced by NestedModel::NestedModel(), and NestedModel::update_sub_model().

size_t cdiv_index_map ( size_t  cdiv_index) [private]

offset active complement cdiv_index to create index into all discrete int arrays

maps index within complement of active discrete int variables to index within all discrete int variables.

References Dakota::abort_handler(), Model::currentVariables, Variables::variables_components_totals(), and Variables::view().

Referenced by NestedModel::NestedModel(), and NestedModel::update_sub_model().

size_t cdrv_index_map ( size_t  cdrv_index) [private]

offset active complement cdrv_index to create index into all discrete real arrays

maps index within complement of active discrete real variables to index within all discrete real variables.

References Dakota::abort_handler(), Model::currentVariables, Variables::variables_components_totals(), and Variables::view().

Referenced by NestedModel::NestedModel(), and NestedModel::update_sub_model().

void response_mapping ( const Response opt_interface_response,
const Response sub_iterator_response,
Response mapped_response 
) [private]

combine the response from the optional interface evaluation with the response from the sub-iteration using the primaryCoeffs/secondaryCoeffs mappings to create the total response for the model

In the OUU case,

optionalInterface fns = {f}, {g} (deterministic primary functions, constraints)
subIterator fns       = {S}      (UQ response statistics)

Problem formulation for mapped functions:
                  minimize    {f} + [W]{S}
                  subject to  {g_l} <= {g}    <= {g_u}
                              {a_l} <= [A]{S} <= {a_u}
                              {g}    == {g_t}
                              [A]{S} == {a_t}

where [W] is the primary_mapping_matrix user input (primaryRespCoeffs class attribute), [A] is the secondary_mapping_matrix user input (secondaryRespCoeffs class attribute), {{g_l},{a_l}} are the top level inequality constraint lower bounds, {{g_u},{a_u}} are the top level inequality constraint upper bounds, and {{g_t},{a_t}} are the top level equality constraint targets.

NOTE: optionalInterface/subIterator primary fns (obj/lsq/generic fns) overlap but optionalInterface/subIterator secondary fns (ineq/eq constraints) do not. The [W] matrix can be specified so as to allow

  • some purely deterministic primary functions and some combined: [W] filled and [W].num_rows() < {f}.length() [combined first] or [W].num_rows() == {f}.length() and [W] contains rows of zeros [combined last]
  • some combined and some purely stochastic primary functions: [W] filled and [W].num_rows() > {f}.length()
  • separate deterministic and stochastic primary functions: [W].num_rows() > {f}.length() and [W] contains {f}.length() rows of zeros.

If the need arises, could change constraint definition to allow overlap as well: {g_l} <= {g} + [A]{S} <= {g_u} with [A] usage the same as for [W] above.

In the UOO case, things are simpler, just compute statistics of each optimization response function: [W] = [I], {f}/{g}/[A] are empty.

References Dakota::abort_handler(), Response::active_set_derivative_vector(), Response::active_set_request_vector(), Dakota::copy_data(), Response::function_gradient(), Response::function_gradient_view(), Response::function_gradients(), Response::function_hessian(), Response::function_hessian_view(), Response::function_hessians(), Response::function_value(), Response::function_values(), Response::function_values_view(), Response::num_functions(), NestedModel::numOptInterfEqCon, NestedModel::numOptInterfIneqCon, NestedModel::numOptInterfPrimary, NestedModel::numSubIterFns, NestedModel::numSubIterMappedEqCon, NestedModel::numSubIterMappedIneqCon, NestedModel::optInterfacePointer, NestedModel::primaryRespCoeffs, Response::reset_inactive(), and NestedModel::secondaryRespCoeffs.

Referenced by NestedModel::derived_compute_response().


Member Data Documentation

Model subModel [private]

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