63 namespace MoochoPack {
70 ,
bool scale_opt_error_by_Gf
91 NLP &nlp = algo.nlp();
99 nb = nlp.num_bounded_x();
102 IterQuantityAccess<value_type>
103 &opt_kkt_err_iq = s.opt_kkt_err(),
104 &feas_kkt_err_iq = s.feas_kkt_err(),
105 &comp_kkt_err_iq = s.comp_kkt_err();
107 IterQuantityAccess<VectorMutable>
111 *c_iq = m ? &s.c() : NULL,
112 *rGL_iq = n > m ? &s.rGL() : NULL,
113 *GL_iq = n > m ? &s.GL() : NULL,
114 *nu_iq = n > m ? &s.nu() : NULL;
119 norm_inf_GLrGL_k = 0.0;
121 if( n > m && scale_opt_error_by_Gf() && Gf_iq.updated_k(0) ) {
123 norm_inf_Gf_k = Gf_iq.get_k(0).norm_inf(),
124 "||Gf_k||inf",
true,&
out
136 "||rGL_k||inf",
true,&
out);
140 "||GL_k||inf",
true,&
out);
145 opt_scale_factor = 1.0 + norm_inf_Gf_k,
146 opt_err = norm_inf_GLrGL_k / opt_scale_factor;
149 const value_type feas_err = ( ( m ? c_iq->get_k(0).norm_inf() : 0.0 ) );
170 opt_kkt_err_k = opt_err/scale_opt_factor,
171 feas_kkt_err_k = feas_err/scale_feas_factor,
172 comp_kkt_err_k = comp_err/scale_comp_factor;
175 if(n > m) opt_kkt_err_iq.set_k(0) = opt_kkt_err_k;
176 feas_kkt_err_iq.set_k(0) = feas_kkt_err_k;
177 comp_kkt_err_iq.set_k(0) = comp_kkt_err_k;
181 if( d_iq.updated_k(0) ) {
187 opt_tol = algo.algo_cntr().opt_tol(),
188 feas_tol = algo.algo_cntr().feas_tol(),
189 comp_tol = algo.algo_cntr().comp_tol(),
190 step_tol = algo.algo_cntr().step_tol();
192 const bool found_solution =
193 opt_kkt_err_k < opt_tol
194 && feas_kkt_err_k < feas_tol
195 && comp_kkt_err_k < comp_tol
196 && step_err < step_tol;
201 <<
"\nscale_opt_factor = " << scale_opt_factor
202 <<
" (scale_opt_error_by = " << (scale_opt_error_by()==
SCALE_BY_ONE ?
"SCALE_BY_ONE"
204 :
"SCALE_BY_NORM_2_X" ) ) <<
")"
206 <<
"\nscale_feas_factor = " << scale_feas_factor
207 <<
" (scale_feas_error_by = " << (scale_feas_error_by()==
SCALE_BY_ONE ?
"SCALE_BY_ONE"
209 :
"SCALE_BY_NORM_2_X" ) ) <<
")"
211 <<
"\nscale_comp_factor = " << scale_comp_factor
212 <<
" (scale_comp_error_by = " << (scale_comp_error_by()==
SCALE_BY_ONE ?
"SCALE_BY_ONE"
214 :
"SCALE_BY_NORM_2_X" ) ) <<
")"
215 <<
"\nopt_scale_factor = " << opt_scale_factor
216 <<
" (scale_opt_error_by_Gf = " << (scale_opt_error_by_Gf()?
"true":
"false") <<
")"
217 <<
"\nopt_kkt_err_k = " << opt_kkt_err_k << ( opt_kkt_err_k < opt_tol ?
" < " :
" > " )
218 <<
"opt_tol = " << opt_tol
219 <<
"\nfeas_kkt_err_k = " << feas_kkt_err_k << ( feas_kkt_err_k < feas_tol ?
" < " :
" > " )
220 <<
"feas_tol = " << feas_tol
221 <<
"\ncomp_kkt_err_k = " << comp_kkt_err_k << ( comp_kkt_err_k < comp_tol ?
" < " :
" > " )
222 <<
"comp_tol = " << comp_tol
223 <<
"\nstep_err = " << step_err << ( step_err < step_tol ?
" < " :
" > " )
224 <<
"step_tol = " << step_tol
228 return found_solution;
235 << L <<
"*** Check to see if the KKT error is small enough for convergence\n"
236 << L <<
"if scale_(opt|feas|comp)_error_by == SCALE_BY_ONE then\n"
237 << L <<
" scale_(opt|feas|comp)_factor = 1.0\n"
238 << L <<
"else if scale_(opt|feas|comp)_error_by == SCALE_BY_NORM_2_X then\n"
239 << L <<
" scale_(opt|feas|comp)_factor = 1.0 + norm_2(x_k)\n"
240 << L <<
"else if scale_(opt|feas|comp)_error_by == SCALE_BY_NORM_INF_X then\n"
241 << L <<
" scale_(opt|feas|comp)_factor = 1.0 + norm_inf(x_k)\n"
243 << L <<
"if scale_opt_error_by_Gf == true then\n"
244 << L <<
" opt_scale_factor = 1.0 + norm_inf(Gf_k)\n"
246 << L <<
" opt_scale_factor = 1.0\n"
251 << L <<
"opt_err = norm_inf(rGL_k)/opt_scale_factor\n";
256 << L <<
"opt_err = norm_inf(GL_k)/opt_scale_factor\n";
260 << L <<
"feas_err = norm_inf(c_k)\n"
261 << L <<
"comp_err = max(i, nu(i)*(xu(i)-x(i)), -nu(i)*(x(i)-xl(i)))\n"
262 << L <<
"opt_kkt_err_k = opt_err/scale_opt_factor\n"
263 << L <<
"feas_kkt_err_k = feas_err/scale_feas_factor\n"
264 << L <<
"comp_kkt_err_k = feas_err/scale_comp_factor\n"
265 << L <<
"if d_k is updated then\n"
266 << L <<
" step_err = max( |d_k(i)|/(1+|x_k(i)|), i=1..n )\n"
268 << L <<
" step_err = 0\n"
270 << L <<
"if opt_kkt_err_k < opt_tol\n"
271 << L <<
" and feas_kkt_err_k < feas_tol\n"
272 << L <<
" and step_err < step_tol then\n"
273 << L <<
" report optimal x_k, lambda_k and nu_k to the nlp\n"
274 << L <<
" terminate, the solution has beed found!\n"
289 scale_factor = 1.0 + state.x().get_k(0).norm_2();
292 scale_factor = 1.0 + state.x().get_k(0).norm_inf();
AbstractLinAlgPack::size_type size_type
CheckConvergenceStd_Strategy(EOptErrorCheck opt_error_check=OPT_ERROR_REDUCED_GRADIENT_LAGR, EScaleKKTErrorBy scale_opt_error_by=SCALE_BY_ONE, EScaleKKTErrorBy scale_feas_error_by=SCALE_BY_ONE, EScaleKKTErrorBy scale_comp_error_by=SCALE_BY_ONE, bool scale_opt_error_by_Gf=true)
rSQP Algorithm control class.
Strategy interface for performing convergence checks.
value_type max_rel_step(const Vector &x, const Vector &d)
Computes the maximum relative step of x = x + d.
value_type CalculateScalingFactor(NLPAlgoState &state, EScaleKKTErrorBy scale_by) const
virtual void print_step(const Algorithm &_algo, std::ostream &out, const std::string &L) const
virtual std::ostream & journal_out() const
Return a reference to a std::ostream to be used to output debug information and the like...
EJournalOutputLevel
enum for journal output.
value_type combined_nu_comp_err(const Vector &v, const Vector &x, const Vector &xl, const Vector &xu)
Computes an estimate of the complementarity error.
Reduced space SQP state encapsulation interface.
AlgorithmTracker & track()
bool assert_print_nan_inf(const value_type &val, const char name[], bool throw_excpt, std::ostream *out)
This function asserts if a value_type scalare is a NaN or Inf and optionally prints out these entires...
AbstractLinAlgPack::value_type value_type
virtual bool Converged(Algorithm &_algo)
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.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)