46 #include "MoochoPack_MoochoTrackerSummaryStd.hpp"
47 #include "MoochoPack_NLPAlgoState.hpp"
48 #include "MoochoPack_moocho_algo_conversion.hpp"
49 #include "NLPInterfacePack_NLPFirstOrder.hpp"
50 #include "AbstractLinAlgPack_Vector.hpp"
51 #include "AbstractLinAlgPack_MatrixSymOp.hpp"
52 #include "Teuchos_dyn_cast.hpp"
57 namespace MoochoPack {
59 MoochoTrackerSummaryStd::MoochoTrackerSummaryStd(
60 const ostream_ptr_t &o
61 ,
const ostream_ptr_t &journal_out
64 :AlgorithmTracker(journal_out)
66 ,opt_error_(opt_error)
67 ,num_total_qp_iter_(0)
84 const NLPAlgo &_algo = rsqp_algo(algo);
86 const NLP &nlp = _algo.nlp();
91 std::ostream& o = this->o();
107 ( act_set_stats_.exists_in(s) && act_set_stats_(s).updated_k(0)
108 ? &act_set_stats_(s).get_k(0)
111 ( qp_solver_stats_.exists_in(s) && qp_solver_stats_(s).updated_k(0)
112 ? &qp_solver_stats_(s).get_k(0)
115 ( quasi_newton_stats_.exists_in(s) && quasi_newton_stats_(s).updated_k(0)
116 ? &quasi_newton_stats_(s).get_k(0)
120 value_type norm_2_Ypy = -1.0, norm_2_Zpz = -1.0;
121 bool Ypy_exists, Zpz_exists;
122 if( m && ( Ypy_exists = s.Ypy().updated_k(0) ) )
123 norm_2_Ypy = s.Ypy().get_k(0).norm_2();
124 if( Zpz_exists = s.Zpz().updated_k(0) )
125 norm_2_Zpz = s.Zpz().get_k(0).norm_2();
130 if( s.f().updated_k(0) )
131 o << setw(w) << s.f().get_k(0);
135 if( s.Gf().updated_k(0) )
136 o << setw(w) << s.Gf().get_k(0).norm_inf();
140 if( m && s.c().updated_k(0) )
142 << s.c().get_k(0).norm_inf();
147 const IterQuantityAccess<VectorMutable>
148 &rGL_GL = ( opt_error_ == OPT_ERROR_REDUCED_GRADIENT_LAGR
149 ? s.rGL() : s.GL() );
150 if( rGL_GL.updated_k(0) )
151 o << setw(w) << rGL_GL.get_k(0).norm_inf();
156 if( quasi_newt_stats ) {
158 switch( quasi_newt_stats->
updated() ) {
159 case QuasiNewtonStats::UNKNOWN:
162 case QuasiNewtonStats:: REINITIALIZED:
165 case QuasiNewtonStats::DAMPENED_UPDATED:
168 case QuasiNewtonStats::UPDATED:
171 case QuasiNewtonStats::SKIPED:
174 case QuasiNewtonStats::INDEF_SKIPED:
188 if( act_stats->
num_adds() == ActSetStats::NOT_KNOWN ) {
192 o << setw(7) << act_stats->
num_adds();
194 if( act_stats->
num_drops() == ActSetStats::NOT_KNOWN ) {
201 else if( s.nu().updated_k(0) ) {
202 o << setw(7) << s.nu().get_k(0).nz()
214 << setw(3) << ( qp_stats->
warm_start() ?
'w' :
'c')
225 o << setw(w) << norm_2_Ypy;
230 o << setw(w) << norm_2_Zpz;
234 if( s.d().updated_k(0) )
236 << s.d().get_k(0).norm_inf();
240 if( s.alpha().updated_k(0) )
241 o << setw(w) << s.alpha().get_k(0);
249 , EAlgoReturn algo_return)
const
253 const NLPAlgo &_algo = rsqp_algo(algo);
255 const NLPObjGrad &nlp =
dyn_cast<
const NLPObjGrad>(_algo.nlp());
256 const NLPFirstOrder *nlp_foi =
dynamic_cast<const NLPFirstOrder*
>(&nlp);
261 std::ostream& o = this->o();
269 ( act_set_stats_.exists_in(s) && act_set_stats_(s).updated_k(0)
270 ? &act_set_stats_(s).get_k(0)
273 ( qp_solver_stats_.exists_in(s) && qp_solver_stats_(s).updated_k(0)
274 ? &qp_solver_stats_(s).get_k(0)
277 ( quasi_newton_stats_.exists_in(s) && quasi_newton_stats_(s).updated_k(0)
278 ? &quasi_newton_stats_(s).get_k(0)
302 if( s.f().updated_k(0) )
303 o << setw(w) << s.f().get_k(0);
307 if( s.Gf().updated_k(0) )
308 o << setw(w) << s.Gf().get_k(0).norm_inf();
312 if( m && s.c().updated_k(0) )
314 << s.c().get_k(0).norm_inf();
319 const IterQuantityAccess<VectorMutable>
320 &rGL_GL = ( opt_error_ == OPT_ERROR_REDUCED_GRADIENT_LAGR
321 ? s.rGL() : s.GL() );
322 if( rGL_GL.updated_k(0) )
323 o << setw(w) << rGL_GL.get_k(0).norm_inf();
329 if( quasi_newt_stats ) {
330 switch( quasi_newt_stats->
updated() ) {
331 case QuasiNewtonStats::UNKNOWN:
334 case QuasiNewtonStats:: REINITIALIZED:
337 case QuasiNewtonStats::DAMPENED_UPDATED:
340 case QuasiNewtonStats::UPDATED:
343 case QuasiNewtonStats::SKIPED:
346 case QuasiNewtonStats::INDEF_SKIPED:
354 o << setw(w) <<
"-";;
362 else if( s.nu().updated_k(0) ) {
363 o << setw(7) << s.nu().get_k(0).nz()
375 << setw(3) << ( qp_stats->
warm_start() ?
'w' :
'c')
385 if(m && s.Ypy().updated_k(0))
387 << s.Ypy().get_k(0).norm_2();
391 if(s.Zpz().updated_k(0))
393 << s.Zpz().get_k(0).norm_2();
397 if( s.d().updated_k(0) )
399 << s.d().get_k(0).norm_inf();
405 o <<
"\nNumber of function evaluations:\n"
406 <<
"-------------------------------\n"
407 <<
"f(x) : " << nlp.num_f_evals() << endl
408 <<
"c(x) : " << ( m ? nlp.num_c_evals() : 0 ) << endl
409 <<
"Gf(x) : " << nlp.num_Gf_evals() << endl
413 o << nlp_foi->num_Gc_evals();
427 num_total_qp_iter_ = 0;
429 std::ostream& o = this->o();
431 NLPAlgoState::space_c_ptr_t
432 space_c = s.get_space_c();
434 o <<
"\n\n********************************\n"
435 <<
"*** Start of rSQP Iterations ***\n"
436 <<
"n = " << s.space_x().dim()
437 <<
", m = " << ( space_c.get() ? space_c->dim() : 0 )
441 if( s.Gc().updated_k(0) )
442 o << s.Gc().get_k(0).nz() << endl;
450 catch(
const AlgorithmState::DoesNotExist& ) {
459 case OPT_ERROR_REDUCED_GRADIENT_LAGR:
462 case OPT_ERROR_GRADIENT_LAGR:
492 <<
" ------------\n";
void output_final(const Algorithm &algo, EAlgoReturn algo_return) const
Class for storing statistics about the Quasi-Newton updating.
void output_iteration(const Algorithm &algo) const
T_To & dyn_cast(T_From &from)
rSQP Algorithm control class.
Class for storing statistics about the changes in the active set of an SQP algorithm.
int infeasible_qp() const
Reduced space SQP state encapsulation interface.
NLPAlgoState & rsqp_state()
<<std aggr>="">> members for algo_cntr
void set_output_stream(const ostream_ptr_t &o)
Set the output stream for summary outputting.
const ostream_ptr_t & get_output_stream() const
Get the output stream for summary outputting.
void print_header(const NLPAlgoState &s) const
Print the header to the output.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)