MOOCHO (Single Doxygen Collection)
Version of the Day
|
Simple example NLP subclass to illustrate how to implement the NLPObjGrad
interface for a specialized NLP
.
More...
#include <NLPInterfacePack_ExampleNLPObjGrad.hpp>
Public Member Functions | |
ExampleNLPObjGrad (const VectorSpace::space_ptr_t &vec_space, value_type xo, bool has_bounds, bool dep_bounded) | |
Constructor. More... | |
Public Member Functions inherited from NLPInterfacePack::NLPObjGrad | |
NLPObjGrad () | |
Initialize to no reference set to calculation quanities. More... | |
virtual bool | supports_Gf () const |
Determine if the objective gradient is supported or not. More... | |
virtual bool | supports_Gf_prod () const |
Determine if the objective gradient product is supported or not. More... | |
virtual void | set_Gf (VectorMutable *Gf) |
Set a pointer to a vector to be updated when this->calc_Gf() is called. More... | |
virtual VectorMutable * | get_Gf () |
Return pointer passed to this->set_Gf() . More... | |
virtual VectorMutable & | Gf () |
Returns non-const *this->get_Gf() . More... | |
virtual const Vector & | Gf () const |
Returns const *this->get_Gf() . More... | |
void | unset_quantities () |
Call to unset all storage quantities (both in this class and all subclasses). More... | |
virtual void | calc_Gf (const Vector &x, bool newx=true) const |
Update the vector for Gf at the point x and put it in the stored reference. More... | |
virtual value_type | calc_Gf_prod (const Vector &x, const Vector &d, bool newx=true) const |
Calculate the inner product Gf(x)'*d at the point x and put it in the stored reference. More... | |
virtual size_type | num_Gf_evals () const |
Objective gradient evaluations count. More... | |
Public Member Functions inherited from NLPInterfacePack::NLP | |
const ZeroOrderInfo | zero_order_info () const |
Return pointer to set quantities. More... | |
const ZeroOrderInfo | zero_order_info_breve () const |
Return pointer to set hat quantities. More... | |
NLP () | |
Initialize to no reference set to calculation quanities. More... | |
virtual | ~NLP () |
Destructor that cleans all the memory it owns. More... | |
virtual void | set_options (const options_ptr_t &options) |
Set the options that this NLP may be interested in. More... | |
virtual const options_ptr_t & | get_options () const |
Get the OptionsFromStream object being used to extract the options from. More... | |
virtual void | get_init_lagrange_mult (VectorMutable *lambda, VectorMutable *nu) const |
Get the initial value of the Lagrange multipliers lambda. More... | |
virtual void | set_f (value_type *f) |
Set a pointer to an value to be updated when this->calc_f() is called. More... | |
virtual value_type * | get_f () |
Return pointer passed to this->set_f() . More... | |
virtual value_type & | f () |
Returns non-const *this->get_f() . More... | |
virtual const value_type & | f () const |
Returns const *this->get_f() . More... | |
virtual void | set_c (VectorMutable *c) |
Set a pointer to a vector to be updated when this->calc_c() is called. More... | |
virtual VectorMutable * | get_c () |
Return pointer passed to this->set_c() . More... | |
virtual VectorMutable & | c () |
Returns non-const *this->get_c() . More... | |
virtual const Vector & | c () const |
Returns const *this->get_c() . More... | |
virtual void | calc_f (const Vector &x, bool newx=true) const |
Update the value for the objective f at the point x and put it in the stored reference. More... | |
virtual void | calc_c (const Vector &x, bool newx=true) const |
Update the constraint residual vector for c at the point x and put it in the stored reference. More... | |
virtual size_type | num_f_evals () const |
Gives the number of object function f(x) evaluations called by the solver since initialize() was called. More... | |
virtual size_type | num_c_evals () const |
Gives the number of constraint function c(x) evaluations called by the solver since initialize() was called. Throws exception if this->m() == 0 . More... | |
virtual size_type | ns () const |
Return the number of slack variables (i.e. number of general inequalities). More... | |
virtual vec_space_ptr_t | space_c_breve () const |
Vector space object for the original equalities c_breve(x_breve) More... | |
virtual vec_space_ptr_t | space_h_breve () const |
Vector space object for the original inequalities h_breve(x_breve) More... | |
virtual const Vector & | hl_breve () const |
Returns a reference to the vector of lower bounds on the general inequality constraints h_breve(x_breve) . More... | |
virtual const Vector & | hu_breve () const |
Returns a reference to the vector of upper bounds on the general inequality constraints h_breve(x_breve) . More... | |
virtual void | set_c_breve (VectorMutable *c_breve) |
Set a pointer to a vector to be updated when this->calc_c_breve() is called. More... | |
virtual VectorMutable * | get_c_breve () |
Return pointer passed to this->set_c_breve() . More... | |
virtual VectorMutable & | c_breve () |
Returns non-const *this->get_c_breve() . More... | |
virtual const Vector & | c_breve () const |
Returns const *this->get_c_breve() . More... | |
virtual void | set_h_breve (VectorMutable *h_breve) |
Set a pointer to a vector to be updated when this->calc_h_breve() is called. More... | |
virtual VectorMutable * | get_h_breve () |
Return pointer passed to this->set_h_breve() . More... | |
virtual VectorMutable & | h_breve () |
Returns non-const *this->get_h_breve() . More... | |
virtual const Vector & | h_breve () const |
Returns const *this->get_h_breve() . More... | |
virtual const Permutation & | P_var () const |
Return the permutation object for the variables. More... | |
virtual const Permutation & | P_equ () const |
Return the permutation object for the constraints. More... | |
virtual void | calc_c_breve (const Vector &x, bool newx=true) const |
Update the constraint residual vector for c_breve at the point x and put it in the stored reference. More... | |
virtual void | calc_h_breve (const Vector &x, bool newx=true) const |
Update the constraint residual vector for h_breve at the point x and put it in the stored reference. More... | |
Public Member Functions inherited from Teuchos::VerboseObject< NLP > | |
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT RCP< const ParameterList > | getValidVerboseObjectSublist () |
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void | setupVerboseObjectSublist (ParameterList *paramList) |
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void | readVerboseObjectSublist (ParameterList *paramList, RCP< FancyOStream > *oStream, EVerbosityLevel *verbLevel) |
void | readVerboseObjectSublist (ParameterList *paramList, VerboseObject< NLP > *verboseObject) |
VerboseObject (const EVerbosityLevel verbLevel=VERB_DEFAULT, const RCP< FancyOStream > &oStream=Teuchos::null) | |
virtual void | initializeVerboseObject (const EVerbosityLevel verbLevel=VERB_DEFAULT, const RCP< FancyOStream > &oStream=Teuchos::null) |
virtual const VerboseObject & | setVerbLevel (const EVerbosityLevel verbLevel) const |
virtual const VerboseObject & | setOverridingVerbLevel (const EVerbosityLevel verbLevel) const |
virtual EVerbosityLevel | getVerbLevel () const |
Private Member Functions | |
void | assert_is_initialized () const |
Private Attributes | |
VectorSpace::space_ptr_t | vec_space_ |
VectorSpace::space_ptr_t | vec_space_comp_ |
Range1D | var_dep_ |
Range1D | var_indep_ |
bool | initialized_ |
value_type | obj_scale_ |
bool | has_bounds_ |
bool | force_xinit_in_bounds_ |
size_type | n_ |
VectorSpace::vec_mut_ptr_t | xinit_ |
VectorSpace::vec_mut_ptr_t | xl_ |
VectorSpace::vec_mut_ptr_t | xu_ |
Helper methods to be used by subclasses. | |
virtual Range1D | var_dep () const |
virtual Range1D | var_indep () const |
Overridden public members from NLP | |
void | initialize (bool test_setup) |
bool | is_initialized () const |
size_type | n () const |
size_type | m () const |
vec_space_ptr_t | space_x () const |
vec_space_ptr_t | space_c () const |
size_type | num_bounded_x () const |
void | force_xinit_in_bounds (bool force_xinit_in_bounds) |
bool | force_xinit_in_bounds () const |
const Vector & | xinit () const |
const Vector & | xl () const |
const Vector & | xu () const |
value_type | max_var_bounds_viol () const |
void | scale_f (value_type scale_f) |
value_type | scale_f () const |
void | report_final_solution (const Vector &x, const Vector *lambda, const Vector *nu, bool optimal) |
Overridden protected members from NLP | |
void | imp_calc_f (const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const |
void | imp_calc_c (const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const |
void | imp_calc_h (const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const |
This implementation does nothing (should never be called though). More... | |
Overridden protected members from NLPObjGrad | |
void | imp_calc_Gf (const Vector &x, bool newx, const ObjGradInfo &obj_grad_info) const |
Additional Inherited Members | |
Public Types inherited from NLPInterfacePack::NLP | |
typedef AbstractLinAlgPack::Vector | Vector |
typedef AbstractLinAlgPack::VectorMutable | VectorMutable |
typedef Teuchos::RCP< const VectorSpace > | vec_space_ptr_t |
typedef Teuchos::RCP< const OptionsFromStreamPack::OptionsFromStream > | options_ptr_t |
Static Public Member Functions inherited from NLPInterfacePack::NLP | |
static value_type | infinite_bound () |
Value for an infinite bound. More... | |
Static Public Member Functions inherited from Teuchos::VerboseObject< NLP > | |
static void | setDefaultVerbLevel (const EVerbosityLevel defaultVerbLevel) |
static EVerbosityLevel | getDefaultVerbLevel () |
Protected Member Functions inherited from NLPInterfacePack::NLPObjGrad | |
const ObjGradInfo | obj_grad_info () const |
Return objective gradient and zero order information. More... | |
Protected Member Functions inherited from NLPInterfacePack::NLP | |
template<class T > | |
void | assert_ref_set (T *p, std::string info) const |
Assert referece has been set for a quanity. More... | |
virtual void | imp_calc_c_breve (const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info_breve) const |
Overridden to compute c_breve(x_breve) and perhaps f(x) and/or h_breve(x_breve) More... | |
virtual void | imp_calc_h_breve (const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info_breve) const |
Overridden to compute h_breve(x_breve) and perhaps f(x) and/or c_breve(x_breve). More... | |
Simple example NLP subclass to illustrate how to implement the NLPObjGrad
interface for a specialized NLP
.
The example NLP we will use is a scalable problem where the basis of the jacobian of the constraints is a diagonal matrix (however it is not computed here).
min f(x) = (1/2) * sum( x(i)^2, for i = 1..n ) s.t. c(x)(j) = x(j) * (x(m+j) -1) - 10 * x(m+j) = 0, for j = 1..m 0.01 < x(i) < 20, for i = p...p+m where: m = n/2 p = 1 if dep_bounded == true or m+1 if dep_bounded = false
This is not really a fully functional NLP in the sense that there is no derivative information for the constraints.
Definition at line 72 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
NLPInterfacePack::ExampleNLPObjGrad::ExampleNLPObjGrad | ( | const VectorSpace::space_ptr_t & | vec_space, |
value_type | xo, | ||
bool | has_bounds, | ||
bool | dep_bounded | ||
) |
Constructor.
vec_space | [in] Smart pointer to a vector space object that will be used to define the spaces of dependent and independent variables. |
xo | [in] The initial starting guess for x. |
has_bounds | [in] If true , then the NLP will have bounds. If false then it will not have bounds. |
dep_bouned | [in] If true , then the bounds will be on the dependent variables. If false , then the bounds will be on the independent variable. This argument is ignored if has_bounds == false . |
Definition at line 75 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Reimplemented in NLPInterfacePack::ExampleNLPDirect.
Definition at line 231 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Reimplemented in NLPInterfacePack::ExampleNLPDirect.
Definition at line 236 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Reimplemented from NLPInterfacePack::NLPObjGrad.
Reimplemented in NLPInterfacePack::ExampleNLPFirstOrder.
Definition at line 128 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Implements NLPInterfacePack::NLP.
Reimplemented in NLPInterfacePack::ExampleNLPFirstOrder.
Definition at line 142 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Reimplemented from NLPInterfacePack::NLP.
Definition at line 147 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Reimplemented from NLPInterfacePack::NLP.
Definition at line 153 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Implements NLPInterfacePack::NLP.
Definition at line 159 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Implements NLPInterfacePack::NLP.
Definition at line 164 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Implements NLPInterfacePack::NLP.
Definition at line 169 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Implements NLPInterfacePack::NLP.
Definition at line 174 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Implements NLPInterfacePack::NLP.
Definition at line 179 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Implements NLPInterfacePack::NLP.
Definition at line 184 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Implements NLPInterfacePack::NLP.
Definition at line 190 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Implements NLPInterfacePack::NLP.
Definition at line 196 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Implements NLPInterfacePack::NLP.
Definition at line 202 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Implements NLPInterfacePack::NLP.
Definition at line 207 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Implements NLPInterfacePack::NLP.
Definition at line 213 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
virtual |
Reimplemented from NLPInterfacePack::NLP.
Definition at line 219 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
protectedvirtual |
Implements NLPInterfacePack::NLP.
Definition at line 243 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
protectedvirtual |
Implements NLPInterfacePack::NLP.
Definition at line 254 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
protected |
This implementation does nothing (should never be called though).
Definition at line 273 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
protectedvirtual |
Implements NLPInterfacePack::NLPObjGrad.
Definition at line 281 of file NLPInterfacePack_ExampleNLPObjGrad.cpp.
|
inlineprivate |
Definition at line 208 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
|
private |
Definition at line 181 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
|
private |
Definition at line 182 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
|
private |
Definition at line 183 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
|
private |
Definition at line 184 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
|
private |
Definition at line 186 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
|
private |
Definition at line 187 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
|
private |
Definition at line 188 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
|
private |
Definition at line 189 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
|
private |
Definition at line 191 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
|
private |
Definition at line 192 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
|
private |
Definition at line 193 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.
|
private |
Definition at line 194 of file NLPInterfacePack_ExampleNLPObjGrad.hpp.