MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NLPInterfacePack_NLPFirstOrder.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 
44 #include "Teuchos_Assert.hpp"
45 
46 namespace {
47  const char name_Gc[] = "Gc";
48 } // end namespace
49 
50 namespace NLPInterfacePack {
51 
52 // constructors
53 
55  : Gc_(NULL)
56 {}
57 
58 void NLPFirstOrder::initialize(bool test_setup) {
59  num_Gc_evals_ = 0;
60  NLPObjGrad::initialize(test_setup);
61 }
62 
63 // BasisSystem
64 
67 {
68  return Teuchos::null;
69 }
70 
71 // <<std aggr>> members for Gc
72 
73 void NLPFirstOrder::set_Gc(MatrixOp* Gc)
74 {
75 #ifdef TEUCHOS_DEBUG
76  TEUCHOS_TEST_FOR_EXCEPTION( this->m() == 0, std::logic_error, "" );
77 #endif
78  Gc_ = Gc;
79 }
80 
82 {
83 #ifdef TEUCHOS_DEBUG
84  TEUCHOS_TEST_FOR_EXCEPTION( this->m() == 0, std::logic_error, "" );
85 #endif
87 }
88 
89 MatrixOp& NLPFirstOrder::Gc()
90 {
91 #ifdef TEUCHOS_DEBUG
92  TEUCHOS_TEST_FOR_EXCEPTION( this->m() == 0, std::logic_error, "" );
93 #endif
95 }
96 
97 const MatrixOp& NLPFirstOrder::Gc() const
98 {
99 #ifdef TEUCHOS_DEBUG
100  TEUCHOS_TEST_FOR_EXCEPTION( this->m() == 0, std::logic_error, "" );
101 #endif
103 }
104 
106 {
108  Gc_ = NULL;
109 }
110 
111 // calculations
112 
113 void NLPFirstOrder::calc_Gc(const Vector& x, bool newx) const
114 {
115 #ifdef TEUCHOS_DEBUG
116  TEUCHOS_TEST_FOR_EXCEPTION( this->m() == 0, std::logic_error, "" );
117 #endif
119  imp_calc_Gc(x,newx,first_order_info());
120  num_Gc_evals_++;
121 }
122 
124 {
125 #ifdef TEUCHOS_DEBUG
126  TEUCHOS_TEST_FOR_EXCEPTION( this->m() == 0, std::logic_error, "" );
127 #endif
128  return num_Gc_evals_;
129 }
130 
131 } // end namespace NLPInterfacePack
void initialize(bool test_setup)
Initialize the NLP for its first use.
void unset_quantities()
Call to unset all storage quantities (both in this class and all subclasses).
AbstractLinAlgPack::size_type size_type
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.
NLPFirstOrder()
Initialize to no reference set to calculation quanities.
void initialize(bool test_setup)
Initialize the NLP for its first use.
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void imp_calc_Gc(const Vector &x, bool newx, const FirstOrderInfo &first_order_info) const =0
Overridden to compute Gc(x) and perhaps Gf(x), f(x) and c(x).
const FirstOrderInfo first_order_info() const
Return objective gradient and zero order information.
virtual size_type num_Gc_evals() const
Gradient of constraints matrix Gc evaluations count.
ContainedClass * get_role_name(ContainedClass *role_name_, bool owns_role_name_, const char name[])
void unset_quantities()
Call to unset all storage quantities (both in this class and all subclasses).
void assert_role_name_set(const ContainedClass *role_name_, const char func_name[], const char name[])
Assert that the reference is set.
virtual MatrixOp & Gc()
Returns non-const *this->get_Gc().
ContainedClass & role_name(ContainedClass *role_name_, bool owns_role_name_, const char name[])
virtual MatrixOp * get_Gc()
Return pointer passed to this->set_Gc().
virtual size_type m() const
Return the number of general equality constraints.
virtual const basis_sys_ptr_t basis_sys() const
Return a BasisSystem object compatible with Gc and Gh.
virtual void set_Gc(MatrixOp *Gc)
Set a pointer to a matrix object to be updated when this->calc_Gc() is called.