46 #include "MoochoPack_CheckSkipBFGSUpdateStd_Step.hpp"
47 #include "MoochoPack_moocho_algo_conversion.hpp"
48 #include "IterationPack_print_algorithm_step.hpp"
49 #include "AbstractLinAlgPack_MatrixSymOp.hpp"
50 #include "AbstractLinAlgPack_MatrixOpOut.hpp"
52 namespace MoochoPack {
55 value_type skip_bfgs_prop_const
57 :skip_bfgs_prop_const_(skip_bfgs_prop_const)
65 NLPAlgo &algo = rsqp_algo(_algo);
68 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
72 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
73 using IterationPack::print_algorithm_step;
74 print_algorithm_step( algo, step_poss, type, assoc_step_poss, out );
77 IterQuantityAccess<MatrixSymOp>
79 if( rHL.updated_k(-1) ) {
80 bool skip_update =
true;
81 if( !s.Ypy().updated_k(-1) || !s.Zpz().updated_k(-1)
82 || !s.rGL().updated_k(-1) || !s.c().updated_k(-1) )
84 if( (
int)olevel >= (int)PRINT_ALGORITHM_STEPS ) {
86 <<
"\n*** Warning, rHL_km1 is updated but one or more of the quantities Ypy_km1, Zpz_km1\n"
87 ",rGL_km1 and c_km1 are not updated. Therefore, there is not sufficient information\n"
88 "to determine if to skip the BFGS update or not. Check storage requirements for\n"
89 " the above quantities\n"
90 "The BFGS wupdate will be skipped in this case ...\n";
100 nrm_rGL_km1 = s.rGL().get_k(-1).norm_2(),
101 nrm_c_km1 = s.c().get_k(-1).norm_2(),
102 nrm_Zpz_km1 = s.Zpz().get_k(-1).norm_2(),
103 nrm_Ypy_km1 = s.Ypy().get_k(-1).norm_2();
106 ratio = ( skip_bfgs_prop_const() / ::sqrt( nrm_rGL_km1 + nrm_c_km1 ) )
107 * ( nrm_Zpz_km1 / nrm_Ypy_km1 );
109 skip_update = ratio < 1.0;
110 if( (
int)olevel >= (int)PRINT_ALGORITHM_STEPS ) {
113 <<
"ratio = (skip_bfgs_prop_const/sqrt(||rGL_km1||+||c_km1||))*(||Zpz_km1||/||Ypy_km1||)\n"
114 <<
" = (" << skip_bfgs_prop_const() <<
"/sqrt("<<nrm_rGL_km1<<
"+"<<nrm_c_km1<<
"))\n"
115 <<
" * ("<<nrm_Zpz_km1<<
"/"<<nrm_Ypy_km1<<
")\n"
116 <<
" = " << ratio << std::endl
117 <<
"ratio " << (skip_update ?
'<' :
'>' ) <<
" 1\n"
119 ?
"Skipping BFGS update ...\n"
120 :
"Perform BFGS update if you can ...\n" );
124 if( (
int)olevel >= (
int)PRINT_ALGORITHM_STEPS ) {
126 <<
"\nrHL_k = rHL_km1\n";
128 const MatrixSymOp &rHL_km1 = rHL.get_k(-1);
129 rHL.set_k(0) = rHL_km1;
130 quasi_newton_stats_(s).set_k(0).set_updated_stats(
131 QuasiNewtonStats::SKIPED );
132 if( (
int)olevel >= (
int)PRINT_ITERATION_QUANTITIES ) {
133 out <<
"\nrHL_k =\n" << rHL.get_k(0);
143 , std::ostream& out,
const std::string& L )
const
146 << L <<
"*** Check if we should do the BFGS update\n"
147 << L <<
"if rHL_km1 is update then\n"
148 << L <<
" If Ypy_km1, Zpz_km1, rGL_km1, or c_km1 is not updated then\n"
149 << L <<
" *** Warning, insufficient information to determine if we should\n"
150 << L <<
" *** perform the update. Check for sufficient backward storage.\n"
151 << L <<
" rHL_k = rHL_km1\n"
153 << L <<
" *** Check if we are in the proper region\n"
154 << L <<
" ratio = (skip_bfgs_prop_const/sqrt(norm(rGL_km1,2)+norm(c_km1,2)))\n"
155 << L <<
" * (norm(Zpz_km1,2)/norm(Ypy_km1,2) )\n"
156 << L <<
" if ratio < 1 then \n"
157 << L <<
" rHL_k = rHL_km1\n"
rSQP Algorithm control class.
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.
CheckSkipBFGSUpdateStd_Step(value_type skip_bfgs_prop_const=10.0)
AlgorithmTracker & track()
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
NLPAlgoState & rsqp_state()
<<std aggr>="">> members for algo_cntr