48 #include "MoochoPack_DampenCrossTermStd_Step.hpp"
49 #include "MoochoPack_moocho_algo_conversion.hpp"
50 #include "IterationPack_print_algorithm_step.hpp"
51 #include "ConstrainedOptPack/src/VectorWithNorms.h"
52 #include "AbstractLinAlgPack/src/MatrixWithOpFactorized.hpp"
53 #include "DenseLinAlgPack_LinAlgOpPack.hpp"
54 #include "DenseLinAlgPack_DVectorClass.hpp"
55 #include "DenseLinAlgPack_DVectorOut.hpp"
58 : frac_descent_(frac_descent)
62 , poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
65 using DenseLinAlgPack::norm_inf;
68 NLPAlgo &algo = rsqp_algo(_algo);
69 NLPAlgoState &s = algo.rsqp_state();
71 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
72 std::ostream& out = algo.track().journal_out();
75 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
76 using IterationPack::print_algorithm_step;
77 print_algorithm_step( _algo, step_poss, type, assoc_step_poss, out );
80 if( s.w().updated_k(0) ) {
83 const DVectorSlice rGf_k = s.rGf().get_k(0)();
85 V_InvMtV( &Inv_rHL_rGf, dynamic_cast<MatrixWithOpFactorized&>(s.rHL().get_k(0))
90 rGfT_Inv_rHL_rGf =
dot( Inv_rHL_rGf(), rGf_k ),
91 rGfT_Inv_rHL_w =
dot( Inv_rHL_rGf(), s.w().get_k(0)() ),
92 term = -(1.0-frac_descent()) * (rGfT_Inv_rHL_rGf + 2*small_num)
93 / (rGfT_Inv_rHL_w + small_num);
95 if( rGfT_Inv_rHL_w >= 0.0 ) {
98 s.zeta().set_k(0) = 1.0;
103 s.zeta().set_k(0) = std::_MIN( term, 1.0 );
106 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
107 out <<
"\nterm1 = rGf_k'*inv(rHL_k)*rGf_k = " << rGfT_Inv_rHL_rGf;
108 out <<
"\nterm2 = rGf_k'*inv(rHL_k)*w_k = " << rGfT_Inv_rHL_w;
109 out <<
"\n(1-frac_descent)*(term1+2*small)/(term2+small) = " << term;
110 out <<
"\nzeta_k = " << s.zeta().get_k(0)
114 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_VECTORS) ) {
115 out <<
"\ninv(rHL_k)*rGf_k = " << Inv_rHL_rGf();
118 if( rGfT_Inv_rHL_rGf < 0.0 ) {
119 std::ostringstream omsg;
121 <<
"Error, rGf_k'*inv(rHL_k)*rGf_k = " << rGfT_Inv_rHL_rGf <<
" < 0.0 and therefore "
122 <<
"the reduced Hessian rHL_k can not be positive definite";
123 if( (
int)(olevel) >= (
int)(PRINT_ALGORITHM_STEPS) ) {
126 throw std::runtime_error( std::string(
"DampenCrossTermStd_Step::do_step(...) : ")
135 , poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss
136 , std::ostream& out,
const std::string& L )
const
139 << L <<
"*** Compute the dampening parameter for the reduced QP cross term w_k\n"
140 << L <<
"default: frac_descent = " << frac_descent() << std::endl
141 << L <<
"if w_k is update then\n"
142 << L <<
" find zeta_k s.t.\n"
143 << L <<
" Gf_k'*Z_k*pz_k approx\n"
144 << L <<
" - zeta_k * rGf_k'*inv(rHL_k)*w_k - rGf_k'*inv(rHL_k)*rGf_k\n"
145 << L <<
" <= - frac_descent * rGf_k'*inv(rHL_k)*rGf_k\n"
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
void V_InvMtV(VectorMutable *v_lhs, const MatrixNonsing &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2)
value_type dot(const Vector &v_rhs1, const Vector &v_rhs2)
DampenCrossTermStd_Step(const value_type &frac_descent=0.9)
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)