46 #include "NLPInterfacePack_NLPFirstOrderThyraModelEvaluator.hpp"
47 #include "AbstractLinAlgPack_LinAlgOpPack.hpp"
48 #include "AbstractLinAlgPack_VectorOut.hpp"
49 #include "AbstractLinAlgPack_ThyraAccessors.hpp"
50 #include "AbstractLinAlgPack_VectorSpaceThyra.hpp"
51 #include "AbstractLinAlgPack_VectorMutableThyra.hpp"
52 #include "AbstractLinAlgPack_MatrixOpNonsingThyra.hpp"
53 #include "AbstractLinAlgPack_BasisSystemComposite.hpp"
54 #include "AbstractLinAlgPack_VectorSpaceBlocked.hpp"
55 #include "AbstractLinAlgPack_VectorAuxiliaryOps.hpp"
56 #include "AbstractLinAlgPack_MatrixSymPosDefCholFactor.hpp"
57 #include "Thyra_ModelEvaluatorHelpers.hpp"
58 #include "Thyra_DetachedVectorView.hpp"
59 #include "Teuchos_AbstractFactoryStd.hpp"
60 #include "Teuchos_Assert.hpp"
61 #include "Teuchos_dyn_cast.hpp"
63 namespace NLPInterfacePack {
127 evalModel(x,newx,NULL,NULL,&first_order_info);
132 void NLPFirstOrderThyraModelEvaluator::evalModel(
135 ,
const ZeroOrderInfo *zero_order_info
136 ,
const ObjGradInfo *obj_grad_info
137 ,
const FirstOrderInfo *first_order_info
144 using Teuchos::rcp_const_cast;
145 using Teuchos::rcp_dynamic_cast;
151 typedef MEB::DerivativeMultiVector<value_type> DerivMV;
152 typedef MEB::Derivative<value_type> Deriv;
157 out = this->getOStream();
159 verbLevel = ( showModelEvaluatorTrace() ? this->getVerbLevel() : Teuchos::
VERB_NONE );
161 VOTSME modelOutputTempState(model_,out,verbLevel);
163 *out <<
"\nEntering MoochoPack::NLPFirstOrderThyraModelEvaluator::calc_point(...) ...\n";
167 MEB::InArgs<value_type> model_inArgs = model_->createInArgs();
168 MEB::OutArgs<value_type> model_outArgs = model_->createOutArgs();
170 VectorMutable *Gf = NULL;
171 value_type *
f = NULL;
172 VectorMutable *
c = NULL;
174 x,newx,zero_order_info,obj_grad_info,first_order_info
175 ,&model_inArgs,&model_outArgs,&Gc,&Gf,&f,&c
178 MatrixOpNonsing *C_aggr;
180 if( Gc && !Gc_updated_ ) {
181 BasisSystemComposite::get_C_N( Gc, &C_aggr, &N_aggr );
185 dyn_cast<MatrixOpNonsingThyra>(*C_aggr).set_uninitialized()
190 model_outArgs.set_DfDp(
195 dyn_cast<MatrixOpThyra>(*N_aggr).set_uninitialized()
198 ,MEB::DERIV_MV_BY_COL
206 model_outArgs.set_DfDp(p_idx_,Thyra::create_DfDp_mv(*model_,p_idx_,MEB::DERIV_MV_BY_COL));
208 if (model_inArgs.supports(MEB::IN_ARG_alpha))
209 model_inArgs.set_alpha(0.0);
210 if (model_inArgs.supports(MEB::IN_ARG_beta))
211 model_inArgs.set_beta(1.0);
216 model_->evalModel(model_inArgs,model_outArgs);
222 if( Gc && !Gc_updated_ ) {
223 RCP<MatrixOpNonsing> C_ptr;
233 RCP<Thyra::LinearOpWithSolveBase<value_type> >
234 model_W = model_outArgs.get_W();
235 model_W->setOStream(out);
236 if(showModelEvaluatorTrace())
237 model_W->setVerbLevel(verbLevel);
241 dyn_cast<MatrixOpThyra>(*N_aggr).initialize(model_outArgs.get_DfDp(p_idx_).getDerivativeMultiVector().getMultiVector(),
BLAS_Cpp::no_trans);
243 BasisSystemComposite::initialize_Gc(
244 this->
space_x(), basis_sys_->var_dep(), basis_sys_->var_indep()
253 *out <<
"\nLeaving MoochoPack::NLPFirstOrderThyraModelEvaluator::calc_point(...) ...\n";
vec_space_ptr_t space_c() const
void initialize(bool test_setup)
void postprocessBaseOutArgs(Thyra::ModelEvaluatorBase::OutArgs< value_type > *model_outArgs_inout, VectorMutable *Gf, value_type *f, VectorMutable *c) const
basic_OSTab< char > OSTab
basic_FancyOStream< char > FancyOStream
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_To & dyn_cast(T_From &from)
void initialize(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.
void initialize(bool test_setup)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
const basis_sys_ptr_t basis_sys() const
Returns an ExampleBasisSystem.
VectorMutable adapter subclass for Thyra::VectorBase.
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
const RCP< T > & assert_not_null() const
NLPFirstOrderThyraModelEvaluator()
Initialize to uninitialized.
MatrixOp adapter subclass for Thyra::LinearOpBase.
MatrixOpNonsing adapter subclass for Thyra::Nonlin::LinearOpWithSolve.
void set_Gc(MatrixOp *Gc)
Overridden to check the concrete type of Gc.
vec_space_ptr_t space_x() const
void imp_calc_Gc(const Vector &x, bool newx, const FirstOrderInfo &first_order_info) const
const NLPFirstOrder::mat_fcty_ptr_t factory_Gc() const
virtual void set_Gc(MatrixOp *Gc)
virtual VectorMutable & c()