45 #include "MoochoPack_TangentialStepIP_Step.hpp" 46 #include "MoochoPack_EvalNewPointTailoredApproach_Step.hpp" 47 #include "MoochoPack_Exceptions.hpp" 48 #include "MoochoPack_IpState.hpp" 49 #include "MoochoPack_moocho_algo_conversion.hpp" 50 #include "IterationPack_print_algorithm_step.hpp" 51 #include "NLPInterfacePack_NLPDirect.hpp" 52 #include "AbstractLinAlgPack_MatrixSymDiagStd.hpp" 53 #include "AbstractLinAlgPack_MatrixSymOpNonsing.hpp" 54 #include "AbstractLinAlgPack_MatrixOpOut.hpp" 55 #include "AbstractLinAlgPack_VectorMutable.hpp" 56 #include "AbstractLinAlgPack_VectorStdOps.hpp" 57 #include "AbstractLinAlgPack_VectorOut.hpp" 58 #include "AbstractLinAlgPack_assert_print_nan_inf.hpp" 59 #include "AbstractLinAlgPack_LinAlgOpPack.hpp" 60 #include "Teuchos_dyn_cast.hpp" 61 #include "Teuchos_Assert.hpp" 71 using Teuchos::dyn_cast;
72 using AbstractLinAlgPack::assert_print_nan_inf;
76 using LinAlgOpPack::V_MtV;
82 NLPAlgo &algo = rsqp_algo(_algo);
83 IpState &s = dyn_cast<IpState>(_algo.
state());
85 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
89 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
90 using IterationPack::print_algorithm_step;
91 print_algorithm_step( algo, step_poss, type, assoc_step_poss, out );
98 const MatrixSymDiagStd &invXu = s.invXu().get_k(0);
99 const MatrixSymDiagStd &invXl = s.invXl().get_k(0);
100 const value_type &mu = s.barrier_parameter().get_k(0);
101 const MatrixOp &Z_k = s.Z().get_k(0);
103 Teuchos::RCP<VectorMutable> rhs = s.Gf().get_k(0).clone();
104 Vp_StV( rhs.get(), mu, invXu.diag() );
105 Vp_StV( rhs.get(), -1.0*mu, invXl.diag() );
107 if( (
int)olevel >= (int)PRINT_ALGORITHM_STEPS )
109 out <<
"\n||Gf_k + mu_k*(invXu_k-invXl_k)||inf = " << rhs->norm_inf() << std::endl;
111 if( (
int)olevel >= (
int)PRINT_VECTORS)
113 out <<
"\nGf_k + mu_k*(invXu_k-invXl_k) =\n" << *rhs;
116 VectorMutable &qp_grad_k = s.qp_grad().set_k(0);
119 if( (
int)olevel >= (
int)PRINT_ALGORITHM_STEPS )
121 out <<
"\n||Z_k'*(Gf_k + mu_k*(invXu_k-invXl_k))||inf = " << qp_grad_k.norm_inf() << std::endl;
123 if( (
int)olevel >= (
int)PRINT_VECTORS )
125 out <<
"\nZ_k'*(Gf_k + mu_k*(invXu_k-invXl_k)) =\n" << qp_grad_k;
129 value_type &zeta = s.zeta().set_k(0);
130 const Vector &w_sigma = s.w_sigma().get_k(0);
135 Vp_StV(&qp_grad_k, zeta, w_sigma);
137 if( (
int)olevel >= (
int)PRINT_ALGORITHM_STEPS )
139 out <<
"\n||qp_grad_k||inf = " << qp_grad_k.norm_inf() << std::endl;
141 if( (
int)olevel >= (
int)PRINT_VECTORS )
143 out <<
"\nqp_grad_k =\n" << qp_grad_k;
148 const MatrixSymOp &rHL_k = s.rHL().get_k(0);
149 const MatrixSymOp &rHB_k = s.rHB().get_k(0);
150 MatrixSymOpNonsing &B_k = dyn_cast<MatrixSymOpNonsing>(s.B().set_k(0));
151 if (B_k.cols() != Z_k.cols())
154 dyn_cast<MatrixSymInitDiag>(B_k).init_identity(Z_k.space_rows(), 0.0);
159 if( (
int)olevel >= (
int)PRINT_VECTORS )
161 out <<
"\nB_k = rHL_k =\n" << B_k;
164 if( (
int)olevel >= (
int)PRINT_VECTORS )
166 out <<
"\nB_k = rHL_k + rHB_k =\n" << B_k;
170 VectorMutable &pz_k = s.pz().set_k(0);
175 V_MtV( &s.Zpz().set_k(0), s.Z().get_k(0),
no_trans, pz_k );
177 if( (
int)olevel >= (int)PRINT_ALGORITHM_STEPS )
179 out <<
"\n||pz||inf = " << s.pz().get_k(0).norm_inf()
183 if( (
int)olevel >= (int)PRINT_VECTORS )
185 out <<
"\npz_k = \n" << s.pz().get_k(0);
186 out <<
"\nnu_k = \n" << s.nu().get_k(0);
187 out <<
"\nZpz_k = \n" << s.Zpz().get_k(0);
191 if(algo.algo_cntr().check_results())
193 assert_print_nan_inf(s.pz().get_k(0),
"pz_k",
true,&out);
194 assert_print_nan_inf(s.Zpz().get_k(0),
"Zpz_k",
true,&out);
200 void TangentialStepIP_Step::print_step(
const Algorithm& algo
202 , std::ostream& out,
const std::string& L )
const 205 << L <<
"*** Calculate the null space step by solving an unconstrainted QP\n" 206 << L <<
"zeta_k = 1.0\n" 207 << L <<
"qp_grad_k = Z_k'*(Gf_k + mu_k*(invXu_k-invXl_k)) + zeta_k*w_sigma_k\n" 208 << L <<
"B_k = rHL_k + rHB_k\n" 209 << L <<
"pz_k = -inv(B_k)*qp_grad_k\n" 210 << L <<
"Zpz_k = Z_k*pz_k\n"
void Vt_S(VectorMutable *v_lhs, const value_type &alpha)
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
rSQP Algorithm control class.
void V_StV(VectorMutable *v_lhs, value_type alpha, const V &V_rhs)
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
void assign(MatrixOp *M_lhs, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
virtual std::ostream & journal_out() const
void M_StM(MatrixOp *M_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
void V_InvMtV(VectorMutable *v_lhs, const MatrixNonsing &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2)
AlgorithmTracker & track()
void Mp_StM(MatrixOp *mwo_lhs, value_type alpha, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
value_type sum(const Vector &v_rhs)