45 #include "MoochoPack_LineSearchNLE_Step.hpp"
46 #include "MoochoPack_Exceptions.hpp"
47 #include "MoochoPack_moocho_algo_conversion.hpp"
48 #include "IterationPack_print_algorithm_step.hpp"
49 #include "ConstrainedOptPack_MeritFuncNLESqrResid.hpp"
50 #include "ConstrainedOptPack_MeritFuncCalcNLE.hpp"
51 #include "ConstrainedOptPack_MeritFuncCalc1DQuadratic.hpp"
52 #include "AbstractLinAlgPack_VectorMutable.hpp"
53 #include "AbstractLinAlgPack_VectorStdOps.hpp"
54 #include "AbstractLinAlgPack_VectorOut.hpp"
55 #include "AbstractLinAlgPack_assert_print_nan_inf.hpp"
56 #include "AbstractLinAlgPack_LinAlgOpPack.hpp"
57 #include "Teuchos_Assert.hpp"
59 namespace MoochoPack {
62 const direct_line_search_ptr_t& direct_line_search
64 :direct_line_search_(direct_line_search)
75 NLPAlgo &algo = rsqp_algo(_algo);
77 NLP &nlp = algo.nlp();
79 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
83 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
84 using IterationPack::print_algorithm_step;
85 print_algorithm_step( algo, step_poss, type, assoc_step_poss, out );
100 IterQuantityAccess<value_type>
101 &alpha_iq = s.alpha();
102 IterQuantityAccess<VectorMutable>
107 VectorMutable &x_kp1 = x_iq.get_k(+1);
108 const Vector &x_k = x_iq.get_k(0);
109 VectorMutable &c_kp1 = c_iq.get_k(+1);
110 const Vector &c_k = c_iq.get_k(0);
111 const Vector &d_k = d_iq.get_k(0);
112 value_type &alpha_k = alpha_iq.get_k(0);
123 const value_type phi_k = phi_c.
value(c_k);
124 value_type phi_kp1 = phi_c.
value(c_kp1);
125 if( (
int)olevel >= (
int)PRINT_ALGORITHM_STEPS ) {
126 out <<
"\nBegin definition of NLP merit function phi_c.value(c(x)):\n";
128 out <<
"end definition of the NLP merit funciton\n";
133 Dphi_k = phi_c.
deriv();
134 if( (
int)olevel >= (
int)PRINT_ALGORITHM_STEPS ) {
135 out <<
"\nDphi_k = " << Dphi_k << std::endl;
139 ,
"LineSearchNLE_Step::do_step(...) : "
140 "Error, d_k is not a descent direction for the merit function "
141 "since Dphi_k = " << Dphi_k <<
" >= 0" );
146 nlp.unset_quantities();
149 const Vector* xd[2] = { &x_k, &d_k };
150 MeritFuncCalc1DQuadratic phi_calc_1d( phi_c_calc, 1, xd, &x_kp1 );
152 if( !direct_line_search().do_line_search(
153 phi_calc_1d, phi_k, &alpha_k, &phi_kp1
154 ,( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS)
155 ? &out : static_cast<std::ostream*>(0) )
160 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_BASIC_ALGORITHM_INFO) )
162 <<
"\nThe maximum number of linesearch iterations has been exceeded "
163 <<
"(k = " << algo.
state().
k() <<
")\n"
164 <<
"(phi_k - phi_kp1)/phi_k = " << ((phi_k - phi_kp1)/phi_k)
165 <<
"\nso we will reject the step and declare a line search failure.\n";
168 ,
"LineSearchNLE_Step::do_step(): Line search failure" );
171 nlp.unset_quantities();
173 if( (
int)olevel >= (
int)PRINT_ALGORITHM_STEPS ) {
174 out <<
"\nalpha_k = " << alpha_k;
175 out <<
"\n||x_kp1||inf = " << x_kp1.norm_inf();
176 out <<
"\n||c_kp1||inf = " << c_kp1.norm_inf();
177 out <<
"\nphi_kp1 = " << phi_kp1;
181 if( (
int)olevel >= (
int)PRINT_VECTORS ) {
182 out <<
"\nx_kp1 =\n" << x_kp1;
183 out <<
"\nc_kp1 =\n" << c_kp1;
191 ,std::ostream& out,
const std::string& L
195 << L <<
"*** Preform a line search for c(x_k + alpha_k*d_k) along the full space search direction d_k.\n"
196 << L <<
"ToDo: Fill this in!\n";
value_type calc_deriv(const Vector &c_k)
void print_merit_func(std::ostream &out, const std::string &leading_str) const
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
value_type value(const Vector &c) const
LineSearchNLE_Step(const direct_line_search_ptr_t &direct_line_search=Teuchos::null)
#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.
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
virtual std::ostream & journal_out() const
Thrown if a line search failure occurs.
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