51 #include "ConstrainedOptPack/src/VectorWithNorms.h"
52 #include "AbstractLinAlgPack/src/MatrixWithOpFactorized.hpp"
58 : frac_descent_(frac_descent)
69 NLPAlgoState &s = algo.rsqp_state();
72 std::ostream&
out = algo.track().journal_out();
80 if( s.w().updated_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 );
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";
126 throw std::runtime_error( std::string(
"DampenCrossTermStd_Step::do_step(...) : ")
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
EJournalOutputLevel
enum for journal output.
void print_algorithm_step(const Algorithm &algo, Algorithm::poss_type step_poss, EDoStepType type, Algorithm::poss_type assoc_step_poss, std::ostream &out)
Prints to 'out' the algorithm step.
void V_InvMtV(VectorMutable *v_lhs, const MatrixNonsing &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2)
v_lhs = inv(op(M_rhs1)) * v_rhs2
value_type dot(const Vector &v_rhs1, const Vector &v_rhs2)
result = v_rhs1' * v_rhs2
DenseLinAlgPack::VectorSliceTmpl< value_type > DVectorSlice
AbstractLinAlgPack::value_type value_type
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)
value_type norm_inf(const DVectorSlice &vs_rhs)
result = ||vs_rhs||infinity (BLAS IxAMAX)
NLPAlgo & rsqp_algo(Algorithm &algo)
Convert from a Algorithm to a NLPAlgo.
value_type dot(const DVectorSlice &vs_rhs1, const DVectorSlice &vs_rhs2)
result = vs_rhs1' * vs_rhs2 (BLAS xDOT)