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

Base class for the iterator class hierarchy. More...

Inheritance diagram for Iterator:
Analyzer Minimizer NonD PStudyDACE Verification LeastSq Optimizer SurrBasedMinimizer NonDCalibration NonDExpansion NonDIntegration NonDInterval NonDReliability NonDSampling DDACEDesignCompExp FSUDesignCompExp ParamStudy PSUADEDesignCompExp RichExtrapVerification NL2SOLLeastSq NLSSOLLeastSq SNLLLeastSq APPSOptimizer COLINOptimizer CONMINOptimizer DOTOptimizer JEGAOptimizer NCSUOptimizer NLPQLPOptimizer NPSOLOptimizer SNLLOptimizer EffGlobalMinimizer SurrBasedGlobalMinimizer SurrBasedLocalMinimizer

List of all members.

Public Member Functions

 Iterator ()
 default constructor
 Iterator (Model &model)
 standard envelope constructor
 Iterator (const String &method_name, Model &model)
 alternate envelope constructor for instantiations by name
 Iterator (const Iterator &iterator)
 copy constructor
virtual ~Iterator ()
 destructor
Iterator operator= (const Iterator &iterator)
 assignment operator
virtual void initialize_run ()
 utility function to perform common operations prior to pre_run(); typically memory initialization; setting of instance pointers
virtual void pre_run ()
 pre-run portion of run_iterator (optional); re-implemented by Iterators which can generate all Variables (parameter sets) a priori
virtual void run ()
 run portion of run_iterator; implemented by all derived classes and may include pre/post steps in lieu of separate pre/post
virtual void post_run (std::ostream &s)
 post-run portion of run_iterator (optional); verbose to print results; re-implemented by Iterators that can read all Variables/Responses and perform final analysis phase in a standalone way
virtual void finalize_run ()
 utility function to perform common operations following post_run(); deallocation and resetting of instance pointers
virtual void reset ()
 restore initial state for repeated sub-iterator executions
virtual const Variablesvariables_results () const
 return a single final iterator solution (variables)
virtual const Responseresponse_results () const
 return a single final iterator solution (response)
virtual const VariablesArray & variables_array_results ()
 return multiple final iterator solutions (variables). This should only be used if returns_multiple_points() returns true.
virtual const ResponseArray & response_array_results ()
 return multiple final iterator solutions (response). This should only be used if returns_multiple_points() returns true.
virtual bool accepts_multiple_points () const
 indicates if this iterator accepts multiple initial points. Default return is false. Override to return true if appropriate.
virtual bool returns_multiple_points () const
 indicates if this iterator returns multiple final points. Default return is false. Override to return true if appropriate.
virtual void initial_points (const VariablesArray &pts)
 sets the multiple initial points for this iterator. This should only be used if accepts_multiple_points() returns true.
virtual void response_results_active_set (const ActiveSet &set)
 set the requested data for the final iterator response results
virtual void initialize_graphics (bool graph_2d, bool tabular_data, const String &tabular_file)
 initialize the 2D graphics window and the tabular graphics data
virtual void print_results (std::ostream &s)
 print the final iterator results
virtual int num_samples () const
 get the current number of samples
virtual void sampling_reset (int min_samples, bool all_data_flag, bool stats_flag)
 reset sampling iterator to use at least min_samples
virtual const Stringsampling_scheme () const
 return sampling name
virtual const Modelalgorithm_space_model () const
 return the result of any recasting or surrogate model recursion layered on top of iteratedModel by the derived Iterator ctor chain
virtual String uses_method () const
 return name of any enabling iterator used by this iterator
virtual void method_recourse ()
 perform a method switch, if possible, due to a detected conflict
virtual const VariablesArray & all_variables ()
 return the complete set of evaluated variables
virtual const RealMatrix & all_samples ()
 return the complete set of evaluated samples
virtual const IntResponseMap & all_responses () const
 return the complete set of computed responses
virtual bool compact_mode () const
 returns Analyzer::compactMode
void run_iterator (std::ostream &s)
 orchestrate initialize/pre/run/post/finalize phases
void assign_rep (Iterator *iterator_rep, bool ref_count_incr=true)
 replaces existing letter with a new one
ProblemDescDBproblem_description_db () const
 return the problem description database (probDescDB)
const Stringmethod_name () const
 return the method name
const Stringmethod_id () const
 return the method identifier (methodId)
void output_level (short out_lev)
 set the method output level (outputLevel)
short output_level () const
 return the method output level (outputLevel)
void summary_output (bool summary_output_flag)
 Set summary output control; true enables evaluation/results summary.
int maximum_concurrency () const
 return the maximum concurrency supported by the iterator
void maximum_concurrency (int max_conc)
 set the maximum concurrency supported by the iterator
size_t num_final_solutions () const
 return the number of solutions to retain in best variables/response arrays
void num_final_solutions (size_t num_final)
 set the number of solutions to retain in best variables/response arrays
void active_set (const ActiveSet &set)
 set the default active set vector (for use with iterators that employ evaluate_parameter_sets())
const ActiveSetactive_set () const
 return the default active set vector (used by iterators that employ evaluate_parameter_sets())
void sub_iterator_flag (bool si_flag)
 set subIteratorFlag (and update summaryOutputFlag if needed)
void active_variable_mappings (const SizetArray &c_index1, const SizetArray &di_index1, const SizetArray &dr_index1, const ShortArray &c_target2, const ShortArray &di_target2, const ShortArray &dr_target2)
 set primaryA{CV,DIV,DRV}MapIndices, secondaryA{CV,DIV,DRV}MapTargets
bool is_null () const
 function to check iteratorRep (does this envelope contain a letter?)
Iteratoriterator_rep () const
 returns iteratorRep for access to derived class member functions that are not mapped to the top Iterator level

Protected Member Functions

 Iterator (BaseConstructor, Model &model)
 constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139)
 Iterator (NoDBBaseConstructor, Model &model)
 alternate constructor for base iterator classes constructed on the fly
 Iterator (NoDBBaseConstructor)
 alternate constructor for base iterator classes constructed on the fly
virtual const VariablesArray & initial_points () const
 gets the multiple initial points for this iterator. This will only be meaningful after a call to initial_points mutator.

Protected Attributes

Model iteratedModel
 shallow copy of the model passed into the constructor or a thin RecastModel wrapped around it
ProblemDescDBprobDescDB
 class member reference to the problem description database
String methodName
 name of the iterator (the user's method spec)
Real convergenceTol
 iteration convergence tolerance
int maxIterations
 maximum number of iterations for the iterator
int maxFunctionEvals
 maximum number of fn evaluations for the iterator
int maxConcurrency
 maximum coarse-grained concurrency
size_t numFunctions
 number of response functions
size_t numContinuousVars
 number of active continuous vars
size_t numDiscreteIntVars
 number of active discrete integer vars
size_t numDiscreteRealVars
 number of active discrete real vars
size_t numFinalSolutions
 number of solutions to retain in best variables/response arrays
ActiveSet activeSet
 tracks the response data requirements on each function evaluation
VariablesArray bestVariablesArray
 collection of N best solution variables found during the study
ResponseArray bestResponseArray
 collection of N best solution responses found during the study
bool subIteratorFlag
 flag indicating if this Iterator is a sub-iterator (NestedModel::subIterator or DataFitSurrModel::daceIterator)
SizetArray primaryACVarMapIndices
 "primary" all continuous variable mapping indices flowed down from higher level iteration
SizetArray primaryADIVarMapIndices
 "primary" all discrete int variable mapping indices flowed down from higher level iteration
SizetArray primaryADRVarMapIndices
 "primary" all discrete real variable mapping indices flowed down from higher level iteration
ShortArray secondaryACVarMapTargets
 "secondary" all continuous variable mapping targets flowed down from higher level iteration
ShortArray secondaryADIVarMapTargets
 "secondary" all discrete int variable mapping targets flowed down from higher level iteration
ShortArray secondaryADRVarMapTargets
 "secondary" all discrete real variable mapping targets flowed down from higher level iteration
String gradientType
 type of gradient data: analytic, numerical, mixed, or none
String methodSource
 source of numerical gradient routine: dakota or vendor
String intervalType
 type of numerical gradient interval: central or forward
String hessianType
 type of Hessian data: analytic, numerical, quasi, mixed, or none
Real fdGradStepSize
 relative finite difference step size for numerical gradients
Real fdHessByGradStepSize
 relative finite difference step size for numerical Hessians estimated using first-order differences of gradients
Real fdHessByFnStepSize
 relative finite difference step size for numerical Hessians estimated using second-order differences of function values
short outputLevel
 output verbosity level: {SILENT,QUIET,NORMAL,VERBOSE,DEBUG}_OUTPUT
bool summaryOutputFlag
 flag for summary output (evaluation stats, final results); default true, but false for on-the-fly (helper) iterators and sub-iterator use cases
bool asynchFlag
 copy of the model's asynchronous evaluation flag
int writePrecision
 write precision as specified by the user

Private Member Functions

Iteratorget_iterator (Model &model)
 Used by the envelope to instantiate the correct letter class.
Iteratorget_iterator (const String &method_name, Model &model)
 Used by the envelope to instantiate the correct letter class.
virtual void pre_output ()
 convenience function to write variables to file, following pre-run
virtual void post_input ()
 read tabular data for post-run mode

Private Attributes

String methodId
 method identifier string from the input file
IteratoriteratorRep
 pointer to the letter (initialized only for the envelope)
int referenceCount
 number of objects sharing iteratorRep

Detailed Description

Base class for the iterator class hierarchy.

The Iterator class is the base class for one of the primary class hierarchies in DAKOTA. The iterator hierarchy contains all of the iterative algorithms which use repeated execution of simulations as function evaluations. For memory efficiency and enhanced polymorphism, the iterator hierarchy employs the "letter/envelope idiom" (see Coplien "Advanced C++", p. 133), for which the base class (Iterator) serves as the envelope and one of the derived classes (selected in Iterator::get_iterator()) serves as the letter.


Constructor & Destructor Documentation

Iterator ( )

default constructor

The default constructor is used in Vector<Iterator> instantiations and for initialization of Iterator objects contained in Strategy derived classes (see derived class header files). iteratorRep is NULL in this case (a populated problem_db is needed to build a meaningful Iterator object). This makes it necessary to check for NULL pointers in the copy constructor, assignment operator, and destructor.

Referenced by SurrBasedGlobalMinimizer::SurrBasedGlobalMinimizer(), and SurrBasedLocalMinimizer::SurrBasedLocalMinimizer().

Iterator ( Model model)

standard envelope constructor

Used in iterator instantiations within strategy constructors. Envelope constructor only needs to extract enough data to properly execute get_iterator(), since letter holds the actual base class data.

References Dakota::abort_handler(), Iterator::get_iterator(), and Iterator::iteratorRep.

Iterator ( const String method_name,
Model model 
)

alternate envelope constructor for instantiations by name

Used in sub-iterator instantiations within iterator constructors. Envelope constructor only needs to extract enough data to properly execute get_iterator(), since letter holds the actual base class data.

References Dakota::abort_handler(), Iterator::get_iterator(), and Iterator::iteratorRep.

Iterator ( const Iterator iterator)

copy constructor

Copy constructor manages sharing of iteratorRep and incrementing of referenceCount.

References Iterator::iteratorRep, and Iterator::referenceCount.

~Iterator ( ) [virtual]

destructor

Destructor decrements referenceCount and only deletes iteratorRep when referenceCount reaches zero.

References Iterator::iteratorRep, and Iterator::referenceCount.

Iterator ( BaseConstructor  ,
Model model 
) [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 builds the base class data for all inherited iterators. get_iterator() instantiates a derived class and the derived class selects this base class constructor in its initialization list (to avoid the recursion of the base class constructor calling get_iterator() again). Since the letter IS the representation, its representation pointer is set to NULL (an uninitialized pointer causes problems in ~Iterator).

References Dakota::abort_handler(), Iterator::fdGradStepSize, Iterator::fdHessByFnStepSize, Iterator::fdHessByGradStepSize, ProblemDescDB::get_dil(), ProblemDescDB::get_rdv(), Iterator::gradientType, Iterator::hessianType, Iterator::intervalType, Iterator::methodName, Iterator::methodSource, Iterator::numContinuousVars, Iterator::numDiscreteIntVars, Iterator::numDiscreteRealVars, Iterator::numFunctions, and Iterator::probDescDB.

Iterator ( NoDBBaseConstructor  ,
Model model 
) [protected]

alternate constructor for base iterator classes constructed on the fly

This alternate constructor builds base class data for inherited iterators. It is used for on-the-fly instantiations for which DB queries cannot be used. Therefore it only sets attributes taken from the incoming model. Since there are no iterator-specific redefinitions of maxIterations or numFinalSolutions in NoDBBaseConstructor mode, go ahead and assign default value for all iterators.

Iterator ( NoDBBaseConstructor  ) [protected]

alternate constructor for base iterator classes constructed on the fly

This alternate constructor builds base class data for inherited iterators. It is used for on-the-fly instantiations for which DB queries cannot be used. It has no incoming model, so only sets up a minimal set of defaults. However, its use is preferable to the default constructor, which should remain as minimal as possible. Since there are no iterator-specific redefinitions of maxIterations or numFinalSolutions in NoDBBaseConstructor mode, go ahead and assign default value for all iterators.


Member Function Documentation

Iterator operator= ( const Iterator iterator)

assignment operator

Assignment operator decrements referenceCount for old iteratorRep, assigns new iteratorRep, and increments referenceCount for new iteratorRep.

References Iterator::iteratorRep, and Iterator::referenceCount.

void initialize_run ( ) [virtual]

utility function to perform common operations prior to pre_run(); typically memory initialization; setting of instance pointers

Perform initialization phases of run sequence, like allocating memory and setting instance pointers. Commonly used in sub-iterator executions. This is a virtual function; when re-implementing, a derived class must call its nearest parent's initialize_run(), typically _before_ performing its own implementation steps.

Reimplemented in SNLLOptimizer, SNLLLeastSq, NonD, NLPQLPOptimizer, Minimizer, CONMINOptimizer, DOTOptimizer, Optimizer, and LeastSq.

References Model::asynch_flag(), Iterator::asynchFlag, Iterator::initialize_run(), Model::is_null(), Iterator::iteratedModel, Iterator::iteratorRep, Iterator::maxConcurrency, Model::set_communicators(), Model::set_evaluation_reference(), and Iterator::summaryOutputFlag.

Referenced by Iterator::initialize_run(), and Iterator::run_iterator().

void pre_run ( ) [virtual]

pre-run portion of run_iterator (optional); re-implemented by Iterators which can generate all Variables (parameter sets) a priori

pre-run phase, which a derived iterator may optionally reimplement; when not present, pre-run is likely integrated into the derived run function. This is a virtual function; when re-implementing, a derived class must call its nearest parent's pre_run(), if implemented, typically _before_ performing its own implementation steps.

Reimplemented in NonDLHSSampling, DDACEDesignCompExp, ParamStudy, FSUDesignCompExp, and PSUADEDesignCompExp.

References Iterator::iteratorRep, and Iterator::pre_run().

Referenced by Iterator::pre_run(), and Iterator::run_iterator().

void run ( ) [virtual]

run portion of run_iterator; implemented by all derived classes and may include pre/post steps in lieu of separate pre/post

Virtual run function for the iterator class hierarchy. All derived classes need to redefine it.

Reimplemented in NonD, Optimizer, PStudyDACE, LeastSq, Verification, and SurrBasedMinimizer.

References Dakota::abort_handler(), Iterator::iteratorRep, and Iterator::run().

Referenced by Iterator::run(), and Iterator::run_iterator().

void post_run ( std::ostream &  s) [virtual]

post-run portion of run_iterator (optional); verbose to print results; re-implemented by Iterators that can read all Variables/Responses and perform final analysis phase in a standalone way

Post-run phase, which a derived iterator may optionally reimplement; when not present, post-run is likely integrated into run. This is a virtual function; when re-implementing, a derived class must call its nearest parent's post_run(), typically _after_ performing its own implementation steps.

Reimplemented in SNLLOptimizer, COLINOptimizer, SNLLLeastSq, NonDLHSSampling, DDACEDesignCompExp, Optimizer, ParamStudy, FSUDesignCompExp, PSUADEDesignCompExp, and LeastSq.

References Model::is_null(), Iterator::iteratedModel, Iterator::iteratorRep, Iterator::post_run(), Model::print_evaluation_summary(), Iterator::print_results(), and Iterator::summaryOutputFlag.

Referenced by Iterator::post_run(), and Iterator::run_iterator().

void finalize_run ( ) [virtual]

utility function to perform common operations following post_run(); deallocation and resetting of instance pointers

Optional: perform finalization phases of run sequence, like deallocating memory and resetting instance pointers. Commonly used in sub-iterator executions. This is a virtual function; when re-implementing, a derived class must call its nearest parent's finalize_run(), typically _after_ performing its own implementation steps.

Reimplemented in SNLLOptimizer, SNLLLeastSq, NonD, Minimizer, Optimizer, and LeastSq.

References Iterator::finalize_run(), and Iterator::iteratorRep.

Referenced by Iterator::finalize_run(), and Iterator::run_iterator().

void initialize_graphics ( bool  graph_2d,
bool  tabular_data,
const String tabular_file 
) [virtual]
void print_results ( std::ostream &  s) [virtual]

print the final iterator results

This virtual function provides additional iterator-specific final results outputs beyond the function evaluation summary printed in finalize_run().

Reimplemented in Analyzer, NonDLHSSampling, NonDGPMSABayesCalibration, NonDLocalReliability, Optimizer, NonDInterval, NonDIncremLHSSampling, NonDGlobalReliability, PStudyDACE, NonDExpansion, LeastSq, Verification, RichExtrapVerification, and SurrBasedMinimizer.

References Iterator::iteratorRep, and Iterator::print_results().

Referenced by Iterator::post_run(), and Iterator::print_results().

int num_samples ( ) const [virtual]

get the current number of samples

Return current number of evaluation points. Since the calculation of samples, collocation points, etc. might be costly, provide a default implementation here that backs out from the maxConcurrency. May be (is) overridden by derived classes.

Reimplemented in NonDQuadrature, NonDSparseGrid, NonDSampling, NonDCubature, DDACEDesignCompExp, FSUDesignCompExp, and PSUADEDesignCompExp.

References Model::derivative_concurrency(), Iterator::iteratedModel, Iterator::iteratorRep, Iterator::maxConcurrency, and Iterator::num_samples().

Referenced by DataFitSurrModel::build_global(), NonDGlobalReliability::get_best_sample(), Iterator::num_samples(), Analyzer::samples_to_variables_array(), Analyzer::variables_array_to_samples(), and Analyzer::variance_based_decomp().

void run_iterator ( std::ostream &  s)

orchestrate initialize/pre/run/post/finalize phases

Iterator supports a construct/initialize-run/pre-run/run/post-run/finalize-run/destruct progression. This member (non-virtual) function sequences these run phases; it accepts an ostream, but controls verbosity with outputLevel

References ParallelLibrary::command_line_post_run(), ParallelLibrary::command_line_pre_run(), ParallelLibrary::command_line_run(), Iterator::finalize_run(), Iterator::initialize_run(), Iterator::iteratedModel, Iterator::iteratorRep, Iterator::methodName, Iterator::outputLevel, Model::parallel_library(), Iterator::post_input(), Iterator::post_run(), Iterator::pre_output(), Iterator::pre_run(), Iterator::run(), Iterator::run_iterator(), and Iterator::summaryOutputFlag.

Referenced by DataFitSurrModel::build_global(), NonDExpansion::compute_statistics(), NestedModel::derived_compute_response(), NonDGlobalReliability::importance_sampling(), SurrBasedLocalMinimizer::minimize_surrogates(), SurrBasedGlobalMinimizer::minimize_surrogates(), EffGlobalMinimizer::minimize_surrogates_on_model(), NonDLocalReliability::mpp_search(), NonDGlobalReliability::optimize_gaussian_process(), GaussProcApproximation::optimize_theta_global(), GaussProcApproximation::optimize_theta_multipoint(), NonDLocalReliability::probability(), NonDLHSInterval::quantify_uncertainty(), NonDBayesCalibration::quantify_uncertainty(), NonDLocalInterval::quantify_uncertainty(), NonDGlobalInterval::quantify_uncertainty(), NonDGPMSABayesCalibration::quantify_uncertainty(), SurrBasedLocalMinimizer::relax_constraints(), Strategy::run_iterator(), and Iterator::run_iterator().

void assign_rep ( Iterator iterator_rep,
bool  ref_count_incr = true 
)

replaces existing letter with a new one

Similar to the assignment operator, the assign_rep() function decrements referenceCount for the old iteratorRep and assigns the new iteratorRep. It is different in that it is used for publishing derived class letters to existing envelopes, as opposed to sharing representations among multiple envelopes (in particular, assign_rep is passed a letter object and operator= is passed an envelope object). Letter assignment supports two models as governed by ref_count_incr:

  • ref_count_incr = true (default): the incoming letter belongs to another envelope. In this case, increment the reference count in the normal manner so that deallocation of the letter is handled properly.
  • ref_count_incr = false: the incoming letter is instantiated on the fly and has no envelope. This case is modeled after get_iterator(): a letter is dynamically allocated using new and passed into assign_rep, the letter's reference count is not incremented, and the letter is not remotely deleted (its memory management is passed over to the envelope).

References Dakota::abort_handler(), Iterator::iterator_rep(), Iterator::iteratorRep, and Iterator::referenceCount.

Referenced by NonDExpansion::construct_cubature(), NonDExpansion::construct_expansion_sampler(), NonD::construct_lhs(), NonDExpansion::construct_quadrature(), NonDExpansion::construct_sparse_grid(), EffGlobalMinimizer::EffGlobalMinimizer(), NonDLocalInterval::method_recourse(), NonDLocalReliability::method_recourse(), NonDBayesCalibration::NonDBayesCalibration(), NonDGlobalInterval::NonDGlobalInterval(), NonDGlobalReliability::NonDGlobalReliability(), NonDGPMSABayesCalibration::NonDGPMSABayesCalibration(), NonDLHSInterval::NonDLHSInterval(), NonDLocalInterval::NonDLocalInterval(), NonDLocalReliability::NonDLocalReliability(), GaussProcApproximation::optimize_theta_global(), GaussProcApproximation::optimize_theta_multipoint(), and SurrBasedLocalMinimizer::relax_constraints().

Iterator * get_iterator ( Model model) [private]

Used by the envelope to instantiate the correct letter class.

Used only by the envelope constructor to initialize iteratorRep to the appropriate derived type, as given by the methodName attribute.

References String::begins(), String::ends(), ProblemDescDB::get_string(), Iterator::method_name(), Iterator::methodName, and Iterator::probDescDB.

Referenced by Iterator::Iterator().

Iterator * get_iterator ( const String method_name,
Model model 
) [private]

Used by the envelope to instantiate the correct letter class.

Used only by the envelope constructor to initialize iteratorRep to the appropriate derived type, as given by the passed method_name.

References String::begins().


Member Data Documentation

Real fdGradStepSize [protected]

relative finite difference step size for numerical gradients

A scalar value (instead of the vector fd_gradient_step_size spec) is used within the iterator hierarchy since this attribute is only used to publish a step size to vendor numerical gradient algorithms.

Referenced by DOTOptimizer::initialize(), CONMINOptimizer::initialize(), Iterator::Iterator(), NLSSOLLeastSq::NLSSOLLeastSq(), NPSOLOptimizer::NPSOLOptimizer(), SNLLLeastSq::SNLLLeastSq(), and SNLLOptimizer::SNLLOptimizer().

Real fdHessByGradStepSize [protected]

relative finite difference step size for numerical Hessians estimated using first-order differences of gradients

A scalar value (instead of the vector fd_hessian_step_size spec) is used within the iterator hierarchy since this attribute is only used to publish a step size to vendor numerical Hessian algorithms.

Referenced by Iterator::Iterator().

Real fdHessByFnStepSize [protected]

relative finite difference step size for numerical Hessians estimated using second-order differences of function values

A scalar value (instead of the vector fd_hessian_step_size spec) is used within the iterator hierarchy since this attribute is only used to publish a step size to vendor numerical Hessian algorithms.

Referenced by Iterator::Iterator().


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