44 #include "MoochoPack_LineSearchFullStep_Step.hpp"
45 #include "MoochoPack_Exceptions.hpp"
46 #include "MoochoPack_moocho_algo_conversion.hpp"
47 #include "IterationPack_print_algorithm_step.hpp"
48 #include "AbstractLinAlgPack_MatrixOpOut.hpp"
49 #include "AbstractLinAlgPack_VectorMutable.hpp"
50 #include "AbstractLinAlgPack_VectorStdOps.hpp"
51 #include "AbstractLinAlgPack_VectorOut.hpp"
52 #include "AbstractLinAlgPack_LinAlgOpPack.hpp"
53 #include "AbstractLinAlgPack_assert_print_nan_inf.hpp"
54 #include "Teuchos_Assert.hpp"
56 namespace MoochoPack {
59 const bounds_tester_ptr_t& bounds_tester
62 bounds_tester_(bounds_tester)
70 using AbstractLinAlgPack::assert_print_nan_inf;
73 NLPAlgo &algo = rsqp_algo(_algo);
75 NLP &nlp = algo.nlp();
80 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
84 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
85 using IterationPack::print_algorithm_step;
86 print_algorithm_step( algo, step_poss, type, assoc_step_poss, out );
90 IterQuantityAccess<value_type>
91 &alpha_iq = s.alpha();
92 if( !alpha_iq.updated_k(0) )
93 alpha_iq.set_k(0) = 1.0;
95 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
96 out <<
"\nf_k = " << s.f().get_k(0);
98 out <<
"\n||c_k||inf = " << s.c().get_k(0).norm_inf();
99 out <<
"\nalpha_k = " << alpha_iq.get_k(0) << std::endl;
103 IterQuantityAccess<VectorMutable> &x_iq = s.x();
104 const Vector &x_k = x_iq.get_k(0);
105 VectorMutable &x_kp1 = x_iq.set_k(+1);
107 Vp_StV( &x_kp1, alpha_iq.get_k(0), s.d().get_k(0) );
109 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
110 out <<
"\n||x_kp1||inf = " << s.x().get_k(+1).norm_inf() << std::endl;
112 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_VECTORS) ) {
113 out <<
"\nx_kp1 =\n" << s.x().get_k(+1);
116 if(algo.algo_cntr().check_results()) {
117 assert_print_nan_inf(
119 ,
int(olevel) >=
int(PRINT_ALGORITHM_STEPS) ? &out : NULL
121 if( nlp.num_bounded_x() ) {
122 if(!bounds_tester().check_in_bounds(
123 int(olevel) >=
int(PRINT_ALGORITHM_STEPS) ? &out : NULL
124 ,
int(olevel) >=
int(PRINT_VECTORS)
125 ,
int(olevel) >=
int(PRINT_ITERATION_QUANTITIES)
133 ,
"LineSearchFullStep_Step::do_step(...) : Error, "
134 "the variables bounds xl <= x_k(+1) <= xu where violated!" );
140 nlp.unset_quantities();
141 nlp.set_f( &s.f().set_k(+1) );
142 if(m) nlp.set_c( &s.c().set_k(+1) );
144 if(m) nlp.calc_c( x_kp1,
false );
145 nlp.unset_quantities();
147 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
148 out <<
"\nf_kp1 = " << s.f().get_k(+1);
150 out <<
"\n||c_kp1||inf = " << s.c().get_k(+1).norm_inf();
154 if( m && static_cast<int>(olevel) >= static_cast<int>(PRINT_VECTORS) ) {
155 out <<
"\nc_kp1 =\n" << s.c().get_k(+1);
158 if(algo.algo_cntr().check_results()) {
159 assert_print_nan_inf( s.f().get_k(+1),
"f(x_kp1)",
true, &out );
161 assert_print_nan_inf( s.c().get_k(+1),
"c(x_kp1)",
true, &out );
169 , std::ostream& out,
const std::string& L )
const
172 << L <<
"if alpha_k is not updated then\n"
173 << L <<
" alpha_k = 1.0\n"
175 << L <<
"x_kp1 = x_k + alpha_k * d_k\n"
176 << L <<
"f_kp1 = f(x_kp1)\n"
177 << L <<
"if m > 0 then c_kp1 = c(x_kp1)\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
Thrown if a runtime test failed.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
rSQP Algorithm control class.
virtual std::ostream & journal_out() const
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
void V_VpV(VectorMutable *v_lhs, const V1 &V1_rhs1, const V2 &V2_rhs2)
Reduced space SQP state encapsulation interface.
AlgorithmTracker & track()
NLPAlgoState & rsqp_state()
<<std aggr>="">> members for algo_cntr
LineSearchFullStep_Step(const bounds_tester_ptr_t &bounds_tester)