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:       MetaIterator
10 //- Description: A multi-level hybrid minimizer which invokes several iterators
11 //- Owner:       Mike Eldred
12 //- Checked by:
13 //- Version: $Id: MetaIterator.hpp 6492 2009-12-19 00:04:28Z briadam $
14 
15 #ifndef META_ITERATOR_H
16 #define META_ITERATOR_H
17 
18 #include "dakota_data_types.hpp"
19 #include "DakotaIterator.hpp"
20 #include "DakotaModel.hpp"
21 #include "IteratorScheduler.hpp"
22 
23 
24 namespace Dakota {
25 
26 
27 /// Base class for meta-iterators.
28 
29 /** This base class shares code for concurrent and hybrid
30     meta-iterators, where the former supports multi-start and Pareto
31     set iteration and the latter supports sequential, embedded, and
32     collaborative hybrids. */
33 
34 class MetaIterator: public Iterator
35 {
36 public:
37 
38   //
39   //- Heading: Virtual function redefinitions
40   //
41 
42   bool resize();
43 
44 protected:
45 
46   //
47   //- Heading: Constructors and destructor
48   //
49 
50   /// standard constructor
51   MetaIterator(ProblemDescDB& problem_db);
52   /// alternate constructor
53   MetaIterator(ProblemDescDB& problem_db, Model& model);
54   /// destructor
55   ~MetaIterator();
56 
57   //
58   //- Heading: Virtual function redefinitions
59   //
60 
61   void post_run(std::ostream& s);
62 
63   //
64   //- Heading: Convenience member functions
65   //
66 
67   /// check that a model identified by pointer has the same id as the
68   /// iteratedModel passed through the ctor chain
69   void check_model(const String& method_ptr, const String& model_ptr);
70 
71   /// initialize the_iterator and the_model based on method_ptr
72   void allocate_by_pointer(const String& method_ptr, Iterator& the_iterator,
73 			   Model& the_model);
74   /// initialize the_iterator based on method_string
75   void allocate_by_name(const String& method_string, const String& model_ptr,
76 			Iterator& the_iterator,	Model& the_model);
77 
78   /// estimate minimum and maximum processors per iterator needed for
79   /// init_iterator_parallelism(); instantiates the_iterator and the_model
80   /// as needed, but on minimal processor ranks (is later augmented by
81   /// allocate_by_pointer())
82   std::pair<int, int> estimate_by_pointer(const String& method_ptr,
83 					  Iterator& the_iterator,
84 					  Model& the_model);
85   /// estimate minimum and maximum processors per iterator needed for
86   /// init_iterator_parallelism(); instantiates the_iterator and the_model
87   /// as needed, but on minimal processor ranks (is later augmented by
88   /// allocate_by_name())
89   std::pair<int, int> estimate_by_name(const String& method_string,
90 				       const String& model_ptr,
91 				       Iterator& the_iterator,
92 				       Model& the_model);
93 
94   //
95   //- Heading: Data members
96   //
97 
98   /// scheduler for concurrent execution of Iterators
99   IteratorScheduler iterSched;
100 
101   /// maximum number of concurrent sub-iterator executions
102   int maxIteratorConcurrency;
103 
104 private:
105 
106   //
107   //- Heading: Convenience member functions
108   //
109 
110 };
111 
112 } // namespace Dakota
113 
114 #endif
115