MOOCHO/Thyra Adapter Software  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
NLPInterfacePack_NLPDirectThyraModelEvaluator.hpp
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 
42 #ifndef NLPIP_NLP_DIRECT_THYRA_MODEL_EVALUATOR_HPP
43 #define NLPIP_NLP_DIRECT_THYRA_MODEL_EVALUATOR_HPP
44 
45 #include "NLPInterfacePack_NLPThyraModelEvaluatorBase.hpp"
46 #include "NLPInterfacePack_NLPDirect.hpp"
47 #include "Thyra_DirectionalFiniteDiffCalculator.hpp"
48 #include "Teuchos_StandardCompositionMacros.hpp"
49 #include "Teuchos_StandardMemberCompositionMacros.hpp"
50 
51 namespace NLPInterfacePack {
52 
59  : virtual public NLPDirect
60  , virtual public NLPThyraModelEvaluatorBase
61 {
62 public:
63 
66 
69 
71  STANDARD_MEMBER_COMPOSITION_MEMBERS( bool, DfDp_is_const );
72 
75 
79  ,const int p_idx
80  ,const int g_idx
81  ,const objDirecFiniteDiffCalculator_ptr_t objDirecFiniteDiffCalculator = Teuchos::null
82  ,const conDirecFiniteDiffCalculator_ptr_t conDirecFiniteDiffCalculator = Teuchos::null
83  );
84 
90  void initialize(
92  ,const int p_idx
93  ,const int g_idx
94  ,const objDirecFiniteDiffCalculator_ptr_t objDirecFiniteDiffCalculator = Teuchos::null
95  ,const conDirecFiniteDiffCalculator_ptr_t conDirecFiniteDiffCalculator = Teuchos::null
96  );
97 
100 
102  void initialize(bool test_setup);
104  void unset_quantities();
105 
107 
110 
112  bool supports_Gf() const;
114  bool supports_Gf_prod() const;
116  value_type calc_Gf_prod(const Vector& x, const Vector& d, bool newx) const;
117 
119 
122 
124  Range1D var_dep() const;
126  Range1D var_indep() const;
128  const mat_fcty_ptr_t factory_D() const;
132  void calc_point(
133  const Vector &x
134  ,value_type *f
135  ,VectorMutable *c
136  ,bool recalc_c
137  ,VectorMutable *Gf
138  ,VectorMutable *py
139  ,VectorMutable *rGf
140  ,MatrixOp *GcU
141  ,MatrixOp *D
142  ,MatrixOp *Uz
143  ) const;
146  const Vector &x
147  ,VectorMutable *c
148  ,bool recalc_c
149  ,VectorMutable *py
150  ) const;
151 
153 
154 private:
155 
158 
159 }; // end class NLPDirectThyraModelEvaluator
160 
161 } // end namespace NLPInterfacePack
162 
163 #endif // NLPIP_NLP_DIRECT_THYRA_MODEL_EVALUATOR_HPP
virtual value_type & f()
void initialize(const Teuchos::RCP< Thyra::ModelEvaluator< value_type > > &model, const int p_idx, const int g_idx, const objDirecFiniteDiffCalculator_ptr_t objDirecFiniteDiffCalculator=Teuchos::null, const conDirecFiniteDiffCalculator_ptr_t conDirecFiniteDiffCalculator=Teuchos::null)
.Initialize given a Thyra::ModelEvaluator and a description of how to interpret it.
STANDARD_COMPOSITION_MEMBERS(Thyra::DirectionalFiniteDiffCalculator< value_type >, objDirecFiniteDiffCalculator)
Utility object that computes directional finite differences for objective.
Implements the base NLP interface using a Thyra::ModelEvaluator object.
Implement the NLPFirstOrder interface using a Thyra::ModelEvaluator object.
value_type calc_Gf_prod(const Vector &x, const Vector &d, bool newx) const
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
void calc_semi_newton_step(const Vector &x, VectorMutable *c, bool recalc_c, VectorMutable *py) const
virtual VectorMutable & Gf()
STANDARD_MEMBER_COMPOSITION_MEMBERS(bool, DfDp_is_const)
Set if model.DfDp is constant or not.
virtual VectorMutable & c()