57 namespace NLPInterfacePack {
 
   63   :print_all_(print_all), throw_exception_(throw_exception)
 
   69   ,
bool                   print_all_warnings
 
   80     *out << std::boolalpha
 
   82        << 
"**************************************\n" 
   83        << 
"*** NLPTester::test_interface(...) ***\n" 
   84        << 
"**************************************\n";
 
   91       *out << 
"\nnlp->force_xinit_in_bounds(true)";
 
   94       *out << 
"\nnlp->initialize(true)\n";
 
  101       *out << 
"\n*** Dimensions of the NLP ...\n" 
  102          << 
"\nnlp->n()  = " << n
 
  103          << 
"\nnlp->m()  = " << m
 
  107         *out << 
"Error! n = " << n << 
" < m = " << m << 
" is not allowed!\n";
 
  109         throw_exception_, std::logic_error
 
  110         ,
"NLPTester::test_interface(...): Error! n = " << n << 
" < m = " << m << 
" is not allowed!" 
  116       *out << 
"\n*** Validate the dimensions of the vector spaces ...\n";
 
  121       *out << 
"\ncheck: nlp->space_x()->dim() = " << nlp->
space_x()->
dim()
 
  122            << 
" == nlp->n() = " << nlp->
n() << 
": " << result << std::endl;
 
  128         *out << 
"\ncheck: nlp->space_c()->dim() = " << nlp->
space_c()->
dim()
 
  129              << 
" == nlp->m() = " << nlp->
m() << 
": " << result << std::endl;
 
  132       result = nlp->
space_c().get() == NULL;
 
  135         *out << 
"\ncheck: nlp->space_c().get() = " << nlp->
space_c().get()
 
  136              << 
" == NULL: " << result << std::endl;
 
  141       *out << 
"\n*** Validate that the initial starting point is in bounds ...\n";
 
  142     const Vector &xinit = nlp->
xinit();
 
  143     if(out) *out << 
"\n||nlp->xinit()||inf = " << xinit.
norm_inf() << std::endl;
 
  144     if(out && print_all()) *out << 
"\nnlp->xinit() =\n" << xinit;
 
  149     if(out && print_all())
 
  150       *out << 
"\nnlp->xl() =\n" << xl
 
  151          << 
"\nnlp->xu() =\n" << xu;
 
  156     VectorSpace::vec_mut_ptr_t
 
  159     std::pair<value_type,value_type>
 
  161         xinit, *d, nlp->
xl(), nlp->
xu(), 0.0
 
  163     result = u.first >= 0.0;
 
  166       *out << 
"\ncheck: xl <= x <= xu : " << result;
 
  168         *out << 
"\nxinit is in bounds with { max |u| | xl <= x + u <= xu } -> " 
  169            << ( u.first > -u.second ? u.first : u.second  ) << std::endl;
 
  178       *out << 
"\ncheck: num_bounded(nlp->xl(),nlp->xu()) = " << num_bounded_x
 
  180          << 
": " << result << std::endl;
 
  184       *out << 
"\nGetting the initial estimates for the Lagrange mutipliers ...\n";
 
  185     VectorSpace::vec_mut_ptr_t  lambda, nu;
 
  189          : (VectorMutable*)NULL )
 
  192          : (VectorMutable*)NULL )
 
  197         *out << 
"\n||lambda||inf  = " << lambda->norm_inf();
 
  199         *out << 
"\n||nu||inf      = " << nu->norm_inf()
 
  200            << 
"\nnu.nz()        = " << nu->nz();
 
  204           *out << 
"\nlambda =\n" << *lambda;
 
  206           *out << 
"\nnu =\n" << *nu;
 
  216     VectorMutable   *c_saved = NULL;
 
  217     f_saved = nlp->
get_f();
 
  218     if( nlp->
m() )  c_saved = nlp->
get_c();
 
  222     VectorSpace::vec_mut_ptr_t   c;
 
  228     if( nlp->
m() )  nlp->
set_c(c.get());
 
  233       *out << 
"\n*** Evaluate the point xo ...\n";
 
  235     if(out) *out << 
"\n||xo||inf = " << xo.norm_inf() << std::endl;
 
  236     if(out && print_all()) *out << 
"\nxo =\n" << xo;
 
  240     if(nlp->
m())  nlp->
calc_c(xo,
false);
 
  243       *out << 
"\nf(xo) = " << f;
 
  245         *out << 
"\n||c(xo)||inf = " << nlp->
c().
norm_inf();
 
  249           *out << 
"\nc(xo) =\n" << nlp->
c();
 
  258       *out << 
"\n*** Report this point to the NLP as suboptimal ...\n";
 
  263       *out << 
"\n*** Print the number of evaluations ...\n";
 
  264       *out << 
"\nnlp->num_f_evals() = " << nlp->
num_f_evals();
 
  266         *out << 
"\nnlp->num_c_evals() = " << nlp->
num_c_evals();
 
  272     if(nlp->
m())  nlp->
set_c(c_saved);
 
  275   catch(
const std::exception& except) {
 
  277       *out << 
"Caught a std::exception: " << except.what() << std::endl;
 
  279     if(throw_exception())
 
  284       *out << 
"Caught an unknown exception!\n";
 
  286     if(throw_exception())
 
AbstractLinAlgPack::size_type size_type
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...
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. 
bool test_interface(NLP *nlp, const Vector &xo, bool print_all_warnings, std::ostream *out)
Test the NLP interface as the given base point xo. 
virtual size_type num_c_evals() const 
Gives the number of constraint function c(x) evaluations called by the solver since initialize() was ...
virtual value_type norm_inf() const 
Infinity norm. ||v||_inf = max( |v(i)|, i = 1,,,this->dim() ) 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void get_init_lagrange_mult(VectorMutable *lambda, VectorMutable *nu) const 
Get the initial value of the Lagrange multipliers lambda. 
AbstractLinAlgPack::VectorSpace * space_c
AbstractLinAlgPack::VectorSpace * space_x
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. 
virtual const Vector & xl() const =0
Returns the lower bounds on the variables x. 
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 void set_c(VectorMutable *c)
Set a pointer to a vector to be updated when this->calc_c() is called. 
virtual const Vector & xu() const =0
Returns a reference to the vector of upper bounds on the variables x. 
virtual value_type * get_f()
Return pointer passed to this->set_f(). 
size_type num_bounded(const Vector &xl, const Vector &xu, value_type inf_bound)
Count the number of finitly bounded elements in xl <= x <= xu. 
bool assert_print_nan_inf(const value_type &val, const char name[], bool throw_excpt, std::ostream *out)
This function asserts if a value_type scalare is a NaN or Inf and optionally prints out these entires...
virtual void force_xinit_in_bounds(bool force_xinit_in_bounds)=0
Set if the initial point must be within the bounds. 
NLP interface class {abstract}. 
NLPTester(bool print_all=false, bool throw_exception=true)
Constructor (default options) 
virtual index_type dim() const =0
Return the dimmension of the vector space. 
std::pair< value_type, value_type > max_near_feas_step(const Vector &x, const Vector &d, const Vector &xl, const Vector &xu, value_type max_bnd_viol)
Computes the maximum positive and negative step that can be taken that are within the relaxed bounds...
AbstractLinAlgPack::value_type value_type
bool update_success(bool result_check, bool *success)
Helper function for updating a flag for if an operation returned false. 
virtual vec_mut_ptr_t create_member() const =0
Create a vector member from the vector space. 
virtual const Vector & xinit() const =0
Returns a reference to the vector of the initial guess for the solution x. 
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...
static value_type infinite_bound()
Value for an infinite bound. 
virtual VectorMutable * get_c()
Return pointer passed to this->set_c(). 
virtual void set_f(value_type *f)
Set a pointer to an value to be updated when this->calc_f() is called. 
const f_int f_dbl_prec const f_int f_int const f_int f_int const f_dbl_prec & u
virtual VectorMutable & c()
Returns non-const *this->get_c().