Constraints Class Reference

Base class for the variable constraints class hierarchy. More...

Inheritance diagram for Constraints:

AllConstraints DistinctConstraints MergedConstraints List of all members.

Public Member Functions

 Constraints ()
 default constructor
 Constraints (const ProblemDescDB &problem_db, const pair< short, short > &view)
 standard constructor
 Constraints (const pair< short, short > &view)
 alternate constructor for instantiations on the fly
 Constraints (const Constraints &con)
 copy constructor
virtual ~Constraints ()
 destructor
Constraints operator= (const Constraints &con)
 assignment operator
virtual const RealVectorcontinuous_lower_bounds () const
 return the active continuous variable lower bounds
virtual void continuous_lower_bounds (const RealVector &c_l_bnds)
 set the active continuous variable lower bounds
virtual const RealVectorcontinuous_upper_bounds () const
 return the active continuous variable upper bounds
virtual void continuous_upper_bounds (const RealVector &c_u_bnds)
 set the active continuous variable upper bounds
virtual const IntVectordiscrete_lower_bounds () const
 return the active discrete variable lower bounds
virtual void discrete_lower_bounds (const IntVector &d_l_bnds)
 set the active discrete variable lower bounds
virtual const IntVectordiscrete_upper_bounds () const
 return the active discrete variable upper bounds
virtual void discrete_upper_bounds (const IntVector &d_u_bnds)
 set the active discrete variable upper bounds
virtual const RealVectorinactive_continuous_lower_bounds () const
 return the inactive continuous lower bounds
virtual void inactive_continuous_lower_bounds (const RealVector &i_c_l_bnds)
 set the inactive continuous lower bounds
virtual const RealVectorinactive_continuous_upper_bounds () const
 return the inactive continuous upper bounds
virtual void inactive_continuous_upper_bounds (const RealVector &i_c_u_bnds)
 set the inactive continuous upper bounds
virtual const IntVectorinactive_discrete_lower_bounds () const
 return the inactive discrete lower bounds
virtual void inactive_discrete_lower_bounds (const IntVector &i_d_l_bnds)
 set the inactive discrete lower bounds
virtual const IntVectorinactive_discrete_upper_bounds () const
 return the inactive discrete upper bounds
virtual void inactive_discrete_upper_bounds (const IntVector &i_d_u_bnds)
 set the inactive discrete upper bounds
virtual RealVector all_continuous_lower_bounds () const
 returns a single array with all continuous lower bounds
virtual void all_continuous_lower_bounds (const RealVector &a_c_l_bnds)
 sets all continuous lower bounds using a single array
virtual RealVector all_continuous_upper_bounds () const
 returns a single array with all continuous upper bounds
virtual void all_continuous_upper_bounds (const RealVector &a_c_u_bnds)
 sets all continuous upper bounds using a single array
virtual IntVector all_discrete_lower_bounds () const
 returns a single array with all discrete lower bounds
virtual void all_discrete_lower_bounds (const IntVector &a_d_l_bnds)
 sets all discrete lower bounds using a single array
virtual IntVector all_discrete_upper_bounds () const
 returns a single array with all discrete upper bounds
virtual void all_discrete_upper_bounds (const IntVector &a_d_u_bnds)
 sets all discrete upper bounds using a single array
virtual void write (ostream &s) const
 write a variable constraints object to an ostream
virtual void read (istream &s)
 read a variable constraints object from an istream
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 RealMatrixlinear_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 RealVectorlinear_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 RealVectorlinear_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 RealMatrixlinear_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 RealVectorlinear_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 RealVectornonlinear_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 RealVectornonlinear_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 RealVectornonlinear_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)
 Constraints hierarchy.
void reshape (const Sizet2DArray &vars_comps)
 reshape the bounds arrays within the Constraints hierarchy
bool is_null () const
 function to check constraintsRep (does this envelope contain a letter)

Protected Member Functions

 Constraints (BaseConstructor, const ProblemDescDB &problem_db, const pair< short, short > &view)
 derived class constructors - Coplien, p. 139)
virtual void copy_rep (const Constraints *con_rep)
 Used by copy() to copy the contents of a letter class.
virtual void reshape_rep (const Sizet2DArray &vars_comps)
 Used by reshape(Sizet2DArray&) to rehape the contents of a letter class.
void manage_linear_constraints (const ProblemDescDB &problem_db)
 coefficient input to matrices, and assign defaults

Protected Attributes

pair< short, short > variablesView
 view enumerations
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 emptyRealVector
 no variable constraints corresponding to the request
IntVector emptyIntVector
 no variable constraints corresponding to the request

Private Member Functions

Constraintsget_constraints (const ProblemDescDB &problem_db, const pair< short, short > &view)
 appropriate derived type.
Constraintsget_constraints (const pair< short, short > &view) const
 derived type.

Private Attributes

ConstraintsconstraintsRep
 pointer to the letter (initialized only for the envelope)
int referenceCount
 number of objects sharing constraintsRep

Detailed Description

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.


Constructor & Destructor Documentation

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 pair< short, short > &  view 
)

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.

Constraints ( const pair< short, short > &  view  ) 

alternate constructor for instantiations on the fly

Envelope constructor for instantiations on the fly.

Constraints ( const Constraints con  ) 

copy constructor

Copy constructor manages sharing of constraintsRep and incrementing of referenceCount.

~Constraints (  )  [virtual]

destructor

Destructor decrements referenceCount and only deletes constraintsRep when referenceCount reaches zero.

Constraints ( BaseConstructor  ,
const ProblemDescDB problem_db,
const pair< short, short > &  view 
) [protected]

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).


Member Function Documentation

Constraints operator= ( const Constraints con  ) 

assignment operator

Assignment operator decrements referenceCount for old constraintsRep, assigns new constraintsRep, and increments referenceCount for new constraintsRep.

Constraints copy (  )  const

for use when a deep copy is needed (the representation is _not_ shared)

Deep copies are used for history mechanisms such as bestVariables and data_pairs since these must catalogue copies (and should not change as the representation within currentVariables changes).

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 
)

Constraints hierarchy.

Resizes the linear and nonlinear constraint arrays at the base class. Does NOT currently resize the derived bounds arrays.

void reshape ( const Sizet2DArray vars_comps  ) 

reshape the bounds arrays within the Constraints hierarchy

Resizes the derived bounds arrays.

void manage_linear_constraints ( const ProblemDescDB problem_db  )  [protected]

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.

Constraints * get_constraints ( const ProblemDescDB problem_db,
const pair< short, short > &  view 
) [private]

appropriate derived type.

Initializes constraintsRep to the appropriate derived type, as given by the variables view.

Constraints * get_constraints ( const pair< short, short > &  view  )  const [private]

derived type.

Initializes constraintsRep to the appropriate derived type, as given by the variables view. The default derived class constructors are invoked.


The documentation for this class was generated from the following files:
Generated on Wed Nov 5 19:54:06 2008 for DAKOTA by  doxygen 1.5.1