Base class for the variable constraints class hierarchy. More...
Public Member Functions | |
Constraints () | |
default constructor | |
Constraints (const ProblemDescDB &prob_db, const SharedVariablesData &svd) | |
standard constructor | |
Constraints (const SharedVariablesData &svd) | |
alternate constructor for instantiations on the fly | |
Constraints (const Constraints &con) | |
copy constructor | |
virtual | ~Constraints () |
destructor | |
Constraints | operator= (const Constraints &con) |
assignment operator | |
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 | |
virtual void | reshape (const SizetArray &vc_totals) |
reshape the lower/upper bound arrays within the Constraints hierarchy | |
const RealVector & | continuous_lower_bounds () const |
return the active continuous variable lower bounds | |
void | continuous_lower_bounds (const RealVector &cl_bnds) |
set the active continuous variable lower bounds | |
void | continuous_lower_bound (const Real &cl_bnd, const size_t &i) |
set an active continuous variable lower bound | |
const RealVector & | continuous_upper_bounds () const |
return the active continuous variable upper bounds | |
void | continuous_upper_bounds (const RealVector &cu_bnds) |
set the active continuous variable upper bounds | |
void | continuous_upper_bound (const Real &cu_bnd, const size_t &i) |
set an active continuous variable upper bound | |
const IntVector & | discrete_int_lower_bounds () const |
return the active discrete variable lower bounds | |
void | discrete_int_lower_bounds (const IntVector &dil_bnds) |
set the active discrete variable lower bounds | |
void | discrete_int_lower_bound (const int &dil_bnd, const size_t &i) |
set an active discrete variable lower bound | |
const IntVector & | discrete_int_upper_bounds () const |
return the active discrete variable upper bounds | |
void | discrete_int_upper_bounds (const IntVector &diu_bnds) |
set the active discrete variable upper bounds | |
void | discrete_int_upper_bound (const int &diu_bnd, const size_t &i) |
set an active discrete variable upper bound | |
const RealVector & | discrete_real_lower_bounds () const |
return the active discrete variable lower bounds | |
void | discrete_real_lower_bounds (const RealVector &drl_bnds) |
set the active discrete variable lower bounds | |
void | discrete_real_lower_bound (const Real &drl_bnd, const size_t &i) |
set an active discrete variable lower bound | |
const RealVector & | discrete_real_upper_bounds () const |
return the active discrete variable upper bounds | |
void | discrete_real_upper_bounds (const RealVector &dru_bnds) |
set the active discrete variable upper bounds | |
void | discrete_real_upper_bound (const Real &dru_bnd, const 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 (const Real &acl_bnd, const 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 (const Real &acu_bnd, const 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 (const int &adil_bnd, const 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 (const int &adiu_bnd, const 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 (const Real &adrl_bnd, const 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 (const Real &adru_bnd, const 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) | |
void | reshape (const size_t &num_nln_ineq_cons, const size_t &num_nln_eq_cons, const size_t &num_lin_ineq_cons, const size_t &num_lin_eq_cons, const SizetArray &vc_totals) |
reshape the linear/nonlinear/bound constraint arrays arrays within the Constraints hierarchy | |
void | reshape (const size_t &num_nln_ineq_cons, const size_t &num_nln_eq_cons, const size_t &num_lin_ineq_cons, const size_t &num_lin_eq_cons) |
reshape the linear/nonlinear constraint arrays within the Constraints hierarchy | |
void | inactive_view (short view2) |
sets the inactive view based on higher level (nested) context | |
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) | |
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) | |
virtual void | build_active_views () |
construct active views of all variables bounds arrays | |
virtual void | build_inactive_views () |
construct inactive views of all variables bounds arrays | |
void | build_views () |
construct active/inactive views of all variables arrays | |
void | manage_linear_constraints (const ProblemDescDB &problem_db) |
perform checks on user input, convert linear constraint coefficient input to matrices, and assign defaults | |
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 | |
Constraints * | get_constraints (const ProblemDescDB &problem_db, const SharedVariablesData &svd) |
Used only by the constructor to initialize constraintsRep to the appropriate derived type. | |
Constraints * | get_constraints (const SharedVariablesData &svd) const |
Used by copy() to initialize constraintsRep to the appropriate derived type. | |
Private Attributes | |
Constraints * | constraintsRep |
pointer to the letter (initialized only for the envelope) | |
int | referenceCount |
number of objects sharing constraintsRep |
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). This makes it necessary to check for NULL in the copy constructor, assignment operator, and destructor.
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(), Constraints::constraintsRep, and Constraints::get_constraints().
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(), Constraints::constraintsRep, and Constraints::get_constraints().
Constraints | ( | const Constraints & | con | ) |
copy constructor
Copy constructor manages sharing of constraintsRep and incrementing of referenceCount.
References Constraints::constraintsRep, and Constraints::referenceCount.
~Constraints | ( | ) | [virtual] |
destructor
Destructor decrements referenceCount and only deletes constraintsRep when referenceCount reaches zero.
References Constraints::constraintsRep, and Constraints::referenceCount.
Constraints | ( | BaseConstructor | , |
const ProblemDescDB & | problem_db, | ||
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_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 (an uninitialized pointer causes problems in ~Constraints).
Constraints | ( | 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_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 (an uninitialized pointer causes problems in ~Constraints).
Constraints operator= | ( | const Constraints & | con | ) |
assignment operator
Assignment operator decrements referenceCount for old constraintsRep, assigns new constraintsRep, and increments referenceCount for new constraintsRep.
References Constraints::constraintsRep, and Constraints::referenceCount.
void reshape | ( | const SizetArray & | vc_totals | ) | [virtual] |
reshape the lower/upper bound arrays within the Constraints hierarchy
Resizes the derived bounds arrays.
Reimplemented in MergedConstraints, and MixedConstraints.
References Constraints::constraintsRep, Constraints::continuousLowerBnds, Constraints::discreteIntLowerBnds, Constraints::discreteRealLowerBnds, Constraints::linearEqConCoeffs, Constraints::linearIneqConCoeffs, Constraints::numLinearEqCons, Constraints::numLinearIneqCons, and Constraints::reshape().
Referenced by DataFitSurrModel::DataFitSurrModel(), RecastModel::RecastModel(), and Constraints::reshape().
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::allContinuousLowerBnds, Constraints::allContinuousUpperBnds, Constraints::allDiscreteIntLowerBnds, Constraints::allDiscreteIntUpperBnds, Constraints::allDiscreteRealLowerBnds, Constraints::allDiscreteRealUpperBnds, Constraints::build_views(), Constraints::constraintsRep, Constraints::get_constraints(), Constraints::linearEqConCoeffs, Constraints::linearEqConTargets, Constraints::linearIneqConCoeffs, Constraints::linearIneqConLowerBnds, Constraints::linearIneqConUpperBnds, Constraints::nonlinearEqConTargets, Constraints::nonlinearIneqConLowerBnds, Constraints::nonlinearIneqConUpperBnds, Constraints::numLinearEqCons, Constraints::numLinearIneqCons, Constraints::numNonlinearEqCons, Constraints::numNonlinearIneqCons, and Constraints::sharedVarsData.
Referenced by SurrogateModel::force_rebuild(), and RecastModel::RecastModel().
void reshape | ( | const size_t & | num_nln_ineq_cons, |
const size_t & | num_nln_eq_cons, | ||
const size_t & | num_lin_ineq_cons, | ||
const size_t & | num_lin_eq_cons | ||
) |
reshape the linear/nonlinear constraint arrays within the Constraints hierarchy
Resizes the linear and nonlinear constraint arrays at the base class. Does NOT currently resize the derived bounds arrays.
References Constraints::constraintsRep, Constraints::linearEqConTargets, Constraints::linearIneqConLowerBnds, Constraints::linearIneqConUpperBnds, Constraints::nonlinearEqConTargets, Constraints::nonlinearIneqConLowerBnds, Constraints::nonlinearIneqConUpperBnds, Constraints::numLinearEqCons, Constraints::numLinearIneqCons, Constraints::numNonlinearEqCons, Constraints::numNonlinearIneqCons, and Constraints::reshape().
void build_views | ( | ) | [inline, protected] |
construct active/inactive views of all variables arrays
= EMPTY)
= EMPTY)
References Constraints::build_active_views(), Constraints::build_inactive_views(), Constraints::sharedVarsData, and SharedVariablesData::view().
Referenced by Constraints::copy(), MergedConstraints::MergedConstraints(), MixedConstraints::MixedConstraints(), MixedConstraints::reshape(), and MergedConstraints::reshape().
void manage_linear_constraints | ( | const ProblemDescDB & | problem_db | ) | [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 variables (the most general case), even though very few optimizers can currently support mixed variable linear constraints.
References Dakota::abort_handler(), Constraints::continuousLowerBnds, Dakota::copy_data(), Constraints::discreteIntLowerBnds, Constraints::discreteRealLowerBnds, ProblemDescDB::get_rdv(), Constraints::linearEqConCoeffs, Constraints::linearEqConTargets, Constraints::linearIneqConCoeffs, Constraints::linearIneqConLowerBnds, Constraints::linearIneqConUpperBnds, Constraints::numLinearEqCons, and Constraints::numLinearIneqCons.
Referenced by MergedConstraints::MergedConstraints(), and MixedConstraints::MixedConstraints().
Constraints * get_constraints | ( | const ProblemDescDB & | problem_db, |
const SharedVariablesData & | svd | ||
) | [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 SharedVariablesData::view().
Referenced by Constraints::Constraints(), and Constraints::copy().
Constraints * get_constraints | ( | const SharedVariablesData & | svd | ) | const [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 SharedVariablesData::view().