MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NLPInterfacePack_test_basis_system.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
48 
50  NLPFirstOrder *nlp
51  ,BasisSystem *basis_sys
53  ,std::ostream *out
54  )
55 {
56  namespace mmp = MemMngPack;
57 
58  const index_type
59  n = nlp->n(),
60  m = nlp->m();
61 
62  // Create the matrices Gc and Gh
63  NLPFirstOrder::mat_fcty_ptr_t::element_type::obj_ptr_t
64  Gc = ( m ? nlp->factory_Gc()->create() : Teuchos::null );
65 
66  // Compute the matrices at xinit
67  const Vector
68  &xo = nlp->xinit();
69  if(m)
70  nlp->set_Gc(Gc.get());
71  if(m)
72  nlp->calc_Gc(xo);
73 
74  // Create the matrices C and D
75  BasisSystem::mat_nonsing_fcty_ptr_t::element_type::obj_ptr_t
76  C = ( m ? basis_sys->factory_C()->create() : Teuchos::null);
77  BasisSystem::mat_fcty_ptr_t::element_type::obj_ptr_t
78  D = ( m && n > m && basis_sys->factory_C().get() ? basis_sys->factory_C()->create() : Teuchos::null);
79  BasisSystem::mat_fcty_ptr_t::element_type::obj_ptr_t
80  GcUP = ( m && n > m && basis_sys->factory_GcUP().get() ? basis_sys->factory_GcUP()->create() : Teuchos::null);
81 
82  // Initialize C and D with basis_sys
83  basis_sys->update_basis(
84  *Gc
85  ,C.get()
86  ,D.get()
87  ,GcUP.get()
88  );
89 
90  // Test the basis and basis system objects.
91  BasisSystemTester
92  basis_sys_tester;
93  if(options) {
94  BasisSystemTesterSetOptions
95  opt_setter(&basis_sys_tester);
96  opt_setter.set_options(*options);
97  }
98  const bool result = basis_sys_tester.test_basis_system(
99  *basis_sys
100  ,Gc.get()
101  ,C.get()
102  ,NULL // Create the N matrix internally
103  ,D.get()
104  ,GcUP.get()
105  ,out
106  );
107 
108  return result;
109 }
Extracts options from a text stream and then allows convenient access to them.
virtual void calc_Gc(const Vector &x, bool newx=true) const
Update the matrix for Gc at the point x and put it in the stored reference.
bool test_basis_system(NLPFirstOrder *nlp, BasisSystem *basis_sys, OptionsFromStreamPack::OptionsFromStream *options, std::ostream *out)
Test a BasisSystem object given matrices from a compatible NLPFirstOrder object.
Teuchos::AbstractFactory< AbstractLinAlgPack::MatrixOp > * factory_Gc
virtual size_type n() const
Return the number of variables.
std::ostream * out
NLP first order information interface class {abstract}.
virtual obj_ptr_t create() const =0
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.
int n
virtual void set_Gc(MatrixOp *Gc)
Set a pointer to a matrix object to be updated when this->calc_Gc() is called.