This file is indexed.

/usr/include/trilinos/NLPInterfacePack_NLPThyraModelEvaluatorBase.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
// @HEADER
// ***********************************************************************
// 
// Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
//                  Copyright (2003) Sandia Corporation
// 
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
// 
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//  
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//  
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
// Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
// 
// ***********************************************************************
// @HEADER

#ifndef NLPIP_NLP_THYRA_MODEL_EVALUATOR_BASE_HPP
#define NLPIP_NLP_THYRA_MODEL_EVALUATOR_BASE_HPP

#include <vector>

#include "NLPInterfacePack_NLPFirstOrder.hpp"
#include "AbstractLinAlgPack_VectorSpace.hpp"
#include "Thyra_ModelEvaluator.hpp"
#include "Teuchos_TestForException.hpp"
#include "Teuchos_StandardMemberCompositionMacros.hpp"

namespace AbstractLinAlgPack { class VectorSpaceThyra; }

namespace NLPInterfacePack {

/** \brief Implements the base %NLP interface using a
 * <tt>Thyra::ModelEvaluator</tt> object.
 *
 * The nonlinear program is mapped as follows:

 \verbatim

    min     f(x)
    s.t.    c(x) = 0
            xL <= x <= xu

    where:

        x = [ model.x        ]
            [ model.p(p_idx) ]

        f(x) = model.g(g_idx)

        c(x) = model.f()

 \endverbatim

 * where <tt>p_idx > 0</tt> and <tt>g_idx > 0</tt> are some indexes that
 * specificy the indepenent variables and the objective function.
 *
 * In addition, the client can also override the bounds on <tt>model.x</tt> and
 * <tt>model.p(p_idx)</tt> defined in the object <tt>model</tt>.
 *
 * The current implementation of this class does not allow the use of any of
 * the auxiliary functions <tt>model.g()</tt> as undecomposed equality
 * constraints or extra general inequality constraints.  This type of
 * functionality can be added when it is needed (just ask for it).
 *
 * ToDo: Finish documentation!
 */
class NLPThyraModelEvaluatorBase : virtual public NLPObjGrad {
public:

  /** \brief Set if a trace of the model evaluations is shown or not. */
  STANDARD_MEMBER_COMPOSITION_MEMBERS( bool, showModelEvaluatorTrace );

  /** @name Overridden public members from NLP */
  //@{

  /** \brief . */
  void initialize(bool test_setup);
  /** \brief . */
  bool is_initialized() const;
  /** \brief . */
  vec_space_ptr_t space_x() const;
  /** \brief . */
  vec_space_ptr_t space_c() const;
  /** \brief . */
    size_type num_bounded_x() const;
  /** \brief . */
  void force_xinit_in_bounds(bool force_xinit_in_bounds);
  /** \brief . */
  bool force_xinit_in_bounds() const;
  /** \brief . */
  const Vector& xinit() const;
  /** \brief . */
  const Vector& xl() const;
  /** \brief . */
  const Vector& xu() const;
  /** \brief . */
  value_type max_var_bounds_viol() const;
  /** \brief . */
  void set_f(value_type* f);
  /** \brief . */
  void set_c(VectorMutable* c);
  /** \brief . */
  void unset_quantities();
  /** \brief . */
  void scale_f( value_type scale_f );
  /** \brief . */
  value_type scale_f() const;
  /** \brief . */
  void report_final_solution(
    const Vector&    x
    ,const Vector*   lambda
    ,const Vector*   nu
    ,bool            optimal
    );

  //@}

  /** @name Overridden public members from NLPObjGrad */
  //@{

  /** \brief . */
  void set_Gf(VectorMutable* Gf);

  //@}

protected:

  /** @name Overridden protected members from NLP */
  //@{

  /** \brief . */
  void imp_calc_f(
    const Vector& x, bool newx
    ,const ZeroOrderInfo& zero_order_info) const;
  /** \brief . */
  void imp_calc_c(
    const Vector& x, bool newx
    ,const ZeroOrderInfo& zero_order_info) const;

  //@}

  /** @name Overridden protected members from NLPObjGrad */
  //@{

  /** \brief . */
  void imp_calc_Gf(
    const Vector& x, bool newx
    ,const ObjGradInfo& obj_grad_info) const;

  //@}

protected:

  /** @name Protected functions to be used by subclasses */
  //@{

  /** Initialize to uninitialized */
  NLPThyraModelEvaluatorBase();

  /** \brief Initialize given a <tt>Thyra::ModelEvaluator</tt> and
   * a description of how to interpret it.
   *
   * @param  model    [in] NonlinearProblem that defines all of the functions and variables.
   * @param  p_idx [in] Index of the subset of parameter vectors to use as the independent
   *               variables.  If <tt>p_idx < 0</tt>, then no extra parameters are added.
   * @param  g_idx [in] Index of the subset of auxiliary response functions to use as
   *               the objective function.  Note, only the first element <tt>model.g(g_idx)(1)</tt>
   *               will be used as the objective function value.
   * @param  model_xL [in] Pointer to upper bounds for the state variables <tt>model.x</tt>.  If NULL
   *               then the default supplied in <tt>model->get_x_lower_bounds()</tt> will be used.
   * @param  model_xU [in] Pointer to upper bounds for the state variables <tt>x</tt>.  If NULL
   *               then the default supplied in <tt>model->get_x_upper_bounds()</tt> will be used.
   * @param  model_x0 [in] Pointer to initial guess for the state variables <tt>x</tt>.  If NULL
   *               the the default supplied in <tt>model->get_x_init()</tt> will be used.
   *
   * ToDo: Finish documentation!
   *
   * Todo: Add arguments for auxiliary inequalites and equalities
   */
  void initializeBase(
    const Teuchos::RCP<Thyra::ModelEvaluator<value_type> >  &model
    ,const int                                                      p_idx
    ,const int                                                      g_idx
    );

  /** \brief Update the initial guess and bounds . */
  void updateInitialGuessAndBounds() const;

  /** \brief . */
  void assert_is_initialized() const;
  /** \brief . */
  void copy_from_model_x( const Thyra::VectorBase<value_type>* model_x, VectorMutable* x_D ) const;
  /** \brief . */
  void copy_from_model_p( const Thyra::VectorBase<value_type> *model_p, VectorMutable* x_I ) const;
  /** \brief . */
  void set_x(
    const Vector                                      &x
    ,Thyra::ModelEvaluatorBase::InArgs<value_type>    *model_inArgs_inout
    ) const;
  /** \brief . */
  void preprocessBaseInOutArgs(
    const Vector                                      &x
    ,bool                                             newx
    ,const ZeroOrderInfo                              *zero_order_info
    ,const ObjGradInfo                                *obj_grad_info
    ,const NLPFirstOrder::FirstOrderInfo              *first_order_info
    ,Thyra::ModelEvaluatorBase::InArgs<value_type>    *model_inArgs_inout
    ,Thyra::ModelEvaluatorBase::OutArgs<value_type>   *model_outArgs_inout
    ,MatrixOp*                                        *Gc_out
    ,VectorMutable*                                   *Gf_out
    ,value_type*                                      *f_out
    ,VectorMutable*                                   *c_out
    ) const;
  /** \brief . */
  void postprocessBaseOutArgs(
    Thyra::ModelEvaluatorBase::OutArgs<value_type>        *model_outArgs_inout
    ,VectorMutable                                        *Gf
    ,value_type                                           *f
    ,VectorMutable                                        *c
    ) const;
    
  //@}

//private: // ToDo: Make these private and refactor the other classes ...

  // /////////////////////////////////////////
  // Private types

  typedef Teuchos::RCP<const AbstractLinAlgPack::VectorSpaceThyra> VectorSpaceThyra_ptr_t;

  // /////////////////////////////////////////
  // Private data members

  bool                                initialized_;  // flag for if initialized has been called.
  value_type                          obj_scale_;    // default = 1.0;
  bool                                has_bounds_;   // True if has bounds
  bool                                force_xinit_in_bounds_; // default = true.
  index_type                          num_bounded_x_;
  Teuchos::RCP<Thyra::ModelEvaluator<value_type> >
                                      model_;
  int                                 p_idx_;
  int                                 g_idx_;
  bool                                DfDp_supports_op_;
  bool                                DfDp_supports_mv_;
  VectorSpace::space_ptr_t            space_x_;      // Space for the variables
  VectorSpaceThyra_ptr_t              space_c_;      // Space for the constraints
  NLPFirstOrder::mat_fcty_ptr_t       factory_Gc_;   // Factory for Gc
  NLPFirstOrder::basis_sys_ptr_t      basis_sys_;    // The basis system
  mutable bool                        x_guess_bounds_updated_;
  VectorSpace::vec_mut_ptr_t          xinit_;        // Initial guess.
  VectorSpace::vec_mut_ptr_t          xl_;           // lower bounds.
  VectorSpace::vec_mut_ptr_t          xu_;           // upper bounds.

  Teuchos::RCP<Thyra::VectorBase<value_type> >                     model_g_;

  mutable bool model_g_updated_;
  mutable bool model_Dg_updated_;

  mutable bool f_updated_;
  mutable bool c_updated_;
  mutable bool Gf_updated_;
  mutable bool Gc_updated_;

  // /////////////////////////////////////////
  // Private member functions

  /** \brief . */
  void evalModel( 
    const Vector            &x
    ,bool                   newx
    ,const ZeroOrderInfo    *zero_order_info  // != NULL if only zero-order info
    ,const ObjGradInfo      *obj_grad_info    // != NULL if obj-grad and below info
    ) const;

};	// end class NLPThyraModelEvaluatorBase

}	// end namespace NLPInterfacePack

#endif	// NLPIP_NLP_THYRA_MODEL_EVALUATOR_BASE_HPP