Dakota
Version 6.21
Explore and Predict with Confidence
|
Base class for the variable constraints class hierarchy. More...
Public Member Functions | |
Constraints () | |
default constructor More... | |
Constraints (const ProblemDescDB &prob_db, const SharedVariablesData &svd) | |
standard constructor More... | |
Constraints (const SharedVariablesData &svd) | |
alternate constructor for instantiations on the fly More... | |
Constraints (const Constraints &con) | |
copy constructor More... | |
virtual | ~Constraints () |
destructor | |
Constraints | operator= (const Constraints &con) |
assignment operator More... | |
virtual void | write (std::ostream &s) const |
write a variable constraints object to an std::ostream | |
virtual void | read (std::istream &s) |
read a variable constraints object from an std::istream | |
void | active_bounds (const Constraints &cons) |
copy active {cv,div,drv} {lower,upper} bounds from incoming object | |
void | all_bounds (const Constraints &cons) |
copy all {cv,div,drv} {lower,upper} bounds from incoming object | |
void | active_to_all_bounds (const Constraints &cons) |
copy active {cv,div,drv} {lower,upper} bounds from incoming object to all bounds of this instance | |
void | all_to_active_bounds (const Constraints &cons) |
copy all {cv,div,drv} {lower,upper} bounds from incoming object to active bounds of this instance | |
void | inactive_bounds (const Constraints &cons) |
copy inactive {cv,div,drv} {lower,upper} bounds from incoming object | |
const RealVector & | continuous_lower_bounds () const |
return the active continuous variable lower bounds | |
Real | continuous_lower_bound (size_t i) const |
return an active continuous variable lower bound | |
void | continuous_lower_bounds (const RealVector &cl_bnds) |
set the active continuous variable lower bounds | |
void | continuous_lower_bound (Real cl_bnd, size_t i) |
set an active continuous variable lower bound | |
const RealVector & | continuous_upper_bounds () const |
return the active continuous variable upper bounds | |
Real | continuous_upper_bound (size_t i) const |
return an active continuous variable upper bound | |
void | continuous_upper_bounds (const RealVector &cu_bnds) |
set the active continuous variable upper bounds | |
void | continuous_upper_bound (Real cu_bnd, size_t i) |
set an active continuous variable upper bound | |
const IntVector & | discrete_int_lower_bounds () const |
return the active discrete variable lower bounds | |
int | discrete_int_lower_bound (size_t i) const |
return an active discrete variable lower bound | |
void | discrete_int_lower_bounds (const IntVector &dil_bnds) |
set the active discrete variable lower bounds | |
void | discrete_int_lower_bound (int dil_bnd, size_t i) |
set an active discrete variable lower bound | |
const IntVector & | discrete_int_upper_bounds () const |
return the active discrete variable upper bounds | |
int | discrete_int_upper_bound (size_t i) const |
return an active discrete variable upper bound | |
void | discrete_int_upper_bounds (const IntVector &diu_bnds) |
set the active discrete variable upper bounds | |
void | discrete_int_upper_bound (int diu_bnd, size_t i) |
set an active discrete variable upper bound | |
const RealVector & | discrete_real_lower_bounds () const |
return the active discrete variable lower bounds | |
Real | discrete_real_lower_bound (size_t i) const |
return an active discrete variable lower bound | |
void | discrete_real_lower_bounds (const RealVector &drl_bnds) |
set the active discrete variable lower bounds | |
void | discrete_real_lower_bound (Real drl_bnd, size_t i) |
set an active discrete variable lower bound | |
const RealVector & | discrete_real_upper_bounds () const |
return the active discrete variable upper bounds | |
Real | discrete_real_upper_bound (size_t i) const |
return an active discrete variable upper bound | |
void | discrete_real_upper_bounds (const RealVector &dru_bnds) |
set the active discrete variable upper bounds | |
void | discrete_real_upper_bound (Real dru_bnd, size_t i) |
set an active discrete variable upper bound | |
const RealVector & | inactive_continuous_lower_bounds () const |
return the inactive continuous lower bounds | |
void | inactive_continuous_lower_bounds (const RealVector &icl_bnds) |
set the inactive continuous lower bounds | |
const RealVector & | inactive_continuous_upper_bounds () const |
return the inactive continuous upper bounds | |
void | inactive_continuous_upper_bounds (const RealVector &icu_bnds) |
set the inactive continuous upper bounds | |
const IntVector & | inactive_discrete_int_lower_bounds () const |
return the inactive discrete lower bounds | |
void | inactive_discrete_int_lower_bounds (const IntVector &idil_bnds) |
set the inactive discrete lower bounds | |
const IntVector & | inactive_discrete_int_upper_bounds () const |
return the inactive discrete upper bounds | |
void | inactive_discrete_int_upper_bounds (const IntVector &idiu_bnds) |
set the inactive discrete upper bounds | |
const RealVector & | inactive_discrete_real_lower_bounds () const |
return the inactive discrete lower bounds | |
void | inactive_discrete_real_lower_bounds (const RealVector &idrl_bnds) |
set the inactive discrete lower bounds | |
const RealVector & | inactive_discrete_real_upper_bounds () const |
return the inactive discrete upper bounds | |
void | inactive_discrete_real_upper_bounds (const RealVector &idru_bnds) |
set the inactive discrete upper bounds | |
const RealVector & | all_continuous_lower_bounds () const |
returns a single array with all continuous lower bounds | |
void | all_continuous_lower_bounds (const RealVector &acl_bnds) |
sets all continuous lower bounds using a single array | |
void | all_continuous_lower_bound (Real acl_bnd, size_t i) |
set a lower bound within the all continuous lower bounds array | |
const RealVector & | all_continuous_upper_bounds () const |
returns a single array with all continuous upper bounds | |
void | all_continuous_upper_bounds (const RealVector &acu_bnds) |
sets all continuous upper bounds using a single array | |
void | all_continuous_upper_bound (Real acu_bnd, size_t i) |
set an upper bound within the all continuous upper bounds array | |
const IntVector & | all_discrete_int_lower_bounds () const |
returns a single array with all discrete lower bounds | |
void | all_discrete_int_lower_bounds (const IntVector &adil_bnds) |
sets all discrete lower bounds using a single array | |
void | all_discrete_int_lower_bound (int adil_bnd, size_t i) |
set a lower bound within the all discrete lower bounds array | |
const IntVector & | all_discrete_int_upper_bounds () const |
returns a single array with all discrete upper bounds | |
void | all_discrete_int_upper_bounds (const IntVector &adiu_bnds) |
sets all discrete upper bounds using a single array | |
void | all_discrete_int_upper_bound (int adiu_bnd, size_t i) |
set an upper bound within the all discrete upper bounds array | |
const RealVector & | all_discrete_real_lower_bounds () const |
returns a single array with all discrete lower bounds | |
void | all_discrete_real_lower_bounds (const RealVector &adrl_bnds) |
sets all discrete lower bounds using a single array | |
void | all_discrete_real_lower_bound (Real adrl_bnd, size_t i) |
set a lower bound within the all discrete lower bounds array | |
const RealVector & | all_discrete_real_upper_bounds () const |
returns a single array with all discrete upper bounds | |
void | all_discrete_real_upper_bounds (const RealVector &adru_bnds) |
sets all discrete upper bounds using a single array | |
void | all_discrete_real_upper_bound (Real adru_bnd, size_t i) |
set an upper bound within the all discrete upper bounds array | |
size_t | num_linear_ineq_constraints () const |
return the number of linear inequality constraints | |
size_t | num_linear_eq_constraints () const |
return the number of linear equality constraints | |
const RealMatrix & | linear_ineq_constraint_coeffs () const |
return the linear inequality constraint coefficients | |
void | linear_ineq_constraint_coeffs (const RealMatrix &lin_ineq_coeffs) |
set the linear inequality constraint coefficients | |
const RealVector & | linear_ineq_constraint_lower_bounds () const |
return the linear inequality constraint lower bounds | |
void | linear_ineq_constraint_lower_bounds (const RealVector &lin_ineq_l_bnds) |
set the linear inequality constraint lower bounds | |
const RealVector & | linear_ineq_constraint_upper_bounds () const |
return the linear inequality constraint upper bounds | |
void | linear_ineq_constraint_upper_bounds (const RealVector &lin_ineq_u_bnds) |
set the linear inequality constraint upper bounds | |
const RealMatrix & | linear_eq_constraint_coeffs () const |
return the linear equality constraint coefficients | |
void | linear_eq_constraint_coeffs (const RealMatrix &lin_eq_coeffs) |
set the linear equality constraint coefficients | |
const RealVector & | linear_eq_constraint_targets () const |
return the linear equality constraint targets | |
void | linear_eq_constraint_targets (const RealVector &lin_eq_targets) |
set the linear equality constraint targets | |
size_t | num_nonlinear_ineq_constraints () const |
return the number of nonlinear inequality constraints | |
size_t | num_nonlinear_eq_constraints () const |
return the number of nonlinear equality constraints | |
const RealVector & | nonlinear_ineq_constraint_lower_bounds () const |
return the nonlinear inequality constraint lower bounds | |
void | nonlinear_ineq_constraint_lower_bounds (const RealVector &nln_ineq_l_bnds) |
set the nonlinear inequality constraint lower bounds | |
const RealVector & | nonlinear_ineq_constraint_upper_bounds () const |
return the nonlinear inequality constraint upper bounds | |
void | nonlinear_ineq_constraint_upper_bounds (const RealVector &nln_ineq_u_bnds) |
set the nonlinear inequality constraint upper bounds | |
const RealVector & | nonlinear_eq_constraint_targets () const |
return the nonlinear equality constraint targets | |
void | nonlinear_eq_constraint_targets (const RealVector &nln_eq_targets) |
set the nonlinear equality constraint targets | |
Constraints | copy () const |
for use when a deep copy is needed (the representation is not shared) More... | |
void | update_nonlinear_constraints (const Constraints &cons) |
copy nonlinear constraint data between existing Constraints objects | |
void | update_linear_constraints (const Constraints &cons) |
copy linear constraint data between existing Constraints objects | |
void | update_variable_bounds (const Constraints &cons) |
copy variable lower/upper bound data between existing Constraints objects | |
void | update (const Constraints &cons) |
copy bounds and linear/nonlinear constraint data between existing Constraints objects More... | |
void | shape_bounds () |
shape the lower/upper bound arrays based on sharedVarsData More... | |
void | reshape (size_t num_nln_ineq_cons, size_t num_nln_eq_cons, const SharedVariablesData &svd) |
reshape the linear/nonlinear/bound constraint arrays arrays and the lower/upper bound arrays | |
void | reshape_bounds () |
reshape the lower/upper bound arrays based on sharedVarsData | |
void | reshape_nonlinear (size_t num_nln_ineq_cons, size_t num_nln_eq_cons) |
reshape the nonlinear constraint array sizes More... | |
void | reshape_linear (size_t num_lin_ineq_cons, size_t num_lin_eq_cons) |
reshape the linear constraint array sizes More... | |
void | reshape_update_linear (const SharedVariablesData &prev_svd, const SharedVariablesData &curr_svd) |
reshape and repopulate the linear constraint arrays More... | |
void | active_view (short view2) |
sets the active view based on higher level context | |
void | inactive_view (short view2) |
sets the inactive view based on higher level context | |
const SharedVariablesData & | shared_data () const |
return sharedVarsData | |
SharedVariablesData & | shared_data () |
return sharedVarsData | |
bool | is_null () const |
function to check constraintsRep (does this envelope contain a letter) | |
Protected Member Functions | |
Constraints (BaseConstructor, const ProblemDescDB &problem_db, 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) More... | |
Constraints (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) More... | |
void | build_views () |
construct active/inactive views of all variables arrays | |
void | build_active_views () |
construct active views of all variables bounds arrays | |
void | build_inactive_views () |
construct inactive views of all variables bounds arrays | |
void | manage_linear_constraints (const ProblemDescDB &problem_db) |
perform checks on user input, convert linear constraint coefficient input to matrices, and assign defaults More... | |
Protected Attributes | |
SharedVariablesData | sharedVarsData |
configuration data shared from a Variables instance | |
RealVector | allContinuousLowerBnds |
a continuous lower bounds array combining continuous design, uncertain, and continuous state variable types (all view). | |
RealVector | allContinuousUpperBnds |
a continuous upper bounds array combining continuous design, uncertain, and continuous state variable types (all view). | |
IntVector | allDiscreteIntLowerBnds |
a discrete lower bounds array combining discrete design and discrete state variable types (all view). | |
IntVector | allDiscreteIntUpperBnds |
a discrete upper bounds array combining discrete design and discrete state variable types (all view). | |
RealVector | allDiscreteRealLowerBnds |
a discrete lower bounds array combining discrete design and discrete state variable types (all view). | |
RealVector | allDiscreteRealUpperBnds |
a discrete upper bounds array combining discrete design and discrete state variable types (all view). | |
size_t | numNonlinearIneqCons |
number of nonlinear inequality constraints | |
size_t | numNonlinearEqCons |
number of nonlinear equality constraints | |
RealVector | nonlinearIneqConLowerBnds |
nonlinear inequality constraint lower bounds | |
RealVector | nonlinearIneqConUpperBnds |
nonlinear inequality constraint upper bounds | |
RealVector | nonlinearEqConTargets |
nonlinear equality constraint targets | |
size_t | numLinearIneqCons |
number of linear inequality constraints | |
size_t | numLinearEqCons |
number of linear equality constraints | |
RealMatrix | linearIneqConCoeffs |
linear inequality constraint coefficients | |
RealMatrix | linearEqConCoeffs |
linear equality constraint coefficients | |
RealVector | linearIneqConLowerBnds |
linear inequality constraint lower bounds | |
RealVector | linearIneqConUpperBnds |
linear inequality constraint upper bounds | |
RealVector | linearEqConTargets |
linear equality constraint targets | |
RealVector | continuousLowerBnds |
the active continuous lower bounds array view | |
RealVector | continuousUpperBnds |
the active continuous upper bounds array view | |
IntVector | discreteIntLowerBnds |
the active discrete lower bounds array view | |
IntVector | discreteIntUpperBnds |
the active discrete upper bounds array view | |
RealVector | discreteRealLowerBnds |
the active discrete lower bounds array view | |
RealVector | discreteRealUpperBnds |
the active discrete upper bounds array view | |
RealVector | inactiveContinuousLowerBnds |
the inactive continuous lower bounds array view | |
RealVector | inactiveContinuousUpperBnds |
the inactive continuous upper bounds array view | |
IntVector | inactiveDiscreteIntLowerBnds |
the inactive discrete lower bounds array view | |
IntVector | inactiveDiscreteIntUpperBnds |
the inactive discrete upper bounds array view | |
RealVector | inactiveDiscreteRealLowerBnds |
the inactive discrete lower bounds array view | |
RealVector | inactiveDiscreteRealUpperBnds |
the inactive discrete upper bounds array view | |
Private Member Functions | |
void | check_zeros (const Real *ptr, int ptr_len) const |
ensure zeros in removed columns when contracting linear constraints coeffs | |
std::shared_ptr< Constraints > | get_constraints (const ProblemDescDB &problem_db, const SharedVariablesData &svd) |
Used only by the constructor to initialize constraintsRep to the appropriate derived type. More... | |
std::shared_ptr< Constraints > | get_constraints (const SharedVariablesData &svd) const |
Used by copy() to initialize constraintsRep to the appropriate derived type. More... | |
Private Attributes | |
std::shared_ptr< Constraints > | constraintsRep |
pointer to the letter (initialized only for the envelope) | |
Base class for the variable constraints class hierarchy.
The Constraints class is the base class for the class hierarchy managing bound, linear, and nonlinear constraints. Using the variable lower and upper bounds arrays from the input specification, different derived classes define different views of this data. The linear and nonlinear constraint data is consistent in all views and is managed at the base class level. For memory efficiency and enhanced polymorphism, the variable constraints hierarchy employs the "letter/envelope idiom" (see Coplien "Advanced C++", p. 133), for which the base class (Constraints) serves as the envelope and one of the derived classes (selected in Constraints::get_constraints()) serves as the letter.
Constraints | ( | ) |
default constructor
The default constructor: constraintsRep is NULL in this case (a populated problem_db is needed to build a meaningful Constraints object).
Constraints | ( | const ProblemDescDB & | problem_db, |
const SharedVariablesData & | svd | ||
) |
standard constructor
The envelope constructor only needs to extract enough data to properly execute get_constraints, since the constructor overloaded with BaseConstructor builds the actual base class data inherited by the derived classes.
References Dakota::abort_handler(), and Constraints::constraintsRep.
Constraints | ( | const SharedVariablesData & | svd | ) |
alternate constructor for instantiations on the fly
Envelope constructor for instantiations on the fly. This constructor executes get_constraints(view), which invokes the default derived/base constructors, followed by a reshape() based on vars_comps.
References Dakota::abort_handler(), and Constraints::constraintsRep.
Constraints | ( | const Constraints & | con | ) |
copy constructor
Copy constructor manages sharing of constraintsRep
References Constraints::constraintsRep.
|
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_constraints() instantiates a derived class letter and the derived constructor selects this base class constructor in its initialization list (to avoid recursion in the base class constructor calling get_constraints() again). Since the letter IS the representation, its rep pointer is set to NULL.
References Constraints::build_views(), Constraints::manage_linear_constraints(), and Constraints::shape_bounds().
|
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_constraints() instantiates a derived class letter and the derived constructor selects this base class constructor in its initialization list (to avoid recursion in the base class constructor calling get_constraints() again). Since the letter IS the representation, its rep pointer is set to NULL.
References Constraints::build_views(), and Constraints::shape_bounds().
Constraints operator= | ( | const Constraints & | con | ) |
assignment operator
Assignment operator shares the constraintsRep with this envelope.
References Constraints::constraintsRep.
Constraints copy | ( | ) | const |
for use when a deep copy is needed (the representation is not shared)
Deep copies are used for history mechanisms that catalogue permanent copies (should not change as the representation within userDefinedConstraints changes).
References Constraints::constraintsRep, Constraints::get_constraints(), and Constraints::update().
void update | ( | const Constraints & | cons | ) |
copy bounds and linear/nonlinear constraint data between existing Constraints objects
Deep copies are used for history mechanisms that catalogue permanent copies (should not change as the representation within userDefinedConstraints changes).
References Constraints::constraintsRep, Constraints::update_linear_constraints(), Constraints::update_nonlinear_constraints(), and Constraints::update_variable_bounds().
Referenced by AdapterModel::AdapterModel(), and Constraints::copy().
void shape_bounds | ( | ) |
shape the lower/upper bound arrays based on sharedVarsData
Resizes the derived bounds arrays.
References SharedVariablesData::all_counts(), Constraints::allContinuousLowerBnds, Constraints::allContinuousUpperBnds, Constraints::allDiscreteIntLowerBnds, Constraints::allDiscreteIntUpperBnds, Constraints::allDiscreteRealLowerBnds, Constraints::allDiscreteRealUpperBnds, Constraints::constraintsRep, and Constraints::sharedVarsData.
Referenced by Constraints::Constraints().
void reshape_nonlinear | ( | size_t | num_nln_ineq_cons, |
size_t | num_nln_eq_cons | ||
) |
reshape the nonlinear constraint array sizes
Resizes the linear and nonlinear constraint arrays at the base class. Does NOT currently resize the derived bounds arrays.
References Constraints::constraintsRep, Constraints::nonlinearEqConTargets, Constraints::nonlinearIneqConLowerBnds, Constraints::nonlinearIneqConUpperBnds, Constraints::numNonlinearEqCons, and Constraints::numNonlinearIneqCons.
Referenced by EffGlobalMinimizer::build_gp(), RecastModel::init_constraints(), and Constraints::reshape().
void reshape_linear | ( | size_t | num_lin_ineq_cons, |
size_t | num_lin_eq_cons | ||
) |
reshape the linear constraint array sizes
Resizes the linear and nonlinear constraint arrays at the base class. Does NOT currently resize the derived bounds arrays.
References Constraints::constraintsRep, Constraints::continuousLowerBnds, Constraints::discreteIntLowerBnds, Constraints::discreteRealLowerBnds, Constraints::linearEqConCoeffs, Constraints::linearEqConTargets, Constraints::linearIneqConCoeffs, Constraints::linearIneqConLowerBnds, Constraints::linearIneqConUpperBnds, Constraints::numLinearEqCons, and Constraints::numLinearIneqCons.
void reshape_update_linear | ( | const SharedVariablesData & | prev_svd, |
const SharedVariablesData & | curr_svd | ||
) |
reshape and repopulate the linear constraint arrays
Resizes the linear coefficient arrays based on change in active variables view.
References Dakota::abort_handler(), Constraints::active_view(), Constraints::check_zeros(), Constraints::constraintsRep, Dakota::copy_data(), SharedVariablesData::cv(), SharedVariablesData::cv_start(), SharedVariablesData::div(), SharedVariablesData::div_start(), SharedVariablesData::drv(), SharedVariablesData::drv_start(), Constraints::linearEqConCoeffs, Constraints::linearIneqConCoeffs, Constraints::numLinearEqCons, Constraints::numLinearIneqCons, and SharedVariablesData::view().
Referenced by RecastModel::init_constraints(), and Constraints::reshape().
|
protected |
perform checks on user input, convert linear constraint coefficient input to matrices, and assign defaults
Convenience function called from derived class constructors. The number of variables active for applying linear constraints is currently defined to be the number of active continuous variables plus the number of active discrete {int,real} variables (most general case), even though very few optimizers can currently support mixed variable linear constraints.
References Dakota::abort_handler(), Dakota::copy_data(), SharedVariablesData::cv(), SharedVariablesData::div(), SharedVariablesData::drv(), ProblemDescDB::get_rv(), Constraints::linearEqConCoeffs, Constraints::linearEqConTargets, Constraints::linearIneqConCoeffs, Constraints::linearIneqConLowerBnds, Constraints::linearIneqConUpperBnds, Constraints::numLinearEqCons, Constraints::numLinearIneqCons, and Constraints::sharedVarsData.
Referenced by Constraints::Constraints().
|
private |
Used only by the constructor to initialize constraintsRep to the appropriate derived type.
Initializes constraintsRep to the appropriate derived type, as given by the variables view.
References Constraints::active_view(), and SharedVariablesData::view().
Referenced by Constraints::copy().
|
private |
Used by copy() to initialize constraintsRep to the appropriate derived type.
Initializes constraintsRep to the appropriate derived type, as given by the variables view. The default derived class constructors are invoked.
References Constraints::active_view(), and SharedVariablesData::view().