45 #include "MoochoPack_QPFailureReinitReducedHessian_Step.hpp"
46 #include "MoochoPack_MoochoAlgorithmStepNames.hpp"
47 #include "MoochoPack_Exceptions.hpp"
48 #include "MoochoPack_moocho_algo_conversion.hpp"
49 #include "IterationPack_print_algorithm_step.hpp"
51 namespace MoochoPack {
53 QPFailureReinitReducedHessian_Step::QPFailureReinitReducedHessian_Step(
54 const null_space_step_ptr_t& null_space_step
56 :null_space_step_(null_space_step)
57 ,last_qp_failure_k_(-100)
66 return null_space_step().do_step(_algo,step_poss,type,assoc_step_poss);
69 NLPAlgo &algo = rsqp_algo(_algo);
71 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
74 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_BASIC_ALGORITHM_INFO) ) {
75 out <<
"\nQP failed! "
76 <<
" (k = " << algo.
state().
k() <<
")\n"
77 <<
"QPFailure description: " << qp_excpt.what() <<
"\n";
79 if( s.
k() >= algo.algo_cntr().
max_iter() ) {
80 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_BASIC_ALGORITHM_INFO) ) {
81 out <<
"\nThe maximum number of rSQP iterations\n"
82 <<
" have been exceeded so quit "
83 <<
" (k = " << algo.
state().
k() <<
")\n";
88 if( last_qp_failure_k_ == s.
k() ) {
89 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_BASIC_ALGORITHM_INFO) ) {
90 out <<
"\nThe QP failed again even with a new reduced Hessian rHL_k!"
91 <<
" (k = " << algo.
state().
k() <<
")\n"
96 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_BASIC_ALGORITHM_INFO) ) {
97 out <<
"\nWiping out all memory for rHL and going back to reinitalize it ..."
98 <<
" (k = " << algo.
state().
k() <<
")\n";
100 last_qp_failure_k_ = s.
k();
101 if( (
int)olevel >= (
int)PRINT_ALGORITHM_STEPS ) {
102 out <<
"Wipe out all update rHL_{k} for all k\n"
103 <<
"goto ReducedHessian\n";
105 s.rHL().set_all_not_updated();
115 ,std::ostream& out,
const std::string& L
119 << L <<
"do null space step : " <<
typeName(null_space_step()) << std::endl;
120 null_space_step().print_step(algo,step_poss,type,assoc_step_poss,out,L+
" ");
122 << L <<
"end null space step\n"
123 << L <<
"if QPFailure was thrown then\n"
124 << L <<
" if QP failed already then\n"
125 << L <<
" rethrow QPFailure\n"
127 << L <<
" if k > max_iter then\n"
128 << L <<
" terminate the algorithm!\n"
130 << L <<
" set all rHL_{k} to not updated\n"
131 << L <<
" goto ReducedHessian\n"
virtual void max_iter(size_t max_iter)
Thrown if a the QP failed and was not corrected.
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
rSQP Algorithm control class.
virtual void terminate(bool success)
virtual std::ostream & journal_out() const
Reduced space SQP state encapsulation interface.
virtual void do_step_next(const std::string &step_name)
AlgorithmTracker & track()
NLPAlgoState & rsqp_state()
<<std aggr>="">> members for algo_cntr
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
std::string typeName(const T &t)