58 namespace MoochoPack {
61 const direct_line_search_ptr_t& direct_line_search
63 :direct_line_search_(direct_line_search)
76 NLP &nlp = algo.nlp();
104 IterQuantityAccess<value_type>
106 &alpha_iq = s.alpha(),
108 IterQuantityAccess<VectorMutable>
113 VectorMutable &x_kp1 = x_iq.get_k(+1);
114 const Vector &x_k = x_iq.get_k(0);
117 VectorMutable *c_kp1 = m ? &c_iq.get_k(+1) : NULL;
118 const Vector *c_k = m ? &c_iq.get_k(0) : NULL;
119 const Vector &d_k = d_iq.get_k(0);
126 &merit_func_nlp_k = s.merit_func_nlp().get_k(0);
128 out <<
"\nBegin definition of NLP merit function phi.value(f(x),c(x)):\n";
129 merit_func_nlp_k.print_merit_func( out,
" " );
130 out <<
"end definition of the NLP merit funciton\n";
134 Dphi_k = merit_func_nlp_k.deriv();
135 if( (
int)olevel >= (
int)PRINT_ALGORITHM_STEPS ) {
136 out <<
"\nDphi_k = " << Dphi_k << std::endl;
140 ,
"LineSearch2ndOrderCorrect_Step::do_step(...) : "
141 "Error, d_k is not a descent direction for the merit function "
142 "since Dphi_k = " << Dphi_k <<
" >= 0" );
145 &phi_kp1 = phi_iq.set_k(+1) = merit_func_nlp_k.value(
154 &phi_k = phi_iq.set_k(0) = merit_func_nlp_k.value(
167 nlp.unset_quantities();
169 if(m) nlp.set_c( c_kp1 );
171 phi_calc( &merit_func_nlp_k, &nlp );
176 const Vector* xd[2] = { &x_k, &d_k };
177 MeritFuncCalc1DQuadratic
178 phi_calc_1d( phi_calc, 1, xd, &x_kp1 );
180 if( !direct_line_search().do_line_search(
181 phi_calc_1d, phi_k, &alpha_k, &phi_kp1
182 ,( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS)
183 ? &out : static_cast<std::ostream*>(0) )
190 <<
"\nThe maximum number of linesearch iterations has been exceeded "
191 <<
"(k = " << algo.
state().
k() <<
")\n"
192 <<
"(phi_k - phi_kp1)/phi_k = " << ((phi_k - phi_kp1)/phi_k)
193 <<
"\nso we will reject the step and declare a line search failure.\n";
196 ,
"LineSearchDirect_Step::do_step(): Line search failure" );
198 nlp.unset_quantities();
200 if( (
int)olevel >= (
int)PRINT_ALGORITHM_STEPS ) {
201 out <<
"\nalpha_k = " << alpha_k;
202 out <<
"\n||x_kp1||inf = " << x_kp1.norm_inf();
203 out <<
"\nf_kp1 = " << f_kp1;
205 out <<
"\n||c_kp1||inf = " << c_kp1->norm_inf();
206 out <<
"\nphi_kp1 = " << phi_kp1;
211 out <<
"\nx_kp1 =\n" << x_kp1;
213 out <<
"\nc_kp1 =\n" << *c_kp1;
221 ,std::ostream&
out,
const std::string& L
225 << L <<
"*** Preform a line search along the full space search direction d_k.\n"
226 << L <<
"Dphi_k = merit_func_nlp_k.deriv()\n"
227 << L <<
"if Dphi_k >= 0 then\n"
228 << L <<
" throw line_search_failure\n"
230 << L <<
"phi_kp1 = merit_func_nlp_k.value(f_kp1,c_kp1,h_kp1,hl,hu)\n"
231 << L <<
"phi_k = merit_func_nlp_k.value(f_k,c_k,h_k,hl,hu)\n"
232 << L <<
"begin direct line search (where phi = merit_func_nlp_k): \"" <<
typeName(direct_line_search()) <<
"\"\n";
233 direct_line_search().print_algorithm( out, L +
" " );
235 << L <<
"end direct line search\n"
236 << L <<
"if maximum number of linesearch iterations are exceeded then\n"
237 << L <<
" throw line_search_failure\n"
AbstractLinAlgPack::size_type size_type
std::string typeName(const T &t)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
v_lhs = alpha * v_rhs + v_lhs
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
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual std::ostream & journal_out() const
Return a reference to a std::ostream to be used to output debug information and the like...
Thrown if a line search failure occurs.
EJournalOutputLevel
enum for journal output.
void V_VpV(VectorMutable *v_lhs, const V1 &V1_rhs1, const V2 &V2_rhs2)
Reduced space SQP state encapsulation interface.
void print_algorithm_step(const Algorithm &algo, Algorithm::poss_type step_poss, EDoStepType type, Algorithm::poss_type assoc_step_poss, std::ostream &out)
Prints to 'out' the algorithm step.
AlgorithmTracker & track()
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
AbstractLinAlgPack::value_type value_type
Acts as the central hub for an iterative algorithm.
NLPAlgoState & rsqp_state()
<<std aggr>="">> members for algo_cntr
NLPAlgo & rsqp_algo(Algorithm &algo)
Convert from a Algorithm to a NLPAlgo.
LineSearchDirect_Step(const direct_line_search_ptr_t &direct_line_search=Teuchos::null)