1 /* _______________________________________________________________________
2
3 DAKOTA: Design Analysis Kit for Optimization and Terascale Applications
4 Copyright 2014-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
5 This software is distributed under the GNU Lesser General Public License.
6 For more information, see the README file in the top Dakota directory.
7 _______________________________________________________________________ */
8
9 //- Class: Iterator
10 //- Description: Base class for iterator objects and envelope for
11 //- letter/envelope idiom.
12 //- Owner: Mike Eldred
13 //- Version: $Id: DakotaIterator.hpp 7029 2010-10-22 00:17:02Z mseldre $
14
15 #ifndef DAKOTA_ITERATOR_H
16 #define DAKOTA_ITERATOR_H
17
18 #include "dakota_data_types.hpp"
19 #include "DakotaModel.hpp"
20 #include "ResultsManager.hpp"
21 #include "DakotaTraitsBase.hpp"
22 #include <memory>
23
24
25 namespace Dakota {
26
27 class ProblemDescDB;
28 class Variables;
29 class Response;
30 class EvaluationStore;
31
32 /// Base class for the iterator class hierarchy.
33
34 /** The Iterator class is the base class for one of the primary class
35 hierarchies in DAKOTA. The iterator hierarchy contains all of the
36 iterative algorithms which use repeated execution of simulations
37 as function evaluations. For memory efficiency and enhanced
38 polymorphism, the iterator hierarchy employs the "letter/envelope
39 idiom" (see Coplien "Advanced C++", p. 133), for which the base
40 class (Iterator) serves as the envelope and one of the derived
41 classes (selected in Iterator::get_iterator()) serves as the letter. */
42
43 class Iterator
44 {
45 public:
46
47 //
48 //- Heading: Constructors, destructor, assignment operator
49 //
50
51 /// default constructor
52 Iterator( std::shared_ptr<TraitsBase> traits = std::shared_ptr<TraitsBase>(new TraitsBase()) );
53 // BMA: Disabled unused ctor when deploying shared_ptr for iteratorRep
54 /// alternate envelope constructor that assigns a representation pointer
55 // Iterator(std::shared_ptr<Iterator> iterator_rep, std::shared_ptr<TraitsBase> traits = std::shared_ptr<TraitsBase>(new TraitsBase()));
56 /// standard envelope constructor, which constructs its own model(s)
57 Iterator(ProblemDescDB& problem_db, std::shared_ptr<TraitsBase> traits = std::shared_ptr<TraitsBase>(new TraitsBase()));
58 /// alternate envelope constructor which uses the ProblemDescDB but
59 /// accepts a model from a higher level (meta-iterator) context,
60 /// instead of constructing its own
61 Iterator(ProblemDescDB& problem_db, Model& model, std::shared_ptr<TraitsBase> traits = std::shared_ptr<TraitsBase>(new TraitsBase()));
62 /// alternate envelope constructor for instantiations by name
63 /// without the ProblemDescDB
64 Iterator(const String& method_string, Model& model, std::shared_ptr<TraitsBase> traits = std::shared_ptr<TraitsBase>(new TraitsBase()));
65 /// copy constructor
66 Iterator(const Iterator& iterator);
67
68 /// destructor
69 virtual ~Iterator();
70
71 /// assignment operator
72 Iterator operator=(const Iterator& iterator);
73
74 //
75 //- Heading: Virtual functions
76 //
77
78 /// derived class contributions to setting the communicators
79 /// associated with this Iterator instance
80 virtual void derived_set_communicators(ParLevLIter pl_iter);
81 /// derived class contributions to freeing the communicators
82 /// associated with this Iterator instance
83 virtual void derived_free_communicators(ParLevLIter pl_iter);
84
85 // Run phase functions: derived classes reimplementing one of these
86 // must call the same function in their closest parent which implements.
87
88 /// utility function to perform common operations prior to pre_run();
89 /// typically memory initialization; setting of instance pointers
90 virtual void initialize_run();
91 /// pre-run portion of run (optional); re-implemented by Iterators
92 /// which can generate all Variables (parameter sets) a priori
93 virtual void pre_run();
94 /// core portion of run; implemented by all derived classes
95 /// and may include pre/post steps in lieu of separate pre/post
96 virtual void core_run();
97 /// post-run portion of run (optional); verbose to print results;
98 /// re-implemented by Iterators that can read all Variables/Responses and
99 /// perform final analysis phase in a standalone way
100 virtual void post_run(std::ostream& s);
101 /// utility function to perform common operations following post_run();
102 /// deallocation and resetting of instance pointers
103 virtual void finalize_run();
104
105 /// write variables to file, following pre-run
106 virtual void pre_output();
107 /// read tabular data for post-run mode
108 virtual void post_input();
109
110 /// restore initial state for repeated sub-iterator executions
111 virtual void reset();
112
113 /// set primaryA{CV,DIV,DRV}MapIndices, secondaryA{CV,DIV,DRV}MapTargets
114 /// within derived Iterators; supports computation of higher-level
115 /// sensitivities in nested contexts (e.g., derivatives of statistics
116 /// w.r.t. inserted design variables)
117 virtual void nested_variable_mappings(const SizetArray& c_index1,
118 const SizetArray& di_index1,
119 const SizetArray& ds_index1,
120 const SizetArray& dr_index1,
121 const ShortArray& c_target2,
122 const ShortArray& di_target2,
123 const ShortArray& ds_target2,
124 const ShortArray& dr_target2);
125
126 /// used by IteratorScheduler to set the starting data for a run
127 virtual void initialize_iterator(int job_index);
128 /// used by IteratorScheduler to pack starting data for an iterator run
129 virtual void pack_parameters_buffer(MPIPackBuffer& send_buffer,
130 int job_index);
131 /// used by IteratorScheduler to unpack starting data for an iterator run
132 virtual void unpack_parameters_buffer(MPIUnpackBuffer& recv_buffer,
133 int job_index);
134 /// used by IteratorScheduler to unpack starting data and initialize
135 /// an iterator run
136 virtual void unpack_parameters_initialize(MPIUnpackBuffer& recv_buffer,
137 int job_index);
138 /// used by IteratorScheduler to pack results data from an iterator run
139 virtual void pack_results_buffer(MPIPackBuffer& send_buffer, int job_index);
140 /// used by IteratorScheduler to unpack results data from an iterator run
141 virtual void unpack_results_buffer(MPIUnpackBuffer& recv_buffer,
142 int job_index);
143 /// used by IteratorScheduler to update local results arrays
144 virtual void update_local_results(int job_index);
145
146 /// return a single final iterator solution (variables)
147 virtual const Variables& variables_results() const;
148 /// return a single final iterator solution (response)
149 virtual const Response& response_results() const;
150
151 /// return multiple final iterator solutions (variables). This should
152 /// only be used if returns_multiple_points() returns true.
153 virtual const VariablesArray& variables_array_results();
154 /// return multiple final iterator solutions (response). This should
155 /// only be used if returns_multiple_points() returns true.
156 virtual const ResponseArray& response_array_results();
157
158 /// set the requested data for the final iterator response results
159 virtual void response_results_active_set(const ActiveSet& set);
160
161 /// return error estimates associated with the final iterator solution
162 virtual const RealVector& response_error_estimates() const;
163
164 /// indicates if this iterator accepts multiple initial points. Default
165 /// return is false. Override to return true if appropriate.
166 virtual bool accepts_multiple_points() const;
167 /// indicates if this iterator returns multiple final points. Default
168 /// return is false. Override to return true if appropriate.
169 virtual bool returns_multiple_points() const;
170
171 /// sets the multiple initial points for this iterator. This should
172 /// only be used if accepts_multiple_points() returns true.
173 virtual void initial_points(const VariablesArray& pts);
174
175 /// initialize the 2D graphics window and the tabular graphics data
176 virtual void initialize_graphics(int iterator_server_id = 1);
177
178 /// print the final iterator results
179 virtual void print_results(std::ostream& s,
180 short results_state = FINAL_RESULTS);
181
182 /// return the result of any recasting or surrogate model recursion
183 /// layered on top of iteratedModel by the derived Iterator ctor chain
184 virtual const Model& algorithm_space_model() const;
185
186 /// return name of any enabling iterator used by this iterator
187 virtual unsigned short uses_method() const;
188 /// perform a method switch, if possible, due to a detected conflict
189 virtual void method_recourse();
190
191 /// return the complete set of evaluated variables
192 virtual const VariablesArray& all_variables();
193 /// return the complete set of evaluated samples
194 virtual const RealMatrix& all_samples();
195 /// return the complete set of computed responses
196 virtual const IntResponseMap& all_responses() const;
197
198 /// get the current number of samples
199 virtual int num_samples() const;
200 /// reset sampling iterator to use at least min_samples
201 virtual void sampling_reset(int min_samples, bool all_data_flag,
202 bool stats_flag);
203 /// set reference number of samples, which is a lower bound during reset
204 virtual void sampling_reference(int samples_ref);
205
206 /// increment to next in sequence of refinement samples
207 virtual void sampling_increment();
208 /// set randomSeed, if present
209 virtual void random_seed(int seed);
210
211 /// return sampling name
212 virtual unsigned short sampling_scheme() const;
213
214 /// returns Analyzer::compactMode
215 virtual bool compact_mode() const;
216
217 /// estimate the minimum and maximum partition sizes that can be
218 /// utilized by this Iterator
219 virtual IntIntPair estimate_partition_bounds();
220
221 /// reinitializes iterator based on new variable size
222 virtual bool resize();
223
224 /// Declare sources to the evaluations database
225 virtual void declare_sources();
226
227 //
228 //- Heading: Member functions
229 //
230
231 /// initialize the communicators associated with this Iterator instance
232 void init_communicators(ParLevLIter pl_iter);
233 /// set the communicators associated with this Iterator instance
234 void set_communicators(ParLevLIter pl_iter);
235 /// free the communicators associated with this Iterator instance
236 void free_communicators(ParLevLIter pl_iter);
237
238 /// Resize the communicators. This is called from the letter's resize()
239 void resize_communicators(ParLevLIter pl_iter, bool reinit_comms);
240
241 /// set methodPCIter
242 void parallel_configuration_iterator(ParConfigLIter pc_iter);
243 /// return methodPCIter
244 ParConfigLIter parallel_configuration_iterator() const;
245
246 /// invoke set_communicators(pl_iter) prior to run()
247 void run(ParLevLIter pl_iter);
248 /// orchestrate initialize/pre/core/post/finalize phases
249 void run();
250
251 /// replaces existing letter with a new one
252 void assign_rep(std::shared_ptr<Iterator> iterator_rep);
253
254 /// set the iteratedModel (iterators and meta-iterators using a single
255 /// model instance)
256 void iterated_model(const Model& model);
257 /// return the iteratedModel (iterators & meta-iterators using a single
258 /// model instance)
259 Model& iterated_model();
260
261 /// return the problem description database (probDescDB)
262 ProblemDescDB& problem_description_db() const;
263 /// return the parallel library (parallelLib)
264 ParallelLibrary& parallel_library() const;
265
266 /// set the method name to an enumeration value
267 void method_name(unsigned short m_name);
268 /// return the method name via its native enumeration value
269 unsigned short method_name() const;
270 /// set the method name by string
271 void method_string(const String& m_str);
272 /// return the method name by string
273 String method_string() const;
274
275 /// convert a method name enumeration value to a string
276 String method_enum_to_string(unsigned short method_enum) const;
277 /// convert a method name string to an enumeration value
278 unsigned short method_string_to_enum(const String& method_str) const;
279 /// convert a sub-method name enumeration value to a string
280 String submethod_enum_to_string(unsigned short submethod_enum) const;
281
282 /// return the method identifier (methodId)
283 const String& method_id() const;
284
285 /// return the maximum evaluation concurrency supported by the iterator
286 int maximum_evaluation_concurrency() const;
287 /// set the maximum evaluation concurrency supported by the iterator
288 void maximum_evaluation_concurrency(int max_conc);
289
290 /// return the maximum iterations for this iterator
291 int maximum_iterations() const;
292 /// set the maximum iterations for this iterator
293 void maximum_iterations(int max_iter);
294
295 /// set the method convergence tolerance (convergenceTol)
296 void convergence_tolerance(Real conv_tol);
297 /// return the method convergence tolerance (convergenceTol)
298 Real convergence_tolerance() const;
299
300 /// set the method output level (outputLevel)
301 void output_level(short out_lev);
302 /// return the method output level (outputLevel)
303 short output_level() const;
304 /// Set summary output control; true enables evaluation/results summary
305 void summary_output(bool summary_output_flag);
306
307 /// return the number of solutions to retain in best variables/response arrays
308 size_t num_final_solutions() const;
309 /// set the number of solutions to retain in best variables/response arrays
310 void num_final_solutions(size_t num_final);
311
312 /// set the default active set (for use with iterators that employ
313 /// evaluate_parameter_sets())
314 void active_set(const ActiveSet& set);
315 /// return the default active set (used by iterators that employ
316 /// evaluate_parameter_sets())
317 const ActiveSet& active_set() const;
318 /// return the default active set request vector (used by iterators
319 /// that employ evaluate_parameter_sets())
320 void active_set_request_vector(const ShortArray& asv);
321 /// return the default active set request vector (used by iterators
322 /// that employ evaluate_parameter_sets())
323 const ShortArray& active_set_request_vector() const;
324 /// return the default active set request vector (used by iterators
325 /// that employ evaluate_parameter_sets())
326 void active_set_request_values(short asv_val);
327
328 /// set subIteratorFlag (and update summaryOutputFlag if needed)
329 void sub_iterator_flag(bool si_flag);
330
331 /// function to check iteratorRep (does this envelope contain a letter?)
332 bool is_null() const;
333
334 /// returns iteratorRep for access to derived class member functions
335 /// that are not mapped to the top Iterator level
336 std::shared_ptr<Iterator> iterator_rep() const;
337
338 /// set the hierarchical eval ID tag prefix
339 virtual void eval_tag_prefix(const String& eval_id_str);
340
341
342 /// returns methodTraits for access to derived class member functions
343 /// that are not mapped to the top TraitsBase level
344 std::shared_ptr<TraitsBase> traits() const;
345
346 //
347 //- Heading: Operator overloaded functions
348 //
349
350 // Possible future implementation for enhanced granularity in
351 // Iterator virtual function. Could be very useful for Strategy
352 // level control!
353 //virtual void operator++(); // increment operator
354 //virtual void operator--(); // decrement operator
355
356 /// Return whether the iterator is the top level iterator
357 bool top_level();
358
359 /// Set the iterator's top level flag
360 void top_level(const bool &tflag);
361
362 protected:
363
364 //
365 //- Heading: Constructors
366 //
367
368 /// constructor initializes the base class part of letter classes
369 /// (BaseConstructor overloading avoids infinite recursion in the
370 /// derived class constructors - Coplien, p. 139)
371 Iterator(BaseConstructor, ProblemDescDB& problem_db, std::shared_ptr<TraitsBase> traits = std::shared_ptr<TraitsBase>(new TraitsBase()));
372
373 /// alternate constructor for base iterator classes constructed on the fly
374 Iterator(NoDBBaseConstructor, unsigned short method_name, Model& model, std::shared_ptr<TraitsBase> traits = std::shared_ptr<TraitsBase>(new TraitsBase()));
375
376 /// alternate constructor for base iterator classes constructed on the fly
377 Iterator(NoDBBaseConstructor, unsigned short method_name, std::shared_ptr<TraitsBase> traits = std::shared_ptr<TraitsBase>(new TraitsBase()));
378
379 //
380 //- Heading: Virtual functions
381 //
382
383 /// derived class contributions to initializing the communicators
384 /// associated with this Iterator instance
385 virtual void derived_init_communicators(ParLevLIter pl_iter);
386
387 /// set inherited data attributes based on extractions from incoming model
388 virtual void update_from_model(const Model& model);
389
390 /// gets the multiple initial points for this iterator. This will only
391 /// be meaningful after a call to initial_points mutator.
392 virtual const VariablesArray& initial_points() const;
393
394 //
395 //- Heading: Member functions
396 //
397
398 /// get the unique run identifier based on method name, id, and
399 /// number of executions
400 StrStrSizet run_identifier() const;
401
402 /// conversion of request vector values for the Gauss-Newton Hessian
403 /// approximation
404 static void gnewton_set_recast(const Variables& recast_vars,
405 const ActiveSet& recast_set,
406 ActiveSet& sub_model_set);
407
408 /// export final surrogates generated, e.g., GP in EGO and friends
409 void export_final_surrogates(Model& data_fit_surr_model);
410
411 //
412 //- Heading: Data
413 //
414
415 /// class member reference to the problem description database
416 /** Iterator and Model cannot use a shallow copy of ProblemDescDB
417 due to circular destruction dependency (reference counts can't
418 get to 0), since ProblemDescDB contains {iterator,model}List. */
419 ProblemDescDB& probDescDB;
420
421 /// class member reference to the parallel library
422 ParallelLibrary& parallelLib;
423
424 /// the active ParallelConfiguration used by this Iterator instance
425 ParConfigLIter methodPCIter;
426 // index for the active ParallelLevel within ParallelConfiguration::miPLIters
427 //size_t miPLIndex;
428
429 /// the model to be iterated (for iterators and meta-iterators
430 /// employing a single model instance)
431 Model iteratedModel;
432
433 /// number of Models locally (in Iterator or derived classes)
434 /// wrapped around the initially passed in Model
435 size_t myModelLayers;
436
437 unsigned short methodName; ///< name of the iterator (the user's method spec)
438
439 Real convergenceTol; ///< iteration convergence tolerance
440 int maxIterations; ///< maximum number of iterations for the iterator
441 int maxFunctionEvals; ///< maximum number of fn evaluations for the iterator
442
443 /// maximum number of concurrent model evaluations
444 /** This is important for parallel configuration init/set/free and may be
445 set within empty envelope instances. Therefore, it cannot be pushed
446 down into Analyzer/Minimizer derived classes. */
447 int maxEvalConcurrency;
448
449 /// the response data requirements on each function evaluation
450 ActiveSet activeSet;
451
452 /// number of solutions to retain in best variables/response arrays
453 size_t numFinalSolutions;
454 /// collection of N best solution variables found during the study;
455 /// always in context of Model originally passed to the Iterator
456 /// (any in-flight Recasts must be undone)
457 VariablesArray bestVariablesArray;
458 /// collection of N best solution responses found during the study;
459 /// always in context of Model originally passed to the Iterator
460 /// (any in-flight Recasts must be undone)
461 ResponseArray bestResponseArray;
462
463 /// flag indicating if this Iterator is a sub-iterator
464 /// (NestedModel::subIterator or DataFitSurrModel::daceIterator)
465 bool subIteratorFlag;
466
467 /// output verbosity level: {SILENT,QUIET,NORMAL,VERBOSE,DEBUG}_OUTPUT
468 short outputLevel;
469 /// flag for summary output (evaluation stats, final results); default true,
470 /// but false for on-the-fly (helper) iterators and sub-iterator use cases
471 bool summaryOutputFlag;
472
473 /// reference to the global iterator results database
474 ResultsManager& resultsDB;
475 /// reference to the global evaluation database
476 EvaluationStore& evaluationsDB;
477
478 /// State of evaluations DB for this iterator
479 EvaluationsDBState evaluationsDBState;
480
481 /// valid names for iterator results
482 ResultsNames resultsNames;
483
484 /// pointer that retains shared ownership of a TraitsBase object,
485 /// or child thereof
486 std::shared_ptr<TraitsBase> methodTraits;
487
488 /// Whether this is the top level iterator
489 bool topLevel;
490
491 /// whether to export final surrogates
492 bool exportSurrogate = false;
493
494 /// base filename for exported surrogates
495 String surrExportPrefix;
496
497 /// (bitwise) format(s) to export
498 unsigned short surrExportFormat = NO_MODEL_FORMAT;
499
500 private:
501
502 //
503 //- Heading: Member functions
504 //
505
506 /// Used by the envelope to instantiate the correct letter class
507 std::shared_ptr<Iterator>
508 get_iterator(ProblemDescDB& problem_db);
509 /// Used by the envelope to instantiate the correct letter class
510 std::shared_ptr<Iterator>
511 get_iterator(ProblemDescDB& problem_db, Model& model);
512 /// Used by the envelope to instantiate the correct letter class
513 std::shared_ptr<Iterator>
514 get_iterator(const String& method_string, Model& model);
515
516 /// return the next available method ID for no-ID user methods
517 static String user_auto_id();
518
519 /// return the next available method ID for on-the-fly methods
520 static String no_spec_id();
521
522 //
523 //- Heading: Data
524 //
525
526 /// method identifier string from the input file, or an
527 /// auto-generated ID, such that each instance of an Iterator has a
528 /// unique ID
529 String methodId;
530
531 // Data for numbering methods and their executions
532
533 /// the last used method ID number for on-the-fly instantiations
534 /// (increment before each use)
535 static size_t noSpecIdNum;
536
537 /// An execution number for this instance of the class. Now that
538 /// each instance has a unique methodId, this is just a simple
539 /// counter.
540 size_t execNum;
541
542 /// track the available configurations that have been created
543 /// (init_communicators) and are available for activation at run
544 /// time (set_communicators)
545 std::map<size_t, ParConfigLIter> methodPCIterMap;
546
547 /// pointer to the letter (initialized only for the envelope)
548 std::shared_ptr<Iterator> iteratorRep;
549
550 };
551
traits() const552 inline std::shared_ptr<TraitsBase> Iterator::traits() const
553 {
554 return (iteratorRep) ? iteratorRep->traits() : methodTraits;
555 }
556
parallel_configuration_iterator(ParConfigLIter pc_iter)557 inline void Iterator::parallel_configuration_iterator(ParConfigLIter pc_iter)
558 {
559 if (iteratorRep) iteratorRep->methodPCIter = pc_iter;
560 else methodPCIter = pc_iter;
561 }
562
563
parallel_configuration_iterator() const564 inline ParConfigLIter Iterator::parallel_configuration_iterator() const
565 { return (iteratorRep) ? iteratorRep->methodPCIter : methodPCIter; }
566
567
iterated_model(const Model & model)568 inline void Iterator::iterated_model(const Model& model)
569 {
570 if (iteratorRep) iteratorRep->iteratedModel = model;
571 else iteratedModel = model;
572 }
573
574
iterated_model()575 inline Model& Iterator::iterated_model()
576 { return (iteratorRep) ? iteratorRep->iteratedModel : iteratedModel; }
577
578
problem_description_db() const579 inline ProblemDescDB& Iterator::problem_description_db() const
580 { return (iteratorRep) ? iteratorRep->probDescDB : probDescDB; }
581
582
parallel_library() const583 inline ParallelLibrary& Iterator::parallel_library() const
584 { return (iteratorRep) ? iteratorRep->parallelLib : parallelLib; }
585
586
method_name(unsigned short m_name)587 inline void Iterator::method_name(unsigned short m_name)
588 {
589 if (iteratorRep) iteratorRep->methodName = m_name;
590 else methodName = m_name;
591 }
592
593
method_name() const594 inline unsigned short Iterator::method_name() const
595 { return (iteratorRep) ? iteratorRep->methodName : methodName; }
596
597
method_string(const String & m_str)598 inline void Iterator::method_string(const String& m_str)
599 {
600 if (iteratorRep) iteratorRep->methodName = method_string_to_enum(m_str);
601 else methodName = method_string_to_enum(m_str);
602 }
603
604
method_string() const605 inline String Iterator::method_string() const
606 {
607 return (iteratorRep) ? iteratorRep->method_string() :
608 method_enum_to_string(methodName);
609 }
610
611
method_id() const612 inline const String& Iterator::method_id() const
613 { return (iteratorRep) ? iteratorRep->methodId : methodId; }
614
615
maximum_evaluation_concurrency() const616 inline int Iterator::maximum_evaluation_concurrency() const
617 { return (iteratorRep) ? iteratorRep->maxEvalConcurrency : maxEvalConcurrency; }
618
619
maximum_evaluation_concurrency(int max_conc)620 inline void Iterator::maximum_evaluation_concurrency(int max_conc)
621 {
622 if (iteratorRep) iteratorRep->maxEvalConcurrency = max_conc;
623 else maxEvalConcurrency = max_conc;
624 }
625
maximum_iterations() const626 inline int Iterator::maximum_iterations() const
627 { return (iteratorRep) ? iteratorRep->maxIterations : maxIterations; }
628
maximum_iterations(int max_iter)629 inline void Iterator::maximum_iterations(int max_iter)
630 {
631 if (iteratorRep) iteratorRep->maxIterations = max_iter;
632 else maxIterations = max_iter;
633 }
634
convergence_tolerance(Real conv_tol)635 inline void Iterator::convergence_tolerance(Real conv_tol)
636 {
637 if (iteratorRep) iteratorRep->convergenceTol = conv_tol;
638 else convergenceTol = conv_tol;
639 }
640
641
convergence_tolerance() const642 inline Real Iterator::convergence_tolerance() const
643 { return (iteratorRep) ? iteratorRep->convergenceTol : convergenceTol; }
644
645
output_level(short out_lev)646 inline void Iterator::output_level(short out_lev)
647 {
648 if (iteratorRep) iteratorRep->outputLevel = out_lev;
649 else outputLevel = out_lev;
650 }
651
652
output_level() const653 inline short Iterator::output_level() const
654 { return (iteratorRep) ? iteratorRep->outputLevel : outputLevel; }
655
656
summary_output(bool summary_output_flag)657 inline void Iterator::summary_output(bool summary_output_flag)
658 {
659 if (iteratorRep) iteratorRep->summaryOutputFlag = summary_output_flag;
660 else summaryOutputFlag = summary_output_flag;
661 }
662
663
num_final_solutions() const664 inline size_t Iterator::num_final_solutions() const
665 { return (iteratorRep) ? iteratorRep->numFinalSolutions : numFinalSolutions; }
666
667
num_final_solutions(size_t num_final)668 inline void Iterator::num_final_solutions(size_t num_final)
669 {
670 if (iteratorRep) iteratorRep->numFinalSolutions = num_final;
671 else numFinalSolutions = num_final;
672 }
673
674
active_set(const ActiveSet & set)675 inline void Iterator::active_set(const ActiveSet& set)
676 {
677 if (iteratorRep) iteratorRep->activeSet = set;
678 else activeSet = set;
679 }
680
681
active_set() const682 inline const ActiveSet& Iterator::active_set() const
683 { return (iteratorRep) ? iteratorRep->activeSet : activeSet; }
684
685
active_set_request_vector(const ShortArray & asv)686 inline void Iterator::active_set_request_vector(const ShortArray& asv)
687 {
688 if (iteratorRep) iteratorRep->activeSet.request_vector(asv);
689 else activeSet.request_vector(asv);
690 }
691
692
active_set_request_vector() const693 inline const ShortArray& Iterator::active_set_request_vector() const
694 {
695 return (iteratorRep) ? iteratorRep->activeSet.request_vector()
696 : activeSet.request_vector();
697 }
698
699
active_set_request_values(short asv_val)700 inline void Iterator::active_set_request_values(short asv_val)
701 {
702 if (iteratorRep) iteratorRep->activeSet.request_values(asv_val);
703 else activeSet.request_values(asv_val);
704 }
705
706
is_null() const707 inline bool Iterator::is_null() const
708 { return (iteratorRep) ? false : true; }
709
710
iterator_rep() const711 inline std::shared_ptr<Iterator> Iterator::iterator_rep() const
712 { return iteratorRep; }
713
714
715 /// global comparison function for Iterator
method_id_compare(const Iterator & iterator,const void * id)716 inline bool method_id_compare(const Iterator& iterator, const void* id)
717 { return ( *(const String*)id == iterator.method_id() ); }
718
719 } // namespace Dakota
720
721 #endif
722