44 #include "MoochoPack_TangentialStepWithoutBounds_Step.hpp"
45 #include "MoochoPack_EvalNewPointTailoredApproach_Step.hpp"
46 #include "MoochoPack_Exceptions.hpp"
47 #include "MoochoPack_moocho_algo_conversion.hpp"
48 #include "IterationPack_print_algorithm_step.hpp"
49 #include "NLPInterfacePack_NLPDirect.hpp"
50 #include "AbstractLinAlgPack_MatrixSymOpNonsing.hpp"
51 #include "AbstractLinAlgPack_MatrixOpOut.hpp"
52 #include "AbstractLinAlgPack_VectorMutable.hpp"
53 #include "AbstractLinAlgPack_VectorStdOps.hpp"
54 #include "AbstractLinAlgPack_VectorOut.hpp"
55 #include "AbstractLinAlgPack_assert_print_nan_inf.hpp"
56 #include "AbstractLinAlgPack_LinAlgOpPack.hpp"
57 #include "Teuchos_dyn_cast.hpp"
58 #include "Teuchos_Assert.hpp"
61 namespace LinAlgOpPack {
66 namespace MoochoPack {
84 using AbstractLinAlgPack::assert_print_nan_inf;
89 using LinAlgOpPack::V_MtV;
91 NLPAlgo &algo = rsqp_algo(_algo);
94 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
95 EJournalOutputLevel ns_olevel = algo.algo_cntr().null_space_journal_output_level();
99 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
100 using IterationPack::print_algorithm_step;
101 print_algorithm_step( algo, step_poss, type, assoc_step_poss, out );
104 if( algo.nlp().num_bounded_x() )
106 true, std::logic_error
107 ,
"TangentialStepWithoutBounds_Step::do_step(...): Error, "
108 "can't solve for pz for NLP with undecomposed constraints or "
109 "has bounds on the variables");
114 VectorMutable &qp_grad_k = s.qp_grad().set_k(0) = s.rGf().get_k(0);
116 IterQuantityAccess<value_type> &zeta_iq = s.zeta();
117 IterQuantityAccess<VectorMutable> &w_iq = s.w();
118 if( w_iq.updated_k(0) && zeta_iq.updated_k(0) ) {
120 Vp_StV( &qp_grad_k, zeta_iq.get_k(0), w_iq.get_k(0) );
124 VectorMutable &pz_k = s.pz().set_k(0);
125 const MatrixSymOpNonsing &rHL_k =
dyn_cast<MatrixSymOpNonsing>(s.rHL().get_k(0));
130 s.nu().set_k(0) = 0.0;
132 value_type pz_norm_inf = -1.0;
133 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
134 pz_norm_inf = pz_k.norm_inf();
135 out <<
"\n||pz_k||inf = " << pz_norm_inf << endl;
137 if( static_cast<int>(ns_olevel) >= static_cast<int>(PRINT_VECTORS) )
138 out <<
"\npz_k = \n" << pz_k << std::endl;
141 const bool dampen_pz = max_pz_norm() >= 0.0 && s.
k() <= num_pz_damp_iters();
142 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
144 <<
"\nChecking if we need to dampen pz:"
145 <<
" ( (max_pz_norm="<<max_pz_norm()<<
") >= 0.0 )"
146 <<
" && ( (k="<<s.
k()<<
") <= (num_pz_damp_iters="<<num_pz_damp_iters()<<
") ) : "
147 << ( dampen_pz ?
"true, dampen pz ..." :
"false, no dampen pz!" )
153 if (pz_norm_inf < 0.0 )
154 pz_norm_inf = pz_k.norm_inf();
155 const value_type pz_damp_factor = ( max_pz_norm() / pz_norm_inf );
156 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
158 <<
"\npz_damp_factor = max_pz_norm / ||pz||inf = "
159 << max_pz_norm() <<
" / " << pz_norm_inf <<
" = "
162 Vt_S( &pz_k, pz_damp_factor );
166 V_MtV( &s.Zpz().set_k(0), s.Z().get_k(0),
no_trans, pz_k );
168 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
169 out <<
"\n||pz_k||inf = " << s.pz().get_k(0).norm_inf()
170 <<
"\n||Zpz_k||2 = " << s.Zpz().get_k(0).norm_2() << std::endl;
173 if( static_cast<int>(ns_olevel) >= static_cast<int>(PRINT_VECTORS) ) {
174 out <<
"\npz_k = \n" << s.pz().get_k(0);
178 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_VECTORS) ) {
179 out <<
"\nnu_k = \n" << s.nu().get_k(0);
180 out <<
"\nZpz_k = \n" << s.Zpz().get_k(0);
184 if(algo.algo_cntr().check_results()) {
185 assert_print_nan_inf(s.pz().get_k(0),
"pz_k",
true,&out);
186 assert_print_nan_inf(s.Zpz().get_k(0),
"Zpz_k",
true,&out);
195 , std::ostream& out,
const std::string& L )
const
198 << L <<
"*** Calculate the null space step by solving an unconstrainted QP\n"
199 << L <<
"qp_grad_k = rGf_k + zeta_k * w_k\n"
201 << L <<
" min qp_grad_k' * pz_k + 1/2 * pz_k' * rHL_k * pz_k\n"
202 << L <<
" pz_k <: R^(n-r)\n"
203 << L <<
"Zpz_k = Z_k * pz_k\n"
204 << L <<
"nu_k = 0\n";
void Vt_S(VectorMutable *v_lhs, const value_type &alpha)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
T_To & dyn_cast(T_From &from)
rSQP Algorithm control class.
void V_StV(VectorMutable *v_lhs, value_type alpha, const V &V_rhs)
void print_step(const Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss, std::ostream &out, const std::string &leading_str) const
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
virtual std::ostream & journal_out() const
Reduced space SQP state encapsulation interface.
void V_InvMtV(VectorMutable *v_lhs, const MatrixNonsing &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2)
AlgorithmTracker & track()
void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta=1.0)
TangentialStepWithoutBounds_Step()
NLPAlgoState & rsqp_state()
<<std aggr>="">> members for algo_cntr