Base class for the variables class hierarchy. More...
Public Member Functions | |
| Variables () | |
| default constructor | |
| Variables (const ProblemDescDB &problem_db) | |
| standard constructor | |
| Variables (const SharedVariablesData &svd) | |
| alternate constructor for instantiations on the fly | |
| Variables (const Variables &vars) | |
| copy constructor | |
| virtual | ~Variables () |
| destructor | |
| Variables | operator= (const Variables &vars) |
| assignment operator | |
| virtual void | reshape (const SizetArray &vc_totals) |
| reshapes an existing Variables object based on the incoming variablesComponents | |
| virtual void | read (std::istream &s) |
| read a variables object from an std::istream | |
| virtual void | write (std::ostream &s) const |
| write a variables object to an std::ostream | |
| virtual void | write_aprepro (std::ostream &s) const |
| write a variables object to an std::ostream in aprepro format | |
| virtual void | read_annotated (std::istream &s) |
| read a variables object in annotated format from an istream | |
| virtual void | write_annotated (std::ostream &s) const |
| write a variables object in annotated format to an std::ostream | |
| virtual void | read_tabular (std::istream &s) |
| read a variables object in tabular format from an istream | |
| virtual void | write_tabular (std::ostream &s) const |
| write a variables object in tabular format to an std::ostream | |
| virtual void | read (BiStream &s) |
| read a variables object from the binary restart stream | |
| virtual void | write (BoStream &s) const |
| write a variables object to the binary restart stream | |
| virtual void | read (MPIUnpackBuffer &s) |
| read a variables object from a packed MPI buffer | |
| virtual void | write (MPIPackBuffer &s) const |
| write a variables object to a packed MPI buffer | |
| size_t | tv () const |
| total number of vars | |
| size_t | cv () const |
| number of active continuous vars | |
| size_t | cv_start () const |
| start index of active continuous vars | |
| size_t | div () const |
| number of active discrete int vars | |
| size_t | div_start () const |
| start index of active discrete int vars | |
| size_t | drv () const |
| number of active discrete real vars | |
| size_t | drv_start () const |
| start index of active discrete real vars | |
| size_t | icv () const |
| number of inactive continuous vars | |
| size_t | icv_start () const |
| start index of inactive continuous vars | |
| size_t | idiv () const |
| number of inactive discrete int vars | |
| size_t | idiv_start () const |
| start index of inactive discrete int vars | |
| size_t | idrv () const |
| number of inactive discrete real vars | |
| size_t | idrv_start () const |
| start index of inactive discrete real vars | |
| size_t | acv () const |
| total number of continuous vars | |
| size_t | adiv () const |
| total number of discrete integer vars | |
| size_t | adrv () const |
| total number of discrete real vars | |
| const SharedVariablesData & | shared_data () const |
| return sharedVarsData | |
| const Real & | continuous_variable (size_t index) const |
| return an active continuous variable | |
| const RealVector & | continuous_variables () const |
| return the active continuous variables | |
| void | continuous_variable (const Real &c_var, size_t index) |
| set an active continuous variable | |
| void | continuous_variables (const RealVector &c_vars) |
| set the active continuous variables | |
| int | discrete_int_variable (size_t index) const |
| return an active discrete integer variable | |
| const IntVector & | discrete_int_variables () const |
| return the active discrete integer variables | |
| void | discrete_int_variable (int di_var, size_t index) |
| set an active discrete integer variable | |
| void | discrete_int_variables (const IntVector &di_vars) |
| set the active discrete integer variables | |
| const Real & | discrete_real_variable (size_t index) const |
| return an active discrete real variable | |
| const RealVector & | discrete_real_variables () const |
| return the active discrete real variables | |
| void | discrete_real_variable (const Real &dr_var, size_t index) |
| set an active discrete real variable | |
| void | discrete_real_variables (const RealVector &dr_vars) |
| set the active discrete real variables | |
| StringMultiArrayConstView | continuous_variable_labels () const |
| return the active continuous variable labels | |
| void | continuous_variable_labels (StringMultiArrayConstView cv_labels) |
| set the active continuous variable labels | |
| void | continuous_variable_label (const String &cv_label, size_t index) |
| set an active continuous variable label | |
| StringMultiArrayConstView | discrete_int_variable_labels () const |
| return the active discrete integer variable labels | |
| void | discrete_int_variable_labels (StringMultiArrayConstView div_labels) |
| set the active discrete integer variable labels | |
| void | discrete_int_variable_label (const String &div_label, size_t index) |
| set an active discrete integer variable label | |
| StringMultiArrayConstView | discrete_real_variable_labels () const |
| return the active discrete real variable labels | |
| void | discrete_real_variable_labels (StringMultiArrayConstView drv_labels) |
| set the active discrete real variable labels | |
| void | discrete_real_variable_label (const String &drv_label, size_t index) |
| set an active discrete real variable label | |
| UShortMultiArrayConstView | continuous_variable_types () const |
| return the active continuous variable types | |
| UShortMultiArrayConstView | discrete_int_variable_types () const |
| return the active discrete integer variable types | |
| UShortMultiArrayConstView | discrete_real_variable_types () const |
| return the active discrete real variable types | |
| SizetMultiArrayConstView | continuous_variable_ids () const |
| return the active continuous variable position identifiers | |
| const SizetArray & | merged_discrete_ids () const |
| returns the list of discrete variables merged into a continuous array | |
| const RealVector & | inactive_continuous_variables () const |
| return the inactive continuous variables | |
| void | inactive_continuous_variables (const RealVector &ic_vars) |
| set the inactive continuous variables | |
| const IntVector & | inactive_discrete_int_variables () const |
| return the inactive discrete variables | |
| void | inactive_discrete_int_variables (const IntVector &idi_vars) |
| set the inactive discrete variables | |
| const RealVector & | inactive_discrete_real_variables () const |
| return the inactive discrete variables | |
| void | inactive_discrete_real_variables (const RealVector &idr_vars) |
| set the inactive discrete variables | |
| StringMultiArrayConstView | inactive_continuous_variable_labels () const |
| return the inactive continuous variable labels | |
| void | inactive_continuous_variable_labels (StringMultiArrayConstView ic_vars) |
| set the inactive continuous variable labels | |
| StringMultiArrayConstView | inactive_discrete_int_variable_labels () const |
| return the inactive discrete variable labels | |
| void | inactive_discrete_int_variable_labels (StringMultiArrayConstView idi_vars) |
| set the inactive discrete variable labels | |
| StringMultiArrayConstView | inactive_discrete_real_variable_labels () const |
| return the inactive discrete variable labels | |
| void | inactive_discrete_real_variable_labels (StringMultiArrayConstView idr_vars) |
| set the inactive discrete variable labels | |
| UShortMultiArrayConstView | inactive_continuous_variable_types () const |
| return the inactive continuous variable types | |
| UShortMultiArrayConstView | inactive_discrete_int_variable_types () const |
| return the inactive discrete integer variable types | |
| UShortMultiArrayConstView | inactive_discrete_real_variable_types () const |
| return the inactive discrete real variable types | |
| SizetMultiArrayConstView | inactive_continuous_variable_ids () const |
| return the inactive continuous variable position identifiers | |
| const RealVector & | all_continuous_variables () const |
| returns a single array with all continuous variables | |
| void | all_continuous_variables (const RealVector &ac_vars) |
| sets all continuous variables using a single array | |
| void | all_continuous_variable (const Real &ac_var, size_t index) |
| set a variable within the all continuous array | |
| const IntVector & | all_discrete_int_variables () const |
| returns a single array with all discrete variables | |
| void | all_discrete_int_variables (const IntVector &adi_vars) |
| sets all discrete variables using a single array | |
| void | all_discrete_int_variable (int adi_var, size_t index) |
| set a variable within the all discrete array | |
| const RealVector & | all_discrete_real_variables () const |
| returns a single array with all discrete variables | |
| void | all_discrete_real_variables (const RealVector &adr_vars) |
| sets all discrete variables using a single array | |
| void | all_discrete_real_variable (const Real &adr_var, size_t index) |
| set a variable within the all discrete array | |
| StringMultiArrayView | all_continuous_variable_labels () const |
| returns a single array with all continuous variable labels | |
| void | all_continuous_variable_labels (StringMultiArrayConstView acv_labels) |
| sets all continuous variable labels using a single array | |
| void | all_continuous_variable_label (const String &acv_label, size_t index) |
| set a label within the all continuous label array | |
| StringMultiArrayView | all_discrete_int_variable_labels () const |
| returns a single array with all discrete variable labels | |
| void | all_discrete_int_variable_labels (StringMultiArrayConstView adiv_labels) |
| sets all discrete variable labels using a single array | |
| void | all_discrete_int_variable_label (const String &adiv_label, size_t index) |
| set a label within the all discrete label array | |
| StringMultiArrayView | all_discrete_real_variable_labels () const |
| returns a single array with all discrete variable labels | |
| void | all_discrete_real_variable_labels (StringMultiArrayConstView adrv_labels) |
| sets all discrete variable labels using a single array | |
| void | all_discrete_real_variable_label (const String &adrv_label, size_t index) |
| set a label within the all discrete label array | |
| UShortMultiArrayConstView | all_continuous_variable_types () const |
| return all continuous variable types | |
| UShortMultiArrayConstView | all_discrete_int_variable_types () const |
| return all discrete variable types | |
| UShortMultiArrayConstView | all_discrete_real_variable_types () const |
| return all discrete variable types | |
| SizetMultiArrayConstView | all_continuous_variable_ids () const |
| return all continuous variable position identifiers | |
| Variables | copy () const |
| for use when a deep copy is needed (the representation is _not_ shared) | |
| const std::pair< short, short > & | view () const |
| returns variablesView | |
| std::pair< short, short > | get_view (const ProblemDescDB &problem_db) const |
| defines variablesView from problem_db attributes | |
| void | inactive_view (short view2) |
| sets the inactive view based on higher level (nested) context | |
| const String & | variables_id () const |
| returns the variables identifier string | |
| const SizetArray & | variables_components_totals () const |
| returns the number of variables for each of the constitutive components | |
| bool | is_null () const |
| function to check variablesRep (does this envelope contain a letter) | |
Protected Member Functions | |
| Variables (BaseConstructor, const ProblemDescDB &problem_db, const std::pair< short, short > &view) | |
| constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139) | |
| Variables (BaseConstructor, const SharedVariablesData &svd) | |
| constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139) | |
| virtual void | build_active_views () |
| construct active views of all variables arrays | |
| virtual void | build_inactive_views () |
| construct inactive views of all variables arrays | |
| void | build_views () |
| construct active/inactive views of all variables arrays | |
Protected Attributes | |
| SharedVariablesData | sharedVarsData |
| reference-counted instance of shared variables data: id's, labels, counts | |
| RealVector | allContinuousVars |
| array combining all of the continuous variables (design, uncertain, state) | |
| IntVector | allDiscreteIntVars |
| array combining all of the discrete integer variables (design, state) | |
| RealVector | allDiscreteRealVars |
| array combining all of the discrete real variables (design, state) | |
| size_t | cvStart |
| start index of active continuous variables within allContinuousVars | |
| size_t | divStart |
| start index of active discrete integer variables within allDiscreteIntVars | |
| size_t | drvStart |
| start index of active discrete real variables within allDiscreteRealVars | |
| size_t | icvStart |
| start index of inactive continuous variables within allContinuousVars | |
| size_t | idivStart |
| start index of inactive discrete integer variables w/i allDiscreteIntVars | |
| size_t | idrvStart |
| start index of inactive discrete real variables within allDiscreteRealVars | |
| size_t | numCV |
| number of active continuous variables | |
| size_t | numDIV |
| number of active discrete integer variables | |
| size_t | numDRV |
| number of active discrete real variables | |
| size_t | numICV |
| number of inactive continuous variables | |
| size_t | numIDIV |
| number of inactive discrete integer variables | |
| size_t | numIDRV |
| number of inactive discrete real variables | |
| RealVector | continuousVars |
| the active continuous variables array view | |
| IntVector | discreteIntVars |
| the active discrete integer variables array view | |
| RealVector | discreteRealVars |
| the active discrete real variables array view | |
| RealVector | inactiveContinuousVars |
| the inactive continuous variables array view | |
| IntVector | inactiveDiscreteIntVars |
| the inactive discrete integer variables array view | |
| RealVector | inactiveDiscreteRealVars |
| the inactive discrete real variables array view | |
Private Member Functions | |
| Variables * | get_variables (const ProblemDescDB &problem_db) |
| Used by the standard envelope constructor to instantiate the correct letter class. | |
| Variables * | get_variables (const SharedVariablesData &svd) const |
| Used by the alternate envelope constructors, by read functions, and by copy() to instantiate a new letter class. | |
| void | check_view_compatibility () |
| perform sanity checks on view.first and view.second after update | |
Private Attributes | |
| Variables * | variablesRep |
| pointer to the letter (initialized only for the envelope) | |
| int | referenceCount |
| number of objects sharing variablesRep | |
Friends | |
| bool | operator== (const Variables &vars1, const Variables &vars2) |
| equality operator | |
| bool | operator!= (const Variables &vars1, const Variables &vars2) |
| inequality operator | |
| std::size_t | hash_value (const Variables &vars) |
| hash_value | |
| bool | binary_equal_to (const Variables &vars1, const Variables &vars2) |
| binary_equal_to (since 'operator==' is not suitable for boost/hash_set) | |
Base class for the variables class hierarchy.
The Variables class is the base class for the class hierarchy providing design, uncertain, and state variables for continuous and discrete domains within a Model. Using the fundamental arrays from the input specification, different derived classes define different views of the data. For memory efficiency and enhanced polymorphism, the variables hierarchy employs the "letter/envelope idiom" (see Coplien "Advanced C++", p. 133), for which the base class (Variables) serves as the envelope and one of the derived classes (selected in Variables::get_variables()) serves as the letter.
| Variables | ( | ) |
default constructor
The default constructor: variablesRep is NULL in this case (a populated problem_db is needed to build a meaningful Variables object). This makes it necessary to check for NULL in the copy constructor, assignment operator, and destructor.
| Variables | ( | const ProblemDescDB & | problem_db | ) |
standard constructor
This is the primary envelope constructor which uses problem_db to build a fully populated variables object. It only needs to extract enough data to properly execute get_variables(problem_db), since the constructor overloaded with BaseConstructor builds the actual base class data inherited by the derived classes.
References Dakota::abort_handler(), Variables::get_variables(), and Variables::variablesRep.
| Variables | ( | const SharedVariablesData & | svd | ) |
alternate constructor for instantiations on the fly
This is the alternate envelope constructor for instantiations on the fly. This constructor executes get_variables(view), which invokes the default derived/base constructors, followed by a resize() based on vars_comps.
References Dakota::abort_handler(), Variables::get_variables(), and Variables::variablesRep.
copy constructor
Copy constructor manages sharing of variablesRep and incrementing of referenceCount.
References Variables::referenceCount, and Variables::variablesRep.
| ~Variables | ( | ) | [virtual] |
destructor
Destructor decrements referenceCount and only deletes variablesRep when referenceCount reaches zero.
References Variables::referenceCount, and Variables::variablesRep.
| Variables | ( | BaseConstructor | , |
| const ProblemDescDB & | problem_db, | ||
| const std::pair< short, short > & | view | ||
| ) | [protected] |
constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139)
This constructor is the one which must build the base class data for all derived classes. get_variables() instantiates a derived class letter and the derived constructor selects this base class constructor in its initialization list (to avoid the recursion of the base class constructor calling get_variables() again). Since the letter IS the representation, its representation pointer is set to NULL (an uninitialized pointer causes problems in ~Variables).
| Variables | ( | BaseConstructor | , |
| const SharedVariablesData & | svd | ||
| ) | [protected] |
constructor initializes the base class part of letter classes (BaseConstructor overloading avoids infinite recursion in the derived class constructors - Coplien, p. 139)
This constructor is the one which must build the base class data for all derived classes. get_variables() instantiates a derived class letter and the derived constructor selects this base class constructor in its initialization list (to avoid the recursion of the base class constructor calling get_variables() again). Since the letter IS the representation, its representation pointer is set to NULL (an uninitialized pointer causes problems in ~Variables).
assignment operator
Assignment operator decrements referenceCount for old variablesRep, assigns new variablesRep, and increments referenceCount for new variablesRep.
References Variables::referenceCount, and Variables::variablesRep.
for use when a deep copy is needed (the representation is _not_ shared)
Deep copies are used for history mechanisms such as bestVariablesArray and data_pairs since these must catalogue copies (and should not change as the representation within currentVariables changes).
References Variables::allContinuousVars, Variables::allDiscreteIntVars, Variables::allDiscreteRealVars, Variables::build_views(), Variables::get_variables(), Variables::sharedVarsData, and Variables::variablesRep.
Referenced by Model::asynch_compute_response(), ApplicationInterface::continuation(), RecastModel::derived_asynch_compute_response(), EffGlobalMinimizer::EffGlobalMinimizer(), SurrogateModel::force_rebuild(), LeastSq::LeastSq(), SurrBasedLocalMinimizer::minimize_surrogates(), Optimizer::Optimizer(), COLINOptimizer::post_run(), Analyzer::read_variables_responses(), RecastModel::RecastModel(), COLINOptimizer::resize_final_points(), DiscrepancyCorrection::search_db(), SurrBasedLocalMinimizer::SurrBasedLocalMinimizer(), Analyzer::update_best(), and NonDLocalReliability::update_mpp_search_data().
| void build_views | ( | ) | [inline, protected] |
construct active/inactive views of all variables arrays
= EMPTY)
= EMPTY)
References Variables::build_active_views(), Variables::build_inactive_views(), Variables::sharedVarsData, SharedVariablesData::view(), and Variables::view().
Referenced by Variables::copy(), MergedVariables::MergedVariables(), MixedVariables::MixedVariables(), Variables::read(), Variables::read_annotated(), MergedVariables::reshape(), and MixedVariables::reshape().
| Variables * get_variables | ( | const ProblemDescDB & | problem_db | ) | [private] |
Used by the standard envelope constructor to instantiate the correct letter class.
Initializes variablesRep to the appropriate derived type, as given by problem_db attributes. The standard derived class constructors are invoked.
References Variables::get_view(), and Variables::view().
Referenced by Variables::copy(), Variables::read(), Variables::read_annotated(), and Variables::Variables().
| Variables * get_variables | ( | const SharedVariablesData & | svd | ) | const [private] |
Used by the alternate envelope constructors, by read functions, and by copy() to instantiate a new letter class.
Initializes variablesRep to the appropriate derived type, as given by view. The default derived class constructors are invoked.
References SharedVariablesData::view().
1.7.6.1