Dakota  Version 6.21
Explore and Predict with Confidence
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
Variables Class Reference

Base class for the variables class hierarchy. More...

Inheritance diagram for Variables:
MixedVariables RelaxedVariables

Public Member Functions

 Variables ()
 default constructor
 
 Variables (const ProblemDescDB &problem_db)
 standard constructor (explicit disallows its use for implicit type conversion)
 
 Variables (const SharedVariablesData &svd)
 alternate constructor for instantiations on the fly (explicit disallows its use for implicit type conversion)
 
 Variables (const Variables &vars)
 copy constructor
 
virtual ~Variables ()
 destructor
 
Variables operator= (const Variables &vars)
 assignment operator
 
virtual void read (std::istream &s)
 read a variables object from an std::istream
 
virtual void write (std::ostream &s, unsigned short vars_part=ALL_VARS) const
 write a variables object to an std::ostream, e.g., the console, optionally specifying which partition (all/active/inactive)
 
virtual void write_aprepro (std::ostream &s) const
 write a variables object to an std::ostream in aprepro format, e.g., a parameters file
 
virtual void write_json (json &s) const
 write a variables object to a json object
 
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, unsigned short vars_part=ALL_VARS)
 read a variables object in tabular format from an istream, optionally specifying which partition (all/active/inactive)
 
virtual void write_tabular (std::ostream &s, unsigned short vars_part=ALL_VARS) const
 write a variables object in tabular format to an std::ostream, optionally specifying which partition (all/active/inactive)
 
virtual void write_tabular_partial (std::ostream &s, size_t start_index, size_t num_items) const
 write range of variables in tabular format to an std::ostream
 
virtual void write_tabular_labels (std::ostream &s, unsigned short vars_part=ALL_VARS) const
 write the labels in input spec order to a std::ostream, optionally specifying which partition (all/active/inactive)
 
virtual void write_tabular_partial_labels (std::ostream &s, size_t start_index, size_t num_items) const
 write range of variable labels in input spec order to a std::ostream
 
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 total_active () const
 total number of active 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 dsv () const
 number of active discrete string vars
 
size_t dsv_start () const
 start index of active discrete string 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 idsv () const
 number of inactive discrete string vars
 
size_t idsv_start () const
 start index of inactive discrete string 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 adsv () const
 total number of discrete string vars
 
size_t adrv () const
 total number of discrete real vars
 
const SharedVariablesDatashared_data () const
 return sharedVarsData
 
SharedVariablesDatashared_data ()
 return sharedVarsData
 
void shape ()
 shape a Variables object based on sharedVarsData
 
void reshape ()
 reshape an existing Variables object based on updated sharedVarsData
 
void reshape (const SharedVariablesData &svd)
 reshape an existing Variables object based on incoming SVD
 
void active_variables (const Variables &vars)
 copy the active cv/div/dsv/drv variables from vars
 
void all_variables (const Variables &vars)
 copy all cv/div/dsv/drv variables from vars
 
void active_to_all_variables (const Variables &vars)
 copy the active cv/div/dsv/drv variables from incoming vars to all variables in this instance
 
void all_to_active_variables (const Variables &vars)
 copy all cv/div/dsv/drv variables from incoming vars to active variables in this instance
 
void inactive_variables (const Variables &vars)
 copy the inactive cv/div/dsv/drv variables from vars
 
void active_to_inactive_variables (const Variables &vars)
 copy the active cv/div/dsv/drv variables from vars to inactive on this
 
void inactive_into_all_variables (const Variables &vars)
 insert the inactive cv/div/dsv/drv variables from vars into all arrays
 
void map_variables_by_view (const Variables &vars)
 map from vars into the corresponding variables based on active views
 
Real continuous_variable (size_t index) const
 return an active continuous variable
 
const RealVector & continuous_variables () const
 return the active continuous variables (Note: returns a view by const reference, but initializing a RealVector from this reference invokes the Teuchos matrix copy constructor to create a Teuchos::Copy instance; to obtain a mutable view, use continuous_variables_view())
 
void continuous_variable (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 (Note: returns a view by const reference, but initializing an IntVector from this reference invokes the Teuchos matrix copy constructor to create a Teuchos::Copy instance; to obtain a mutable view, use discrete_int_variables_view())
 
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 String & discrete_string_variable (size_t index) const
 return an active discrete string variable
 
StringMultiArrayConstView discrete_string_variables () const
 return the active discrete string variables (Note: returns a view by const reference, but initializing a StringArray from this reference invokes the Teuchos matrix copy constructor to create a Teuchos::Copy instance; to obtain a mutable view, use discrete_string_variables_view())
 
void discrete_string_variable (const String &ds_var, size_t index)
 set an active discrete string variable
 
void discrete_string_variables (StringMultiArrayConstView ds_vars)
 set the active discrete string variables
 
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 (Note: returns a view by const reference, but initializing a RealVector from this reference invokes the Teuchos matrix copy constructor to create a Teuchos::Copy instance; to obtain a mutable view, use discrete_real_variables_view())
 
void discrete_real_variable (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
 
RealVector & continuous_variables_view ()
 return a mutable view of the active continuous variables
 
IntVector & discrete_int_variables_view ()
 return a mutable view of the active discrete integer variables
 
StringMultiArrayView discrete_string_variables_view ()
 return a mutable view of the active discrete string variables More...
 
RealVector & discrete_real_variables_view ()
 return a mutable view of 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_string_variable_labels () const
 return the active discrete string variable labels
 
void discrete_string_variable_labels (StringMultiArrayConstView dsv_labels)
 set the active discrete string variable labels
 
void discrete_string_variable_label (const String &dsv_label, size_t index)
 set an active discrete string 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
 
void active_labels (const Variables &vars)
 copy all cv/div/dsv/drv variable labels from vars
 
void all_labels (const Variables &vars)
 copy all cv/div/dsv/drv variable labels from vars
 
void active_to_all_labels (const Variables &vars)
 copy the active cv/div/dsv/drv variable labels from incoming vars to all variables in this instance
 
void all_to_active_labels (const Variables &vars)
 copy all cv/div/dsv/drv variable labels from incoming vars to active variables in this instance
 
void inactive_labels (const Variables &vars)
 copy the inactive cv/div/dsv/drv variable labels from vars
 
UShortMultiArrayConstView continuous_variable_types () const
 return the active continuous variable types
 
void continuous_variable_types (UShortMultiArrayConstView cv_types)
 set the active continuous variable types
 
void continuous_variable_type (unsigned short cv_type, size_t index)
 set an active continuous variable type
 
UShortMultiArrayConstView discrete_int_variable_types () const
 return the active discrete integer variable types
 
void discrete_int_variable_types (UShortMultiArrayConstView div_types)
 set the active discrete integer variable types
 
void discrete_int_variable_type (unsigned short div_type, size_t index)
 set an active discrete integer variable type
 
UShortMultiArrayConstView discrete_string_variable_types () const
 return the active discrete string variable types
 
void discrete_string_variable_types (UShortMultiArrayConstView dsv_types)
 set the active discrete string variable types
 
void discrete_string_variable_type (unsigned short dsv_type, size_t index)
 set an active discrete string variable type
 
UShortMultiArrayConstView discrete_real_variable_types () const
 return the active discrete real variable types
 
void discrete_real_variable_types (UShortMultiArrayConstView drv_types)
 set the active discrete real variable types
 
void discrete_real_variable_type (unsigned short drv_type, size_t index)
 set an active discrete real variable type
 
SizetMultiArrayConstView continuous_variable_ids () const
 return the active continuous variable position identifiers
 
void continuous_variable_ids (SizetMultiArrayConstView cv_ids)
 set the active continuous variable position identifiers
 
void continuous_variable_id (size_t cv_id, size_t index)
 set an active continuous variable position identifier
 
const RealVector & inactive_continuous_variables () const
 return the inactive continuous variables
 
void inactive_continuous_variables (const RealVector &ic_vars)
 set the inactive continuous variables
 
void inactive_continuous_variable (Real ic_var, size_t index)
 set an inactive continuous variable
 
const IntVector & inactive_discrete_int_variables () const
 return the inactive discrete int variables
 
void inactive_discrete_int_variables (const IntVector &idi_vars)
 set the inactive discrete int variables
 
void inactive_discrete_int_variable (int idi_var, size_t index)
 set an inactive discrete int variable
 
StringMultiArrayConstView inactive_discrete_string_variables () const
 return the inactive discrete string variables
 
void inactive_discrete_string_variables (StringMultiArrayConstView ids_vars)
 set the inactive discrete string variables
 
void inactive_discrete_string_variable (const String &ids_var, size_t index)
 set an inactive discrete string variable
 
const RealVector & inactive_discrete_real_variables () const
 return the inactive discrete real variables
 
void inactive_discrete_real_variables (const RealVector &idr_vars)
 set the inactive discrete real variables
 
void inactive_discrete_real_variable (Real idr_var, size_t index)
 set an inactive discrete real variable
 
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_string_variable_labels () const
 return the inactive discrete variable labels
 
void inactive_discrete_string_variable_labels (StringMultiArrayConstView ids_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_string_variable_types () const
 return the inactive discrete string 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 (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
 
StringMultiArrayConstView all_discrete_string_variables () const
 returns a single array with all discrete variables
 
void all_discrete_string_variables (StringMultiArrayConstView ads_vars)
 sets all discrete variables using a single array
 
void all_discrete_string_variable (const String &ads_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 (Real adr_var, size_t index)
 set a variable within the all discrete array
 
void as_vector (const StringSetArray &dss_vals, RealVector &var_values) const
 get the active variables as a vector of reals, converting string values to zero-based set indices
 
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_string_variable_labels () const
 returns a single array with all discrete variable labels
 
void all_discrete_string_variable_labels (StringMultiArrayConstView adsv_labels)
 sets all discrete variable labels using a single array
 
void all_discrete_string_variable_label (const String &adsv_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_string_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
 
SizetMultiArrayConstView all_discrete_int_variable_ids () const
 return all discrete integer variable position identifiers
 
SizetMultiArrayConstView all_discrete_string_variable_ids () const
 return all discrete string variable position identifiers
 
SizetMultiArrayConstView all_discrete_real_variable_ids () const
 return all discrete real variable position identifiers
 
StringArray ordered_labels (unsigned short vars_part=ALL_VARS) const
 get all or active labels in input spec order
 
Variables copy (bool deep_svd=false) const
 a deep variables copy for use in history mechanisms (SharedVariablesData uses a shallow copy by default)
 
Variables copy (const SharedVariablesData &svd) const
 a deep variables copy that shares an incoming SharedVariablesData
 
void copy_rep (std::shared_ptr< Variables > source_vars_rep)
 copy attributes from source to target representation (shared code among copy() implementations)
 
const ShortShortPair & view () const
 returns variablesView
 
ShortShortPair get_view (const ProblemDescDB &problem_db) const
 defines variablesView from problem_db attributes
 
void active_view (short view1)
 overrides the active view
 
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 ShortShortPair &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)
 
void build_views ()
 construct active/inactive views of all variables arrays
 
void build_active_views ()
 construct active views of all variables arrays
 
void build_inactive_views ()
 construct 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
 
IntVector allDiscreteIntVars
 array combining all of the discrete integer variables
 
StringMultiArray allDiscreteStringVars
 array combining all of the discrete string variables
 
RealVector allDiscreteRealVars
 array combining all of the 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

std::shared_ptr< Variablesget_variables (const ProblemDescDB &problem_db)
 Used by the standard envelope constructor to instantiate the correct letter class.
 
std::shared_ptr< Variablesget_variables (const SharedVariablesData &svd) const
 Used by the alternate envelope constructors, by read functions, and by copy() to instantiate a new letter class.
 
short method_map (short view_spec, bool relaxed) const
 infer domain from method selection
 
short method_domain (const ProblemDescDB &problem_db) const
 infer domain from method selection
 
short method_view (const ProblemDescDB &problem_db) const
 infer view from method selection
 
short response_view (const ProblemDescDB &problem_db) const
 infer view from type of response data set
 
void check_view_compatibility ()
 perform sanity checks on view.first and view.second after update
 
template<class Archive >
void load (Archive &ar, const unsigned int version)
 read a Variables object from an archive
 
template<class Archive >
void save (Archive &ar, const unsigned int version) const
 write a Variables object to an archive
 

Friends

class boost::serialization::access
 for serializing private data members
 
bool operator== (const Variables &vars1, const Variables &vars2)
 strict equality operator (for boost hash-based lookups)
 
bool operator!= (const Variables &vars1, const Variables &vars2)
 strict inequality operator
 
bool nearby (const Variables &vars1, const Variables &vars2, Real rel_tol)
 tolerance-based equality operator
 
std::size_t hash_value (const Variables &vars)
 hash_value
 

Detailed Description

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.

Member Function Documentation

◆ discrete_string_variables_view()

StringMultiArrayView discrete_string_variables_view ( )
inline

return a mutable view of the active discrete string variables

same as discrete_string_variables(), except mutable view

References Variables::allDiscreteStringVars, SharedVariablesData::dsv(), SharedVariablesData::dsv_start(), and Variables::sharedVarsData.


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