MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NLPInterfacePack_NLPThyraModelEvaluatorBase.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 
42 //
43 // Note: I am using a BasisSystem here just to make it easy to generate
44 // var_dep() and var_indep() and for not much else.
45 //
46 
58 #include "Thyra_DetachedVectorView.hpp"
59 #include "Thyra_VectorStdOps.hpp"
61 #include "Teuchos_Assert.hpp"
62 #include "Teuchos_dyn_cast.hpp"
63 
64 namespace NLPInterfacePack {
65 
66 // Overridden public members from NLP
67 
69 {
72  if(initialized_) {
73  NLPObjGrad::initialize(test_setup);
74  return;
75  }
76  //TEUCHOS_TEST_FOR_EXCEPT(true); // Todo: push the variables in bounds!
78  NLPObjGrad::initialize(test_setup);
79  initialized_ = true;
80 }
81 
83 {
84  return initialized_;
85 }
86 
89 {
90  return space_x_;
91 }
92 
95 {
96  return space_c_;
97 }
98 
100 {
101  return num_bounded_x_;
102 }
103 
105 {
107 }
108 
110 {
111  return force_xinit_in_bounds_;
112 }
113 
115 {
117  return *xinit_;
118 }
119 
121 {
123  return *xl_;
124 }
125 
127 {
129  return *xu_;
130 }
131 
133 {
134  return 1e-5; // I have no idea?
135 }
136 
138 {
139  NLP::set_f(f);
140  f_updated_ = false;
141 }
142 
144 {
145  NLP::set_c(c);
146  c_updated_ = false;
147 }
148 
150 {
152 }
153 
155 {
157 }
158 
160 {
161  return obj_scale_;
162 }
163 
165  const Vector& x
166  ,const Vector* lambda
167  ,const Vector* nu
168  ,bool optimal
169  )
170 {
171  using Teuchos::dyn_cast;
172  using Teuchos::RCP;
173  typedef Thyra::ModelEvaluatorBase MEB;
175  MEB::InArgs<value_type> model_finalPoint = model_->createInArgs();
176  if( basis_sys_.get() ) {
177  const Range1D
178  var_dep = basis_sys_->var_dep(),
179  var_indep = basis_sys_->var_indep();
180  RCP<const Vector> xD = x.sub_view(var_dep), xI;
181  if(p_idx_>=0) xI = x.sub_view(var_indep);
182  model_finalPoint.set_x(dyn_cast<const VectorMutableThyra>(*xD).thyra_vec().assert_not_null());
183  if(p_idx_ >= 0)
184  model_finalPoint.set_p(p_idx_,dyn_cast<const VectorMutableThyra>(*xI).thyra_vec().assert_not_null());
185  else if( model_finalPoint.Np() >= 1 )
186  model_finalPoint.set_p(0,model_->getNominalValues().get_p(0)); // Assume we will find in it zero!
187  }
188  else { // no dependent vars
190  model_finalPoint.set_p(p_idx_,dyn_cast<const VectorMutableThyra>(x).thyra_vec().assert_not_null());
191  }
192  model_->reportFinalPoint(model_finalPoint,optimal);
193 }
194 
195 // Overridden public members from NLPObjGrad
196 
198 {
199  NLPObjGrad::set_Gf(Gf);
200  Gf_updated_ = false;
201 }
202 
203 // Overridden protected members from NLP
204 
206  const Vector& x, bool newx
207  ,const ZeroOrderInfo& zero_order_info
208  ) const
209 {
210  evalModel(x,newx,&zero_order_info,NULL);
211 }
212 
214  const Vector& x, bool newx
215  ,const ZeroOrderInfo& zero_order_info
216  ) const
217 {
218  evalModel(x,newx,&zero_order_info,NULL);
219 }
220 
221 // Overridden protected members from NLPObjGrad
222 
224  const Vector& x, bool newx
225  ,const ObjGradInfo& obj_grad_info
226  ) const
227 {
228  evalModel(x,newx,NULL,&obj_grad_info);
229 }
230 
231 // Protected functions to be used by subclasses
232 
234  :showModelEvaluatorTrace_(false),initialized_(false)
235  ,obj_scale_(1.0),has_bounds_(false)
236  ,force_xinit_in_bounds_(true),num_bounded_x_(0)
237  ,x_guess_bounds_updated_(false)
238 {}
239 
241  const Teuchos::RCP<Thyra::ModelEvaluator<value_type> > &model,
242  const int p_idx,
243  const int g_idx
244  )
245 {
246 
247  using Teuchos::dyn_cast;
251  typedef ::Thyra::ModelEvaluatorBase MEB;
252 
253  initialized_ = false;
254  x_guess_bounds_updated_ = false;
256 
257  const char msg_err[] = "NLPThyraModelEvaluatorBase::initialize(...): Errror!";
258  Thyra::ModelEvaluatorBase::OutArgs<value_type> model_outArgs = model->createOutArgs();
259  TEUCHOS_TEST_FOR_EXCEPTION( model.get() == NULL, std::invalid_argument, msg_err );
260  TEUCHOS_TEST_FOR_EXCEPTION( p_idx >= 0 && ( p_idx > model_outArgs.Np()-1 ), std::invalid_argument, msg_err );
261  TEUCHOS_TEST_FOR_EXCEPTION( g_idx >= 0 && ( g_idx > model_outArgs.Ng()-1 ), std::invalid_argument, msg_err );
262  //
263  Teuchos::RCP<const Thyra::VectorSpaceBase<value_type> > model_space_x(model->get_x_space());
264  const bool no_model_x = (model_space_x.get() == NULL);
265  Teuchos::RCP<const Thyra::VectorSpaceBase<value_type> > model_space_f(model->get_f_space());
266  const bool no_model_f = (model_space_f.get() == NULL);
267  //
268  if( !no_model_f ) {
269  TEUCHOS_TEST_FOR_EXCEPTION( !model_outArgs.supports(MEB::OUT_ARG_W), std::invalid_argument, msg_err );
270  MEB::DerivativeProperties model_W_properties = model_outArgs.get_W_properties();
271  TEUCHOS_TEST_FOR_EXCEPTION( model_W_properties.supportsAdjoint==false, std::invalid_argument, msg_err );
272  TEUCHOS_TEST_FOR_EXCEPTION( model_W_properties.rank==MEB::DERIV_RANK_DEFICIENT, std::invalid_argument, msg_err );
273  /*
274  if(p_idx >= 0 ) {
275  TEUCHOS_TEST_FOR_EXCEPTION( model_outArgs.supports(MEB::OUT_ARG_DfDp,p_idx).none(), std::invalid_argument, msg_err );
276  if(g_idx >= 0) {
277  TEUCHOS_TEST_FOR_EXCEPTION( model_outArgs.supports(MEB::OUT_ARG_DgDp,g_idx,p_idx).none(), std::invalid_argument, msg_err );
278  }
279  }
280  if(g_idx >= 0) {
281  TEUCHOS_TEST_FOR_EXCEPTION( model_outArgs.supports(MEB::OUT_ARG_DgDx,g_idx).none(), std::invalid_argument, msg_err );
282  }
283  */
284  }
285 
286  model_ = model;
287  p_idx_ = p_idx;
288  g_idx_ = g_idx;
289 
290  if(p_idx >= 0 ) {
291  DfDp_supports_op_ = model_outArgs.supports(MEB::OUT_ARG_DfDp,p_idx).supports(MEB::DERIV_LINEAR_OP);
292  DfDp_supports_mv_ = model_outArgs.supports(MEB::OUT_ARG_DfDp,p_idx).supports(MEB::DERIV_MV_BY_COL);
293  }
294  else {
295  DfDp_supports_op_ = false;
296  DfDp_supports_mv_ = false;
297  }
298 
299  VectorSpace::space_ptr_t space_xI;
300  if(p_idx >= 0)
301  space_xI = Teuchos::rcp(new VectorSpaceThyra(model_->get_p_space(p_idx)));
302  VectorSpace::space_ptr_t space_xD;
303  //
304  if(!no_model_x) {
305  space_xD = Teuchos::rcp(new VectorSpaceThyra(model_space_x));
306  if (p_idx >= 0) {
307  VectorSpace::space_ptr_t spaces_xD_xI[] = { space_xD, space_xI };
308  space_x_ = Teuchos::rcp(new VectorSpaceBlocked(spaces_xD_xI,2));
309  }
310  else {
311  space_x_ = space_xD;
312  }
313  }
314  else {
315  space_x_ = space_xI;
316  }
318 
319  if(!no_model_f)
320  space_c_ = Teuchos::rcp(new VectorSpaceThyra(model_space_f));
321  else
323 
324  xinit_ = space_x_->create_member(); *xinit_ = 0.0;
325  xl_ = space_x_->create_member(); *xl_ = -NLP::infinite_bound();
326  xu_ = space_x_->create_member(); *xu_ = +NLP::infinite_bound();
327 
328  if(!no_model_f) {
329 
330  factory_Gc_ = BasisSystemComposite::factory_Gc();
331 
333  new BasisSystemComposite(
334  space_x_
335  ,space_c_
339  )
340  );
341 
342  }
343  else {
344 
346 
348 
349  }
350 
351  if(g_idx >= 0) {
352  model_g_ = createMember(model_->get_g_space(g_idx));
353  }
354 
355 }
356 
358 {
359 
360  using Teuchos::dyn_cast;
364  typedef ::Thyra::ModelEvaluatorBase MEB;
365 
367  return;
368 
369  Thyra::ModelEvaluatorBase::OutArgs<value_type>
370  model_outArgs = model_->createOutArgs();
372  model_space_x = model_->get_x_space();
373  const bool
374  no_model_x = (model_space_x.get() == NULL);
376  model_space_f = model_->get_f_space();
377  const bool
378  no_model_f = (model_space_f.get() == NULL);
379 
380  Thyra::ModelEvaluatorBase::InArgs<value_type>
381  model_initialGuess = model_->getNominalValues(),
382  model_lowerBounds = model_->getLowerBounds(),
383  model_upperBounds = model_->getUpperBounds();
384 
385  if(!no_model_x) {
386  VectorSpace::vec_mut_ptr_t xinit_D = xinit_->sub_view(basis_sys_->var_dep());
387  copy_from_model_x( model_initialGuess.get_x().get(), &*xinit_D );
388  VectorSpace::vec_mut_ptr_t xl_D = xl_->sub_view(basis_sys_->var_dep());
389  copy_from_model_x( model_lowerBounds.get_x().get(), &*xl_D );
390  VectorSpace::vec_mut_ptr_t xu_D = xu_->sub_view(basis_sys_->var_dep());
391  copy_from_model_x( model_upperBounds.get_x().get(), &*xu_D );
392  }
393 
394  if(p_idx_ >= 0) {
395  Range1D var_indep = ( basis_sys_.get() ? basis_sys_->var_indep() : Range1D() );
396  VectorSpace::vec_mut_ptr_t xinit_I = xinit_->sub_view(var_indep);
397  copy_from_model_p( model_initialGuess.get_p(p_idx_).get(), &*xinit_I );
398  VectorSpace::vec_mut_ptr_t xl_I = xl_->sub_view(var_indep);
399  copy_from_model_p( model_lowerBounds.get_p(p_idx_).get(), &*xl_I );
400  VectorSpace::vec_mut_ptr_t xu_I = xu_->sub_view(var_indep);
401  copy_from_model_p( model_upperBounds.get_p(p_idx_).get(), &*xu_I );
402  }
403 
405 
406 }
407 
409 {
412  ,"NLPThyraModelEvaluatorBase::assert_is_initialized() : Error, "
413  "NLPThyraModelEvaluatorBase::initialize() has not been called yet."
414  );
415 }
416 
417 void NLPThyraModelEvaluatorBase::copy_from_model_x( const Thyra::VectorBase<value_type>* model_x, VectorMutable* x_D ) const
418 {
419  if(!model_x) return;
420  *x_D = AbstractLinAlgPack::VectorMutableThyra(Teuchos::rcp(const_cast<Thyra::VectorBase<value_type>*>(model_x),false));
421 }
422 
423 void NLPThyraModelEvaluatorBase::copy_from_model_p( const Thyra::VectorBase<value_type> *model_p, VectorMutable* x_I ) const
424 {
425  if(!model_p) return;
426  *x_I = AbstractLinAlgPack::VectorMutableThyra(Teuchos::rcp(const_cast<Thyra::VectorBase<value_type>*>(model_p),false));
427 }
428 
430  const Vector &x
431  ,Thyra::ModelEvaluatorBase::InArgs<value_type> *model_inArgs_inout
432  ) const
433 {
434  using Teuchos::dyn_cast;
435  using Teuchos::RCP;
436  using Teuchos::rcp_const_cast;
437  using Teuchos::rcp_dynamic_cast;
439  typedef Thyra::ModelEvaluatorBase MEB;
440  //
441  // Set the input arguments
442  //
443  MEB::InArgs<value_type> &model_inArgs = *model_inArgs_inout;
444  if( basis_sys_.get() ) {
445  const Range1D
446  var_dep = basis_sys_->var_dep(),
447  var_indep = basis_sys_->var_indep();
448  RCP<const Vector> xD = x.sub_view(var_dep), xI;
449  if(p_idx_>=0) xI = x.sub_view(var_indep);
450  model_inArgs.set_x(dyn_cast<const VectorMutableThyra>(*xD).thyra_vec().assert_not_null());
451  if(p_idx_ >= 0)
452  model_inArgs.set_p(p_idx_,dyn_cast<const VectorMutableThyra>(*xI).thyra_vec().assert_not_null());
453  }
454  else { // no dependent vars
456  model_inArgs.set_p(p_idx_,dyn_cast<const VectorMutableThyra>(x).thyra_vec().assert_not_null());
457  }
458 }
459 
461  const Vector &x
462  ,bool newx
463  ,const ZeroOrderInfo *zero_order_info
464  ,const ObjGradInfo *obj_grad_info
465  ,const NLPFirstOrder::FirstOrderInfo *first_order_info
466  ,Thyra::ModelEvaluatorBase::InArgs<value_type> *model_inArgs_inout
467  ,Thyra::ModelEvaluatorBase::OutArgs<value_type> *model_outArgs_inout
468  ,MatrixOp* *Gc_out
469  ,VectorMutable* *Gf_out
470  ,value_type* *f_out
471  ,VectorMutable* *c_out
472  ) const
473 {
474  using Teuchos::dyn_cast;
475  using Teuchos::RCP;
476  using Teuchos::rcp_const_cast;
477  using Teuchos::rcp_dynamic_cast;
481  typedef Thyra::ModelEvaluatorBase MEB;
482  typedef MEB::DerivativeMultiVector<value_type> DerivMV;
483  typedef MEB::Derivative<value_type> Deriv;
484  //
486  //
487  // Set the input arguments
488  //
489  MEB::InArgs<value_type> &model_inArgs = *model_inArgs_inout;
490  set_x(x,&model_inArgs);
491  //
492  // Set the output arguments
493  //
494  MatrixOp *Gc = NULL;
495  VectorMutable *Gf = NULL;
496  value_type *f = NULL;
497  VectorMutable *c = NULL;
498  //
499  if(zero_order_info) {
500  f = zero_order_info->f;
501  c = zero_order_info->c;
502  }
503  else if(obj_grad_info) {
504  Gf = obj_grad_info->Gf;
505  f = obj_grad_info->f;
506  c = obj_grad_info->c;
507  }
508  else if(first_order_info) {
509  Gc = first_order_info->Gc;
510  Gf = first_order_info->Gf;
511  f = first_order_info->f;
512  c = first_order_info->c;
513  }
514  else {
515  TEUCHOS_TEST_FOR_EXCEPT(true); // Should never be called!
516  }
517  //
518  MEB::OutArgs<value_type> &model_outArgs = *model_outArgs_inout;
519  if( f && (g_idx_>=0) && !f_updated_ ) {
520  model_outArgs.set_g(g_idx_,model_g_.assert_not_null()); // ToDo: Make more general!
521  }
522  if( c && !c_updated_ ) {
524  get_thyra_vector(*space_c_,c,&thyra_c);
525  model_outArgs.set_f(thyra_c.assert_not_null());
526  }
527  if( Gf && !Gf_updated_ ) {
528  if(g_idx_>=0) {
529  if(p_idx_>=0) {
530  const Range1D
531  var_dep = ( basis_sys_.get() ? basis_sys_->var_dep() : Range1D::Invalid ),
532  var_indep = ( basis_sys_.get() ? basis_sys_->var_indep() : Range1D() );
533  if( var_dep.size() ) {
534  model_outArgs.set_DgDx(
535  g_idx_
536  ,DerivMV(
537  rcp_const_cast<Thyra::VectorBase<value_type> >(
538  dyn_cast<VectorMutableThyra>(*Gf->sub_view(var_dep)).thyra_vec()
539  ).assert_not_null()
540  ,MEB::DERIV_TRANS_MV_BY_ROW
541  )
542  );
543  }
544  model_outArgs.set_DgDp(
545  g_idx_,p_idx_
546  ,DerivMV(
547  rcp_const_cast<Thyra::VectorBase<value_type> >(
548  dyn_cast<VectorMutableThyra>(*Gf->sub_view(var_indep)).thyra_vec()
549  ).assert_not_null()
550  ,MEB::DERIV_TRANS_MV_BY_ROW
551  )
552  );
553  }
554  }
555  }
556  if(Gc_out) *Gc_out = Gc;
557  if(Gf_out) *Gf_out = Gf;
558  if(f_out) *f_out = f;
559  if(c_out) *c_out = c;
560 }
561 
563  Thyra::ModelEvaluatorBase::OutArgs<value_type> *model_outArgs_inout
564  ,VectorMutable *Gf
565  ,value_type *f
566  ,VectorMutable *c
567  ) const
568 {
569  typedef Thyra::ModelEvaluatorBase MEB;
570  MEB::OutArgs<value_type> &model_outArgs = *model_outArgs_inout;
571  if( f && !f_updated_ ) {
572  if(g_idx_>=0) {
573  *f = obj_scale_ * ::Thyra::get_ele(*model_g_,0);
574  }
575  else {
576  *f = 0.0;
577  }
578  f_updated_ = true;
579  }
580  if( c && !c_updated_ ) {
582  thyra_c = model_outArgs.get_f();
583  commit_thyra_vector(*space_c_,c,&thyra_c);
584  model_outArgs.set_f(Teuchos::null);
585  c_updated_ = true;
586  }
587  if( Gf && !Gf_updated_ ) {
588  if(g_idx_>=0) {
589  const Range1D
590  var_dep = ( basis_sys_.get() ? basis_sys_->var_dep() : Range1D::Invalid ),
591  var_indep = ( basis_sys_.get() ? basis_sys_->var_indep() : Range1D() );
592  if (obj_scale_ != 1.0 )
593  Vt_S( Gf, obj_scale_ );
594  if(var_dep.size())
595  Gf->sub_view(var_dep)->has_changed();
596  if(var_indep.size())
597  Gf->sub_view(var_indep)->has_changed();
598  }
599  else {
600  *Gf = 0.0;
601  }
602  Gf_updated_ = true;
603  }
604 }
605 
606 // private
607 
609  const Vector &x
610  ,bool newx
611  ,const ZeroOrderInfo *zero_order_info
612  ,const ObjGradInfo *obj_grad_info
613  ) const
614 {
615  typedef Thyra::ModelEvaluatorBase MEB;
616  //
617  // Get output and verbosity
618  //
620  out = this->getOStream();
622  verbLevel = ( showModelEvaluatorTrace() ? this->getVerbLevel() : Teuchos::VERB_NONE );
623  Teuchos::OSTab tab(out);
625  VOTSME modelOutputTempState(model_,out,verbLevel);
626  if(out.get() && static_cast<int>(verbLevel) >= static_cast<int>(Teuchos::VERB_LOW))
627  *out << "\nEntering MoochoPack::NLPThyraModelEvaluatorBase::evalModel(...) ...\n";
628  //
629  // Set the input and output arguments
630  //
631  MEB::InArgs<value_type> model_inArgs = model_->createInArgs();
632  MEB::OutArgs<value_type> model_outArgs = model_->createOutArgs();
633  VectorMutable *Gf = NULL;
634  value_type *f = NULL;
635  VectorMutable *c = NULL;
637  x,newx,zero_order_info,obj_grad_info,NULL
638  ,&model_inArgs,&model_outArgs,NULL,&Gf,&f,&c
639  );
640  //
641  // Evaluate the model
642  //
643  model_->evalModel(model_inArgs,model_outArgs);
644  //
645  // Postprocess the output arguments
646  //
647  postprocessBaseOutArgs(&model_outArgs,Gf,f,c);
648  //
649  if(out.get() && static_cast<int>(verbLevel) >= static_cast<int>(Teuchos::VERB_LOW))
650  *out << "\nLeaving MoochoPack::NLPThyraModelEvaluatorBase::evalModel(...) ...\n";
651 }
652 
653 } // end namespace NLPInterfacePack
void initialize(bool test_setup)
Initialize the NLP for its first use.
virtual value_type & f()
Returns non-const *this->get_f().
virtual vec_ptr_t sub_view(const Range1D &rng) const
Create an abstract view of a vector object .
AbstractLinAlgPack::size_type size_type
VectorMutable * Gf
Pointer to gradient of objective function Gf (may be NULL if not set)
virtual vec_mut_ptr_t sub_view(const Range1D &rng)
Create a mutable abstract view of a vector object.
VectorMutable * c
Pointer to constraints residual c (Will be NULL if not set)
Struct for gradient (objective), objective and constriants (pointers)
MatrixOp * Gc
Pointer to Jacobian of equality constraints Gc (may be NULL if not set)
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
VectorMutable * c
Pointer to constraints residual c (may be NULL if not set)
void postprocessBaseOutArgs(Thyra::ModelEvaluatorBase::OutArgs< value_type > *model_outArgs_inout, VectorMutable *Gf, value_type *f, VectorMutable *c) const
void Vt_S(VectorMutable *v_lhs, const value_type &alpha)
v_lhs *= alpha
VectorMutable * Gf
Pointer to gradient of objective function Gf (may be NULL if not set)
VectorSpace adapter subclass for Thyra::VectorSpaceBase<value_type> .
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void initializeBase(const Teuchos::RCP< Thyra::ModelEvaluator< value_type > > &model, const int p_idx, const int g_idx)
Initialize given a Thyra::ModelEvaluator and a description of how to interpret it.
T * get() const
void report_final_solution(const Vector &x, const Vector *lambda, const Vector *nu, bool optimal)
value_type * f
Pointer to objective function f (may be NULL if not set)
void get_thyra_vector(const VectorSpaceThyra &thyra_vec_spc, const Vector &vec, Teuchos::RCP< const Thyra::VectorBase< value_type > > *thyra_vec)
virtual void unset_quantities()
Call to unset all storage quantities (both in this class and all subclasses).
void imp_calc_f(const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const
void commit_thyra_vector(const VectorSpaceThyra &thyra_vec_spc, VectorMutable *vec, Teuchos::RCP< Thyra::VectorBase< value_type > > *thyra_vec)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void imp_calc_Gf(const Vector &x, bool newx, const ObjGradInfo &obj_grad_info) const
virtual void has_changed() const
Must be called by any vector subclass that modifies this vector object!
void copy_from_model_p(const Thyra::VectorBase< value_type > *model_p, VectorMutable *x_I) const
void copy_from_model_x(const Thyra::VectorBase< value_type > *model_x, VectorMutable *x_D) const
T_To & dyn_cast(T_From &from)
VectorMutable adapter subclass for Thyra::VectorBase.
std::ostream * out
Struct for zero and first order quantities (pointers)
virtual void set_c(VectorMutable *c)
Set a pointer to a vector to be updated when this->calc_c() is called.
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
size_type num_bounded(const Vector &xl, const Vector &xu, value_type inf_bound)
Count the number of finitly bounded elements in xl <= x <= xu.
Struct for objective and constriants (pointer).
const RCP< T > & assert_not_null() const
VectorMutable * c
Pointer to equality constraints residule c (may be NULL if not set)
MatrixOp adapter subclass for Thyra::LinearOpBase.
MatrixOpNonsing adapter subclass for Thyra::Nonlin::LinearOpWithSolve.
Thrown if any member functions are called before initialize() has been called.
Teuchos::RCP< Thyra::ModelEvaluator< value_type > > model_
AbstractLinAlgPack::value_type value_type
void set_x(const Vector &x, Thyra::ModelEvaluatorBase::InArgs< value_type > *model_inArgs_inout) const
Abstract interface for mutable coordinate vectors {abstract}.
value_type * f
Pointer to objective function f (Will be NULL if not set)
void updateInitialGuessAndBounds() const
Update the initial guess and bounds .
virtual VectorMutable & Gf()
Returns non-const *this->get_Gf().
void imp_calc_c(const Vector &x, bool newx, const ZeroOrderInfo &zero_order_info) const
value_type * f
Pointer to objective function f (may be NULL if not set)
void evalModel(const Vector &x, bool newx, const ZeroOrderInfo *zero_order_info, const ObjGradInfo *obj_grad_info) const
static value_type infinite_bound()
Value for an infinite bound.
virtual EVerbosityLevel getVerbLevel() const
virtual void set_Gf(VectorMutable *Gf)
Set a pointer to a vector to be updated when this->calc_Gf() is called.
virtual void set_f(value_type *f)
Set a pointer to an value to be updated when this->calc_f() is called.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
virtual VectorMutable & c()
Returns non-const *this->get_c().