77 <<
"\n****************************"
78 <<
"\n*** test_nlp_direct(...) ***"
79 <<
"\n*****************************\n";
85 *out <<
"\nTesting the vector spaces ...\n";
87 VectorSpaceTester vec_space_tester;
89 VectorSpaceTesterSetOptions
90 opt_setter(&vec_space_tester);
91 opt_setter.set_options(*options);
95 *out <<
"\nTesting nlp->space_x() ...\n";
96 result = vec_space_tester.check_vector_space(*nlp->
space_x(),
out);
99 *out <<
"nlp->space_x() checks out!\n";
101 *out <<
"nlp->space_x() check failed!\n";
105 *out <<
"\nTesting nlp->space_x()->sub_space(nlp->var_dep()) ...\n";
106 result = vec_space_tester.check_vector_space(
110 *out <<
"nlp->space_x()->sub_space(nlp->var_dep()) checks out!\n";
112 *out <<
"nlp->space_x()->sub_space(nlp->var_dep()) check failed!\n";
116 *out <<
"\nTesting nlp->space_x()->sub_space(nlp->var_indep()) ...\n";
117 result = vec_space_tester.check_vector_space(
121 *out <<
"nlp->space_x()->sub_space(nlp->var_indep()) checks out!\n";
123 *out <<
"nlp->space_x()->sub_space(nlp->var_indep()) check failed!\n";
127 *out <<
"\nTesting nlp->space_c() ...\n";
128 result = vec_space_tester.check_vector_space(*nlp->
space_c(),
out);
131 *out <<
"nlp->space_c() checks out!\n";
133 *out <<
"nlp->space_c() check failed!\n";
137 *out <<
"\nTesting nlp->space_c()->sub_space(nlp->con_decomp()) ...\n";
138 result = vec_space_tester.check_vector_space(
142 *out <<
"nlp->space_c()->sub_space(nlp->con_decomp()) checks out!\n";
144 *out <<
"nlp->space_c()->sub_space(nlp->con_decomp()) check failed!\n";
149 *out <<
"\nTesting nlp->space_c()->sub_space(nlp->con_undecomp()) ...\n";
150 result = vec_space_tester.check_vector_space(
154 *out <<
"nlp->space_c()->sub_space(nlp->con_undecomp()) checks out!\n";
156 *out <<
"nlp->space_c()->sub_space(nlp->con_undecomp()) check failed!\n";
166 nlp_tester_opt_setter(&nlp_tester);
169 const bool print_all_warnings = nlp_tester.print_all();
172 nlp, nlp->
xinit(), print_all_warnings,
out );
180 *out <<
"\nCalling nlp->calc_point(...) at nlp->xinit() ...\n";
189 VectorSpace::vec_mut_ptr_t
190 c = nlp->
space_c()->create_member(),
191 Gf = nlp->
space_x()->create_member(),
192 py = nlp->
space_x()->sub_space(var_dep)->create_member(),
193 rGf = nlp->
space_x()->sub_space(var_indep)->create_member();
194 NLPDirect::mat_fcty_ptr_t::element_type::obj_ptr_t
199 nlp->
xinit(), NULL, c.get(),
true, supports_Gf?Gf.get():NULL, py.get(), rGf.get()
200 ,GcU.get(), D.get(), Uz.get() );
203 *out <<
"\n||Gf||inf = " << Gf->norm_inf();
204 if(nlp_tester.print_all())
205 *out <<
"\nGf =\n" << *Gf;
207 *out <<
"\n||py||inf = " << py->norm_inf();
208 if(nlp_tester.print_all())
209 *out <<
"\npy =\n" << *py;
210 *out <<
"\n||rGf||inf = " << rGf->norm_inf();
211 if(nlp_tester.print_all())
212 *out <<
"\nrGf =\n" << *rGf;
213 if(nlp_tester.print_all())
214 *out <<
"\nD =\n" << *D;
215 if( con_decomp.size() < m ) {
225 options_setter( &calc_fd_prod );
229 nlp_first_order_direct_tester(
Teuchos::rcp(&calc_fd_prod,
false));
232 nlp_tester_opt_setter(&nlp_first_order_direct_tester);
240 ,supports_Gf?Gf.get():NULL,py.get(),rGf.get(),GcU.get(),D.get(),Uz.get()
241 ,print_all_warnings,
out
Extracts options from a text stream and then allows convenient access to them.
AbstractLinAlgPack::size_type size_type
virtual Range1D con_decomp() const
Return the range of decomposed equality constraints.
virtual const mat_fcty_ptr_t factory_GcU() const
Return a matrix factory object for creating GcU.
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 const mat_fcty_ptr_t factory_Uz() const
Return a matrix factory object for Uz = F + E * D.
Set options for NLPDirectTester from an OptionsFromStream object.
virtual vec_space_ptr_t space_x() const =0
Vector space object for unknown variables x (dimension n).
void set_options(const OptionsFromStream &options)
Overridden from SetOptionsFromStream and calls setOption(...).
virtual void calc_point(const Vector &x, value_type *f, VectorMutable *c, bool recalc_c, VectorMutable *Gf, VectorMutable *py, VectorMutable *rGf, MatrixOp *GcU, MatrixOp *D, MatrixOp *Uz) const =0
Compute all of the needed quanities for direct sensitivities.
Set options for NLPTester from an OptionsFromStream object.
Interface providing only direct first order sensitivity information.
Set options for CalcFiniteDiffProd from an OptionsFromStream object.
bool test_nlp_direct(NLPDirect *nlp, OptionsFromStreamPack::OptionsFromStream *options, std::ostream *out)
Test an NLPDirect object.
Testing class for base NLP interface.
virtual Range1D con_undecomp() const
Return the range of undecomposed equality constraints.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool finite_diff_check(NLPDirect *nlp, const Vector &xo, const Vector *xl, const Vector *xu, const Vector *c, const Vector *Gf, const Vector *py, const Vector *rGf, const MatrixOp *GcU, const MatrixOp *D, const MatrixOp *Uz, bool print_all_warnings, std::ostream *out) const
This function takes an NLP object and its computed derivatives and function values and validates the ...
void initialize(bool test_setup)
Initialize the NLP for its first use.
Strategy interface for computing the product of the derivatives of the functions of an NLP along give...
virtual size_type n() const
Return the number of variables.
virtual vec_space_ptr_t space_c() const =0
Vector space object for general equality constraints c(x) (dimension m).
virtual const Vector & xl() const =0
Returns the lower bounds on the variables x.
virtual Range1D var_dep() const
Return the range of dependent (i.e. basic) variables.
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...
Concrete class that tests the computed values of the NLPDirect interface using finite differences...
virtual const Vector & xu() const =0
Returns a reference to the vector of upper bounds on the variables x.
virtual Range1D var_indep() const
Return the range of independent (i.e. nonbasic) variables.
virtual const mat_fcty_ptr_t factory_D() const =0
Return a matrix factory object for D = -inv(C)*N {abstract}.
virtual obj_ptr_t create() const =0
bool update_success(bool result_check, bool *success)
Helper function for updating a flag for if an operation returned false.
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.
RangePack::Range1D Range1D
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
virtual bool supports_Gf() const
Determine if the objective gradient is supported or not.