44 #include "NLPInterfacePack_NLP.hpp" 45 #include "AbstractLinAlgPack_VectorMutable.hpp" 46 #include "AbstractLinAlgPack_VectorSpace.hpp" 47 #include "Teuchos_Assert.hpp" 50 const char name_f[] =
"f";
51 const char name_c[] =
"c";
52 const char name_c_breve[] =
"c_breve";
53 const char name_h_breve[] =
"h_breve";
88 num_f_evals_ = num_c_evals_ = 0;
102 VectorSpace::space_ptr_t spc = this->
space_c();
103 return spc.get() ? spc->dim() : 0;
114 TEUCHOS_TEST_FOR_EXCEPTION( lambda && this->
m() == 0, std::logic_error,
"" );
115 TEUCHOS_TEST_FOR_EXCEPTION( nu && this->
num_bounded_x() == 0, std::logic_error,
"" );
119 TEUCHOS_TEST_FOR_EXCEPTION( !this->
space_c()->is_compatible(lambda->
space()), VectorSpace::IncompatibleVectorSpaces,
"" );
125 TEUCHOS_TEST_FOR_EXCEPTION( !this->
space_x()->is_compatible(nu->
space()), VectorSpace::IncompatibleVectorSpaces,
"" );
135 first_order_info_.
f =
f;
140 return StandardCompositionRelationshipsPack::get_role_name(first_order_info_.
f,
false, name_f);
145 return StandardCompositionRelationshipsPack::role_name(first_order_info_.
f,
false, name_f);
150 return StandardCompositionRelationshipsPack::role_name(first_order_info_.
f,
false, name_f);
158 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() == 0, std::logic_error,
"" );
159 TEUCHOS_TEST_FOR_EXCEPTION( c && !this->
space_c()->is_compatible(c->
space()), VectorSpace::IncompatibleVectorSpaces,
"" );
161 first_order_info_.
c =
c;
167 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() == 0, std::logic_error,
"" );
169 return StandardCompositionRelationshipsPack::get_role_name(first_order_info_.
c,
false, name_c);
175 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() == 0, std::logic_error,
"" );
177 return StandardCompositionRelationshipsPack::role_name(first_order_info_.
c,
false, name_c);
183 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() == 0, std::logic_error,
"" );
185 return StandardCompositionRelationshipsPack::role_name(first_order_info_.
c,
false, name_c);
200 StandardCompositionRelationshipsPack::assert_role_name_set(first_order_info_.
f,
"NLP::calc_f()", name_f);
208 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() == 0, std::logic_error,
"" );
210 StandardCompositionRelationshipsPack::assert_role_name_set(first_order_info_.
c,
"NLP::calc_c()", name_c);
233 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() == 0, std::logic_error,
"" );
243 return space_h_breve.get() ? space_h_breve->dim() : 0;
253 return Teuchos::null;
258 TEUCHOS_TEST_FOR_EXCEPTION(
259 true, std::logic_error
260 ,
"NLP::hl_breve(): Error, this method must be overridden if space_h_breve is defined" );
273 TEUCHOS_TEST_FOR_EXCEPTION(
274 true, std::logic_error
275 ,
"NLP::hl_breve(): Error, this method must be overridden if space_h_breve is defined" );
289 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() - this->
ns() == 0, std::logic_error,
"" );
290 TEUCHOS_TEST_FOR_EXCEPTION( c_breve && !this->
space_c_breve()->is_compatible(c_breve->
space()), VectorSpace::IncompatibleVectorSpaces,
"" );
292 first_order_info_breve_.
c =
c_breve;
298 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() - this->
ns() == 0, std::logic_error,
"" );
300 return first_order_info_breve_.
c;
306 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() - this->
ns() == 0, std::logic_error,
"" );
308 return StandardCompositionRelationshipsPack::role_name(first_order_info_breve_.
c,
false, name_c_breve);
314 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() - this->
ns() == 0, std::logic_error,
"" );
316 return StandardCompositionRelationshipsPack::role_name(first_order_info_breve_.
c,
false, name_c_breve);
322 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() - this->
ns() == 0, std::logic_error,
"" );
323 TEUCHOS_TEST_FOR_EXCEPTION( h_breve && !this->
space_h_breve()->is_compatible(h_breve->
space()), VectorSpace::IncompatibleVectorSpaces,
"" );
325 first_order_info_breve_.
c =
h_breve;
331 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() - this->
ns() == 0, std::logic_error,
"" );
333 return first_order_info_breve_.
h;
339 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() - this->
ns() == 0, std::logic_error,
"" );
341 return StandardCompositionRelationshipsPack::role_name(first_order_info_breve_.
c,
false, name_h_breve);
347 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() - this->
ns() == 0, std::logic_error,
"" );
349 return StandardCompositionRelationshipsPack::role_name(first_order_info_breve_.
c,
false, name_h_breve);
354 TEUCHOS_TEST_FOR_EXCEPT(
true);
361 TEUCHOS_TEST_FOR_EXCEPT(
true);
369 TEUCHOS_TEST_FOR_EXCEPTION( this->
m() == 0 || this->
ns() > 0, std::logic_error,
"" );
371 StandardCompositionRelationshipsPack::assert_role_name_set(first_order_info_breve_.
c,
"NLP::calc_c_breve()", name_c_breve);
379 TEUCHOS_TEST_FOR_EXCEPTION( this->
ns() == 0, std::logic_error,
"" );
381 StandardCompositionRelationshipsPack::assert_role_name_set(first_order_info_breve_.
h,
"NLP::calc_h_breve()", name_h_breve);
403 TEUCHOS_TEST_FOR_EXCEPTION(
404 true, std::logic_error
405 ,
"NLP::hl_breve(): Error, this method must be overridden if space_h_breve is defined" );
virtual value_type & f()
Returns non-const *this->get_f().
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...
VectorMutable * c
Pointer to constraints residual c (Will be NULL if not set)
virtual size_type ns() const
Return the number of slack variables (i.e. number of general inequalities).
virtual vec_space_ptr_t space_x() const =0
Vector space object for unknown variables x (dimension n).
virtual void report_final_solution(const Vector &x, const Vector *lambda, const Vector *nu, bool is_optimal)
Used by the solver to report the final solution and multipliers.
virtual size_type num_bounded_x() const =0
Returns the number of variables in x(i) for which xl(i)> -infinite_bound() or xu(i) < +infinite_bound...
virtual size_type num_c_evals() const
Gives the number of constraint function c(x) evaluations called by the solver since initialize() was ...
virtual VectorMutable & c_breve()
Returns non-const *this->get_c_breve().
virtual VectorMutable * get_c_breve()
Return pointer passed to this->set_c_breve().
virtual vec_space_ptr_t space_c_breve() const
Vector space object for the original equalities c_breve(x_breve)
virtual void get_init_lagrange_mult(VectorMutable *lambda, VectorMutable *nu) const
Get the initial value of the Lagrange multipliers lambda.
const ZeroOrderInfo zero_order_info() const
Return pointer to set quantities.
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)
virtual vec_space_ptr_t space_c() const =0
Vector space object for general equality constraints c(x) (dimension m).
virtual void imp_calc_f(const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const =0
Overridden to compute f(x) (and perhaps other quantities if set).
virtual void set_options(const options_ptr_t &options)
Set the options that this NLP may be interested in.
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).
virtual void unset_quantities()
Call to unset all storage quantities (both in this class and all subclasses).
virtual const Vector & hl_breve() const
Returns a reference to the vector of lower bounds on the general inequality constraints h_breve(x_bre...
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.
virtual size_type n() const
Return the number of variables.
const ZeroOrderInfo zero_order_info_breve() const
Return pointer to set hat quantities.
virtual const VectorSpace & space() const =0
Teuchos::RCP< const OptionsFromStreamPack::OptionsFromStream > options_ptr_t
virtual void set_c(VectorMutable *c)
Set a pointer to a vector to be updated when this->calc_c() is called.
virtual value_type * get_f()
Return pointer passed to this->set_f().
Teuchos::RCP< const VectorSpace > vec_space_ptr_t
virtual ~NLP()
Destructor that cleans all the memory it owns.
Struct for objective and constriants (pointer).
virtual const options_ptr_t & get_options() const
Get the OptionsFromStream object being used to extract the options from.
virtual vec_space_ptr_t space_h_breve() const
Vector space object for the original inequalities h_breve(x_breve)
virtual const Permutation & P_var() const
Return the permutation object for the variables.
NLP()
Initialize to no reference set to calculation quanities.
virtual void set_c_breve(VectorMutable *c_breve)
Set a pointer to a vector to be updated when this->calc_c_breve() is called.
virtual const Permutation & P_equ() const
Return the permutation object for the constraints.
virtual const Vector & hu_breve() const
Returns a reference to the vector of upper bounds on the general inequality constraints h_breve(x_bre...
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...
value_type * f
Pointer to objective function f (Will be NULL if not set)
virtual void set_h_breve(VectorMutable *h_breve)
Set a pointer to a vector to be updated when this->calc_h_breve() is called.
virtual void imp_calc_c(const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const =0
Overridden to compute c(x) and perhaps f(x) and/or h(x) (if multiple calculaiton = true)...
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...
virtual size_type m() const
Return the number of general equality constraints.
virtual void initialize(bool test_setup=false)
Initialize the NLP before it is used.
virtual size_type num_f_evals() const
Gives the number of object function f(x) evaluations called by the solver since initialize() was call...
virtual VectorMutable * get_h_breve()
Return pointer passed to this->set_h_breve().
static value_type infinite_bound()
Value for an infinite bound.
virtual VectorMutable * get_c()
Return pointer passed to this->set_c().
VectorMutable * h
Pointer to inequality constraints h (Will be NULL if not set)
virtual void set_f(value_type *f)
Set a pointer to an value to be updated when this->calc_f() is called.
virtual VectorMutable & c()
Returns non-const *this->get_c().
virtual VectorMutable & h_breve()
Returns non-const *this->get_h_breve().