57 namespace MoochoPack {
64 ,
bool scale_opt_error_by_Gf
86 bool found_solution =
false;
93 NLP& nlp = algo.nlp();
96 std::ostream&
out = algo.track().journal_out();
99 const value_type &mu_km1 = s.barrier_parameter().get_k(-1);
100 const Vector& x_k = s.x().get_k(0);
101 const VectorMutable& Gf_k = s.Gf().get_k(0);
102 const Vector& rGL_k = s.rGL().get_k(0);
103 const Vector& c_k = s.c().get_k(0);
104 const Vector& vl_k = s.Vl().get_k(0).diag();
105 const Vector& vu_k = s.Vu().get_k(0).diag();
108 value_type& opt_err = s.opt_kkt_err().set_k(0);
109 value_type& feas_err = s.feas_kkt_err().set_k(0);
110 value_type& comp_err = s.comp_kkt_err().set_k(0);
111 value_type& comp_err_mu = s.comp_err_mu().set_k(0);
114 value_type scale_1 = 1 + x_k.norm_1()/x_k.dim();
117 temp->axpy(-1.0, vl_k);
118 temp->axpy(1.0, vu_k);
120 scale_2 += vl_k.norm_1() + vu_k.norm_1();
122 *temp = nlp.infinite_bound();
124 *temp = -nlp.infinite_bound();
126 scale_2 = 1 + scale_2/(1+nlp.m()+nlb+nub);
129 opt_err = rGL_k.norm_inf() / scale_2;
132 feas_err = c_k.norm_inf() / scale_1;
137 out <<
"\nx =\n" << s.x().get_k(0);
138 out <<
"\nxl =\n" << nlp.xl();
139 out <<
"\nvl =\n" << s.Vl().get_k(0).diag();
140 out <<
"\nxu =\n" << nlp.xu();
141 out <<
"\nvu =\n" << s.Vu().get_k(0).diag();
145 0.0, nlp.infinite_bound(), s.x().get_k(0), nlp.xl(), nlp.xu()
146 ,s.Vl().get_k(0).diag(), s.Vu().get_k(0).diag());
149 mu_km1, nlp.infinite_bound(), s.x().get_k(0), nlp.xl(), nlp.xu()
150 ,s.Vl().get_k(0).diag(), s.Vu().get_k(0).diag());
152 comp_err = comp_err / scale_2;
153 comp_err_mu = comp_err_mu / scale_2;
157 const value_type opt_tol = algo.algo_cntr().opt_tol();
158 const value_type feas_tol = algo.algo_cntr().feas_tol();
159 const value_type comp_tol = algo.algo_cntr().comp_tol();
161 if (opt_err < opt_tol && feas_err < feas_tol && comp_err < comp_tol)
163 found_solution =
true;
169 <<
"\nopt_kkt_err_k = " << opt_err << ( opt_err < opt_tol ?
" < " :
" > " )
170 <<
"opt_tol = " << opt_tol
171 <<
"\nfeas_kkt_err_k = " << feas_err << ( feas_err < feas_tol ?
" < " :
" > " )
172 <<
"feas_tol = " << feas_tol
173 <<
"\ncomp_kkt_err_k = " << comp_err << ( comp_err < comp_tol ?
" < " :
" > " )
174 <<
"comp_tol = " << comp_tol
175 <<
"\ncomp_err_mu = " << comp_err_mu
176 <<
"\nbarrier_parameter_k (mu_km1) = " << mu_km1
177 <<
"comp_tol = " << comp_tol
181 return found_solution;
187 << L <<
"CheckConvergenceIP_Strategy\n"
188 << L <<
" IP_found_solution = CheckConvergedStd_Strategy::Converged(_algo, reportFinalSolution)\n";
193 << L <<
"*** recalculate comp_err\n"
194 << L <<
"comp_err_k = 0.0"
195 << L <<
"for all i = 1 to n\n"
196 << L <<
" comp_err_k = max( comp_err_k, vl_k(i)*(x_k(i)-xl_k(i))-mu_km1, vu_k(i)*(xu_k(i)-x_k(i))-mu_k )\n"
198 << L <<
"if IP_found_solution then\n"
199 << L <<
" IP_found_solution = false\n"
200 << L <<
" if (comp_err_k < comp_tol && mu_k < comp_tol) then\n"
201 << L <<
" IP_found_solution = true\n"
204 << L <<
"return IP_found_solution\n";
AbstractLinAlgPack::size_type size_type
CheckConvergenceIP_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)
state_ptr_t & get_state()
value_type IP_comp_err_with_mu(const value_type mu, const value_type inf_bound, const Vector &x, const Vector &xl, const Vector &xu, const Vector &vl, const Vector &vu)
Computes the complementarity error for a primal/dual interior point algorithm using inf norm...
rSQP Algorithm control class.
virtual bool Converged(Algorithm &_algo)
virtual void print_step(const Algorithm &_algo, std::ostream &out, const std::string &L) const
virtual void print_step(const Algorithm &_algo, std::ostream &out, const std::string &L) const
EJournalOutputLevel
enum for journal output.
T_To & dyn_cast(T_From &from)
size_type num_bounded(const Vector &xl, const Vector &xu, value_type inf_bound)
Count the number of finitly bounded elements in xl <= x <= xu.
Implementation of CheckConvergence_Strategy interface.
AbstractLinAlgPack::value_type value_type
Acts as the central hub for an iterative algorithm.
NLPAlgo & rsqp_algo(Algorithm &algo)
Convert from a Algorithm to a NLPAlgo.