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:       Model
10 //- Description: The model to be iterated.  Contains Variables,
11 //-              Interface, and Response objects.
12 //- Owner:       Mike Eldred
13 //- Version: $Id: DakotaModel.hpp 7029 2010-10-22 00:17:02Z mseldre $
14 
15 #ifndef DAKOTA_MODEL_H
16 #define DAKOTA_MODEL_H
17 
18 #include "dakota_data_types.hpp"
19 #include "MPIManager.hpp"
20 #include "ProblemDescDB.hpp"
21 #include "DakotaVariables.hpp"
22 #include "DakotaConstraints.hpp"
23 //#include "DakotaInterface.hpp"
24 #include "DakotaResponse.hpp"
25 #include "MultivariateDistribution.hpp"
26 #include "ScalingOptions.hpp"
27 
28 namespace Pecos { /* forward declarations */
29 class SurrogateData;
30 class ProbabilityTransformation;
31 }
32 
33 namespace Dakota {
34 
35 // define special values for serve_init_mapping()
36 #define FREE_COMMS 1
37 #define INIT_COMMS 2
38 #define SERVE_RUN 3
39 #define ESTIMATE_MESSAGE_LENGTHS 4
40 
41 // forward declarations
42 class ParallelLibrary;
43 class Approximation;
44 class SharedApproxData;
45 class DiscrepancyCorrection;
46 class EvaluationStore;
47 
48 
49 /// Base class for the model class hierarchy.
50 
51 /** The Model class is the base class for one of the primary
52     class hierarchies in DAKOTA.  The model hierarchy contains a set
53     of variables, an interface, and a set of responses, and an
54     iterator operates on the model to map the variables into responses
55     using the interface.  For memory efficiency and enhanced
56     polymorphism, the model hierarchy employs the "letter/envelope
57     idiom" (see Coplien "Advanced C++", p. 133), for which the base
58     class (Model) serves as the envelope and one of the derived
59     classes (selected in Model::get_model()) serves as the letter. */
60 
61 class Model
62 {
63   //
64   //- Heading: Friends
65   //
66 
67   /// equality operator (detect same letter instance)
68   friend bool operator==(const Model& m1, const Model& m2);
69   /// inequality operator (detect different letter instances)
70   friend bool operator!=(const Model& m1, const Model& m2);
71 
72 public:
73 
74   //
75   //- Heading: Constructors, destructor, assignment operator
76   //
77 
78   /// default constructor
79   Model();
80   /// standard constructor for envelope
81   Model(ProblemDescDB& problem_db);
82   /// copy constructor
83   Model(const Model& model);
84 
85   /// destructor
86   virtual ~Model();
87 
88   /// assignment operator
89   Model operator=(const Model& model);
90 
91   //
92   //- Heading: Virtual functions
93   //
94 
95   /// return the sub-iterator in nested and surrogate models
96   virtual Iterator& subordinate_iterator();
97   /// return a single sub-model defined from subModel in nested and recast
98   /// models and truth_model() in surrogate models; used for a directed
99   /// dive through model recursions that may bypass some components.
100   virtual Model& subordinate_model();
101 
102   /// set the active multi-index key within surrogate data, grid driver,
103   /// and approximation classes that support the management of multiple
104   /// approximation states within surrogate models
105   virtual void active_model_key(const UShortArray& mi_key);
106   /// reset by removing all multi-index keys within surrogate data, grid
107   /// driver, and approximation classes that support the management of
108   /// multiple approximation states within surrogate models
109   virtual void clear_model_keys();
110 
111   /// return number of unique response functions (managing any aggregations)
112   virtual size_t qoi() const;
113 
114   /// return the active approximation sub-model in surrogate models
115   virtual Model& surrogate_model();
116   /// return the active approximation sub-model in surrogate models
117   virtual const Model& surrogate_model() const;
118   /// return the active truth sub-model in surrogate models
119   virtual Model& truth_model();
120   /// return the active truth sub-model in surrogate models
121   virtual const Model& truth_model() const;
122 
123   /// portion of subordinate_models() specific to derived model classes
124   virtual void derived_subordinate_models(ModelList& ml, bool recurse_flag);
125   /// resize vars/resp if needed from the bottom up
126   virtual void resize_from_subordinate_model(size_t depth =
127     std::numeric_limits<size_t>::max());
128   /// propagate vars/labels/bounds/targets from the bottom up
129   virtual void update_from_subordinate_model(size_t depth =
130     std::numeric_limits<size_t>::max());
131   /// return the interface employed by the derived model class, if present:
132   /// SimulationModel::userDefinedInterface, DataFitSurrModel::approxInterface,
133   /// or NestedModel::optionalInterface
134   virtual Interface& derived_interface();
135 
136   /// number of discrete levels within solution control (SimulationModel)
137   virtual size_t solution_levels(bool lwr_bnd = true) const;
138   /// activate a particular level within the solution level control
139   /// and return the cost estimate (SimulationModel)
140   virtual void solution_level_index(unsigned short index);
141   /// return currently active level within the solution level control
142   /// (SimulationModel)
143   virtual unsigned short solution_level_index() const;
144   /// return ordered cost estimates across solution levels (SimulationModel)
145   virtual RealVector solution_level_costs() const;
146   /// return currently active cost estimate from solution level
147   /// control (SimulationModel)
148   virtual Real solution_level_cost() const;
149 
150   /// set the relative weightings for multiple objective functions or least
151   /// squares terms
152   virtual void primary_response_fn_weights(const RealVector& wts,
153 					   bool recurse_flag = true);
154 
155   /// set the (currently active) surrogate function index set
156   virtual void surrogate_function_indices(const IntSet& surr_fn_indices);
157 
158   /// return probability transformation employed by the Model (forwarded along
159   /// to ProbabilityTransformModel recasting)
160   virtual Pecos::ProbabilityTransformation& probability_transformation();
161 
162   /// Perform any global updates prior to individual evaluate() calls;
163   /// returns true if the variables size has changed
164   virtual bool initialize_mapping(ParLevLIter pl_iter);
165   /// restore state in preparation for next initialization;
166   /// returns true if the variables size has changed
167   virtual bool finalize_mapping();
168   /// return true if a potential resize is still pending, such that
169   /// sizing-based initialization should be deferred
170   virtual bool resize_pending() const;
171 
172   /// set primaryA{C,DI,DS,DR}VarMapIndices, secondaryA{C,DI,DS,DR}VarMapTargets
173   /// (coming from a higher-level NestedModel context to inform derivative est.)
174   virtual void nested_variable_mappings(const SizetArray& c_index1,
175 					const SizetArray& di_index1,
176 					const SizetArray& ds_index1,
177 					const SizetArray& dr_index1,
178 					const ShortArray& c_target2,
179 					const ShortArray& di_target2,
180 					const ShortArray& ds_target2,
181 					const ShortArray& dr_target2);
182   /// return primaryACVarMapIndices
183   virtual const SizetArray& nested_acv1_indices() const;
184   /// return secondaryACVarMapTargets
185   virtual const ShortArray& nested_acv2_targets() const;
186   /// calculate and return derivative composition of final results
187   /// w.r.t. distribution parameters (none, all, or mixed)
188   virtual short query_distribution_parameter_derivatives() const;
189   /// activate derivative setting w.r.t. distribution parameters
190   virtual void activate_distribution_parameter_derivatives();
191   /// deactivate derivative setting w.r.t. distribution parameters
192   virtual void deactivate_distribution_parameter_derivatives();
193 
194   /// transform x-space gradient vector to u-space
195   virtual void trans_grad_X_to_U(const RealVector& fn_grad_x,
196 				 RealVector& fn_grad_u,
197 				 const RealVector& x_vars);
198   /// transform u-space gradient vector to x-space
199   virtual void trans_grad_U_to_X(const RealVector& fn_grad_u,
200 				 RealVector& fn_grad_x,
201 				 const RealVector& x_vars);
202   /// transform x-space gradient vector to gradient with respect to inserted
203   /// distribution parameters
204   virtual void trans_grad_X_to_S(const RealVector& fn_grad_x,
205 				 RealVector& fn_grad_s,
206 				 const RealVector& x_vars);
207   /// transform x-space Hessian matrix to u-space
208   virtual void trans_hess_X_to_U(const RealSymMatrix& fn_hess_x,
209 				 RealSymMatrix& fn_hess_u,
210 				 const RealVector& x_vars,
211 				 const RealVector& fn_grad_x);
212 
213   /// build a new SurrogateModel approximation
214   virtual void build_approximation();
215   /// build a new SurrogateModel approximation using/enforcing
216   /// anchor response at vars; rebuild if needed
217   virtual bool build_approximation(const Variables& vars,
218 				   const IntResponsePair& response_pr);
219   /// update an existing SurrogateModel approximation
220   virtual void rebuild_approximation();
221 
222   /// replace the approximation data within an existing surrogate
223   /// based on data updates propagated elsewhere
224   virtual void update_approximation(bool rebuild_flag);
225   /// replace the anchor point data within an existing surrogate
226   virtual void update_approximation(const Variables& vars,
227 				    const IntResponsePair& response_pr,
228 				    bool rebuild_flag);
229   /// replace the data points within an existing surrogate
230   virtual void update_approximation(const VariablesArray& vars_array,
231 				    const IntResponseMap& resp_map,
232 				    bool rebuild_flag);
233   /// replace the data points within an existing surrogate
234   virtual void update_approximation(const RealMatrix& samples,
235 				    const IntResponseMap& resp_map,
236 				    bool rebuild_flag);
237 
238   /// append to the existing approximation data within a surrogate
239   /// based on data updates propagated elsewhere
240   virtual void append_approximation(bool rebuild_flag);
241   /// append a single point to an existing surrogate's data
242   virtual void append_approximation(const Variables& vars,
243 				    const IntResponsePair& response_pr,
244 				    bool rebuild_flag);
245   /// append multiple points to an existing surrogate's data
246   virtual void append_approximation(const VariablesArray& vars_array,
247 				    const IntResponseMap& resp_map,
248 				    bool rebuild_flag);
249   /// append multiple points to an existing surrogate's data
250   virtual void append_approximation(const RealMatrix& samples,
251 				    const IntResponseMap& resp_map,
252 				    bool rebuild_flag);
253 
254   /// remove the previous data set addition to a surrogate (e.g., due
255   /// to a previous append_approximation() call); flag manages storing
256   /// of surrogate data for use in a subsequent push_approximation()
257   virtual void pop_approximation(bool save_surr_data,
258 				 bool rebuild_flag = false);
259 
260   /// push a previous approximation data state; reverse of pop_approximation
261   virtual void push_approximation();
262   /// query for whether a trial increment is restorable within a surrogate
263   virtual bool push_available();
264 
265   /// finalize an approximation by applying all previous trial increments
266   virtual void finalize_approximation();
267 
268   /// combine the current approximation with previously stored data sets
269   virtual void combine_approximation();
270   /// promote the combined approximation into the active approximation
271   virtual void combined_to_active(bool clear_combined = true);
272   /// clear inactive approximations (finalization + combination completed)
273   virtual void clear_inactive();
274 
275   /// query the approximation for available advancement in resolution controls
276   /// (order, rank, etc.); an input to adaptive refinement strategies
277   virtual bool advancement_available();
278   /// query the approximation for updates in formulation, requiring a rebuild
279   /// even if no updates to the build data
280   virtual bool formulation_updated() const;
281   /// assign the status of approximation formulation updates
282   virtual void formulation_updated(bool update);
283 
284   /// execute the DACE iterator (prior to building/appending the approximation)
285   virtual void run_dace();
286 
287   // retrieve the variables used to build a surrogate model
288   //virtual const VariablesArray build_variables() const;
289   // retrieve the responses used to build a surrogate model
290   //virtual const ResponseArray build_responses() const;
291 
292   /// determine whether a surrogate model rebuild should be forced
293   /// based on changes in the inactive data
294   virtual bool force_rebuild();
295 
296   /// retrieve the shared approximation data within the ApproximationInterface
297   /// of a DataFitSurrModel
298   virtual SharedApproxData& shared_approximation();
299   /// retrieve the set of Approximations within the ApproximationInterface
300   /// of a DataFitSurrModel
301   virtual std::vector<Approximation>& approximations();
302   /// retrieve a SurrogateData instance from a particular Approximation
303   /// instance within the ApproximationInterface of a DataFitSurrModel
304   virtual const Pecos::SurrogateData& approximation_data(size_t fn_index);
305 
306   /// retrieve the approximation coefficients from each Approximation
307   /// within a DataFitSurrModel
308   virtual const RealVectorArray&
309     approximation_coefficients(bool normalized = false);
310   /// set the approximation coefficients for each Approximation within
311   /// a DataFitSurrModel
312   virtual void approximation_coefficients(const RealVectorArray& approx_coeffs,
313 					  bool normalized = false);
314 
315   /// retrieve the prediction variances from each Approximation within
316   /// a DataFitSurrModel
317   virtual const RealVector& approximation_variances(const Variables& vars);
318 
319   /// set response computation mode used in SurrogateModels for
320   /// forming currentResponse
321   virtual void surrogate_response_mode(short mode);
322   /// return response computation mode used in SurrogateModels for
323   /// forming currentResponse
324   virtual short surrogate_response_mode() const;
325 
326   // link together more than one SurrogateData instance (DataFitSurrModel)
327   //virtual void link_multilevel_approximation_data();
328 
329   /// retrieve error estimates corresponding to the Model's response
330   /// (could be surrogate error for SurrogateModels, statistical MSE for
331   /// NestedModels, or adjoint error estimates for SimulationModels).
332   /// Errors returned correspond to most recent evaluate().
333   virtual const RealVector& error_estimates();
334 
335   /// return the DiscrepancyCorrection object used by SurrogateModels
336   virtual DiscrepancyCorrection& discrepancy_correction();
337   /// set the correction type from the DiscrepancyCorrection object
338   /// used by SurrogateModels
339   virtual void correction_type(short corr_type);
340   /// return the correction type from the DiscrepancyCorrection object
341   /// used by SurrogateModels
342   virtual short correction_type();
343 
344   /// apply a DiscrepancyCorrection to correct an approximation within
345   /// a HierarchSurrModel
346   virtual void single_apply(const Variables& vars, Response& resp,
347 			    const UShortArray& paired_key);
348   /// apply a sequence of DiscrepancyCorrections to recursively correct an
349   /// approximation within a HierarchSurrModel
350   virtual void recursive_apply(const Variables& vars, Response& resp);
351 
352   /// update componentParallelMode for supporting parallelism in model
353   /// sub-components
354   virtual void component_parallel_mode(short mode);
355 
356   /// estimate the minimum and maximum partition sizes that can be
357   /// utilized by this Model
358   virtual IntIntPair estimate_partition_bounds(int max_eval_concurrency);
359 
360   /// return the index for the metaiterator-iterator parallelism level within
361   /// ParallelConfiguration::miPLIters that is active for use in a particular
362   /// Model at runtime
363   virtual size_t mi_parallel_level_index() const;
364 
365   /// migrate an unmatched response record from active response map (computed
366   /// by synchronize() or synhronize_nowait()) to cached response map
367   virtual void cache_unmatched_response(int raw_id);
368 
369   /// return derived model synchronization setting
370   virtual short local_eval_synchronization();
371   /// return derived model asynchronous evaluation concurrency
372   virtual int local_eval_concurrency();
373 
374   /// Service job requests received from the master.  Completes when
375   /// a termination message is received from stop_servers().
376   virtual void serve_run(ParLevLIter pl_iter, int max_eval_concurrency);
377   /// Executed by the master to terminate all server operations for a
378   /// particular model when iteration on the model is complete.
379   virtual void stop_servers();
380 
381   /// Return a flag indicating the combination of multiprocessor
382   /// evaluations and a dedicated master iterator scheduling.  Used
383   /// in synchronous evaluate functions to prevent the error
384   /// of trying to run a multiprocessor job on the master.
385   virtual bool derived_master_overload() const;
386 
387   /// update the Model's inactive view based on higher level (nested) context
388   virtual void inactive_view(short view, bool recurse_flag = true);
389 
390   /// return the interface identifier
391   virtual const String& interface_id() const;
392   /// Return the value of the evaluation id counter for the Model
393   virtual int derived_evaluation_id() const;
394 
395   /// Indicates the usage of an evaluation cache by the Model
396   virtual bool evaluation_cache(bool recurse_flag = true) const;
397   /// Indicates the usage of a restart file by the Model
398   virtual bool restart_file(bool recurse_flag = true) const;
399 
400   /// Set the reference points for the evaluation counters within the Model
401   virtual void set_evaluation_reference();
402   /// Request fine-grained evaluation reporting within the Model
403   virtual void fine_grained_evaluation_counters();
404   /// Print an evaluation summary for the Model
405   virtual void print_evaluation_summary(std::ostream& s,
406 					bool minimal_header = false,
407 					bool relative_count = true) const;
408 
409   /// set the hierarchical eval ID tag prefix
410   virtual void eval_tag_prefix(const String& eval_id_str);
411 
412   /// search the eval database (during derivative estimation); derived
413   /// may need to reimplement due to problem transformations
414   /// (RecastModel); return true if found in DB
415   virtual bool db_lookup(const Variables& search_vars,
416 			 const ActiveSet& search_set, Response& found_resp);
417 
418   /// called from IteratorScheduler::run_iterator() for iteratorComm rank 0 to
419   /// terminate serve_init_mapping() on other iteratorComm processors
420   virtual void stop_init_mapping(ParLevLIter pl_iter);
421   /// called from IteratorScheduler::run_iterator() for iteratorComm rank != 0
422   /// to balance resize() calls on iteratorComm rank 0
423   virtual int serve_init_mapping(ParLevLIter pl_iter);
424 
425   /// called from IteratorScheduler::run_iterator() for iteratorComm rank 0 to
426   /// terminate serve_finalize_mapping() on other iteratorComm processors
427   virtual void stop_finalize_mapping(ParLevLIter pl_iter);
428   /// called from IteratorScheduler::run_iterator() for iteratorComm rank != 0
429   /// to balance resize() calls on iteratorComm rank 0
430   virtual int serve_finalize_mapping(ParLevLIter pl_iter);
431 
432   /// set the warm start flag (warmStartFlag)
433   virtual void warm_start_flag(const bool flag);
434 
435   /// Declare a model's sources to the evaluationsDB
436   virtual void declare_sources();
437 
438   //
439   //- Heading: Member functions
440   //
441 
442   /// return the sub-models in nested and surrogate models
443   ModelList& subordinate_models(bool recurse_flag = true);
444 
445   // TO DO: synchronous evaluate() should return int codes for
446   // algorithm-specific mitigation of captured failures
447 
448   /// Compute the Response at currentVariables (default ActiveSet).
449   void evaluate();
450   /// Compute the Response at currentVariables (specified ActiveSet).
451   void evaluate(const ActiveSet& set);
452 
453   /// Spawn an asynchronous job (or jobs) that computes the value of the
454   /// Response at currentVariables (default ActiveSet).
455   void evaluate_nowait();
456   /// Spawn an asynchronous job (or jobs) that computes the value of the
457   /// Response at currentVariables (specified ActiveSet).
458   void evaluate_nowait(const ActiveSet& set);
459 
460   // TO DO: for evaluate_nowait(), add access fns for ShortArray/List
461   // return codes for algorithm-specific mitigation of captured failures.
462 
463   /// Execute a blocking scheduling algorithm to collect the
464   /// complete set of results from a group of asynchronous evaluations.
465   const IntResponseMap& synchronize();
466   /// Execute a nonblocking scheduling algorithm to collect all
467   /// available results from a group of asynchronous evaluations.
468   const IntResponseMap& synchronize_nowait();
469 
470   /// return Model's (top-level) evaluation counter, not to be confused
471   /// with derived counter returned by derived_evaluation_id()
472   int evaluation_id() const;
473 
474   // return mappingInitialized
475   bool mapping_initialized() const;
476 
477   /// allocate communicator partitions for a model and store
478   /// configuration in modelPCIterMap
479   void init_communicators(ParLevLIter pl_iter, int max_eval_concurrency,
480 			  bool recurse_flag = true);
481   /// for cases where init_communicators() will not be called,
482   /// modify some default settings to behave properly in serial.
483   void init_serial();
484   /// set active parallel configuration for the model (set modelPCIter
485   /// from modelPCIterMap)
486   void set_communicators(ParLevLIter pl_iter, int max_eval_concurrency,
487 			 bool recurse_flag = true);
488   /// deallocate communicator partitions for a model
489   void free_communicators(ParLevLIter pl_iter, int max_eval_concurrency,
490 			  bool recurse_flag = true);
491 
492   /// retrieve the MPI communicator on which this model is configured to
493   /// conduct function evaluation analyses (provided for library clients)
494   MPI_Comm analysis_comm() const;
495 
496   /// called from IteratorScheduler::init_iterator() for iteratorComm rank 0 to
497   /// terminate serve_init_communicators() on other iteratorComm processors
498   void stop_init_communicators(ParLevLIter pl_iter);
499   /// called from IteratorScheduler::init_iterator() for iteratorComm rank != 0
500   /// to balance init_communicators() calls on iteratorComm rank 0
501   int serve_init_communicators(ParLevLIter pl_iter);
502 
503   /// estimate messageLengths for a model
504   void estimate_message_lengths();
505 
506   /// return (potentially aggregated) size of response vector in currentResponse
507   size_t response_size() const;
508 
509   /// initialize modelList and recastFlags for data import/export
510   bool manage_data_recastings();
511   /// return true if recastFlags is defined
512   bool recastings() const;
513 
514   /// employ the model recursion to transform from bottom level
515   /// user-space data to top level iterator-space data
516   void user_space_to_iterator_space(const Variables& user_vars,
517 				    const Response&  user_resp,
518 				    Variables& iter_vars, Response& iter_resp);
519   /// employ the model recursion to transform from top level
520   /// iterator-space data to bottom level user-space data
521   void iterator_space_to_user_space(const Variables& iter_vars,
522 				    const Response&  iter_resp,
523 				    Variables& user_vars, Response& user_resp);
524 
525   //
526   //- Heading: Set and Inquire functions
527   //
528 
529   /// replaces existing letter with a new one
530   void assign_rep(std::shared_ptr<Model> model_rep);
531 
532   // VARIABLES
533 
534   size_t  tv()  const; ///< returns total number of vars
535   size_t  cv()  const; ///< returns number of active continuous variables
536   size_t div()  const; ///< returns number of active discrete integer vars
537   size_t dsv()  const; ///< returns number of active discrete string vars
538   size_t drv()  const; ///< returns number of active discrete real vars
539   size_t icv()  const; ///< returns number of inactive continuous variables
540   size_t idiv() const; ///< returns number of inactive discrete integer vars
541   size_t idsv() const; ///< returns number of inactive discrete string vars
542   size_t idrv() const; ///< returns number of inactive discrete real vars
543   size_t acv()  const; ///< returns total number of continuous variables
544   size_t adiv() const; ///< returns total number of discrete integer vars
545   size_t adsv() const; ///< returns total number of discrete string vars
546   size_t adrv() const; ///< returns total number of discrete real vars
547 
548   /// set the active variables in currentVariables
549   void active_variables(const Variables& vars);
550 
551   /// return the active continuous variables from currentVariables
552   const RealVector& continuous_variables() const;
553   /// return an active continuous variable from currentVariables
554   Real continuous_variable(size_t i) const;
555   /// set the active continuous variables in currentVariables
556   void continuous_variables(const RealVector& c_vars);
557   /// set an active continuous variable in currentVariables
558   void continuous_variable(Real c_var, size_t i);
559   /// return the active discrete integer variables from currentVariables
560   const IntVector& discrete_int_variables() const;
561   /// return an active discrete integer variable from currentVariables
562   int discrete_int_variable(size_t i) const;
563   /// set the active discrete integer variables in currentVariables
564   void discrete_int_variables(const IntVector& d_vars);
565   /// set an active discrete integer variable in currentVariables
566   void discrete_int_variable(int d_var, size_t i);
567   /// return the active discrete string variables from currentVariables
568   StringMultiArrayConstView discrete_string_variables() const;
569   /// return an active discrete string variable from currentVariables
570   const String& discrete_string_variable(size_t i) const;
571   /// set the active discrete string variables in currentVariables
572   void discrete_string_variables(StringMultiArrayConstView d_vars);
573   /// set an active discrete string variable in currentVariables
574   void discrete_string_variable(const String& d_var, size_t i);
575   /// return the active discrete real variables from currentVariables
576   const RealVector& discrete_real_variables() const;
577   /// return an active discrete real variable from currentVariables
578   Real discrete_real_variable(size_t i) const;
579   /// set the active discrete real variables in currentVariables
580   void discrete_real_variables(const RealVector& d_vars);
581   /// set an active discrete real variable in currentVariables
582   void discrete_real_variable(Real d_var, size_t i);
583 
584   /// return the active continuous variable types from currentVariables
585   UShortMultiArrayConstView continuous_variable_types() const;
586   /// set the active continuous variable types in currentVariables
587   void continuous_variable_types(UShortMultiArrayConstView cv_types);
588   /// set an active continuous variable type in currentVariables
589   void continuous_variable_type(unsigned short cv_type, size_t i);
590   /// return the active discrete variable types from currentVariables
591   UShortMultiArrayConstView discrete_int_variable_types() const;
592   /// set the active discrete variable types in currentVariables
593   void discrete_int_variable_types(UShortMultiArrayConstView div_types);
594   /// set an active discrete variable type in currentVariables
595   void discrete_int_variable_type(unsigned short div_type, size_t i);
596   /// return the active discrete variable types from currentVariables
597   UShortMultiArrayConstView discrete_string_variable_types() const;
598   /// set the active discrete variable types in currentVariables
599   void discrete_string_variable_types(UShortMultiArrayConstView div_types);
600   /// set an active discrete variable type in currentVariables
601   void discrete_string_variable_type(unsigned short div_type, size_t i);
602   /// return the active discrete variable types from currentVariables
603   UShortMultiArrayConstView discrete_real_variable_types() const;
604   /// set the active discrete variable types in currentVariables
605   void discrete_real_variable_types(UShortMultiArrayConstView drv_types);
606   /// set an active discrete variable type in currentVariables
607   void discrete_real_variable_type(unsigned short drv_type, size_t i);
608   /// return the active continuous variable identifiers from currentVariables
609   SizetMultiArrayConstView continuous_variable_ids() const;
610   /// set the active continuous variable identifiers in currentVariables
611   void continuous_variable_ids(SizetMultiArrayConstView cv_ids);
612   /// set an active continuous variable identifier in currentVariables
613   void continuous_variable_id(size_t cv_id, size_t i);
614 
615   /// return the inactive continuous variables in currentVariables
616   const RealVector& inactive_continuous_variables() const;
617   /// set the inactive continuous variables in currentVariables
618   void inactive_continuous_variables(const RealVector& i_c_vars);
619   /// return the inactive discrete variables in currentVariables
620   const IntVector& inactive_discrete_int_variables() const;
621   /// set the inactive discrete variables in currentVariables
622   void inactive_discrete_int_variables(const IntVector& i_d_vars);
623   /// return the inactive discrete variables in currentVariables
624   StringMultiArrayConstView inactive_discrete_string_variables() const;
625   /// set the inactive discrete variables in currentVariables
626   void inactive_discrete_string_variables(StringMultiArrayConstView i_d_vars);
627   /// return the inactive discrete variables in currentVariables
628   const RealVector& inactive_discrete_real_variables() const;
629   /// set the inactive discrete variables in currentVariables
630   void inactive_discrete_real_variables(const RealVector& i_d_vars);
631 
632   /// return the inactive continuous variable types from currentVariables
633   UShortMultiArrayConstView inactive_continuous_variable_types() const;
634   /// return the inactive continuous variable identifiers from currentVariables
635   SizetMultiArrayConstView inactive_continuous_variable_ids() const;
636 
637   /// return all continuous variables in currentVariables
638   const RealVector& all_continuous_variables() const;
639   /// set all continuous variables in currentVariables
640   void all_continuous_variables(const RealVector& a_c_vars);
641   /// set a variable within the all continuous variables in currentVariables
642   void all_continuous_variable(Real a_c_var, size_t i);
643   /// return all discrete variables in currentVariables
644   const IntVector& all_discrete_int_variables() const;
645   /// set all discrete variables in currentVariables
646   void all_discrete_int_variables(const IntVector& a_d_vars);
647   /// set a variable within the all discrete variables in currentVariables
648   void all_discrete_int_variable(int a_d_var, size_t i);
649   /// return all discrete variables in currentVariables
650   StringMultiArrayConstView all_discrete_string_variables() const;
651   /// set all discrete variables in currentVariables
652   void all_discrete_string_variables(StringMultiArrayConstView a_d_vars);
653   /// set a variable within the all discrete variables in currentVariables
654   void all_discrete_string_variable(const String& a_d_var, size_t i);
655   /// return all discrete variables in currentVariables
656   const RealVector& all_discrete_real_variables() const;
657   /// set all discrete variables in currentVariables
658   void all_discrete_real_variables(const RealVector& a_d_vars);
659   /// set a variable within the all discrete variables in currentVariables
660   void all_discrete_real_variable(Real a_d_var, size_t i);
661 
662   /// return all continuous variable types from currentVariables
663   UShortMultiArrayConstView all_continuous_variable_types()    const;
664   /// return all discrete variable types from currentVariables
665   UShortMultiArrayConstView all_discrete_int_variable_types()  const;
666   /// return all discrete variable types from currentVariables
667   UShortMultiArrayConstView all_discrete_string_variable_types()  const;
668   /// return all discrete variable types from currentVariables
669   UShortMultiArrayConstView all_discrete_real_variable_types() const;
670   /// return all continuous variable identifiers from currentVariables
671   SizetMultiArrayConstView  all_continuous_variable_ids()      const;
672 
673   // array indicating which discrete integer variables are set vs. range?
674   /// define and return discreteIntSets using active view from currentVariables
675   const BitArray& discrete_int_sets();
676   /// define and return discreteIntSets using passed active view
677   const BitArray& discrete_int_sets(short active_view);
678   // define and return discreteStringSets
679   //const BitArray& discrete_string_sets();
680   // define and return discreteRealSets
681   //const BitArray& discrete_real_sets();
682 
683   /// return the sets of values available for each of the active
684   /// discrete set integer variables (aggregated in activeDiscSetIntValues)
685   const IntSetArray& discrete_set_int_values();
686   /// return the sets of values available for each of the active
687   /// discrete set integer variables (aggregated in activeDiscSetIntValues)
688   const IntSetArray& discrete_set_int_values(short active_view);
689   /// return the sets of values available for each of the active
690   /// discrete set string variables (aggregated in activeDiscSetStringValues)
691   const StringSetArray& discrete_set_string_values();
692   /// return the sets of values available for each of the active
693   /// discrete set string variables (aggregated in activeDiscSetStringValues)
694   const StringSetArray& discrete_set_string_values(short active_view);
695   /// return the sets of values available for each of the active
696   /// discrete set real variables (aggregated in activeDiscSetRealValues)
697   const RealSetArray& discrete_set_real_values();
698   /// return the sets of values available for each of the active
699   /// discrete set real variables (aggregated in activeDiscSetRealValues)
700   const RealSetArray& discrete_set_real_values(short active_view);
701 
702   /// return mvDist
703   Pecos::MultivariateDistribution& multivariate_distribution();
704   /// return mvDist
705   const Pecos::MultivariateDistribution& multivariate_distribution() const;
706   // set mvDist
707   //void multivariate_distribution(const Pecos::MultivariateDistribution& dist);
708 
709   // LABELS and TAGS
710 
711   /// return the active continuous variable labels from currentVariables
712   StringMultiArrayConstView continuous_variable_labels() const;
713   /// set the active continuous variable labels in currentVariables
714   void continuous_variable_labels(StringMultiArrayConstView c_v_labels);
715   /// return the active discrete variable labels from currentVariables
716   StringMultiArrayConstView discrete_int_variable_labels()   const;
717   /// set the active discrete variable labels in currentVariables
718   void discrete_int_variable_labels(StringMultiArrayConstView d_v_labels);
719   /// return the active discrete variable labels from currentVariables
720   StringMultiArrayConstView discrete_string_variable_labels()   const;
721   /// set the active discrete variable labels in currentVariables
722   void discrete_string_variable_labels(StringMultiArrayConstView d_v_labels);
723   /// return the active discrete variable labels from currentVariables
724   StringMultiArrayConstView discrete_real_variable_labels()   const;
725   /// set the active discrete variable labels in currentVariables
726   void discrete_real_variable_labels(StringMultiArrayConstView d_v_labels);
727 
728   /// return the inactive continuous variable labels in currentVariables
729   StringMultiArrayConstView inactive_continuous_variable_labels() const;
730   /// set the inactive continuous variable labels in currentVariables
731   void inactive_continuous_variable_labels(
732     StringMultiArrayConstView i_c_v_labels);
733   /// return the inactive discrete variable labels in currentVariables
734   StringMultiArrayConstView inactive_discrete_int_variable_labels() const;
735   /// set the inactive discrete variable labels in currentVariables
736   void inactive_discrete_int_variable_labels(
737     StringMultiArrayConstView i_d_v_labels);
738   /// return the inactive discrete variable labels in currentVariables
739   StringMultiArrayConstView inactive_discrete_string_variable_labels() const;
740   /// set the inactive discrete variable labels in currentVariables
741   void inactive_discrete_string_variable_labels(
742     StringMultiArrayConstView i_d_v_labels);
743   /// return the inactive discrete variable labels in currentVariables
744   StringMultiArrayConstView inactive_discrete_real_variable_labels() const;
745   /// set the inactive discrete variable labels in currentVariables
746   void inactive_discrete_real_variable_labels(
747     StringMultiArrayConstView i_d_v_labels);
748 
749   /// return all continuous variable labels in currentVariables
750   StringMultiArrayConstView all_continuous_variable_labels() const;
751   /// set all continuous variable labels in currentVariables
752   void all_continuous_variable_labels(StringMultiArrayConstView a_c_v_labels);
753   /// set a label within the all continuous labels in currentVariables
754   void all_continuous_variable_label(const String& a_c_v_label,size_t i);
755   /// return all discrete variable labels in currentVariables
756   StringMultiArrayConstView all_discrete_int_variable_labels() const;
757   /// set all discrete variable labels in currentVariables
758   void all_discrete_int_variable_labels(StringMultiArrayConstView a_d_v_labels);
759   /// set a label within the all discrete labels in currentVariables
760   void all_discrete_int_variable_label(const String& a_d_v_label,
761 				       size_t i);
762   /// return all discrete variable labels in currentVariables
763   StringMultiArrayConstView all_discrete_string_variable_labels() const;
764   /// set all discrete variable labels in currentVariables
765   void all_discrete_string_variable_labels(StringMultiArrayConstView
766 					   a_d_v_labels);
767   /// set a label within the all discrete labels in currentVariables
768   void all_discrete_string_variable_label(const String& a_d_v_label,
769 					  size_t i);
770   /// return all discrete variable labels in currentVariables
771   StringMultiArrayConstView all_discrete_real_variable_labels() const;
772   /// set all discrete variable labels in currentVariables
773   void all_discrete_real_variable_labels(
774     StringMultiArrayConstView a_d_v_labels);
775   /// set a label within the all discrete labels in currentVariables
776   void all_discrete_real_variable_label(const String& a_d_v_label, size_t i);
777 
778   /// return the response labels from currentResponse
779   const StringArray& response_labels() const;
780   /// set the response labels in currentResponse
781   void response_labels(const StringArray& resp_labels);
782 
783   // BOUNDS
784 
785   /// return the active continuous lower bounds from userDefinedConstraints
786   const RealVector& continuous_lower_bounds() const;
787   /// return an active continuous lower bound from userDefinedConstraints
788   Real continuous_lower_bound(size_t i) const;
789   /// set the active continuous lower bounds in userDefinedConstraints
790   void continuous_lower_bounds(const RealVector& c_l_bnds);
791   /// set the i-th active continuous lower bound in userDefinedConstraints
792   void continuous_lower_bound(Real c_l_bnd, size_t i);
793   /// return the active continuous upper bounds from userDefinedConstraints
794   const RealVector& continuous_upper_bounds() const;
795   /// return an active continuous upper bound from userDefinedConstraints
796   Real continuous_upper_bound(size_t i) const;
797   /// set the active continuous upper bounds in userDefinedConstraints
798   void continuous_upper_bounds(const RealVector& c_u_bnds);
799   /// set the i-th active continuous upper bound from userDefinedConstraints
800   void continuous_upper_bound(Real c_u_bnd, size_t i);
801   /// return the active discrete int lower bounds from userDefinedConstraints
802   const IntVector& discrete_int_lower_bounds() const;
803   /// return an active discrete int lower bound from userDefinedConstraints
804   int discrete_int_lower_bound(size_t i) const;
805   /// set the active discrete int lower bounds in userDefinedConstraints
806   void discrete_int_lower_bounds(const IntVector& d_l_bnds);
807   /// set the i-th active discrete int lower bound in userDefinedConstraints
808   void discrete_int_lower_bound(int d_l_bnd, size_t i);
809   /// return the active discrete int upper bounds from userDefinedConstraints
810   const IntVector& discrete_int_upper_bounds() const;
811   /// return an active discrete int upper bound from userDefinedConstraints
812   int discrete_int_upper_bound(size_t i) const;
813   /// set the active discrete int upper bounds in userDefinedConstraints
814   void discrete_int_upper_bounds(const IntVector& d_u_bnds);
815   /// set the i-th active discrete int upper bound in userDefinedConstraints
816   void discrete_int_upper_bound(int d_u_bnd, size_t i);
817   /// return the active discrete real lower bounds from userDefinedConstraints
818   const RealVector& discrete_real_lower_bounds() const;
819   /// return an active discrete real lower bound from userDefinedConstraints
820   Real discrete_real_lower_bound(size_t i) const;
821   /// set the active discrete real lower bounds in userDefinedConstraints
822   void discrete_real_lower_bounds(const RealVector& d_l_bnds);
823   /// set the i-th active discrete real lower bound in userDefinedConstraints
824   void discrete_real_lower_bound(Real d_l_bnd, size_t i);
825   /// return the active discrete real upper bounds from userDefinedConstraints
826   const RealVector& discrete_real_upper_bounds() const;
827   /// return an active discrete real upper bound from userDefinedConstraints
828   Real discrete_real_upper_bound(size_t i) const;
829   /// set the active discrete real upper bounds in userDefinedConstraints
830   void discrete_real_upper_bounds(const RealVector& d_u_bnds);
831   /// set the i-th active discrete real upper bound in userDefinedConstraints
832   void discrete_real_upper_bound(Real d_u_bnd, size_t i);
833 
834   /// return the inactive continuous lower bounds in userDefinedConstraints
835   const RealVector& inactive_continuous_lower_bounds() const;
836   /// set the inactive continuous lower bounds in userDefinedConstraints
837   void inactive_continuous_lower_bounds(const RealVector& i_c_l_bnds);
838   /// return the inactive continuous upper bounds in userDefinedConstraints
839   const RealVector& inactive_continuous_upper_bounds() const;
840   /// set the inactive continuous upper bounds in userDefinedConstraints
841   void inactive_continuous_upper_bounds(const RealVector& i_c_u_bnds);
842   /// return the inactive discrete lower bounds in userDefinedConstraints
843   const IntVector& inactive_discrete_int_lower_bounds() const;
844   /// set the inactive discrete lower bounds in userDefinedConstraints
845   void inactive_discrete_int_lower_bounds(const IntVector& i_d_l_bnds);
846   /// return the inactive discrete upper bounds in userDefinedConstraints
847   const IntVector& inactive_discrete_int_upper_bounds() const;
848   /// set the inactive discrete upper bounds in userDefinedConstraints
849   void inactive_discrete_int_upper_bounds(const IntVector& i_d_u_bnds);
850   /// return the inactive discrete lower bounds in userDefinedConstraints
851   const RealVector& inactive_discrete_real_lower_bounds() const;
852   /// set the inactive discrete lower bounds in userDefinedConstraints
853   void inactive_discrete_real_lower_bounds(const RealVector& i_d_l_bnds);
854   /// return the inactive discrete upper bounds in userDefinedConstraints
855   const RealVector& inactive_discrete_real_upper_bounds() const;
856   /// set the inactive discrete upper bounds in userDefinedConstraints
857   void inactive_discrete_real_upper_bounds(const RealVector& i_d_u_bnds);
858 
859   /// return all continuous lower bounds in userDefinedConstraints
860   const RealVector& all_continuous_lower_bounds() const;
861   /// set all continuous lower bounds in userDefinedConstraints
862   void all_continuous_lower_bounds(const RealVector& a_c_l_bnds);
863   /// set a lower bound within continuous lower bounds in
864   /// userDefinedConstraints
865   void all_continuous_lower_bound(Real a_c_l_bnd, size_t i);
866   /// return all continuous upper bounds in userDefinedConstraints
867   const RealVector& all_continuous_upper_bounds() const;
868   /// set all continuous upper bounds in userDefinedConstraints
869   void all_continuous_upper_bounds(const RealVector& a_c_u_bnds);
870   /// set an upper bound within all continuous upper bounds in
871   /// userDefinedConstraints
872   void all_continuous_upper_bound(Real a_c_u_bnd, size_t i);
873   /// return all discrete lower bounds in userDefinedConstraints
874   const IntVector& all_discrete_int_lower_bounds() const;
875   /// set all discrete lower bounds in userDefinedConstraints
876   void all_discrete_int_lower_bounds(const IntVector& a_d_l_bnds);
877   /// set a lower bound within all discrete lower bounds in
878   /// userDefinedConstraints
879   void all_discrete_int_lower_bound(int a_d_l_bnd, size_t i);
880   /// return all discrete upper bounds in userDefinedConstraints
881   const IntVector& all_discrete_int_upper_bounds() const;
882   /// set all discrete upper bounds in userDefinedConstraints
883   void all_discrete_int_upper_bounds(const IntVector& a_d_u_bnds);
884   /// set an upper bound within all discrete upper bounds in
885   /// userDefinedConstraints
886   void all_discrete_int_upper_bound(int a_d_u_bnd, size_t i);
887   /// return all discrete lower bounds in userDefinedConstraints
888   const RealVector& all_discrete_real_lower_bounds() const;
889   /// set all discrete lower bounds in userDefinedConstraints
890   void all_discrete_real_lower_bounds(const RealVector& a_d_l_bnds);
891   /// set a lower bound within all discrete lower bounds in
892   /// userDefinedConstraints
893   void all_discrete_real_lower_bound(Real a_d_l_bnd, size_t i);
894   /// return all discrete upper bounds in userDefinedConstraints
895   const RealVector& all_discrete_real_upper_bounds() const;
896   /// set all discrete upper bounds in userDefinedConstraints
897   void all_discrete_real_upper_bounds(const RealVector& a_d_u_bnds);
898   /// set an upper bound within all discrete upper bounds in
899   /// userDefinedConstraints
900   void all_discrete_real_upper_bound(Real a_d_u_bnd, size_t i);
901 
902   // CONSTRAINTS
903 
904   /// reshape the linear/nonlinear constraint arrays
905   void reshape_constraints(size_t num_nln_ineq_cons, size_t num_nln_eq_cons,
906 			   size_t num_lin_ineq_cons, size_t num_lin_eq_cons);
907 
908   // LINEAR CONSTRAINTS
909 
910   /// return the number of linear inequality constraints
911   size_t num_linear_ineq_constraints() const;
912   /// return the number of linear equality constraints
913   size_t num_linear_eq_constraints() const;
914 
915   /// return the linear inequality constraint coefficients
916   const RealMatrix& linear_ineq_constraint_coeffs() const;
917   /// set the linear inequality constraint coefficients
918   void linear_ineq_constraint_coeffs(const RealMatrix& lin_ineq_coeffs);
919   /// return the linear inequality constraint lower bounds
920   const RealVector& linear_ineq_constraint_lower_bounds() const;
921   /// set the linear inequality constraint lower bounds
922   void linear_ineq_constraint_lower_bounds(
923     const RealVector& lin_ineq_l_bnds);
924   /// return the linear inequality constraint upper bounds
925   const RealVector& linear_ineq_constraint_upper_bounds() const;
926   /// set the linear inequality constraint upper bounds
927   void linear_ineq_constraint_upper_bounds(
928     const RealVector& lin_ineq_u_bnds);
929   /// return the linear equality constraint coefficients
930   const RealMatrix& linear_eq_constraint_coeffs() const;
931   /// set the linear equality constraint coefficients
932   void linear_eq_constraint_coeffs(const RealMatrix& lin_eq_coeffs);
933   /// return the linear equality constraint targets
934   const RealVector& linear_eq_constraint_targets() const;
935   /// set the linear equality constraint targets
936   void linear_eq_constraint_targets(const RealVector& lin_eq_targets);
937 
938   // NONLINEAR CONSTRAINTS
939 
940   /// return the number of nonlinear inequality constraints
941   size_t num_nonlinear_ineq_constraints() const;
942   /// return the number of nonlinear equality constraints
943   size_t num_nonlinear_eq_constraints() const;
944 
945   /// return the nonlinear inequality constraint lower bounds
946   const RealVector& nonlinear_ineq_constraint_lower_bounds() const;
947   /// set the nonlinear inequality constraint lower bounds
948   void nonlinear_ineq_constraint_lower_bounds(
949     const RealVector& nln_ineq_l_bnds);
950   /// return the nonlinear inequality constraint upper bounds
951   const RealVector& nonlinear_ineq_constraint_upper_bounds() const;
952   /// set the nonlinear inequality constraint upper bounds
953   void nonlinear_ineq_constraint_upper_bounds(
954     const RealVector& nln_ineq_u_bnds);
955   /// return the nonlinear equality constraint targets
956   const RealVector& nonlinear_eq_constraint_targets() const;
957   /// set the nonlinear equality constraint targets
958   void nonlinear_eq_constraint_targets(const RealVector& nln_eq_targets);
959 
960   // return the array of discrete variable identifiers that were
961   // relaxed into a continuous array in currentVariables
962   //const SizetArray& relaxed_discrete_ids() const;
963 
964   /// return the current variables (currentVariables) as const
965   /// reference (preferred)
966   const Variables& current_variables() const;
967   /// return the current variables (currentVariables) in mutable form
968   /// (special cases)
969   Variables& current_variables();
970   /// return the user-defined constraints (userDefinedConstraints)
971   const Constraints& user_defined_constraints() const;
972   /// return the current response (currentResponse)
973   const Response& current_response() const;
974   /// return the problem description database (probDescDB)
975   ProblemDescDB& problem_description_db() const;
976   /// return the parallel library (parallelLib)
977   ParallelLibrary& parallel_library() const;
978   /// return the model type (modelType)
979   const String& model_type() const;
980   /// return the surrogate type (surrogateType)
981   const String& surrogate_type() const;
982   /// return the model identifier (modelId)
983   const String& model_id() const;
984 
985   /// return number of primary functions (total less nonlinear constraints)
986   size_t num_primary_fns() const;
987   /// return number of secondary functions (number of nonlinear constraints)
988   size_t num_secondary_fns() const;
989 
990   /// return the gradient evaluation type (gradientType)
991   const String& gradient_type() const;
992   /// return the numerical gradient evaluation method source (methodSource)
993   const String& method_source() const;
994   /// return the numerical gradient evaluation interval type (intervalType)
995   const String& interval_type() const;
996   /// option for ignoring bounds when numerically estimating derivatives
997   bool ignore_bounds() const;
998   /// option for using old 2nd-order scheme when computing finite-diff Hessian
999   bool central_hess() const;
1000   /// return the finite difference gradient step size (fdGradStepSize)
1001   const RealVector& fd_gradient_step_size() const;
1002   /// return the finite difference gradient step type (fdGradStepType)
1003   const String& fd_gradient_step_type() const;
1004   /// return the mixed gradient analytic IDs (gradIdAnalytic)
1005   const IntSet& gradient_id_analytic() const;
1006   /// return the mixed gradient numerical IDs (gradIdNumerical)
1007   const IntSet& gradient_id_numerical() const;
1008 
1009   /// return the Hessian evaluation type (hessianType)
1010   const String& hessian_type() const;
1011   /// return the Hessian evaluation type (quasiHessType)
1012   const String& quasi_hessian_type() const;
1013   /// return gradient-based finite difference Hessian step size
1014   /// (fdHessByGradStepSize)
1015   const RealVector& fd_hessian_by_grad_step_size() const;
1016   /// return function-based finite difference Hessian step size
1017   /// (fdHessByFnStepSize)
1018   const RealVector& fd_hessian_by_fn_step_size() const;
1019   /// return the finite difference Hessian step type (fdHessStepType)
1020   const String& fd_hessian_step_type() const;
1021   /// return the mixed Hessian analytic IDs (hessIdAnalytic)
1022   const IntSet& hessian_id_analytic() const;
1023   /// return the mixed Hessian analytic IDs (hessIdNumerical)
1024   const IntSet& hessian_id_numerical() const;
1025   /// return the mixed Hessian analytic IDs (hessIdQuasi)
1026   const IntSet& hessian_id_quasi() const;
1027 
1028   /// set the optimization sense for multiple objective functions
1029   void primary_response_fn_sense(const BoolDeque& sense);
1030   /// get the optimization sense for multiple objective functions
1031   const BoolDeque& primary_response_fn_sense() const;
1032   /// get the relative weightings for multiple objective functions or least
1033   /// squares terms
1034   const RealVector& primary_response_fn_weights() const;
1035   /// user-provided scaling options
1036   const ScalingOptions& scaling_options() const;
1037 
1038   /// get the primary response function type (generic, objective, calibration)
1039   short primary_fn_type() const;
1040   /// set the primary response function type, e.g., when recasting
1041   void primary_fn_type(short type);
1042 
1043   /// indicates potential usage of estimate_derivatives() based on
1044   /// gradientType/hessianType
1045   bool derivative_estimation();
1046   /// set whether this model should perform or pass on derivative estimation
1047   void supports_derivative_estimation(bool sed_flag);
1048 
1049   /// set initCommsBcastFlag
1050   void init_comms_bcast_flag(bool icb_flag);
1051 
1052   /// return the evaluation capacity for use in iterator logic
1053   int evaluation_capacity() const;
1054 
1055   /// return the gradient concurrency for use in parallel configuration logic
1056   int derivative_concurrency() const;
1057 
1058   /// return the asynchronous evaluation flag (asynchEvalFlag)
1059   bool asynch_flag() const;
1060   /// set the asynchronous evaluation flag (asynchEvalFlag)
1061   void asynch_flag(const bool flag);
1062 
1063   /// return the outputLevel
1064   short output_level() const;
1065   /// set the outputLevel
1066   void output_level(const short level);
1067 
1068   /// return the array of MPI packed message buffer lengths (messageLengths)
1069   const IntArray& message_lengths() const;
1070 
1071   /// set modelPCIter
1072   void parallel_configuration_iterator(ParConfigLIter pc_iter);
1073   /// return modelPCIter
1074   ParConfigLIter parallel_configuration_iterator() const;
1075 
1076   /// set modelAutoGraphicsFlag to activate posting of graphics data within
1077   /// evaluate/synchronize functions (automatic graphics posting in
1078   /// the model as opposed to graphics posting at the strategy level).
1079   void auto_graphics(const bool flag);
1080 
1081   /// get modelAutoGraphicsFlag to activate posting of graphics data within
1082   /// evaluate/synchronize functions (automatic graphics posting in
1083   /// the model as opposed to graphics posting at the strategy level).
1084   bool auto_graphics() const;
1085 
1086   /// function to check modelRep (does this envelope contain a letter)
1087   bool is_null() const;
1088 
1089   /// returns modelRep for access to derived class member functions
1090   /// that are not mapped to the top Model level
1091   std::shared_ptr<Model> model_rep() const;
1092 
1093   /// set the specified configuration to the Model's inactive vars,
1094   /// converting from real to integer or through index to string value
1095   /// as needed
1096   static void active_variables(const RealVector& config_vars, Model& model);
1097   /// set the specified configuration to the Model's inactive vars,
1098   /// converting from real to integer or through index to string value
1099   /// as needed
1100   static void inactive_variables(const RealVector& config_vars, Model& model);
1101 
1102   static void inactive_variables(const RealVector& config_vars, Model& model,
1103 				 Variables& updated_vars);
1104 
1105   /// Bulk synchronously evaluate the model for each column in the
1106   /// samples matrix and return as columns of the response matrix
1107   static void evaluate(const RealMatrix& samples_matrix,
1108 		       Model& model, RealMatrix& resp_matrix);
1109 
1110   /// Return the model ID of the "innermost" model.
1111   /// For all derived Models except RecastModels, return modelId.
1112   /// The RecastModel override returns the root_model_id() of the subModel.
1113   virtual String root_model_id();
1114 
1115   virtual ActiveSet default_active_set();
1116 
1117 protected:
1118 
1119   //
1120   //- Heading: Constructors
1121   //
1122 
1123   /// constructor initializing the base class part of letter classes
1124   /// (BaseConstructor overloading avoids infinite recursion in the
1125   /// derived class constructors - Coplien, p. 139)
1126   Model(BaseConstructor, ProblemDescDB& problem_db);
1127 
1128   /// constructor initializing base class for derived model class instances
1129   /// constructed on the fly
1130   Model(LightWtBaseConstructor, ProblemDescDB& problem_db,
1131 	ParallelLibrary& parallel_lib,
1132 	const SharedVariablesData& svd, bool share_svd,
1133 	const SharedResponseData&  srd, bool share_srd,
1134 	const ActiveSet& set, short output_level);
1135 
1136   /// constructor initializing base class for recast model instances
1137   Model(LightWtBaseConstructor, ProblemDescDB& problem_db,
1138 	ParallelLibrary& parallel_lib);
1139 
1140 
1141   /// return the next available model ID for no-ID user methods
1142   static String user_auto_id();
1143 
1144   /// return the next available model ID for on-the-fly methods
1145   static String no_spec_id();
1146 
1147   /// Whether to write model evals to the evaluations DB
1148   EvaluationsDBState modelEvaluationsDBState;
1149   /// Whether to write interface evals to the evaluations DB
1150   EvaluationsDBState interfEvaluationsDBState;
1151 
1152   //
1153   //- Heading: Virtual functions
1154   //
1155 
1156   /// portion of evaluate() specific to derived model classes
1157   virtual void derived_evaluate(const ActiveSet& set);
1158   /// portion of evaluate_nowait() specific to derived model classes
1159   virtual void derived_evaluate_nowait(const ActiveSet& set);
1160 
1161   /// portion of synchronize() specific to derived model classes
1162   virtual const IntResponseMap& derived_synchronize();
1163   /// portion of synchronize_nowait() specific to derived model classes
1164   virtual const IntResponseMap& derived_synchronize_nowait();
1165 
1166   /// portion of init_communicators() specific to derived model classes
1167   virtual void derived_init_communicators(ParLevLIter pl_iter,
1168 					  int max_eval_concurrency,
1169 					  bool recurse_flag = true);
1170   /// portion of init_serial() specific to derived model classes
1171   virtual void derived_init_serial();
1172   /// portion of set_communicators() specific to derived model classes
1173   virtual void derived_set_communicators(ParLevLIter pl_iter,
1174 					 int max_eval_concurrency,
1175 					 bool recurse_flag = true);
1176   /// portion of free_communicators() specific to derived model classes
1177   virtual void derived_free_communicators(ParLevLIter pl_iter,
1178 					  int max_eval_concurrency,
1179 					  bool recurse_flag = true);
1180 
1181   //
1182   //- Heading: Member functions
1183   //
1184 
1185   /// initialize distribution types from problemDescDB
1186   void initialize_distribution(
1187     Pecos::MultivariateDistribution& mv_dist, bool active_only = false);
1188   /// initialize distribution parameters from problemDescDB
1189   void initialize_distribution_parameters(
1190     Pecos::MultivariateDistribution& mv_dist, bool active_only = false);
1191 
1192   /// default logic for defining asynchEvalFlag and evaluationCapacity
1193   /// based on ie_pl settings
1194   void set_ie_asynchronous_mode(int max_eval_concurrency);
1195 
1196   /// assign all of the longest possible string values into vars
1197   void assign_max_strings(const Pecos::MultivariateDistribution& mv_dist,
1198 			  Variables& vars);
1199   /// return iterator for longest string value found in string set
1200   SSCIter max_string(const StringSet& ss);
1201   /// return iterator for longest string value found in string map
1202   SRMCIter max_string(const StringRealMap& srm);
1203 
1204   /// Initialize data needed for computing finite differences
1205   /// (active/inactive, center point, and bounds)
1206   SizetMultiArrayConstView
1207   initialize_x0_bounds(const SizetArray& original_dvv, bool& active_derivs,
1208                        bool& inactive_derivs, RealVector& x0, RealVector& fd_lb,
1209                        RealVector& fd_ub) const;
1210 
1211   /// Compute the forward step for a finite difference gradient;
1212   /// updates shortStep
1213   Real forward_grad_step(size_t num_deriv_vars, size_t xj_index,
1214                          Real x0_j, Real lb_j, Real ub_j);
1215 
1216   /*
1217   /// rekey jobs from resp_map to resp_map_rekey according to id_map; this
1218   /// version selects a loop over response or id map based on the smaller
1219   /// array size
1220   void rekey_response_map(const IntResponseMap& resp_map, IntIntMap& id_map,
1221 			  IntResponseMap& resp_map_rekey,
1222 			  bool deep_copy_resp = false);
1223   /// rekey jobs from resp_map to resp_map_rekey according to id_map;
1224   /// this version iterates over resp_map and searches id_map
1225   void rekey_response_map_rloop(const IntResponseMap& resp_map,
1226 				IntIntMap& id_map,
1227 				IntResponseMap& resp_map_rekey,
1228 				bool deep_copy_resp = false);
1229   /// rekey jobs from resp_map to resp_map_rekey according to id_map;
1230   /// this version iterates over id_map and searches resp_map
1231   void rekey_response_map_iloop(const IntResponseMap& resp_map,
1232 				IntIntMap& id_map,
1233 				IntResponseMap& resp_map_rekey,
1234 				bool deep_copy_resp = false);
1235   /// migrate and rekey jobs from resp_map and cached_resp_map to resp_map_rekey
1236   /// according to id_map; insert unmatched resp_map jobs into cached_resp_map
1237   void rekey_response_map(const IntResponseMap& resp_map, IntIntMap& id_map,
1238 			  IntResponseMap& resp_map_rekey,
1239 			  IntResponseMap& cached_resp_map,
1240 			  bool deep_copy_resp = false);
1241   */
1242 
1243   /// Return the interface flag for the EvaluationsDB state
1244   EvaluationsDBState evaluations_db_state(const Interface &interface);
1245   /// Return the model flag for the EvaluationsDB state
1246   EvaluationsDBState evaluations_db_state(const Model &model);
1247 
1248 
1249   /// Store the response portion of an interface evaluation. Called from rekey_response_map
1250   void asynch_eval_store(const Interface &interface, const int &id, const Response &response);
1251   /// Exists to support storage of interface evaluations. No-op so that
1252   ///  rekey_response_map<Model> can be generated.
1253   void asynch_eval_store(const Model &model, const int &id, const Response &response);
1254 
1255   /// rekey returned jobs matched in id_map into resp_map_rekey;
1256   /// unmatched jobs are cached within the meta_object
1257   template <typename MetaType>
1258   void rekey_response_map(MetaType& meta_object, const IntResponseMap& resp_map,
1259 			  IntIntMap& id_map, IntResponseMap& resp_map_rekey,
1260 			  bool deep_copy_resp = false);
1261   /// synchronize via meta_object and rekey returned jobs matched in id_map
1262   /// into resp_map_rekey; unmatched jobs are cached within the meta_object
1263   template <typename MetaType>
1264   void rekey_synch(MetaType& meta_object, bool block, IntIntMap& id_map,
1265 		   IntResponseMap& resp_map_rekey, bool deep_copy_resp = false);
1266 
1267   //
1268   //- Heading: Data
1269   //
1270 
1271   // The 3 parts of the mapping performed by a model. Note that the size_t's
1272   // describing the sizes of data within these objects must be declared in the
1273   // order that ModelRep initialization should occur (see Effective C++, p. 41).
1274 
1275   /// the set of current variables used by the model for performing
1276   /// function evaluations
1277   Variables currentVariables;
1278   /// the number of active continuous variables used in computing most response
1279   /// derivatives (i.e., in places such as quasi-Hessians and response
1280   /// corrections where only the active continuous variables are supported)
1281   size_t numDerivVars;
1282 
1283   // presence of a Interface now varies by derived model class
1284   //Interface userDefinedInterface;
1285 
1286   /// the set of current responses that holds the results of model
1287   /// function evaluations
1288   Response currentResponse;
1289   /// the number of functions in currentResponse
1290   size_t numFns;
1291 
1292   /// Explicit constraints on variables are maintained in the Constraints
1293   /// class hierarchy.  Currently, this includes linear constraints and bounds,
1294   /// but could be extended in the future to include other explicit constraints
1295   /// which (1) have their form specified by the user, and (2) are not
1296   /// catalogued in Response since their form and coefficients are published to
1297   /// an iterator at startup.
1298   Constraints userDefinedConstraints;
1299 
1300   /// model identifier string from the input file
1301   String modelId;
1302   /// type of model: simulation, nested, or surrogate
1303   String modelType;
1304   /// type of surrogate model: local_*, multipoint_*, global_*, or hierarchical
1305   String surrogateType;
1306 
1307   /// type of gradient data: analytic, numerical, mixed, or none
1308   String gradientType;
1309   /// source of numerical gradient routine: dakota or vendor
1310   String methodSource;
1311   /// type of numerical gradient interval: central or forward
1312   String intervalType;
1313   /// type of Hessian data: analytic, numerical, quasi, mixed, or none
1314   String hessianType;
1315 
1316   /// relative finite difference step size for numerical gradients
1317   /** A scalar value (instead of the vector fd_gradient_step_size spec) is
1318       used within the iterator hierarchy since this attribute is only used
1319       to publish a step size to vendor numerical gradient algorithms. */
1320   RealVector fdGradStepSize;
1321   /// type of finite difference step to use for numerical gradient:
1322   /// relative - step length is relative to x
1323   /// absolute - step length is what is specified
1324   /// bounds - step length is relative to range of x
1325   String fdGradStepType;
1326   /// relative finite difference step size for numerical Hessians estimated
1327   /// using first-order differences of gradients
1328   /** For vendor numerical Hessian algorithms, a scalar value is used. */
1329   RealVector fdHessByGradStepSize;
1330   /// relative finite difference step size for numerical Hessians estimated
1331   /// using second-order differences of function values
1332   /** For vendor numerical Hessian algorithms, a scalar value is used. */
1333   RealVector fdHessByFnStepSize;
1334   /// type of finite difference step to use for numerical Hessian:
1335   /// relative - step length is relative to x
1336   /// absolute - step length is what is specified
1337   /// bounds - step length is relative to range of x
1338   String fdHessStepType;
1339 
1340   /// option to ignore bounds when computing finite diffs
1341   bool ignoreBounds;
1342   /// option to use old 2nd-order finite diffs for Hessians
1343   bool centralHess;
1344   /// if in warm-start mode, don't reset accumulated data (e.g., quasiHessians)
1345   bool warmStartFlag;
1346   /// whether model should perform or forward derivative estimation
1347   bool supportsEstimDerivs;
1348   /// quasi-Hessian type: bfgs, damped_bfgs, sr1
1349   String quasiHessType;
1350 
1351   IntSet gradIdAnalytic;  ///< analytic id's for mixed gradients
1352   IntSet gradIdNumerical; ///< numerical id's for mixed gradients
1353   IntSet hessIdAnalytic;  ///< analytic id's for mixed Hessians
1354   IntSet hessIdNumerical; ///< numerical id's for mixed Hessians
1355   IntSet hessIdQuasi;     ///< quasi id's for mixed Hessians
1356 
1357   /// length of packed MPI buffers containing vars, vars/set, response,
1358   /// and PRPair
1359   IntArray messageLengths;
1360 
1361   /// track use of initialize_mapping() and finalize_mapping()
1362   bool mappingInitialized;
1363 
1364   /// class member reference to the problem description database
1365   /** Iterator and Model cannot use a shallow copy of ProblemDescDB
1366       due to circular destruction dependency (reference counts can't
1367       get to 0), since ProblemDescDB contains {iterator,model}List. */
1368   ProblemDescDB& probDescDB;
1369 
1370   /// class member reference to the parallel library
1371   ParallelLibrary& parallelLib;
1372 
1373   /// the ParallelConfiguration node used by this Model instance
1374   ParConfigLIter modelPCIter;
1375 
1376   /// the component parallelism mode: NO_PARALLEL_MODE, SURROGATE_MODEL_MODE,
1377   // TRUTH_MODEL_MODE, SUB_MODEL_MODE, INTERFACE_MODE, OPTIONAL_INTERFACE_MODE
1378   short componentParallelMode;
1379 
1380   /// flags asynch evaluations (local or distributed)
1381   bool asynchEvalFlag;
1382 
1383   /// capacity for concurrent evaluations supported by the Model
1384   int evaluationCapacity;
1385 
1386   /// output verbosity level: {SILENT,QUIET,NORMAL,VERBOSE,DEBUG}_OUTPUT
1387   short outputLevel;
1388 
1389   /*
1390   /// array of IntSet's, each containing the set of allowable integer
1391   /// values corresponding to a discrete design integer set variable
1392   IntSetArray discreteDesignSetIntValues;
1393   /// array of IntSet's, each containing the set of allowable integer
1394   /// values corresponding to a discrete design string set variable
1395   StringSetArray discreteDesignSetStringValues;
1396   /// array of RealSet's, each containing the set of allowable real
1397   /// values corresponding to a discrete design real set variable
1398   RealSetArray discreteDesignSetRealValues;
1399 
1400   /// array of IntSet's, each containing the set of allowable integer
1401   /// values corresponding to a discrete state integer set variable
1402   IntSetArray discreteStateSetIntValues;
1403   /// array of IntSet's, each containing the set of allowable integer
1404   /// values corresponding to a discrete state string set variable
1405   StringSetArray discreteStateSetStringValues;
1406   /// array of RealSet's, each containing the set of allowable real
1407   /// values corresponding to a discrete state real set variable
1408   RealSetArray discreteStateSetRealValues;
1409   */
1410 
1411   /// the multivariate random variable distribution (in probability space
1412   /// corresponding to currentVariables)
1413   Pecos::MultivariateDistribution mvDist;
1414 
1415   /// array of flags (one per primary function) for switching the
1416   /// sense to maximize the primary function (default is minimize)
1417   BoolDeque primaryRespFnSense;
1418   /// primary response function weightings (either weights for
1419   /// multiobjective optimization or weighted least squares)
1420   RealVector primaryRespFnWts;
1421 
1422   /// whether to perform hierarchical evalID tagging of params/results
1423   bool hierarchicalTagging;
1424 
1425   /// user-provided scaling data from the problem DB, possibly
1426   /// modified by Recasting
1427   ScalingOptions scalingOpts;
1428 
1429   /// cached evalTag Prefix from parents to use at evaluate time
1430   String evalTagPrefix;
1431 
1432   /// reference to the global evaluation database
1433   EvaluationStore &evaluationsDB;
1434 
1435 private:
1436 
1437   //
1438   //- Heading: Member functions
1439   //
1440 
1441   /// Used by the envelope to instantiate the correct letter class
1442   std::shared_ptr<Model> get_model(ProblemDescDB& problem_db);
1443 
1444   /// evaluate numerical gradients using finite differences.  This
1445   /// routine is selected with "method_source dakota" (the default
1446   /// method_source) in the numerical gradient specification.
1447   int estimate_derivatives(const ShortArray& map_asv,
1448 			   const ShortArray& fd_grad_asv,
1449 			   const ShortArray& fd_hess_asv,
1450 			   const ShortArray& quasi_hess_asv,
1451 			   const ActiveSet& original_set,
1452 			   const bool asynch_flag);
1453 
1454   /// combine results from an array of finite difference response
1455   /// objects (fd_grad_responses) into a single response (new_response)
1456   void synchronize_derivatives(const Variables& vars,
1457 			       const IntResponseMap& fd_responses,
1458 			       Response& new_response,
1459 			       const ShortArray& fd_grad_asv,
1460 			       const ShortArray& fd_hess_asv,
1461 			       const ShortArray& quasi_hess_asv,
1462 			       const ActiveSet& original_set);
1463 
1464   /// overlay results to update a response object
1465   void update_response(const Variables& vars, Response& new_response,
1466 		       const ShortArray& fd_grad_asv,
1467 		       const ShortArray& fd_hess_asv,
1468 		       const ShortArray& quasi_hess_asv,
1469 		       const ActiveSet& original_set,
1470 		       Response& initial_map_response,
1471 		       const RealMatrix& new_fn_grads,
1472 		       const RealSymMatrixArray& new_fn_hessians);
1473 
1474   /// perform quasi-Newton Hessian updates
1475   void update_quasi_hessians(const Variables& vars, Response& new_response,
1476 			     const ActiveSet& original_set);
1477 
1478   /// Coordinates usage of estimate_derivatives() calls based on asv_in
1479   bool manage_asv(const ActiveSet& original_set, ShortArray& map_asv_out,
1480 		  ShortArray& fd_grad_asv_out, ShortArray& fd_hess_asv_out,
1481 		  ShortArray& quasi_hess_asv_out);
1482 
1483   /// function to determine initial finite difference h (before step
1484   /// length adjustment) based on type of step desired
1485   Real initialize_h(Real x_j, Real lb_j, Real ub_j, Real step_size,
1486 		    String step_type) const;
1487   /// function returning finite-difference step size (affected by bounds)
1488   Real FDstep1(Real x0_j, Real lb_j, Real ub_j, Real h_mag);
1489   /// function returning second central-difference step size (affected
1490   /// by bounds)
1491   Real FDstep2(Real x0_j, Real lb_j, Real ub_j, Real h);
1492 
1493   //
1494   //- Heading: Data
1495   //
1496 
1497   /// evaluation counter for top-level evaluate() and evaluate_nowait()
1498   /// calls.  Differs from lower level counters in case of numerical
1499   /// derivative estimation (several lower level evaluations are
1500   /// assimilated into a single higher level evaluation)
1501   int modelEvalCntr;
1502 
1503   /// flags presence of estimated derivatives within a set of calls to
1504   /// evaluate_nowait()
1505   bool estDerivsFlag;
1506   /// flags finite-difference step size adjusted by bounds
1507   bool shortStep;
1508 
1509   /// map<> used for tracking modelPCIter instances using depth of parallelism
1510   /// level and max evaluation concurrency as the lookup keys
1511   std::map<SizetIntPair, ParConfigLIter> modelPCIterMap;
1512 
1513   /// flag for determining need to bcast the max concurrency from
1514   /// init_communicators(); set from IteratorScheduler::init_iterator()
1515   bool initCommsBcastFlag;
1516 
1517   /// flag for posting of graphics data within evaluate()
1518   /// (automatic graphics posting in the model as opposed to
1519   /// graphics posting at the strategy level)
1520   bool modelAutoGraphicsFlag;
1521 
1522   /// history of vars populated in evaluate_nowait() and used in
1523   /// synchronize().
1524   IntVariablesMap varsMap;
1525   /// if estimate_derivatives() is used, transfers ASVs from
1526   /// evaluate_nowait() to synchronize()
1527   std::list<ShortArray> asvList;
1528   /// if estimate_derivatives() is used, transfers ActiveSets from
1529   /// evaluate_nowait() to synchronize()
1530   std::list<ActiveSet> setList;
1531   /// transfers initial_map flag values from estimate_derivatives() to
1532   /// synchronize_derivatives()
1533   BoolList initialMapList;
1534   /// transfers db_capture flag values from estimate_derivatives() to
1535   /// synchronize_derivatives()
1536   BoolList dbCaptureList;
1537   /// transfers database captures from estimate_derivatives() to
1538   /// synchronize_derivatives()
1539   ResponseList dbResponseList;
1540   /// transfers deltas from estimate_derivatives() to synchronize_derivatives()
1541   RealList deltaList;
1542 
1543   /// tracks the number of evaluations used within estimate_derivatives().
1544   /// Used in synchronize() as a key for combining finite difference
1545   /// responses into numerical gradients.
1546   IntIntMap numFDEvalsMap;
1547   /// maps from the raw evaluation ids returned by derived_synchronize() and
1548   /// derived_synchronize_nowait() to the corresponding modelEvalCntr id.
1549   /// Used for rekeying responseMap.
1550   IntIntMap rawEvalIdMap;
1551 
1552   /// previous parameter vectors used in computing s for quasi-Newton updates
1553   RealVectorArray xPrev;
1554   /// previous gradient vectors used in computing y for quasi-Newton updates
1555   RealMatrix fnGradsPrev;
1556 
1557   /// quasi-Newton Hessian approximations
1558   RealSymMatrixArray quasiHessians;
1559   /// number of quasi-Newton Hessian updates applied
1560   SizetArray numQuasiUpdates;
1561 
1562   /// used to return a map of responses for asynchronous evaluations in final
1563   /// concatenated form.  The similar map in Interface contains raw responses.
1564   IntResponseMap responseMap;
1565   /// caching of responses returned by derived_synchronize{,_nowait}()
1566   /// but not matched within current rawEvalIdMap
1567   IntResponseMap cachedResponseMap;
1568   /// used to cache the data returned from derived_synchronize_nowait() prior
1569   /// to sequential input into the graphics
1570   IntResponseMap graphicsRespMap;
1571 
1572   /// aggregation of the admissible value sets for all active discrete
1573   /// set integer variables
1574   IntSetArray activeDiscSetIntValues;
1575   /// aggregation of the admissible value sets for all active discrete
1576   /// set string variables
1577   StringSetArray activeDiscSetStringValues;
1578   /// aggregation of the admissible value sets for all active discrete
1579   /// set real variables
1580   RealSetArray activeDiscSetRealValues;
1581   /// key for identifying discrete integer set variables within the
1582   /// active discrete integer variables
1583   BitArray discreteIntSets;
1584   // key for identifying discrete string set variables within the active
1585   // discrete string variables
1586   //BitArray discreteStringSets;
1587   // key for identifying discrete real set variables within the active
1588   // discrete real variables
1589   //BitArray discreteRealSets;
1590 
1591   /// previous view used in discrete_set_int_values(view): avoids
1592   /// recomputation of activeDiscSetIntValues
1593   short prevDSIView;
1594   /// previous view used in discrete_set_string_values(view): avoids
1595   /// recomputation of activeDiscSetStringValues
1596   short prevDSSView;
1597   /// previous view used in discrete_set_real_values(view): avoids
1598   /// recomputation of activeDiscSetRealValues
1599   short prevDSRView;
1600 
1601   /// used to collect sub-models for subordinate_models()
1602   ModelList modelList;
1603   /// a key indicating which models within a model recursion involve recasting
1604   BoolDeque recastFlags;
1605 
1606   /// pointer to the letter (initialized only for the envelope)
1607   std::shared_ptr<Model> modelRep;
1608 
1609   /// the last used model ID number for on-the-fly instantiations
1610   /// (increment before each use)
1611   static size_t noSpecIdNum;
1612 };
1613 
1614 
evaluation_id() const1615 inline int Model::evaluation_id() const
1616 { return (modelRep) ? modelRep->modelEvalCntr : modelEvalCntr; }
1617 
1618 
recastings() const1619 inline bool Model::recastings() const
1620 { return (modelRep) ? !modelRep->recastFlags.empty() : !recastFlags.empty(); }
1621 
1622 
tv() const1623 inline size_t Model::tv() const
1624 { return (modelRep) ? modelRep->currentVariables.tv() : currentVariables.tv(); }
1625 
1626 
cv() const1627 inline size_t Model::cv() const
1628 { return (modelRep) ? modelRep->currentVariables.cv() : currentVariables.cv(); }
1629 
1630 
div() const1631 inline size_t Model::div() const
1632 {
1633   return (modelRep) ? modelRep->currentVariables.div() : currentVariables.div();
1634 }
1635 
1636 
dsv() const1637 inline size_t Model::dsv() const
1638 {
1639   return (modelRep) ? modelRep->currentVariables.dsv() : currentVariables.dsv();
1640 }
1641 
1642 
drv() const1643 inline size_t Model::drv() const
1644 {
1645   return (modelRep) ? modelRep->currentVariables.drv() : currentVariables.drv();
1646 }
1647 
1648 
icv() const1649 inline size_t Model::icv() const
1650 {
1651   return (modelRep) ? modelRep->currentVariables.icv() : currentVariables.icv();
1652 }
1653 
1654 
idiv() const1655 inline size_t Model::idiv() const
1656 {
1657   return (modelRep) ? modelRep->currentVariables.idiv()
1658                     : currentVariables.idiv();
1659 }
1660 
1661 
idsv() const1662 inline size_t Model::idsv() const
1663 {
1664   return (modelRep) ? modelRep->currentVariables.idsv()
1665                     : currentVariables.idsv();
1666 }
1667 
1668 
idrv() const1669 inline size_t Model::idrv() const
1670 {
1671   return (modelRep) ? modelRep->currentVariables.idrv()
1672                     : currentVariables.idrv();
1673 }
1674 
1675 
acv() const1676 inline size_t Model::acv() const
1677 {
1678   return (modelRep) ? modelRep->currentVariables.acv() : currentVariables.acv();
1679 }
1680 
1681 
adiv() const1682 inline size_t Model::adiv() const
1683 {
1684   return (modelRep) ? modelRep->currentVariables.adiv()
1685                     : currentVariables.adiv();
1686 }
1687 
1688 
adsv() const1689 inline size_t Model::adsv() const
1690 {
1691   return (modelRep) ? modelRep->currentVariables.adsv()
1692                     : currentVariables.adsv();
1693 }
1694 
1695 
adrv() const1696 inline size_t Model::adrv() const
1697 {
1698   return (modelRep) ? modelRep->currentVariables.adrv()
1699                     : currentVariables.adrv();
1700 }
1701 
1702 
active_variables(const Variables & vars)1703 inline void Model::active_variables(const Variables& vars)
1704 {
1705   if (modelRep) modelRep->currentVariables.active_variables(vars);
1706   else          currentVariables.active_variables(vars);
1707 }
1708 
1709 
continuous_variables() const1710 inline const RealVector& Model::continuous_variables() const
1711 {
1712   return (modelRep) ? modelRep->currentVariables.continuous_variables()
1713                     : currentVariables.continuous_variables();
1714 }
1715 
1716 
continuous_variable(size_t i) const1717 inline Real Model::continuous_variable(size_t i) const
1718 {
1719   return (modelRep) ? modelRep->currentVariables.continuous_variable(i)
1720                     : currentVariables.continuous_variable(i);
1721 }
1722 
1723 
continuous_variables(const RealVector & c_vars)1724 inline void Model::continuous_variables(const RealVector& c_vars)
1725 {
1726   if (modelRep) modelRep->currentVariables.continuous_variables(c_vars);
1727   else          currentVariables.continuous_variables(c_vars);
1728 }
1729 
1730 
continuous_variable(Real c_var,size_t i)1731 inline void Model::continuous_variable(Real c_var, size_t i)
1732 {
1733   if (modelRep) modelRep->currentVariables.continuous_variable(c_var, i);
1734   else          currentVariables.continuous_variable(c_var, i);
1735 }
1736 
1737 
discrete_int_variables() const1738 inline const IntVector& Model::discrete_int_variables() const
1739 {
1740   return (modelRep) ? modelRep->currentVariables.discrete_int_variables()
1741                     : currentVariables.discrete_int_variables();
1742 }
1743 
1744 
discrete_int_variable(size_t i) const1745 inline int Model::discrete_int_variable(size_t i) const
1746 {
1747   return (modelRep) ? modelRep->currentVariables.discrete_int_variable(i)
1748                     : currentVariables.discrete_int_variable(i);
1749 }
1750 
1751 
discrete_int_variables(const IntVector & d_vars)1752 inline void Model::discrete_int_variables(const IntVector& d_vars)
1753 {
1754   if (modelRep) modelRep->currentVariables.discrete_int_variables(d_vars);
1755   else          currentVariables.discrete_int_variables(d_vars);
1756 }
1757 
1758 
discrete_int_variable(int d_var,size_t i)1759 inline void Model::discrete_int_variable(int d_var, size_t i)
1760 {
1761   if (modelRep) modelRep->currentVariables.discrete_int_variable(d_var, i);
1762   else          currentVariables.discrete_int_variable(d_var, i);
1763 }
1764 
1765 
discrete_string_variables() const1766 inline StringMultiArrayConstView Model::discrete_string_variables() const
1767 {
1768   return (modelRep) ? modelRep->currentVariables.discrete_string_variables()
1769                     : currentVariables.discrete_string_variables();
1770 }
1771 
1772 
discrete_string_variable(size_t i) const1773 inline const String& Model::discrete_string_variable(size_t i) const
1774 {
1775   return (modelRep) ? modelRep->currentVariables.discrete_string_variable(i)
1776                     : currentVariables.discrete_string_variable(i);
1777 }
1778 
1779 
discrete_string_variables(StringMultiArrayConstView d_vars)1780 inline void Model::discrete_string_variables(StringMultiArrayConstView d_vars)
1781 {
1782   if (modelRep) modelRep->currentVariables.discrete_string_variables(d_vars);
1783   else          currentVariables.discrete_string_variables(d_vars);
1784 }
1785 
1786 
discrete_string_variable(const String & d_var,size_t i)1787 inline void Model::discrete_string_variable(const String& d_var, size_t i)
1788 {
1789   if (modelRep) modelRep->currentVariables.discrete_string_variable(d_var, i);
1790   else          currentVariables.discrete_string_variable(d_var, i);
1791 }
1792 
1793 
discrete_real_variables() const1794 inline const RealVector& Model::discrete_real_variables() const
1795 {
1796   return (modelRep) ? modelRep->currentVariables.discrete_real_variables()
1797                     : currentVariables.discrete_real_variables();
1798 }
1799 
1800 
discrete_real_variable(size_t i) const1801 inline Real Model::discrete_real_variable(size_t i) const
1802 {
1803   return (modelRep) ? modelRep->currentVariables.discrete_real_variable(i)
1804                     : currentVariables.discrete_real_variable(i);
1805 }
1806 
1807 
discrete_real_variables(const RealVector & d_vars)1808 inline void Model::discrete_real_variables(const RealVector& d_vars)
1809 {
1810   if (modelRep) modelRep->currentVariables.discrete_real_variables(d_vars);
1811   else          currentVariables.discrete_real_variables(d_vars);
1812 }
1813 
1814 
discrete_real_variable(Real d_var,size_t i)1815 inline void Model::discrete_real_variable(Real d_var, size_t i)
1816 {
1817   if (modelRep) modelRep->currentVariables.discrete_real_variable(d_var, i);
1818   else          currentVariables.discrete_real_variable(d_var, i);
1819 }
1820 
1821 
continuous_variable_types() const1822 inline UShortMultiArrayConstView Model::continuous_variable_types() const
1823 {
1824   return (modelRep) ? modelRep->currentVariables.continuous_variable_types()
1825                     : currentVariables.continuous_variable_types();
1826 }
1827 
1828 
continuous_variable_types(UShortMultiArrayConstView cv_types)1829 inline void Model::continuous_variable_types(UShortMultiArrayConstView cv_types)
1830 {
1831   if (modelRep)
1832     modelRep->currentVariables.continuous_variable_types(cv_types);
1833   else
1834     currentVariables.continuous_variable_types(cv_types);
1835 }
1836 
1837 
continuous_variable_type(unsigned short cv_type,size_t i)1838 inline void Model::continuous_variable_type(unsigned short cv_type, size_t i)
1839 {
1840   if (modelRep)
1841     modelRep->currentVariables.continuous_variable_type(cv_type, i);
1842   else
1843     currentVariables.continuous_variable_type(cv_type, i);
1844 }
1845 
1846 
discrete_int_variable_types() const1847 inline UShortMultiArrayConstView Model::discrete_int_variable_types() const
1848 {
1849   return (modelRep) ? modelRep->currentVariables.discrete_int_variable_types()
1850                     : currentVariables.discrete_int_variable_types();
1851 }
1852 
1853 
1854 inline void Model::
discrete_int_variable_types(UShortMultiArrayConstView div_types)1855 discrete_int_variable_types(UShortMultiArrayConstView div_types)
1856 {
1857   if (modelRep)
1858     modelRep->currentVariables.discrete_int_variable_types(div_types);
1859   else
1860     currentVariables.discrete_int_variable_types(div_types);
1861 }
1862 
1863 
discrete_int_variable_type(unsigned short div_type,size_t i)1864 inline void Model::discrete_int_variable_type(unsigned short div_type, size_t i)
1865 {
1866   if (modelRep)
1867     modelRep->currentVariables.discrete_int_variable_type(div_type, i);
1868   else
1869     currentVariables.discrete_int_variable_type(div_type, i);
1870 }
1871 
1872 
discrete_string_variable_types() const1873 inline UShortMultiArrayConstView Model::discrete_string_variable_types() const
1874 {
1875   return (modelRep) ?
1876     modelRep->currentVariables.discrete_string_variable_types() :
1877     currentVariables.discrete_string_variable_types();
1878 }
1879 
1880 
1881 inline void Model::
discrete_string_variable_types(UShortMultiArrayConstView dsv_types)1882 discrete_string_variable_types(UShortMultiArrayConstView dsv_types)
1883 {
1884   if (modelRep)
1885     modelRep->currentVariables.discrete_string_variable_types(dsv_types);
1886   else
1887     currentVariables.discrete_string_variable_types(dsv_types);
1888 }
1889 
1890 
1891 inline void Model::
discrete_string_variable_type(unsigned short dsv_type,size_t i)1892 discrete_string_variable_type(unsigned short dsv_type, size_t i)
1893 {
1894   if (modelRep)
1895     modelRep->currentVariables.discrete_string_variable_type(dsv_type, i);
1896   else
1897     currentVariables.discrete_string_variable_type(dsv_type, i);
1898 }
1899 
1900 
discrete_real_variable_types() const1901 inline UShortMultiArrayConstView Model::discrete_real_variable_types() const
1902 {
1903   return (modelRep) ? modelRep->currentVariables.discrete_real_variable_types()
1904                     : currentVariables.discrete_real_variable_types();
1905 }
1906 
1907 
1908 inline void Model::
discrete_real_variable_types(UShortMultiArrayConstView drv_types)1909 discrete_real_variable_types(UShortMultiArrayConstView drv_types)
1910 {
1911   if (modelRep)
1912     modelRep->currentVariables.discrete_real_variable_types(drv_types);
1913   else
1914     currentVariables.discrete_real_variable_types(drv_types);
1915 }
1916 
1917 
1918 inline void Model::
discrete_real_variable_type(unsigned short drv_type,size_t i)1919 discrete_real_variable_type(unsigned short drv_type, size_t i)
1920 {
1921   if (modelRep)
1922     modelRep->currentVariables.discrete_real_variable_type(drv_type, i);
1923   else
1924     currentVariables.discrete_real_variable_type(drv_type, i);
1925 }
1926 
1927 
continuous_variable_ids() const1928 inline SizetMultiArrayConstView Model::continuous_variable_ids() const
1929 {
1930   return (modelRep) ? modelRep->currentVariables.continuous_variable_ids()
1931                     : currentVariables.continuous_variable_ids();
1932 }
1933 
1934 
continuous_variable_ids(SizetMultiArrayConstView cv_ids)1935 inline void Model::continuous_variable_ids(SizetMultiArrayConstView cv_ids)
1936 {
1937   if (modelRep)
1938     modelRep->currentVariables.continuous_variable_ids(cv_ids);
1939   else
1940     currentVariables.continuous_variable_ids(cv_ids);
1941 }
1942 
1943 
continuous_variable_id(size_t cv_id,size_t i)1944 inline void Model::continuous_variable_id(size_t cv_id, size_t i)
1945 {
1946   if (modelRep)
1947     modelRep->currentVariables.continuous_variable_id(cv_id, i);
1948   else
1949     currentVariables.continuous_variable_id(cv_id, i);
1950 }
1951 
1952 
inactive_continuous_variables() const1953 inline const RealVector& Model::inactive_continuous_variables() const
1954 {
1955   return (modelRep) ? modelRep->currentVariables.inactive_continuous_variables()
1956                     : currentVariables.inactive_continuous_variables();
1957 }
1958 
1959 
1960 inline void Model::
inactive_continuous_variables(const RealVector & i_c_vars)1961 inactive_continuous_variables(const RealVector& i_c_vars)
1962 {
1963   if (modelRep)
1964     modelRep->currentVariables.inactive_continuous_variables(i_c_vars);
1965   else
1966     currentVariables.inactive_continuous_variables(i_c_vars);
1967 }
1968 
1969 
inactive_discrete_int_variables() const1970 inline const IntVector& Model::inactive_discrete_int_variables() const
1971 {
1972   return (modelRep) ?
1973     modelRep->currentVariables.inactive_discrete_int_variables() :
1974     currentVariables.inactive_discrete_int_variables();
1975 }
1976 
1977 
inactive_discrete_int_variables(const IntVector & i_d_vars)1978 inline void Model::inactive_discrete_int_variables(const IntVector& i_d_vars)
1979 {
1980   if (modelRep)
1981     modelRep->currentVariables.inactive_discrete_int_variables(i_d_vars);
1982   else
1983     currentVariables.inactive_discrete_int_variables(i_d_vars);
1984 }
1985 
1986 
1987 inline StringMultiArrayConstView Model::
inactive_discrete_string_variables() const1988 inactive_discrete_string_variables() const
1989 {
1990   return (modelRep) ?
1991     modelRep->currentVariables.inactive_discrete_string_variables() :
1992     currentVariables.inactive_discrete_string_variables();
1993 }
1994 
1995 
1996 inline void Model::
inactive_discrete_string_variables(StringMultiArrayConstView i_d_vars)1997 inactive_discrete_string_variables(StringMultiArrayConstView i_d_vars)
1998 {
1999   if (modelRep)
2000     modelRep->currentVariables.inactive_discrete_string_variables(i_d_vars);
2001   else
2002     currentVariables.inactive_discrete_string_variables(i_d_vars);
2003 }
2004 
2005 
inactive_discrete_real_variables() const2006 inline const RealVector& Model::inactive_discrete_real_variables() const
2007 {
2008   return (modelRep) ?
2009     modelRep->currentVariables.inactive_discrete_real_variables() :
2010     currentVariables.inactive_discrete_real_variables();
2011 }
2012 
2013 
inactive_discrete_real_variables(const RealVector & i_d_vars)2014 inline void Model::inactive_discrete_real_variables(const RealVector& i_d_vars)
2015 {
2016   if (modelRep)
2017     modelRep->currentVariables.inactive_discrete_real_variables(i_d_vars);
2018   else
2019     currentVariables.inactive_discrete_real_variables(i_d_vars);
2020 }
2021 
2022 
2023 inline UShortMultiArrayConstView Model::
inactive_continuous_variable_types() const2024 inactive_continuous_variable_types() const
2025 {
2026   return (modelRep) ?
2027     modelRep->currentVariables.inactive_continuous_variable_types() :
2028     currentVariables.inactive_continuous_variable_types();
2029 }
2030 
2031 
inactive_continuous_variable_ids() const2032 inline SizetMultiArrayConstView Model::inactive_continuous_variable_ids() const
2033 {
2034   return (modelRep) ?
2035     modelRep->currentVariables.inactive_continuous_variable_ids() :
2036     currentVariables.inactive_continuous_variable_ids();
2037 }
2038 
2039 
all_continuous_variables() const2040 inline const RealVector& Model::all_continuous_variables() const
2041 {
2042   return (modelRep) ? modelRep->currentVariables.all_continuous_variables()
2043                     : currentVariables.all_continuous_variables();
2044 }
2045 
2046 
all_continuous_variables(const RealVector & a_c_vars)2047 inline void Model::all_continuous_variables(const RealVector& a_c_vars)
2048 {
2049   if (modelRep) modelRep->currentVariables.all_continuous_variables(a_c_vars);
2050   else          currentVariables.all_continuous_variables(a_c_vars);
2051 }
2052 
2053 
all_continuous_variable(Real a_c_var,size_t i)2054 inline void Model::all_continuous_variable(Real a_c_var, size_t i)
2055 {
2056   if (modelRep) modelRep->currentVariables.all_continuous_variable(a_c_var, i);
2057   else          currentVariables.all_continuous_variable(a_c_var, i);
2058 }
2059 
2060 
all_discrete_int_variables() const2061 inline const IntVector& Model::all_discrete_int_variables() const
2062 {
2063   return (modelRep) ? modelRep->currentVariables.all_discrete_int_variables()
2064                     : currentVariables.all_discrete_int_variables();
2065 }
2066 
2067 
all_discrete_int_variables(const IntVector & a_d_vars)2068 inline void Model::all_discrete_int_variables(const IntVector& a_d_vars)
2069 {
2070   if (modelRep) modelRep->currentVariables.all_discrete_int_variables(a_d_vars);
2071   else          currentVariables.all_discrete_int_variables(a_d_vars);
2072 }
2073 
2074 
all_discrete_int_variable(int a_d_var,size_t i)2075 inline void Model::all_discrete_int_variable(int a_d_var, size_t i)
2076 {
2077   if (modelRep)
2078     modelRep->currentVariables.all_discrete_int_variable(a_d_var, i);
2079   else
2080     currentVariables.all_discrete_int_variable(a_d_var, i);
2081 }
2082 
2083 
all_discrete_string_variables() const2084 inline StringMultiArrayConstView Model::all_discrete_string_variables() const
2085 {
2086   return (modelRep) ? modelRep->currentVariables.all_discrete_string_variables()
2087                     : currentVariables.all_discrete_string_variables();
2088 }
2089 
2090 
2091 inline void Model::
all_discrete_string_variables(StringMultiArrayConstView a_d_vars)2092 all_discrete_string_variables(StringMultiArrayConstView a_d_vars)
2093 {
2094   if (modelRep)
2095     modelRep->currentVariables.all_discrete_string_variables(a_d_vars);
2096   else
2097     currentVariables.all_discrete_string_variables(a_d_vars);
2098 }
2099 
2100 
all_discrete_string_variable(const String & a_d_var,size_t i)2101 inline void Model::all_discrete_string_variable(const String& a_d_var, size_t i)
2102 {
2103   if (modelRep)
2104     modelRep->currentVariables.all_discrete_string_variable(a_d_var, i);
2105   else
2106     currentVariables.all_discrete_string_variable(a_d_var, i);
2107 }
2108 
2109 
all_discrete_real_variables() const2110 inline const RealVector& Model::all_discrete_real_variables() const
2111 {
2112   return (modelRep) ? modelRep->currentVariables.all_discrete_real_variables()
2113                     : currentVariables.all_discrete_real_variables();
2114 }
2115 
2116 
all_discrete_real_variables(const RealVector & a_d_vars)2117 inline void Model::all_discrete_real_variables(const RealVector& a_d_vars)
2118 {
2119   if (modelRep)
2120     modelRep->currentVariables.all_discrete_real_variables(a_d_vars);
2121   else
2122     currentVariables.all_discrete_real_variables(a_d_vars);
2123 }
2124 
2125 
all_discrete_real_variable(Real a_d_var,size_t i)2126 inline void Model::all_discrete_real_variable(Real a_d_var, size_t i)
2127 {
2128   if (modelRep)
2129     modelRep->currentVariables.all_discrete_real_variable(a_d_var, i);
2130   else
2131     currentVariables.all_discrete_real_variable(a_d_var, i);
2132 }
2133 
2134 
all_continuous_variable_types() const2135 inline UShortMultiArrayConstView Model::all_continuous_variable_types() const
2136 {
2137   return (modelRep) ? modelRep->currentVariables.all_continuous_variable_types()
2138                     : currentVariables.all_continuous_variable_types();
2139 }
2140 
2141 
all_discrete_int_variable_types() const2142 inline UShortMultiArrayConstView Model::all_discrete_int_variable_types() const
2143 {
2144   return (modelRep) ?
2145     modelRep->currentVariables.all_discrete_int_variable_types() :
2146     currentVariables.all_discrete_int_variable_types();
2147 }
2148 
2149 
2150 inline UShortMultiArrayConstView Model::
all_discrete_string_variable_types() const2151 all_discrete_string_variable_types() const
2152 {
2153   return (modelRep) ?
2154     modelRep->currentVariables.all_discrete_string_variable_types() :
2155     currentVariables.all_discrete_string_variable_types();
2156 }
2157 
2158 
all_discrete_real_variable_types() const2159 inline UShortMultiArrayConstView Model::all_discrete_real_variable_types() const
2160 {
2161   return (modelRep) ?
2162     modelRep->currentVariables.all_discrete_real_variable_types() :
2163     currentVariables.all_discrete_real_variable_types();
2164 }
2165 
2166 
all_continuous_variable_ids() const2167 inline SizetMultiArrayConstView Model::all_continuous_variable_ids() const
2168 {
2169   return (modelRep) ? modelRep->currentVariables.all_continuous_variable_ids()
2170                     : currentVariables.all_continuous_variable_ids();
2171 }
2172 
2173 
2174 /*
2175 inline const IntSetArray& Model::discrete_design_set_int_values() const
2176 {
2177   return (modelRep) ? modelRep->discreteDesignSetIntValues
2178                     : discreteDesignSetIntValues;
2179 }
2180 
2181 
2182 inline void Model::discrete_design_set_int_values(const IntSetArray& isa)
2183 {
2184   if (modelRep) modelRep->discreteDesignSetIntValues = isa;
2185   else          discreteDesignSetIntValues = isa;
2186 }
2187 
2188 
2189 inline const StringSetArray& Model::discrete_design_set_string_values() const
2190 {
2191   return (modelRep) ? modelRep->discreteDesignSetStringValues
2192                     : discreteDesignSetStringValues;
2193 }
2194 
2195 
2196 inline void Model::discrete_design_set_string_values(const StringSetArray& ssa)
2197 {
2198   if (modelRep) modelRep->discreteDesignSetStringValues = ssa;
2199   else          discreteDesignSetStringValues = ssa;
2200 }
2201 
2202 
2203 inline const RealSetArray& Model::discrete_design_set_real_values() const
2204 {
2205   return (modelRep) ? modelRep->discreteDesignSetRealValues
2206                     : discreteDesignSetRealValues;
2207 }
2208 
2209 
2210 inline void Model::discrete_design_set_real_values(const RealSetArray& rsa)
2211 {
2212   if (modelRep) modelRep->discreteDesignSetRealValues = rsa;
2213   else          discreteDesignSetRealValues = rsa;
2214 }
2215 
2216 
2217 inline const IntSetArray& Model::discrete_state_set_int_values() const
2218 {
2219   return (modelRep) ? modelRep->discreteStateSetIntValues
2220                     : discreteStateSetIntValues;
2221 }
2222 
2223 
2224 inline void Model::discrete_state_set_int_values(const IntSetArray& isa)
2225 {
2226   if (modelRep) modelRep->discreteStateSetIntValues = isa;
2227   else          discreteStateSetIntValues = isa;
2228 }
2229 
2230 
2231 inline const StringSetArray& Model::discrete_state_set_string_values() const
2232 {
2233   return (modelRep) ? modelRep->discreteStateSetStringValues
2234                     : discreteStateSetStringValues;
2235 }
2236 
2237 
2238 inline void Model::discrete_state_set_string_values(const StringSetArray& ssa)
2239 {
2240   if (modelRep) modelRep->discreteStateSetStringValues = ssa;
2241   else          discreteStateSetStringValues = ssa;
2242 }
2243 
2244 
2245 inline const RealSetArray& Model::discrete_state_set_real_values() const
2246 {
2247   return (modelRep) ? modelRep->discreteStateSetRealValues
2248                     : discreteStateSetRealValues;
2249 }
2250 
2251 
2252 inline void Model::discrete_state_set_real_values(const RealSetArray& rsa)
2253 {
2254   if (modelRep) modelRep->discreteStateSetRealValues = rsa;
2255   else          discreteStateSetRealValues = rsa;
2256 }
2257 */
2258 
2259 
discrete_int_sets()2260 inline const BitArray& Model::discrete_int_sets()
2261 {
2262   if (modelRep)
2263     return modelRep->discrete_int_sets(modelRep->currentVariables.view().first);
2264   else
2265     return discrete_int_sets(currentVariables.view().first);
2266 }
2267 
2268 
discrete_set_int_values()2269 inline const IntSetArray& Model::discrete_set_int_values()
2270 {
2271   if (modelRep)
2272     return modelRep->
2273       discrete_set_int_values(modelRep->currentVariables.view().first);
2274   else
2275     return discrete_set_int_values(currentVariables.view().first);
2276 }
2277 
2278 
discrete_set_string_values()2279 inline const StringSetArray& Model::discrete_set_string_values()
2280 {
2281   if (modelRep)
2282     return modelRep->
2283       discrete_set_string_values(modelRep->currentVariables.view().first);
2284   else
2285     return discrete_set_string_values(currentVariables.view().first);
2286 }
2287 
2288 
discrete_set_real_values()2289 inline const RealSetArray& Model::discrete_set_real_values()
2290 {
2291   if (modelRep)
2292     return modelRep->
2293       discrete_set_real_values(modelRep->currentVariables.view().first);
2294   else
2295     return discrete_set_real_values(currentVariables.view().first);
2296 }
2297 
2298 
multivariate_distribution()2299 inline Pecos::MultivariateDistribution& Model::multivariate_distribution()
2300 { return (modelRep) ? modelRep->mvDist : mvDist; }
2301 
2302 
2303 inline const Pecos::MultivariateDistribution& Model::
multivariate_distribution() const2304 multivariate_distribution() const
2305 { return (modelRep) ? modelRep->mvDist : mvDist; }
2306 
2307 
2308 // inline void Model::
2309 // multivariate_distribution(const Pecos::MultivariateDistribution& dist)
2310 // {
2311 //   if (modelRep) modelRep->mvDist = dist;
2312 //   else          mvDist = dist;
2313 // }
2314 
2315 
continuous_variable_labels() const2316 inline StringMultiArrayConstView Model::continuous_variable_labels() const
2317 {
2318   return (modelRep) ? modelRep->currentVariables.continuous_variable_labels()
2319                     : currentVariables.continuous_variable_labels();
2320 }
2321 
2322 
2323 inline void Model::
continuous_variable_labels(StringMultiArrayConstView c_v_labels)2324 continuous_variable_labels(StringMultiArrayConstView c_v_labels)
2325 {
2326   if (modelRep)
2327     modelRep->currentVariables.continuous_variable_labels(c_v_labels);
2328   else
2329     currentVariables.continuous_variable_labels(c_v_labels);
2330 }
2331 
2332 
discrete_int_variable_labels() const2333 inline StringMultiArrayConstView Model::discrete_int_variable_labels() const
2334 {
2335   return (modelRep) ? modelRep->currentVariables.discrete_int_variable_labels()
2336                     : currentVariables.discrete_int_variable_labels();
2337 }
2338 
2339 
2340 inline void Model::
discrete_int_variable_labels(StringMultiArrayConstView d_v_labels)2341 discrete_int_variable_labels(StringMultiArrayConstView d_v_labels)
2342 {
2343   if (modelRep)
2344     modelRep->currentVariables.discrete_int_variable_labels(d_v_labels);
2345   else
2346     currentVariables.discrete_int_variable_labels(d_v_labels);
2347 }
2348 
2349 
discrete_string_variable_labels() const2350 inline StringMultiArrayConstView Model::discrete_string_variable_labels() const
2351 {
2352   return (modelRep) ?
2353     modelRep->currentVariables.discrete_string_variable_labels() :
2354     currentVariables.discrete_string_variable_labels();
2355 }
2356 
2357 
2358 inline void Model::
discrete_string_variable_labels(StringMultiArrayConstView d_v_labels)2359 discrete_string_variable_labels(StringMultiArrayConstView d_v_labels)
2360 {
2361   if (modelRep)
2362     modelRep->currentVariables.discrete_string_variable_labels(d_v_labels);
2363   else
2364     currentVariables.discrete_string_variable_labels(d_v_labels);
2365 }
2366 
2367 
discrete_real_variable_labels() const2368 inline StringMultiArrayConstView Model::discrete_real_variable_labels() const
2369 {
2370   return (modelRep) ? modelRep->currentVariables.discrete_real_variable_labels()
2371                     : currentVariables.discrete_real_variable_labels();
2372 }
2373 
2374 
2375 inline void Model::
discrete_real_variable_labels(StringMultiArrayConstView d_v_labels)2376 discrete_real_variable_labels(StringMultiArrayConstView d_v_labels)
2377 {
2378   if (modelRep)
2379     modelRep->currentVariables.discrete_real_variable_labels(d_v_labels);
2380   else
2381     currentVariables.discrete_real_variable_labels(d_v_labels);
2382 }
2383 
2384 
2385 inline StringMultiArrayConstView Model::
inactive_continuous_variable_labels() const2386 inactive_continuous_variable_labels() const
2387 {
2388   return (modelRep) ?
2389     modelRep->currentVariables.inactive_continuous_variable_labels() :
2390     currentVariables.inactive_continuous_variable_labels();
2391 }
2392 
2393 
2394 inline void Model::
inactive_continuous_variable_labels(StringMultiArrayConstView i_c_v_labels)2395 inactive_continuous_variable_labels(StringMultiArrayConstView i_c_v_labels)
2396 {
2397   if (modelRep)
2398     modelRep->
2399       currentVariables.inactive_continuous_variable_labels(i_c_v_labels);
2400   else
2401     currentVariables.inactive_continuous_variable_labels(i_c_v_labels);
2402 }
2403 
2404 
2405 inline StringMultiArrayConstView Model::
inactive_discrete_int_variable_labels() const2406 inactive_discrete_int_variable_labels() const
2407 {
2408   return (modelRep) ?
2409     modelRep->currentVariables.inactive_discrete_int_variable_labels() :
2410     currentVariables.inactive_discrete_int_variable_labels();
2411 }
2412 
2413 
2414 inline void Model::
inactive_discrete_int_variable_labels(StringMultiArrayConstView i_d_v_labels)2415 inactive_discrete_int_variable_labels(StringMultiArrayConstView i_d_v_labels)
2416 {
2417   if (modelRep)
2418     modelRep->
2419       currentVariables.inactive_discrete_int_variable_labels(i_d_v_labels);
2420   else
2421     currentVariables.inactive_discrete_int_variable_labels(i_d_v_labels);
2422 }
2423 
2424 
2425 inline StringMultiArrayConstView Model::
inactive_discrete_string_variable_labels() const2426 inactive_discrete_string_variable_labels() const
2427 {
2428   return (modelRep) ?
2429     modelRep->currentVariables.inactive_discrete_string_variable_labels() :
2430     currentVariables.inactive_discrete_string_variable_labels();
2431 }
2432 
2433 
2434 inline void Model::
inactive_discrete_string_variable_labels(StringMultiArrayConstView i_d_v_labels)2435 inactive_discrete_string_variable_labels(StringMultiArrayConstView i_d_v_labels)
2436 {
2437   if (modelRep)
2438     modelRep->
2439       currentVariables.inactive_discrete_string_variable_labels(i_d_v_labels);
2440   else
2441     currentVariables.inactive_discrete_string_variable_labels(i_d_v_labels);
2442 }
2443 
2444 
2445 inline StringMultiArrayConstView Model::
inactive_discrete_real_variable_labels() const2446 inactive_discrete_real_variable_labels() const
2447 {
2448   return (modelRep) ?
2449     modelRep->currentVariables.inactive_discrete_real_variable_labels() :
2450     currentVariables.inactive_discrete_real_variable_labels();
2451 }
2452 
2453 
2454 inline void Model::
inactive_discrete_real_variable_labels(StringMultiArrayConstView i_d_v_labels)2455 inactive_discrete_real_variable_labels(StringMultiArrayConstView i_d_v_labels)
2456 {
2457   if (modelRep)
2458     modelRep->
2459       currentVariables.inactive_discrete_real_variable_labels(i_d_v_labels);
2460   else
2461     currentVariables.inactive_discrete_real_variable_labels(i_d_v_labels);
2462 }
2463 
2464 
all_continuous_variable_labels() const2465 inline StringMultiArrayConstView Model::all_continuous_variable_labels() const
2466 {
2467   return (modelRep) ?
2468     modelRep->currentVariables.all_continuous_variable_labels() :
2469     currentVariables.all_continuous_variable_labels();
2470 }
2471 
2472 
2473 inline void Model::
all_continuous_variable_labels(StringMultiArrayConstView a_c_v_labels)2474 all_continuous_variable_labels(StringMultiArrayConstView a_c_v_labels)
2475 {
2476   if (modelRep)
2477     modelRep->currentVariables.all_continuous_variable_labels(a_c_v_labels);
2478   else
2479     currentVariables.all_continuous_variable_labels(a_c_v_labels);
2480 }
2481 
2482 
2483 inline void Model::
all_continuous_variable_label(const String & a_c_v_label,size_t i)2484 all_continuous_variable_label(const String& a_c_v_label, size_t i)
2485 {
2486   if (modelRep)
2487     modelRep->currentVariables.all_continuous_variable_label(a_c_v_label, i);
2488   else
2489     currentVariables.all_continuous_variable_label(a_c_v_label, i);
2490 }
2491 
2492 
all_discrete_int_variable_labels() const2493 inline StringMultiArrayConstView Model::all_discrete_int_variable_labels() const
2494 {
2495   return (modelRep) ?
2496     modelRep->currentVariables.all_discrete_int_variable_labels() :
2497     currentVariables.all_discrete_int_variable_labels();
2498 }
2499 
2500 
2501 inline void Model::
all_discrete_int_variable_labels(StringMultiArrayConstView a_d_v_labels)2502 all_discrete_int_variable_labels(StringMultiArrayConstView a_d_v_labels)
2503 {
2504   if (modelRep)
2505     modelRep->currentVariables.all_discrete_int_variable_labels(a_d_v_labels);
2506   else
2507     currentVariables.all_discrete_int_variable_labels(a_d_v_labels);
2508 }
2509 
2510 
2511 inline void Model::
all_discrete_int_variable_label(const String & a_d_v_label,size_t i)2512 all_discrete_int_variable_label(const String& a_d_v_label, size_t i)
2513 {
2514   if (modelRep)
2515     modelRep->currentVariables.all_discrete_int_variable_label(a_d_v_label, i);
2516   else
2517     currentVariables.all_discrete_int_variable_label(a_d_v_label, i);
2518 }
2519 
2520 
2521 inline StringMultiArrayConstView Model::
all_discrete_string_variable_labels() const2522 all_discrete_string_variable_labels() const
2523 {
2524   return (modelRep) ?
2525     modelRep->currentVariables.all_discrete_string_variable_labels() :
2526     currentVariables.all_discrete_string_variable_labels();
2527 }
2528 
2529 
2530 inline void Model::
all_discrete_string_variable_labels(StringMultiArrayConstView a_d_v_labels)2531 all_discrete_string_variable_labels(StringMultiArrayConstView a_d_v_labels)
2532 {
2533   if (modelRep)
2534     modelRep->
2535       currentVariables.all_discrete_string_variable_labels(a_d_v_labels);
2536   else
2537     currentVariables.all_discrete_string_variable_labels(a_d_v_labels);
2538 }
2539 
2540 
2541 inline void Model::
all_discrete_string_variable_label(const String & a_d_v_label,size_t i)2542 all_discrete_string_variable_label(const String& a_d_v_label, size_t i)
2543 {
2544   if (modelRep)
2545     modelRep->
2546       currentVariables.all_discrete_string_variable_label(a_d_v_label, i);
2547   else
2548     currentVariables.all_discrete_string_variable_label(a_d_v_label, i);
2549 }
2550 
2551 
2552 inline StringMultiArrayConstView Model::
all_discrete_real_variable_labels() const2553 all_discrete_real_variable_labels() const
2554 {
2555   return (modelRep) ?
2556     modelRep->currentVariables.all_discrete_real_variable_labels() :
2557     currentVariables.all_discrete_real_variable_labels();
2558 }
2559 
2560 
2561 inline void Model::
all_discrete_real_variable_labels(StringMultiArrayConstView a_d_v_labels)2562 all_discrete_real_variable_labels(StringMultiArrayConstView a_d_v_labels)
2563 {
2564   if (modelRep)
2565     modelRep->currentVariables.all_discrete_real_variable_labels(a_d_v_labels);
2566   else
2567     currentVariables.all_discrete_real_variable_labels(a_d_v_labels);
2568 }
2569 
2570 
2571 inline void Model::
all_discrete_real_variable_label(const String & a_d_v_label,size_t i)2572 all_discrete_real_variable_label(const String& a_d_v_label, size_t i)
2573 {
2574   if (modelRep)
2575     modelRep->currentVariables.all_discrete_real_variable_label(a_d_v_label, i);
2576   else
2577     currentVariables.all_discrete_real_variable_label(a_d_v_label, i);
2578 }
2579 
2580 
response_size() const2581 inline size_t Model::response_size() const
2582 {
2583   return (modelRep) ? modelRep->currentResponse.num_functions()
2584                     : currentResponse.num_functions();
2585 }
2586 
2587 
response_labels() const2588 inline const StringArray& Model::response_labels() const
2589 {
2590   return (modelRep) ? modelRep->currentResponse.function_labels()
2591                     : currentResponse.function_labels();
2592 }
2593 
2594 
response_labels(const StringArray & resp_labels)2595 inline void Model::response_labels(const StringArray& resp_labels)
2596 {
2597   if (modelRep) modelRep->currentResponse.function_labels(resp_labels);
2598   else          currentResponse.function_labels(resp_labels);
2599 }
2600 
2601 
continuous_lower_bounds() const2602 inline const RealVector& Model::continuous_lower_bounds() const
2603 {
2604   return (modelRep) ? modelRep->userDefinedConstraints.continuous_lower_bounds()
2605                     : userDefinedConstraints.continuous_lower_bounds();
2606 }
2607 
2608 
continuous_lower_bound(size_t i) const2609 inline Real Model::continuous_lower_bound(size_t i) const
2610 {
2611   return (modelRep) ? modelRep->userDefinedConstraints.continuous_lower_bound(i)
2612                     : userDefinedConstraints.continuous_lower_bound(i);
2613 }
2614 
2615 
continuous_lower_bounds(const RealVector & c_l_bnds)2616 inline void Model::continuous_lower_bounds(const RealVector& c_l_bnds)
2617 {
2618   if (modelRep)
2619     modelRep->continuous_lower_bounds(c_l_bnds);
2620   else {
2621     userDefinedConstraints.continuous_lower_bounds(c_l_bnds);
2622     if (mvDist.global_bounds())
2623       mvDist.lower_bounds(c_l_bnds,
2624 	currentVariables.shared_data().cv_to_all_mask());
2625   }
2626 }
2627 
2628 
continuous_lower_bound(Real c_l_bnd,size_t i)2629 inline void Model::continuous_lower_bound(Real c_l_bnd, size_t i)
2630 {
2631   if (modelRep)
2632     modelRep->continuous_lower_bound(c_l_bnd, i);
2633   else {
2634     userDefinedConstraints.continuous_lower_bound(c_l_bnd, i);
2635     if (mvDist.global_bounds())
2636       mvDist.lower_bound(c_l_bnd,
2637 	currentVariables.shared_data().cv_index_to_all_index(i));
2638   }
2639 }
2640 
2641 
continuous_upper_bounds() const2642 inline const RealVector& Model::continuous_upper_bounds() const
2643 {
2644   return (modelRep) ? modelRep->userDefinedConstraints.continuous_upper_bounds()
2645                     : userDefinedConstraints.continuous_upper_bounds();
2646 }
2647 
2648 
continuous_upper_bound(size_t i) const2649 inline Real Model::continuous_upper_bound(size_t i) const
2650 {
2651   return (modelRep) ? modelRep->userDefinedConstraints.continuous_upper_bound(i)
2652                     : userDefinedConstraints.continuous_upper_bound(i);
2653 }
2654 
2655 
continuous_upper_bounds(const RealVector & c_u_bnds)2656 inline void Model::continuous_upper_bounds(const RealVector& c_u_bnds)
2657 {
2658   if (modelRep)
2659     modelRep->continuous_upper_bounds(c_u_bnds);
2660   else {
2661     userDefinedConstraints.continuous_upper_bounds(c_u_bnds);
2662     if (mvDist.global_bounds())
2663       mvDist.upper_bounds(c_u_bnds,
2664 	currentVariables.shared_data().cv_to_all_mask());
2665   }
2666 }
2667 
2668 
continuous_upper_bound(Real c_u_bnd,size_t i)2669 inline void Model::continuous_upper_bound(Real c_u_bnd, size_t i)
2670 {
2671   if (modelRep)
2672     modelRep->continuous_upper_bound(c_u_bnd, i);
2673   else {
2674     userDefinedConstraints.continuous_upper_bound(c_u_bnd, i);
2675     if (mvDist.global_bounds())
2676       mvDist.upper_bound(c_u_bnd,
2677 	currentVariables.shared_data().cv_index_to_all_index(i));
2678   }
2679 }
2680 
2681 
discrete_int_lower_bounds() const2682 inline const IntVector& Model::discrete_int_lower_bounds() const
2683 {
2684   return (modelRep) ?
2685     modelRep->userDefinedConstraints.discrete_int_lower_bounds() :
2686     userDefinedConstraints.discrete_int_lower_bounds();
2687 }
2688 
2689 
discrete_int_lower_bound(size_t i) const2690 inline int Model::discrete_int_lower_bound(size_t i) const
2691 {
2692   return (modelRep) ?
2693     modelRep->userDefinedConstraints.discrete_int_lower_bound(i) :
2694     userDefinedConstraints.discrete_int_lower_bound(i);
2695 }
2696 
2697 
discrete_int_lower_bounds(const IntVector & d_l_bnds)2698 inline void Model::discrete_int_lower_bounds(const IntVector& d_l_bnds)
2699 {
2700   if (modelRep)
2701     modelRep->discrete_int_lower_bounds(d_l_bnds);
2702   else {
2703     userDefinedConstraints.discrete_int_lower_bounds(d_l_bnds);
2704     if (mvDist.global_bounds())
2705       mvDist.lower_bounds(d_l_bnds,
2706 	currentVariables.shared_data().div_to_all_mask());
2707   }
2708 }
2709 
2710 
discrete_int_lower_bound(int d_l_bnd,size_t i)2711 inline void Model::discrete_int_lower_bound(int d_l_bnd, size_t i)
2712 {
2713   if (modelRep)
2714     modelRep->discrete_int_lower_bound(d_l_bnd, i);
2715   else {
2716     userDefinedConstraints.discrete_int_lower_bound(d_l_bnd, i);
2717     if (mvDist.global_bounds())
2718       mvDist.lower_bound(d_l_bnd,
2719 	currentVariables.shared_data().div_index_to_all_index(i));
2720   }
2721 }
2722 
2723 
discrete_int_upper_bounds() const2724 inline const IntVector& Model::discrete_int_upper_bounds() const
2725 {
2726   return (modelRep) ?
2727     modelRep->userDefinedConstraints.discrete_int_upper_bounds() :
2728     userDefinedConstraints.discrete_int_upper_bounds();
2729 }
2730 
2731 
discrete_int_upper_bound(size_t i) const2732 inline int Model::discrete_int_upper_bound(size_t i) const
2733 {
2734   return (modelRep) ?
2735     modelRep->userDefinedConstraints.discrete_int_upper_bound(i) :
2736     userDefinedConstraints.discrete_int_upper_bound(i);
2737 }
2738 
2739 
discrete_int_upper_bounds(const IntVector & d_u_bnds)2740 inline void Model::discrete_int_upper_bounds(const IntVector& d_u_bnds)
2741 {
2742   if (modelRep)
2743     modelRep->discrete_int_upper_bounds(d_u_bnds);
2744   else {
2745     userDefinedConstraints.discrete_int_upper_bounds(d_u_bnds);
2746     if (mvDist.global_bounds())
2747       mvDist.upper_bounds(d_u_bnds,
2748 	currentVariables.shared_data().div_to_all_mask());
2749   }
2750 }
2751 
2752 
discrete_int_upper_bound(int d_u_bnd,size_t i)2753 inline void Model::discrete_int_upper_bound(int d_u_bnd, size_t i)
2754 {
2755   if (modelRep)
2756     modelRep->discrete_int_upper_bound(d_u_bnd, i);
2757   else {
2758     userDefinedConstraints.discrete_int_upper_bound(d_u_bnd, i);
2759     if (mvDist.global_bounds())
2760       mvDist.upper_bound(d_u_bnd,
2761 	currentVariables.shared_data().div_index_to_all_index(i));
2762   }
2763 }
2764 
2765 
discrete_real_lower_bounds() const2766 inline const RealVector& Model::discrete_real_lower_bounds() const
2767 {
2768   return (modelRep) ?
2769     modelRep->userDefinedConstraints.discrete_real_lower_bounds() :
2770     userDefinedConstraints.discrete_real_lower_bounds();
2771 }
2772 
2773 
discrete_real_lower_bound(size_t i) const2774 inline Real Model::discrete_real_lower_bound(size_t i) const
2775 {
2776   return (modelRep) ?
2777     modelRep->userDefinedConstraints.discrete_real_lower_bound(i) :
2778     userDefinedConstraints.discrete_real_lower_bound(i);
2779 }
2780 
2781 
discrete_real_lower_bounds(const RealVector & d_l_bnds)2782 inline void Model::discrete_real_lower_bounds(const RealVector& d_l_bnds)
2783 {
2784   if (modelRep)
2785     modelRep->discrete_real_lower_bounds(d_l_bnds);
2786   else {
2787     userDefinedConstraints.discrete_real_lower_bounds(d_l_bnds);
2788     if (mvDist.global_bounds())
2789       mvDist.lower_bounds(d_l_bnds,
2790 	currentVariables.shared_data().drv_to_all_mask());
2791   }
2792 }
2793 
2794 
discrete_real_lower_bound(Real d_l_bnd,size_t i)2795 inline void Model::discrete_real_lower_bound(Real d_l_bnd, size_t i)
2796 {
2797   if (modelRep)
2798     modelRep->discrete_real_lower_bound(d_l_bnd, i);
2799   else {
2800     userDefinedConstraints.discrete_real_lower_bound(d_l_bnd, i);
2801     if (mvDist.global_bounds())
2802       mvDist.lower_bound(d_l_bnd,
2803 	currentVariables.shared_data().drv_index_to_all_index(i));
2804   }
2805 }
2806 
2807 
discrete_real_upper_bounds() const2808 inline const RealVector& Model::discrete_real_upper_bounds() const
2809 {
2810   return (modelRep) ?
2811     modelRep->userDefinedConstraints.discrete_real_upper_bounds() :
2812     userDefinedConstraints.discrete_real_upper_bounds();
2813 }
2814 
2815 
discrete_real_upper_bound(size_t i) const2816 inline Real Model::discrete_real_upper_bound(size_t i) const
2817 {
2818   return (modelRep) ?
2819     modelRep->userDefinedConstraints.discrete_real_upper_bound(i) :
2820     userDefinedConstraints.discrete_real_upper_bound(i);
2821 }
2822 
2823 
discrete_real_upper_bounds(const RealVector & d_u_bnds)2824 inline void Model::discrete_real_upper_bounds(const RealVector& d_u_bnds)
2825 {
2826   if (modelRep)
2827     modelRep->discrete_real_upper_bounds(d_u_bnds);
2828   else {
2829     userDefinedConstraints.discrete_real_upper_bounds(d_u_bnds);
2830     if (mvDist.global_bounds())
2831       mvDist.upper_bounds(d_u_bnds,
2832 	currentVariables.shared_data().drv_to_all_mask());
2833   }
2834 }
2835 
2836 
discrete_real_upper_bound(Real d_u_bnd,size_t i)2837 inline void Model::discrete_real_upper_bound(Real d_u_bnd, size_t i)
2838 {
2839   if (modelRep)
2840     modelRep->discrete_real_upper_bound(d_u_bnd, i);
2841   else {
2842     userDefinedConstraints.discrete_real_upper_bound(d_u_bnd, i);
2843     if (mvDist.global_bounds())
2844       mvDist.upper_bound(d_u_bnd,
2845 	currentVariables.shared_data().drv_index_to_all_index(i));
2846   }
2847 }
2848 
2849 
inactive_continuous_lower_bounds() const2850 inline const RealVector& Model::inactive_continuous_lower_bounds() const
2851 {
2852   return (modelRep) ?
2853     modelRep->userDefinedConstraints.inactive_continuous_lower_bounds() :
2854     userDefinedConstraints.inactive_continuous_lower_bounds();
2855 }
2856 
2857 
2858 inline void Model::
inactive_continuous_lower_bounds(const RealVector & i_c_l_bnds)2859 inactive_continuous_lower_bounds(const RealVector& i_c_l_bnds)
2860 {
2861   if (modelRep)
2862     modelRep->inactive_continuous_lower_bounds(i_c_l_bnds);
2863   else {
2864     userDefinedConstraints.inactive_continuous_lower_bounds(i_c_l_bnds);
2865     if (mvDist.global_bounds())
2866       mvDist.lower_bounds(i_c_l_bnds,
2867 	currentVariables.shared_data().icv_to_all_mask());
2868   }
2869 }
2870 
2871 
inactive_continuous_upper_bounds() const2872 inline const RealVector& Model::inactive_continuous_upper_bounds() const
2873 {
2874   return (modelRep) ?
2875     modelRep->userDefinedConstraints.inactive_continuous_upper_bounds() :
2876     userDefinedConstraints.inactive_continuous_upper_bounds();
2877 }
2878 
2879 
2880 inline void Model::
inactive_continuous_upper_bounds(const RealVector & i_c_u_bnds)2881 inactive_continuous_upper_bounds(const RealVector& i_c_u_bnds)
2882 {
2883   if (modelRep)
2884     modelRep->inactive_continuous_upper_bounds(i_c_u_bnds);
2885   else {
2886     userDefinedConstraints.inactive_continuous_upper_bounds(i_c_u_bnds);
2887     if (mvDist.global_bounds())
2888       mvDist.upper_bounds(i_c_u_bnds,
2889 	currentVariables.shared_data().icv_to_all_mask());
2890   }
2891 }
2892 
2893 
inactive_discrete_int_lower_bounds() const2894 inline const IntVector& Model::inactive_discrete_int_lower_bounds() const
2895 {
2896   return (modelRep) ?
2897     modelRep->userDefinedConstraints.inactive_discrete_int_lower_bounds() :
2898     userDefinedConstraints.inactive_discrete_int_lower_bounds();
2899 }
2900 
2901 
2902 inline void Model::
inactive_discrete_int_lower_bounds(const IntVector & i_d_l_bnds)2903 inactive_discrete_int_lower_bounds(const IntVector& i_d_l_bnds)
2904 {
2905   if (modelRep)
2906     modelRep->inactive_discrete_int_lower_bounds(i_d_l_bnds);
2907   else {
2908     userDefinedConstraints.inactive_discrete_int_lower_bounds(i_d_l_bnds);
2909     if (mvDist.global_bounds())
2910       mvDist.lower_bounds(i_d_l_bnds,
2911 	currentVariables.shared_data().idiv_to_all_mask());
2912   }
2913 }
2914 
2915 
inactive_discrete_int_upper_bounds() const2916 inline const IntVector& Model::inactive_discrete_int_upper_bounds() const
2917 {
2918   return (modelRep) ?
2919     modelRep->userDefinedConstraints.inactive_discrete_int_upper_bounds() :
2920     userDefinedConstraints.inactive_discrete_int_upper_bounds();
2921 }
2922 
2923 
2924 inline void Model::
inactive_discrete_int_upper_bounds(const IntVector & i_d_u_bnds)2925 inactive_discrete_int_upper_bounds(const IntVector& i_d_u_bnds)
2926 {
2927   if (modelRep)
2928     modelRep->inactive_discrete_int_upper_bounds(i_d_u_bnds);
2929   else {
2930     userDefinedConstraints.inactive_discrete_int_upper_bounds(i_d_u_bnds);
2931     if (mvDist.global_bounds())
2932       mvDist.upper_bounds(i_d_u_bnds,
2933 	currentVariables.shared_data().idiv_to_all_mask());
2934   }
2935 }
2936 
2937 
inactive_discrete_real_lower_bounds() const2938 inline const RealVector& Model::inactive_discrete_real_lower_bounds() const
2939 {
2940   return (modelRep) ?
2941     modelRep->userDefinedConstraints.inactive_discrete_real_lower_bounds() :
2942     userDefinedConstraints.inactive_discrete_real_lower_bounds();
2943 }
2944 
2945 
2946 inline void Model::
inactive_discrete_real_lower_bounds(const RealVector & i_d_l_bnds)2947 inactive_discrete_real_lower_bounds(const RealVector& i_d_l_bnds)
2948 {
2949   if (modelRep)
2950     modelRep->inactive_discrete_real_lower_bounds(i_d_l_bnds);
2951   else {
2952     userDefinedConstraints.inactive_discrete_real_lower_bounds(i_d_l_bnds);
2953     if (mvDist.global_bounds())
2954       mvDist.lower_bounds(i_d_l_bnds,
2955 	currentVariables.shared_data().idrv_to_all_mask());
2956   }
2957 }
2958 
2959 
inactive_discrete_real_upper_bounds() const2960 inline const RealVector& Model::inactive_discrete_real_upper_bounds() const
2961 {
2962   return (modelRep) ?
2963     modelRep->userDefinedConstraints.inactive_discrete_real_upper_bounds() :
2964     userDefinedConstraints.inactive_discrete_real_upper_bounds();
2965 }
2966 
2967 
2968 inline void Model::
inactive_discrete_real_upper_bounds(const RealVector & i_d_u_bnds)2969 inactive_discrete_real_upper_bounds(const RealVector& i_d_u_bnds)
2970 {
2971   if (modelRep)
2972     modelRep->inactive_discrete_real_upper_bounds(i_d_u_bnds);
2973   else {
2974     userDefinedConstraints.inactive_discrete_real_upper_bounds(i_d_u_bnds);
2975     if (mvDist.global_bounds())
2976       mvDist.upper_bounds(i_d_u_bnds,
2977 	currentVariables.shared_data().idrv_to_all_mask());
2978   }
2979 }
2980 
2981 
all_continuous_lower_bounds() const2982 inline const RealVector& Model::all_continuous_lower_bounds() const
2983 {
2984   return (modelRep) ?
2985     modelRep->userDefinedConstraints.all_continuous_lower_bounds() :
2986     userDefinedConstraints.all_continuous_lower_bounds();
2987 }
2988 
2989 
all_continuous_lower_bounds(const RealVector & a_c_l_bnds)2990 inline void Model::all_continuous_lower_bounds(const RealVector& a_c_l_bnds)
2991 {
2992   if (modelRep)
2993     modelRep->all_continuous_lower_bounds(a_c_l_bnds);
2994   else {
2995     userDefinedConstraints.all_continuous_lower_bounds(a_c_l_bnds);
2996     if (mvDist.global_bounds())
2997       mvDist.lower_bounds(a_c_l_bnds,
2998 	currentVariables.shared_data().acv_to_all_mask());
2999   }
3000 }
3001 
3002 
all_continuous_lower_bound(Real a_c_l_bnd,size_t i)3003 inline void Model::all_continuous_lower_bound(Real a_c_l_bnd, size_t i)
3004 {
3005   if (modelRep)
3006     modelRep->all_continuous_lower_bound(a_c_l_bnd, i);
3007   else {
3008     userDefinedConstraints.all_continuous_lower_bound(a_c_l_bnd, i);
3009     if (mvDist.global_bounds())
3010       mvDist.lower_bound(a_c_l_bnd,
3011         currentVariables.shared_data().acv_index_to_all_index(i));
3012   }
3013 }
3014 
3015 
all_continuous_upper_bounds() const3016 inline const RealVector& Model::all_continuous_upper_bounds() const
3017 {
3018   return (modelRep) ?
3019     modelRep->userDefinedConstraints.all_continuous_upper_bounds() :
3020     userDefinedConstraints.all_continuous_upper_bounds();
3021 }
3022 
3023 
all_continuous_upper_bounds(const RealVector & a_c_u_bnds)3024 inline void Model::all_continuous_upper_bounds(const RealVector& a_c_u_bnds)
3025 {
3026   if (modelRep)
3027     modelRep->all_continuous_upper_bounds(a_c_u_bnds);
3028   else {
3029     userDefinedConstraints.all_continuous_upper_bounds(a_c_u_bnds);
3030     if (mvDist.global_bounds())
3031       mvDist.upper_bounds(a_c_u_bnds,
3032         currentVariables.shared_data().acv_to_all_mask());
3033   }
3034 }
3035 
3036 
all_continuous_upper_bound(Real a_c_u_bnd,size_t i)3037 inline void Model::all_continuous_upper_bound(Real a_c_u_bnd, size_t i)
3038 {
3039   if (modelRep)
3040     modelRep->all_continuous_upper_bound(a_c_u_bnd, i);
3041   else {
3042     userDefinedConstraints.all_continuous_upper_bound(a_c_u_bnd, i);
3043     if (mvDist.global_bounds())
3044       mvDist.upper_bound(a_c_u_bnd,
3045         currentVariables.shared_data().acv_index_to_all_index(i));
3046   }
3047 }
3048 
3049 
all_discrete_int_lower_bounds() const3050 inline const IntVector& Model::all_discrete_int_lower_bounds() const
3051 {
3052   return (modelRep) ?
3053     modelRep->userDefinedConstraints.all_discrete_int_lower_bounds() :
3054     userDefinedConstraints.all_discrete_int_lower_bounds();
3055 }
3056 
3057 
all_discrete_int_lower_bounds(const IntVector & a_d_l_bnds)3058 inline void Model::all_discrete_int_lower_bounds(const IntVector& a_d_l_bnds)
3059 {
3060   if (modelRep)
3061     modelRep->all_discrete_int_lower_bounds(a_d_l_bnds);
3062   else {
3063     userDefinedConstraints.all_discrete_int_lower_bounds(a_d_l_bnds);
3064     if (mvDist.global_bounds())
3065       mvDist.lower_bounds(a_d_l_bnds,
3066         currentVariables.shared_data().adiv_to_all_mask());
3067   }
3068 }
3069 
3070 
all_discrete_int_lower_bound(int a_d_l_bnd,size_t i)3071 inline void Model::all_discrete_int_lower_bound(int a_d_l_bnd, size_t i)
3072 {
3073   if (modelRep)
3074     modelRep->all_discrete_int_lower_bound(a_d_l_bnd, i);
3075   else {
3076     userDefinedConstraints.all_discrete_int_lower_bound(a_d_l_bnd, i);
3077     if (mvDist.global_bounds())
3078       mvDist.lower_bound(a_d_l_bnd,
3079         currentVariables.shared_data().adiv_index_to_all_index(i));
3080   }
3081 }
3082 
3083 
all_discrete_int_upper_bounds() const3084 inline const IntVector& Model::all_discrete_int_upper_bounds() const
3085 {
3086   return (modelRep) ?
3087     modelRep->userDefinedConstraints.all_discrete_int_upper_bounds() :
3088     userDefinedConstraints.all_discrete_int_upper_bounds();
3089 }
3090 
3091 
all_discrete_int_upper_bounds(const IntVector & a_d_u_bnds)3092 inline void Model::all_discrete_int_upper_bounds(const IntVector& a_d_u_bnds)
3093 {
3094   if (modelRep)
3095     modelRep->all_discrete_int_upper_bounds(a_d_u_bnds);
3096   else {
3097     userDefinedConstraints.all_discrete_int_upper_bounds(a_d_u_bnds);
3098     if (mvDist.global_bounds())
3099       mvDist.upper_bounds(a_d_u_bnds,
3100         currentVariables.shared_data().adiv_to_all_mask());
3101   }
3102 }
3103 
3104 
all_discrete_int_upper_bound(int a_d_u_bnd,size_t i)3105 inline void Model::all_discrete_int_upper_bound(int a_d_u_bnd, size_t i)
3106 {
3107   if (modelRep)
3108     modelRep->all_discrete_int_upper_bound(a_d_u_bnd, i);
3109   else {
3110     userDefinedConstraints.all_discrete_int_upper_bound(a_d_u_bnd, i);
3111     if (mvDist.global_bounds())
3112       mvDist.upper_bound(a_d_u_bnd,
3113         currentVariables.shared_data().adiv_index_to_all_index(i));
3114   }
3115 }
3116 
3117 
all_discrete_real_lower_bounds() const3118 inline const RealVector& Model::all_discrete_real_lower_bounds() const
3119 {
3120   return (modelRep) ?
3121     modelRep->userDefinedConstraints.all_discrete_real_lower_bounds() :
3122     userDefinedConstraints.all_discrete_real_lower_bounds();
3123 }
3124 
3125 
all_discrete_real_lower_bounds(const RealVector & a_d_l_bnds)3126 inline void Model::all_discrete_real_lower_bounds(const RealVector& a_d_l_bnds)
3127 {
3128   if (modelRep)
3129     modelRep->all_discrete_real_lower_bounds(a_d_l_bnds);
3130   else {
3131     userDefinedConstraints.all_discrete_real_lower_bounds(a_d_l_bnds);
3132     if (mvDist.global_bounds())
3133       mvDist.lower_bounds(a_d_l_bnds,
3134         currentVariables.shared_data().adrv_to_all_mask());
3135   }
3136 }
3137 
3138 
all_discrete_real_lower_bound(Real a_d_l_bnd,size_t i)3139 inline void Model::all_discrete_real_lower_bound(Real a_d_l_bnd, size_t i)
3140 {
3141   if (modelRep)
3142     modelRep->all_discrete_real_lower_bound(a_d_l_bnd, i);
3143   else {
3144     userDefinedConstraints.all_discrete_real_lower_bound(a_d_l_bnd, i);
3145     if (mvDist.global_bounds())
3146       mvDist.lower_bound(a_d_l_bnd,
3147         currentVariables.shared_data().adrv_index_to_all_index(i));
3148   }
3149 }
3150 
3151 
all_discrete_real_upper_bounds() const3152 inline const RealVector& Model::all_discrete_real_upper_bounds() const
3153 {
3154   return (modelRep) ?
3155     modelRep->userDefinedConstraints.all_discrete_real_upper_bounds() :
3156     userDefinedConstraints.all_discrete_real_upper_bounds();
3157 }
3158 
3159 
all_discrete_real_upper_bounds(const RealVector & a_d_u_bnds)3160 inline void Model::all_discrete_real_upper_bounds(const RealVector& a_d_u_bnds)
3161 {
3162   if (modelRep)
3163     modelRep->all_discrete_real_upper_bounds(a_d_u_bnds);
3164   else {
3165     userDefinedConstraints.all_discrete_real_upper_bounds(a_d_u_bnds);
3166     if (mvDist.global_bounds())
3167       mvDist.upper_bounds(a_d_u_bnds,
3168         currentVariables.shared_data().adrv_to_all_mask());
3169   }
3170 }
3171 
3172 
all_discrete_real_upper_bound(Real a_d_u_bnd,size_t i)3173 inline void Model::all_discrete_real_upper_bound(Real a_d_u_bnd, size_t i)
3174 {
3175   if (modelRep)
3176     modelRep->all_discrete_real_upper_bound(a_d_u_bnd, i);
3177   else {
3178     userDefinedConstraints.all_discrete_real_upper_bound(a_d_u_bnd, i);
3179     if (mvDist.global_bounds())
3180       mvDist.upper_bound(a_d_u_bnd,
3181         currentVariables.shared_data().adrv_index_to_all_index(i));
3182   }
3183 }
3184 
3185 
3186 inline void
reshape_constraints(size_t num_nln_ineq_cons,size_t num_nln_eq_cons,size_t num_lin_ineq_cons,size_t num_lin_eq_cons)3187 Model::reshape_constraints(size_t num_nln_ineq_cons, size_t num_nln_eq_cons,
3188 			   size_t num_lin_ineq_cons, size_t num_lin_eq_cons)
3189 {
3190   if (modelRep)
3191     modelRep->
3192       userDefinedConstraints.reshape(num_nln_ineq_cons, num_nln_eq_cons,
3193 				     num_lin_ineq_cons, num_lin_eq_cons);
3194   else
3195     userDefinedConstraints.reshape(num_nln_ineq_cons, num_nln_eq_cons,
3196 				   num_lin_ineq_cons, num_lin_eq_cons);
3197 }
3198 
3199 
num_linear_ineq_constraints() const3200 inline size_t Model::num_linear_ineq_constraints() const
3201 {
3202   return (modelRep) ? modelRep->
3203                       userDefinedConstraints.num_linear_ineq_constraints()
3204                     : userDefinedConstraints.num_linear_ineq_constraints();
3205 }
3206 
3207 
num_linear_eq_constraints() const3208 inline size_t Model::num_linear_eq_constraints() const
3209 {
3210   return (modelRep) ? modelRep->
3211                       userDefinedConstraints.num_linear_eq_constraints()
3212                     : userDefinedConstraints.num_linear_eq_constraints();
3213 }
3214 
3215 
linear_ineq_constraint_coeffs() const3216 inline const RealMatrix& Model::linear_ineq_constraint_coeffs() const
3217 {
3218   return (modelRep) ? modelRep->
3219                       userDefinedConstraints.linear_ineq_constraint_coeffs()
3220                     : userDefinedConstraints.linear_ineq_constraint_coeffs();
3221 }
3222 
3223 
3224 inline void Model::
linear_ineq_constraint_coeffs(const RealMatrix & lin_ineq_coeffs)3225 linear_ineq_constraint_coeffs(const RealMatrix& lin_ineq_coeffs)
3226 {
3227   if (modelRep)
3228     modelRep->userDefinedConstraints.linear_ineq_constraint_coeffs(
3229       lin_ineq_coeffs);
3230   else
3231     userDefinedConstraints.linear_ineq_constraint_coeffs(lin_ineq_coeffs);
3232 }
3233 
3234 
linear_ineq_constraint_lower_bounds() const3235 inline const RealVector& Model::linear_ineq_constraint_lower_bounds() const
3236 {
3237   return (modelRep) ?
3238       modelRep->userDefinedConstraints.linear_ineq_constraint_lower_bounds()
3239     : userDefinedConstraints.linear_ineq_constraint_lower_bounds();
3240 }
3241 
3242 
3243 inline void Model::
linear_ineq_constraint_lower_bounds(const RealVector & lin_ineq_l_bnds)3244 linear_ineq_constraint_lower_bounds(const RealVector& lin_ineq_l_bnds)
3245 {
3246   if (modelRep)
3247     modelRep->userDefinedConstraints.linear_ineq_constraint_lower_bounds(
3248       lin_ineq_l_bnds);
3249   else
3250     userDefinedConstraints.linear_ineq_constraint_lower_bounds(lin_ineq_l_bnds);
3251 }
3252 
3253 
linear_ineq_constraint_upper_bounds() const3254 inline const RealVector& Model::linear_ineq_constraint_upper_bounds() const
3255 {
3256   return (modelRep) ?
3257       modelRep->userDefinedConstraints.linear_ineq_constraint_upper_bounds()
3258     : userDefinedConstraints.linear_ineq_constraint_upper_bounds();
3259 }
3260 
3261 
3262 inline void Model::
linear_ineq_constraint_upper_bounds(const RealVector & lin_ineq_u_bnds)3263 linear_ineq_constraint_upper_bounds(const RealVector& lin_ineq_u_bnds)
3264 {
3265   if (modelRep)
3266     modelRep->userDefinedConstraints.linear_ineq_constraint_upper_bounds(
3267       lin_ineq_u_bnds);
3268   else
3269     userDefinedConstraints.linear_ineq_constraint_upper_bounds(lin_ineq_u_bnds);
3270 }
3271 
3272 
linear_eq_constraint_coeffs() const3273 inline const RealMatrix& Model::linear_eq_constraint_coeffs() const
3274 {
3275   return (modelRep) ? modelRep->
3276                       userDefinedConstraints.linear_eq_constraint_coeffs()
3277                     : userDefinedConstraints.linear_eq_constraint_coeffs();
3278 }
3279 
3280 
3281 inline void Model::
linear_eq_constraint_coeffs(const RealMatrix & lin_eq_coeffs)3282 linear_eq_constraint_coeffs(const RealMatrix& lin_eq_coeffs)
3283 {
3284   if (modelRep)
3285     modelRep->userDefinedConstraints.linear_eq_constraint_coeffs(lin_eq_coeffs);
3286   else
3287     userDefinedConstraints.linear_eq_constraint_coeffs(lin_eq_coeffs);
3288 }
3289 
3290 
linear_eq_constraint_targets() const3291 inline const RealVector& Model::linear_eq_constraint_targets() const
3292 {
3293   return (modelRep) ? modelRep->
3294                       userDefinedConstraints.linear_eq_constraint_targets()
3295                     : userDefinedConstraints.linear_eq_constraint_targets();
3296 }
3297 
3298 
3299 inline void Model::
linear_eq_constraint_targets(const RealVector & lin_eq_targets)3300 linear_eq_constraint_targets(const RealVector& lin_eq_targets)
3301 {
3302   if (modelRep)
3303     modelRep->userDefinedConstraints.linear_eq_constraint_targets(
3304       lin_eq_targets);
3305   else
3306     userDefinedConstraints.linear_eq_constraint_targets(lin_eq_targets);
3307 }
3308 
3309 
num_nonlinear_ineq_constraints() const3310 inline size_t Model::num_nonlinear_ineq_constraints() const
3311 {
3312   return (modelRep) ? modelRep->
3313                       userDefinedConstraints.num_nonlinear_ineq_constraints()
3314                     : userDefinedConstraints.num_nonlinear_ineq_constraints();
3315 }
3316 
3317 
num_nonlinear_eq_constraints() const3318 inline size_t Model::num_nonlinear_eq_constraints() const
3319 {
3320   return (modelRep) ? modelRep->
3321                       userDefinedConstraints.num_nonlinear_eq_constraints()
3322                     : userDefinedConstraints.num_nonlinear_eq_constraints();
3323 }
3324 
3325 
3326 inline const RealVector& Model::
nonlinear_ineq_constraint_lower_bounds() const3327 nonlinear_ineq_constraint_lower_bounds() const
3328 {
3329   return (modelRep) ?
3330       modelRep->userDefinedConstraints.nonlinear_ineq_constraint_lower_bounds()
3331     : userDefinedConstraints.nonlinear_ineq_constraint_lower_bounds();
3332 }
3333 
3334 
3335 inline void Model::
nonlinear_ineq_constraint_lower_bounds(const RealVector & nln_ineq_l_bnds)3336 nonlinear_ineq_constraint_lower_bounds(const RealVector& nln_ineq_l_bnds)
3337 {
3338   if (modelRep)
3339     modelRep->userDefinedConstraints.nonlinear_ineq_constraint_lower_bounds(
3340       nln_ineq_l_bnds);
3341   else
3342     userDefinedConstraints.nonlinear_ineq_constraint_lower_bounds(
3343       nln_ineq_l_bnds);
3344 }
3345 
3346 
3347 inline const RealVector& Model::
nonlinear_ineq_constraint_upper_bounds() const3348 nonlinear_ineq_constraint_upper_bounds() const
3349 {
3350   return (modelRep) ?
3351       modelRep->userDefinedConstraints.nonlinear_ineq_constraint_upper_bounds()
3352     : userDefinedConstraints.nonlinear_ineq_constraint_upper_bounds();
3353 }
3354 
3355 
3356 inline void Model::
nonlinear_ineq_constraint_upper_bounds(const RealVector & nln_ineq_u_bnds)3357 nonlinear_ineq_constraint_upper_bounds(const RealVector& nln_ineq_u_bnds)
3358 {
3359   if (modelRep)
3360     modelRep->userDefinedConstraints.nonlinear_ineq_constraint_upper_bounds(
3361       nln_ineq_u_bnds);
3362   else
3363     userDefinedConstraints.nonlinear_ineq_constraint_upper_bounds(
3364       nln_ineq_u_bnds);
3365 }
3366 
3367 
nonlinear_eq_constraint_targets() const3368 inline const RealVector& Model::nonlinear_eq_constraint_targets() const
3369 {
3370   return (modelRep) ? modelRep->
3371                       userDefinedConstraints.nonlinear_eq_constraint_targets()
3372                     : userDefinedConstraints.nonlinear_eq_constraint_targets();
3373 }
3374 
3375 
3376 inline void Model::
nonlinear_eq_constraint_targets(const RealVector & nln_eq_targets)3377 nonlinear_eq_constraint_targets(const RealVector& nln_eq_targets)
3378 {
3379   if (modelRep)
3380     modelRep->userDefinedConstraints.nonlinear_eq_constraint_targets(
3381       nln_eq_targets);
3382   else
3383     userDefinedConstraints.nonlinear_eq_constraint_targets(nln_eq_targets);
3384 }
3385 
3386 
3387 //inline const SizetArray& Model::relaxed_discrete_ids() const
3388 //{
3389 //  return (modelRep) ? modelRep->currentVariables.relaxed_discrete_ids()
3390 //                    : currentVariables.relaxed_discrete_ids();
3391 //}
3392 
3393 
current_variables() const3394 inline const Variables& Model::current_variables() const
3395 { return (modelRep) ? modelRep->currentVariables : currentVariables; }
3396 
3397 
current_variables()3398 inline Variables& Model::current_variables()
3399 { return (modelRep) ? modelRep->currentVariables : currentVariables; }
3400 
3401 
user_defined_constraints() const3402 inline const Constraints& Model::user_defined_constraints() const
3403 {
3404   return (modelRep) ? modelRep->userDefinedConstraints
3405                     : userDefinedConstraints;
3406 }
3407 
3408 
current_response() const3409 inline const Response& Model::current_response() const
3410 { return (modelRep) ? modelRep->currentResponse : currentResponse; }
3411 
3412 
problem_description_db() const3413 inline ProblemDescDB& Model::problem_description_db() const
3414 { return (modelRep) ? modelRep->probDescDB : probDescDB; }
3415 
3416 
parallel_library() const3417 inline ParallelLibrary& Model::parallel_library() const
3418 { return (modelRep) ? modelRep->parallelLib : parallelLib; }
3419 
3420 
model_type() const3421 inline const String& Model::model_type() const
3422 { return (modelRep) ? modelRep->modelType : modelType; }
3423 
3424 
surrogate_type() const3425 inline const String& Model::surrogate_type() const
3426 { return (modelRep) ? modelRep->surrogateType : surrogateType; }
3427 
3428 
model_id() const3429 inline const String& Model::model_id() const
3430 { return (modelRep) ? modelRep->modelId : modelId; }
3431 
3432 
num_secondary_fns() const3433 inline size_t Model::num_secondary_fns() const
3434 {
3435   return (modelRep) ? modelRep->num_secondary_fns() :
3436     num_nonlinear_ineq_constraints() + num_nonlinear_eq_constraints();
3437 }
3438 
3439 
num_primary_fns() const3440 inline size_t Model::num_primary_fns() const
3441 {
3442   return (modelRep) ? modelRep->num_primary_fns() :
3443     response_size() - num_secondary_fns();
3444 }
3445 
3446 
gradient_type() const3447 inline const String& Model::gradient_type() const
3448 { return (modelRep) ? modelRep->gradientType : gradientType; }
3449 
3450 
method_source() const3451 inline const String& Model::method_source() const
3452 { return (modelRep) ? modelRep->methodSource : methodSource; }
3453 
3454 
interval_type() const3455 inline const String& Model::interval_type() const
3456 { return (modelRep) ? modelRep->intervalType : intervalType; }
3457 
3458 
ignore_bounds() const3459 inline bool Model::ignore_bounds() const
3460 { return (modelRep) ? modelRep->ignoreBounds : ignoreBounds; }
3461 
3462 
central_hess() const3463 inline bool Model::central_hess() const
3464 { return (modelRep) ? modelRep->centralHess : centralHess; }
3465 
3466 
fd_gradient_step_size() const3467 inline const RealVector& Model::fd_gradient_step_size() const
3468 { return (modelRep) ? modelRep->fdGradStepSize : fdGradStepSize; }
3469 
3470 
fd_gradient_step_type() const3471 inline const String& Model::fd_gradient_step_type() const
3472 { return (modelRep) ? modelRep->fdGradStepType : fdGradStepType; }
3473 
3474 
gradient_id_analytic() const3475 inline const IntSet& Model::gradient_id_analytic() const
3476 { return (modelRep) ? modelRep->gradIdAnalytic : gradIdAnalytic; }
3477 
3478 
gradient_id_numerical() const3479 inline const IntSet& Model::gradient_id_numerical() const
3480 { return (modelRep) ? modelRep->gradIdNumerical : gradIdNumerical; }
3481 
3482 
hessian_type() const3483 inline const String& Model::hessian_type() const
3484 { return (modelRep) ? modelRep->hessianType : hessianType; }
3485 
3486 
quasi_hessian_type() const3487 inline const String& Model::quasi_hessian_type() const
3488 { return (modelRep) ? modelRep->quasiHessType : quasiHessType; }
3489 
3490 
fd_hessian_by_grad_step_size() const3491 inline const RealVector& Model::fd_hessian_by_grad_step_size() const
3492 { return (modelRep) ? modelRep-> fdHessByGradStepSize : fdHessByGradStepSize; }
3493 
3494 
fd_hessian_by_fn_step_size() const3495 inline const RealVector& Model::fd_hessian_by_fn_step_size() const
3496 { return (modelRep) ? modelRep->fdHessByFnStepSize : fdHessByFnStepSize; }
3497 
3498 
fd_hessian_step_type() const3499 inline const String& Model::fd_hessian_step_type() const
3500 { return (modelRep) ? modelRep->fdHessStepType : fdHessStepType; }
3501 
3502 
hessian_id_analytic() const3503 inline const IntSet& Model::hessian_id_analytic() const
3504 { return (modelRep) ? modelRep->hessIdAnalytic : hessIdAnalytic; }
3505 
3506 
hessian_id_numerical() const3507 inline const IntSet& Model::hessian_id_numerical() const
3508 { return (modelRep) ? modelRep->hessIdNumerical : hessIdNumerical; }
3509 
3510 
hessian_id_quasi() const3511 inline const IntSet& Model::hessian_id_quasi() const
3512 { return (modelRep) ? modelRep->hessIdQuasi : hessIdQuasi; }
3513 
3514 
primary_response_fn_sense(const BoolDeque & sense)3515 inline void Model::primary_response_fn_sense(const BoolDeque& sense)
3516 {
3517   if (modelRep) modelRep->primaryRespFnSense = sense;
3518   else          primaryRespFnSense = sense;
3519 }
3520 
3521 
primary_response_fn_sense() const3522 inline const BoolDeque& Model::primary_response_fn_sense() const
3523 { return (modelRep) ? modelRep->primaryRespFnSense : primaryRespFnSense; }
3524 
3525 
primary_response_fn_weights() const3526 inline const RealVector& Model::primary_response_fn_weights() const
3527 { return (modelRep) ? modelRep->primaryRespFnWts : primaryRespFnWts; }
3528 
3529 
scaling_options() const3530 inline const ScalingOptions& Model::scaling_options() const
3531 { return (modelRep) ? modelRep->scalingOpts : scalingOpts; }
3532 
3533 
primary_fn_type() const3534 inline short Model::primary_fn_type() const
3535 {
3536   return (modelRep) ?
3537     modelRep->currentResponse.shared_data().primary_fn_type() :
3538     currentResponse.shared_data().primary_fn_type();
3539 }
3540 
primary_fn_type(short type)3541 inline void Model::primary_fn_type(short type)
3542 {
3543   if (modelRep) modelRep->currentResponse.shared_data().primary_fn_type(type);
3544   else          currentResponse.shared_data().primary_fn_type(type);
3545 }
3546 
3547 
derivative_estimation()3548 inline bool Model::derivative_estimation()
3549 {
3550   return (modelRep) ? modelRep->derivative_estimation() :
3551     ( (gradientType == "numerical" || gradientType == "mixed") ||
3552       (hessianType == "numerical" || hessianType == "mixed" ||
3553        hessianType == "quasi") );
3554 }
3555 
3556 
supports_derivative_estimation(bool sed_flag)3557 inline void Model::supports_derivative_estimation(bool sed_flag)
3558 {
3559   if (modelRep) modelRep->supportsEstimDerivs = sed_flag;
3560   else          supportsEstimDerivs = sed_flag;
3561 }
3562 
3563 
init_comms_bcast_flag(bool icb_flag)3564 inline void Model::init_comms_bcast_flag(bool icb_flag)
3565 {
3566   if (modelRep) modelRep->initCommsBcastFlag = icb_flag;
3567   else          initCommsBcastFlag = icb_flag;
3568 }
3569 
3570 
evaluation_capacity() const3571 inline int Model::evaluation_capacity() const
3572 { return (modelRep) ? modelRep->evaluationCapacity : evaluationCapacity; }
3573 
3574 
asynch_flag() const3575 inline bool Model::asynch_flag() const
3576 { return (modelRep) ? modelRep->asynchEvalFlag : asynchEvalFlag; }
3577 
3578 
asynch_flag(const bool flag)3579 inline void Model::asynch_flag(const bool flag)
3580 {
3581   if (modelRep) modelRep->asynchEvalFlag = flag;
3582   else          asynchEvalFlag = flag;
3583 }
3584 
3585 
output_level() const3586 inline short Model::output_level() const
3587 { return (modelRep) ? modelRep->outputLevel : outputLevel; }
3588 
3589 
output_level(const short level)3590 inline void Model::output_level(const short level)
3591 {
3592   if (modelRep) modelRep->outputLevel = level;
3593   else          outputLevel = level;
3594 }
3595 
3596 
message_lengths() const3597 inline const IntArray& Model::message_lengths() const
3598 { return (modelRep) ? modelRep->messageLengths : messageLengths; }
3599 
3600 
mapping_initialized() const3601 inline bool Model::mapping_initialized() const
3602 { return (modelRep) ? modelRep->mappingInitialized : mappingInitialized; }
3603 
3604 
parallel_configuration_iterator(ParConfigLIter pc_iter)3605 inline void Model::parallel_configuration_iterator(ParConfigLIter pc_iter)
3606 {
3607   if (modelRep) modelRep->modelPCIter = pc_iter;
3608   else          modelPCIter = pc_iter;
3609 }
3610 
3611 
parallel_configuration_iterator() const3612 inline ParConfigLIter Model::parallel_configuration_iterator() const
3613 { return (modelRep) ? modelRep->modelPCIter : modelPCIter; }
3614 
3615 
auto_graphics(const bool flag)3616 inline void Model::auto_graphics(const bool flag)
3617 {
3618   if (modelRep) modelRep->modelAutoGraphicsFlag = flag;
3619   else          modelAutoGraphicsFlag = flag;
3620 }
3621 
auto_graphics() const3622 inline bool Model::auto_graphics() const
3623 {
3624   if (modelRep) return modelRep->modelAutoGraphicsFlag;
3625   else          return modelAutoGraphicsFlag;
3626 }
3627 
3628 
is_null() const3629 inline bool Model::is_null() const
3630 { return (modelRep) ? false : true; }
3631 
3632 
model_rep() const3633 inline std::shared_ptr<Model> Model::model_rep() const
3634 { return modelRep; }
3635 
3636 
max_string(const StringSet & ss)3637 inline SSCIter Model::max_string(const StringSet& ss)
3638 {
3639   SSCIter ss_it = ss.begin(),  max_it = ss_it;  ++ss_it;
3640   for (; ss_it!=ss.end(); ++ss_it)
3641     if (ss_it->size() > max_it->size())
3642       max_it = ss_it;
3643   return max_it;
3644 }
3645 
3646 
max_string(const StringRealMap & srm)3647 inline SRMCIter Model::max_string(const StringRealMap& srm)
3648 {
3649   SRMCIter srm_it = srm.begin(),  max_it = srm_it;  ++srm_it;
3650   for (; srm_it!=srm.end(); ++srm_it)
3651     if (srm_it->first.size() > max_it->first.size())
3652       max_it = srm_it;
3653   return max_it;
3654 }
3655 
3656 
3657 /*
3658 inline void Model::
3659 rekey_response_map(const IntResponseMap& resp_map, IntIntMap& id_map,
3660 		   IntResponseMap& resp_map_rekey, bool deep_copy_resp)
3661 {
3662   if (resp_map.size() <= id_map.size()) // e.g., nonblocking synch
3663     rekey_response_map_rloop(resp_map, id_map, resp_map_rekey, deep_copy_resp);
3664   else                   // e.g., derived_synchronize_same_model()
3665     rekey_response_map_iloop(resp_map, id_map, resp_map_rekey, deep_copy_resp);
3666 }
3667 
3668 
3669 inline void Model::
3670 rekey_response_map_rloop(const IntResponseMap& resp_map, IntIntMap& id_map,
3671 			 IntResponseMap& resp_map_rekey, bool deep_copy_resp)
3672 {
3673   // rekey registered evals
3674   resp_map_rekey.clear();
3675   IntIntMIter id_it; IntRespMCIter r_cit;
3676   for (r_cit=resp_map.begin(); r_cit!=resp_map.end(); ++r_cit) {
3677     id_it = id_map.find(r_cit->first); // Note: no iterator hint accelerator
3678     // unfound jobs may be from another Model using a shared Interface instance
3679     if (id_it != id_map.end()) {
3680       resp_map_rekey[id_it->second] = (deep_copy_resp) ?
3681 	r_cit->second.copy() : r_cit->second;
3682       id_map.erase(id_it);
3683     }
3684   }
3685 }
3686 
3687 
3688 inline void Model::
3689 rekey_response_map_iloop(const IntResponseMap& resp_map, IntIntMap& id_map,
3690 			 IntResponseMap& resp_map_rekey, bool deep_copy_resp)
3691 {
3692   // rekey registered evals
3693   resp_map_rekey.clear();
3694   // Immediate erasure relying on iterator invalidation + postfix rules
3695   IntIntMIter id_it = id_map.begin(); IntRespMCIter r_cit;
3696   while (id_it!=id_map.end()) {
3697     r_cit = resp_map.find(id_it->first); // Note: no iterator hint API
3698     if (r_cit != resp_map.end()) {
3699       resp_map_rekey[id_it->second] = (deep_copy_resp) ?
3700 	r_cit->second.copy() : r_cit->second;
3701       // postfix increment must generate a copy _before_ fn call
3702       // --> increment occurs before iterator invalidation
3703       id_map.erase(id_it++);
3704     }
3705     else
3706       ++id_it;
3707   }
3708 }
3709 
3710 
3711 inline void Model::
3712 rekey_response_map(const IntResponseMap& resp_map, IntIntMap& id_map,
3713 		   IntResponseMap& resp_map_rekey,
3714 		   IntResponseMap& cached_resp_map, bool deep_copy_resp)
3715 {
3716   // rekey registered evals
3717   resp_map_rekey.clear();
3718 
3719   // process incoming resp_map against remaining id_map
3720   IntIntMIter id_it; IntRespMCIter r_cit;
3721   for (r_cit=resp_map.begin(); r_cit!=resp_map.end(); ++r_cit) {
3722     id_it = id_map.find(r_cit->first); // Note: no iterator hint API
3723     if (id_it != id_map.end()) {
3724       resp_map_rekey[id_it->second] = (deep_copy_resp) ?
3725 	r_cit->second.copy() : r_cit->second;
3726       id_map.erase(id_it);
3727     }
3728     // insert unmatched resp_map jobs into cache (may be from another Model
3729     // using a shared Interface instance).  Neither deep copy nor rekey are
3730     // performed until id is matched above (on a subsequent pass).
3731     else
3732       // Approach 1: the resp_map record is duplicated, not migrated, due to
3733       // const ref --> rely on subsequent clearing of resp_map on reentry
3734       cached_resp_map[r_cit->first] = r_cit->second;
3735       // Approach 2: virtual fn approach could accomplish a migration and
3736       // avoid duplication, but it lacks level clarity (SimulationModel:
3737       // augment its own cache or delegate to userDefinedInterface?)
3738       //cache_unmatched_response(r_cit->first); // virtual fn
3739       // Approach 3: resolve level clarity by passing a meta-object in a
3740       // template.  Consistency: use meta-object to synchronize and cache,
3741       // requiring renaming of Interface fns and adding nowait variant.
3742       //meta_object.cache_unmatched_response(r_cit->first); // level clarity
3743   }
3744 }
3745 */
3746 
3747 
3748 template <typename MetaType> void Model::
rekey_response_map(MetaType & meta_object,const IntResponseMap & resp_map,IntIntMap & id_map,IntResponseMap & resp_map_rekey,bool deep_copy_resp)3749 rekey_response_map(MetaType& meta_object, const IntResponseMap& resp_map,
3750 		   IntIntMap& id_map, IntResponseMap& resp_map_rekey,
3751 		   bool deep_copy_resp)
3752 {
3753   // rekey the resp_map evals matched in id_map, else move to cache
3754   resp_map_rekey.clear();
3755   IntIntMIter id_it; IntRespMCIter r_cit = resp_map.begin();
3756   while (r_cit != resp_map.end()) {
3757     int raw_id = r_cit->first;
3758     id_it = id_map.find(raw_id); // Note: no iterator hint API
3759     if (id_it != id_map.end()) {
3760       resp_map_rekey[id_it->second] = (deep_copy_resp) ?
3761 	r_cit->second.copy() : r_cit->second;
3762       if(evaluations_db_state(meta_object) == EvaluationsDBState::ACTIVE)
3763         asynch_eval_store(meta_object, id_it->first, r_cit->second);
3764       id_map.erase(id_it);
3765       ++r_cit;
3766     }
3767     // insert unmatched resp_map jobs into cache (may be from another Model
3768     // using a shared Interface instance).  Neither deep copy nor rekey are
3769     // performed until id is matched above (on a subsequent pass).
3770     else {
3771       // Approach 3: resolve level clarity by passing a meta-object in a
3772       // template.  Consistency: use meta-object to synchronize and cache,
3773       // requiring renaming of Interface fns and adding nowait variant.
3774       ++r_cit; // prior to invalidation from erase()
3775       meta_object.cache_unmatched_response(raw_id);// same level as synchronize
3776     }
3777   }
3778 }
3779 
3780 
3781 template <typename MetaType> void Model::
rekey_synch(MetaType & meta_object,bool block,IntIntMap & id_map,IntResponseMap & resp_map_rekey,bool deep_copy)3782 rekey_synch(MetaType& meta_object, bool block, IntIntMap& id_map,
3783 	    IntResponseMap& resp_map_rekey, bool deep_copy)
3784 {
3785   const IntResponseMap& resp_map = (block) ? meta_object.synchronize() :
3786     meta_object.synchronize_nowait();
3787   rekey_response_map(meta_object, resp_map, id_map, resp_map_rekey, deep_copy);
3788 }
3789 
3790 
3791 /// global comparison function for Model
model_id_compare(const Model & model,const void * id)3792 inline bool model_id_compare(const Model& model, const void* id)
3793 { return ( *(const String*)id == model.model_id() ); }
3794 
3795 
3796 /// equality operator for Envelope is true if same letter instance
operator ==(const Model & m1,const Model & m2)3797 inline bool operator==(const Model& m1, const Model& m2)
3798 { return (m1.modelRep == m2.modelRep); } // friend of Model
3799 
3800 
3801 /// inequality operator for Envelope is true if different letter instance
operator !=(const Model & m1,const Model & m2)3802 inline bool operator!=(const Model& m1, const Model& m2)
3803 { return (m1.modelRep != m2.modelRep); } // friend of Model
3804 
3805 } // namespace Dakota
3806 
3807 #endif
3808