47 #include "MoochoPack_UpdateBarrierParameter_Step.hpp"
48 #include "MoochoPack_moocho_algo_conversion.hpp"
49 #include "IterationPack_print_algorithm_step.hpp"
50 #include "Teuchos_dyn_cast.hpp"
51 #include "MoochoPack_IpState.hpp"
52 #include "AbstractLinAlgPack_MatrixSymDiagStd.hpp"
53 #include "AbstractLinAlgPack_VectorStdOps.hpp"
54 #include "AbstractLinAlgPack_VectorAuxiliaryOps.hpp"
55 #include "Teuchos_Assert.hpp"
57 #include "OptionsFromStreamPack_StringToBool.hpp"
59 #define min(a,b) ( (a < b) ? a : b )
60 #define max(a,b) ( (a > b) ? a : b )
62 namespace MoochoPack {
65 const value_type init_barrier_parameter,
66 const value_type tau_mu,
67 const value_type theta_mu,
68 const value_type tau_epsilon,
69 const value_type theta_epsilon,
70 const value_type e_tol_max
73 init_barrier_parameter_(init_barrier_parameter),
76 tau_epsilon_(tau_epsilon),
77 theta_epsilon_(theta_epsilon),
88 using IterationPack::print_algorithm_step;
92 NLP &nlp = algo.nlp();
94 if (!nlp.is_initialized())
96 nlp.initialize(
false);
99 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
103 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) )
105 using IterationPack::print_algorithm_step;
106 print_algorithm_step( _algo, step_poss, type, assoc_step_poss, out );
113 IterQuantityAccess<value_type>& e_tol_iq = s.e_tol();
114 IterQuantityAccess<value_type>& mu_iq = s.barrier_parameter();
135 const value_type opt_err = s.opt_kkt_err().get_k(0);
136 const value_type feas_err = s.feas_kkt_err().get_k(0);
137 const value_type comp_err_mu = s.comp_err_mu().get_k(0);
139 const value_type mu_km1 = mu_iq.get_k(-1);
140 if (e_tol_iq.last_updated() == IterQuantity::NONE_UPDATED)
144 e_tol_iq.set_k(0) = Calculate_e_tol(mu_iq.get_k(0));
148 const value_type e_tol_km1 = e_tol_iq.get_k(-1);
149 bool sub_prob_converged = (opt_err < e_tol_km1 && feas_err < e_tol_km1 && comp_err_mu < e_tol_km1);
150 if (sub_prob_converged)
153 value_type& mu_k = mu_iq.set_k(0);
154 mu_k = min(tau_mu_*mu_km1, pow(mu_km1, theta_mu_));
155 e_tol_iq.set_k(0) = Calculate_e_tol(mu_k);
157 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) )
159 out <<
"\nSub-problem converged!\n"
160 <<
" Updating barrier parameter (mu) and sub problem tolerance (e_tol) ...\n";
165 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) )
167 out <<
"\nSub-problem not-converged!\n"
168 <<
" Keeping existing barrier parameter (mu) and sub problem tolerance (e_tol) ...\n";
171 e_tol_iq.set_k(0,-1);
175 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) )
177 out <<
"\nbarrier_parameter (mu) = " << mu_iq.get_k(0)
178 <<
"\nsub problem tolerance (e_tol) = " << e_tol_iq.get_k(0) << std::endl;
186 void UpdateBarrierParameter_Step::print_step(
187 const Algorithm& _algo, poss_type step_poss, IterationPack::EDoStepType type
188 ,poss_type assoc_step_poss, std::ostream& out,
const std::string& L
193 out << L <<
"# Update the interior point barrier parameter (mu)\n"
194 << L <<
"if (KKTerror < e_tol) then\n"
195 << L <<
" mu_kp1 = min(tau_mu*mu_k, mu_k^theta_mu)\n"
196 << L <<
" e_tol_kp1 = min(e_tol_max, tau_epsilon*min(mu_k, mu_k^theta_epsilon))\n"
198 << L <<
" mu_kp1 = mu_k\n"
199 << L <<
" e_tol_kp1 = e_tol_k\n"
203 value_type UpdateBarrierParameter_Step::Calculate_e_tol(value_type mu)
205 value_type e_tol = tau_epsilon_*min(mu, pow(mu, theta_epsilon_));
206 e_tol = min(e_tol_max_, e_tol);
214 const int local_num_options = 5;
225 const char* local_SOptions[local_num_options] =
237 UpdateBarrierParameter_StepSetOptions::UpdateBarrierParameter_StepSetOptions(
238 UpdateBarrierParameter_Step* target
239 ,
const char opt_grp_name[] )
241 OptionsFromStreamPack::SetOptionsFromStreamNode(
242 opt_grp_name, local_num_options, local_SOptions ),
243 OptionsFromStreamPack::SetOptionsToTargetBase< UpdateBarrierParameter_Step >( target )
247 void UpdateBarrierParameter_StepSetOptions::setOption(
248 int option_num,
const std::string& option_value )
250 using OptionsFromStreamPack::StringToBool;
252 typedef UpdateBarrierParameter_Step target_t;
253 switch( (local_EOptions)option_num )
256 target().tau_mu(std::atof(option_value.c_str()));
259 target().theta_mu(std::atof(option_value.c_str()));
262 target().tau_epsilon(std::atof(option_value.c_str()));
265 target().theta_epsilon(std::atof(option_value.c_str()));
268 target().e_tol_max(std::atof(option_value.c_str()));
UpdateBarrierParameter_Step(const value_type init_barrier_parameter=0.1, const value_type tau_mu=0.2, const value_type theta_mu=1.5, const value_type tau_epsilon=10, const value_type theta_epsilon=1.1, const value_type e_tol_max=1000)
Constructor.
T_To & dyn_cast(T_From &from)
rSQP Algorithm control class.
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
virtual std::ostream & journal_out() const
AlgorithmTracker & track()
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)