53 namespace MoochoPack {
59 using std::setprecision;
74 const ostream_ptr_t& o
75 ,
const ostream_ptr_t& journal_out
77 :AlgorithmTracker(journal_out)
79 ,printed_lines_(NUM_PRINT_LINES)
103 const NLP &nlp = algo.nlp();
109 nb = nlp.num_bounded_x();
131 std::ostream&
o = this->
o();
136 if( s.f().updated_k(0) )
137 o <<
" " << setprecision(
p3_) <<
right << setw(
w_p3_) << s.f().get_k(0);
141 if( m && s.feas_kkt_err().updated_k(0) )
142 o <<
" " << setprecision(
p3_) <<
right << setw(
w_p3_) << s.feas_kkt_err().get_k(0);
146 if( s.opt_kkt_err().updated_k(0) )
147 o <<
" " << setprecision(
p3_) <<
right << setw(
w_p3_) << s.opt_kkt_err().get_k(0);
151 if( quasi_newt_stats ) {
153 switch( quasi_newt_stats->
updated() ) {
181 if( s.nu().updated_k(0) )
182 o <<
" " <<
right << setw(
w_i4_) << s.nu().get_k(0).nz();
187 if( m && s.Ypy().updated_k(0) )
188 o <<
" "<< setprecision(
p2_) <<
right << setw(
w_p2_) << s.Ypy().get_k(0).norm_2();
192 if( s.Zpz().updated_k(0) )
193 o <<
" " << setprecision(
p2_) <<
right << setw(
w_p2_) << s.Zpz().get_k(0).norm_2();
197 if( s.d().updated_k(0) )
198 o <<
" " << setprecision(
p2_) <<
right << setw(
w_p2_) << s.d().get_k(0).norm_inf();
202 if( s.alpha().updated_k(0) )
203 o <<
" " << setprecision(
p2_) <<
right << setw(
w_p2_) << s.alpha().get_k(0);
221 const NLPObjGrad &nlp =
dyn_cast<
const NLPObjGrad>(algo.nlp());
222 const NLPFirstOrder *nlp_foi =
dynamic_cast<const NLPFirstOrder*
>(&nlp);
228 nb = nlp.num_bounded_x();
230 std::ostream&
o = this->
o();
262 if( s.f().updated_k(0) )
263 o <<
" " << setprecision(
p3_) <<
right << setw(
w_p3_) << s.f().get_k(0);
267 if( m && s.feas_kkt_err().updated_k(0) )
268 o <<
" " << setprecision(
p3_) <<
right << setw(
w_p3_) << s.feas_kkt_err().get_k(0);
272 if( s.opt_kkt_err().updated_k(0) )
273 o <<
" " << setprecision(
p3_) <<
right << setw(
w_p3_) << s.opt_kkt_err().get_k(0);
277 if( quasi_newt_stats ) {
279 switch( quasi_newt_stats->
updated() ) {
307 if( s.nu().updated_k(0) )
308 o <<
" " <<
right << setw(
w_i4_) << s.nu().get_k(0).nz();
313 if( m && s.Ypy().updated_k(0) )
314 o <<
" "<< setprecision(
p2_) <<
right << setw(
w_p2_) << s.Ypy().get_k(0).norm_2();
318 if( s.Zpz().updated_k(0) )
319 o <<
" " << setprecision(
p2_) <<
right << setw(
w_p2_) << s.Zpz().get_k(0).norm_2();
323 if( s.d().updated_k(0) )
324 o <<
" " << setprecision(
p2_) <<
right << setw(
w_p2_) << s.d().get_k(0).norm_inf();
328 if( s.alpha().updated_k(0) )
329 o <<
" " << setprecision(
p2_) <<
right << setw(
w_p2_) << s.alpha().get_k(0);
338 o << setprecision(5) <<
"\nTotal time = " <<
timer_.
read() <<
" sec\n";
340 switch( algo_return ) {
342 o <<
"\nJackpot! You have found the solution!!!!!!\n";
345 o <<
"\nOops! Not the solution. Some error has occured!\n";
348 o <<
"\nOops! Not the solution. Maximum number of SQP iteration exceeded!\n";
351 o <<
"\nOops! Not the solution. Maximum runtime exceeded!\n";
354 o <<
"\nJackpot? The user terminated the algorithm but said to return optimal!!!!!!\n";
357 o <<
"\nOops! Not the solution. The user terminated the algorithm and said to return non-optimal!\n";
363 o <<
"\nNumber of function evaluations:\n"
364 <<
"-------------------------------\n"
365 <<
"f(x) : " << nlp.num_f_evals() << endl
366 <<
"c(x) : " << ( m ? nlp.num_c_evals() : 0 ) << endl
367 <<
"Gf(x) : " << nlp.num_Gf_evals() << endl
371 o << nlp_foi->num_Gc_evals();
384 std::ostream&
o = this->
o();
386 NLPAlgoState::space_c_ptr_t
387 space_c = s.get_space_c();
389 o <<
"\n\n********************************\n"
390 <<
"*** Start of rSQP Iterations ***\n"
391 <<
"n = " << s.space_x().dim()
392 <<
", m = " << ( space_c.get() ? space_c->dim() : 0 )
396 if( s.Gc().updated_k(0) )
397 o << s.Gc().get_k(0).nz() << endl;
405 catch(
const AlgorithmState::DoesNotExist& ) {
408 if( algo.nlp().scale_f() != 1.0 ) {
409 o <<
"f(x) is scaled by : " << algo.nlp().scale_f() << endl;
416 std::ostream&
o = this->
o();
418 const NLP &nlp = algo.nlp();
421 nb = nlp.num_bounded_x();
427 <<
" " <<
left << setw(
w_p3_) <<
"||c||s"
428 <<
" " <<
left << setw(
w_p3_) <<
"||rGL||s"
431 o <<
" " <<
left << setw(
w_i4_) <<
"#act";
433 <<
" " <<
left << setw(
w_p2_) <<
"||Ypy||2"
434 <<
" " <<
left << setw(
w_p2_) <<
"||Zpz||2"
435 <<
" " <<
left << setw(
w_p2_) <<
"||d||inf"
437 <<
" " <<
left << setw(
w_p3_) <<
"time(sec)"
void initialize()
Restarts the timer.
void output_iteration(const Algorithm &algo) const
AbstractLinAlgPack::size_type size_type
StopWatchPack::stopwatch timer_
Class for storing statistics about the Quasi-Newton updating.
void print_top_header(const NLPAlgoState &s, const NLPAlgo &algo) const
Print the top header to the output.
const ostream_ptr_t & get_output_stream() const
Get the output stream for console outputting.
void reset()
Stops and resets the clock if it is running.
rSQP Algorithm control class.
void print_header(const NLPAlgoState &s, const NLPAlgo &algo) const
Print the header to the output.
MoochoTrackerConsoleStd()
T_To & dyn_cast(T_From &from)
Reduced space SQP state encapsulation interface.
void start()
Starts timing if it has already not been started.
Acts as the central hub for an iterative algorithm.
NLPAlgoState & rsqp_state()
<<std aggr>="">> members for algo_cntr
void set_output_stream(const ostream_ptr_t &o)
Set the output stream for console outputting.
void output_final(const Algorithm &algo, EAlgoReturn algo_return) const
quasi_newton_stats_iq_member quasi_newton_stats_
double read()
Reads the elapsed time (sec.) and leaves the clock running.
NLPAlgo & rsqp_algo(Algorithm &algo)
Convert from a Algorithm to a NLPAlgo.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)