44 #include "NLPInterfacePack_test_nlp_first_order.hpp"
45 #include "NLPInterfacePack_CalcFiniteDiffProd.hpp"
46 #include "NLPInterfacePack_CalcFiniteDiffProdSetOptions.hpp"
47 #include "NLPInterfacePack_NLPTester.hpp"
48 #include "NLPInterfacePack_NLPTesterSetOptions.hpp"
49 #include "NLPInterfacePack_NLPFirstDerivTester.hpp"
50 #include "NLPInterfacePack_NLPFirstDerivTesterSetOptions.hpp"
51 #include "NLPInterfacePack_NLPFirstOrder.hpp"
52 #include "AbstractLinAlgPack_VectorSpace.hpp"
53 #include "AbstractLinAlgPack_VectorSpaceTester.hpp"
54 #include "AbstractLinAlgPack_VectorSpaceTesterSetOptions.hpp"
55 #include "AbstractLinAlgPack_VectorMutable.hpp"
56 #include "AbstractLinAlgPack_VectorOut.hpp"
57 #include "AbstractLinAlgPack_MatrixOp.hpp"
58 #include "AbstractLinAlgPack_MatrixOpOut.hpp"
59 #include "TestingHelperPack_update_success.hpp"
60 #include "Teuchos_FancyOStream.hpp"
62 bool NLPInterfacePack::test_nlp_first_order(
68 namespace rcp = MemMngPack;
69 using TestingHelperPack::update_success;
78 *out <<
"\n*********************************"
79 <<
"\n*** test_nlp_first_order(...) ***"
80 <<
"\n*********************************\n";
82 nlp->initialize(
true);
86 *out <<
"\nTesting the vector spaces ...\n";
88 VectorSpaceTester vec_space_tester;
90 VectorSpaceTesterSetOptions
91 opt_setter(&vec_space_tester);
92 opt_setter.set_options(*options);
96 *out <<
"\nTesting nlp->space_x() ...\n";
97 result = vec_space_tester.check_vector_space(*nlp->space_x(),out);
100 *out <<
"nlp->space_x() checks out!\n";
102 *out <<
"nlp->space_x() check failed!\n";
104 update_success( result, &success );
108 *out <<
"\nTesting nlp->space_c() ...\n";
109 result = vec_space_tester.check_vector_space(*nlp->space_c(),out);
112 *out <<
"nlp->space_c() checks out!\n";
114 *out <<
"nlp->space_c() check failed!\n";
116 update_success( result, &success );
121 NLPTester nlp_tester;
124 nlp_tester_opt_setter(&nlp_tester);
125 nlp_tester_opt_setter.set_options(*options);
127 const bool print_all_warnings = nlp_tester.print_all();
129 result = nlp_tester.test_interface(
130 nlp, nlp->xinit(), print_all_warnings, out );
131 update_success( result, &success );
138 VectorSpace::vec_mut_ptr_t
139 c = m ? nlp->space_c()->create_member() : Teuchos::null,
140 Gf = nlp->space_x()->create_member();
141 NLPFirstOrder::mat_fcty_ptr_t::element_type::obj_ptr_t
142 Gc = m ? nlp->factory_Gc()->create() : Teuchos::null;
146 *out <<
"\nCalling nlp->calc_Gc(...) at nlp->xinit() ...\n";
147 nlp->set_Gc( Gc.get() );
148 nlp->calc_Gc( nlp->xinit(), true );
149 if(nlp_tester.print_all()) {
150 *out <<
"\nGc =\n" << *Gc;
155 *out <<
"\nCalling nlp->calc_Gf(...) at nlp->xinit() ...\n";
156 nlp->set_Gf( Gf.get() );
157 nlp->calc_Gf( nlp->xinit(), m == 0 );
158 if(nlp_tester.print_all())
159 *out <<
"\nGf =\n" << *Gf;
164 CalcFiniteDiffProdSetOptions
165 options_setter( &calc_fd_prod );
166 options_setter.set_options(*options);
169 nlp_first_derivatives_tester(
Teuchos::rcp(&calc_fd_prod,
false));
171 NLPFirstDerivTesterSetOptions
172 nlp_tester_opt_setter(&nlp_first_derivatives_tester);
173 nlp_tester_opt_setter.set_options(*options);
175 result = nlp_first_derivatives_tester.finite_diff_check(
177 ,nlp->num_bounded_x() ? &nlp->xl() : NULL
178 ,nlp->num_bounded_x() ? &nlp->xu() : NULL
180 ,print_all_warnings, out
182 update_success( result, &success );
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)