47 #include "AbstractLinAlgPack_assert_print_nan_inf.hpp"
48 #include "AbstractLinAlgPack_VectorAuxiliaryOps.hpp"
49 #include "AbstractLinAlgPack_MatrixSymDiagStd.hpp"
50 #include "AbstractLinAlgPack_VectorOut.hpp"
51 #include "AbstractLinAlgPack_LinAlgOpPack.hpp"
52 #include "NLPInterfacePack_NLPBarrier.hpp"
53 #include "MoochoPack_PreProcessBarrierLineSearch_Step.hpp"
54 #include "MoochoPack_IpState.hpp"
55 #include "MoochoPack_moocho_algo_conversion.hpp"
56 #include "IterationPack_print_algorithm_step.hpp"
57 #include "Teuchos_dyn_cast.hpp"
58 #include "Teuchos_Assert.hpp"
60 #define min(a,b) ( (a < b) ? a : b )
61 #define max(a,b) ( (a > b) ? a : b )
63 namespace MoochoPack {
67 const value_type tau_boundary_frac
70 tau_boundary_frac_(tau_boundary_frac),
71 barrier_nlp_(barrier_nlp),
72 filter_(FILTER_IQ_STRING)
77 "PreProcessBarrierLineSearch_Step given NULL NLPBarrier."
88 using IterationPack::print_algorithm_step;
89 using AbstractLinAlgPack::assert_print_nan_inf;
96 NLP &nlp = algo.nlp();
98 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
102 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) )
104 using IterationPack::print_algorithm_step;
105 print_algorithm_step( _algo, step_poss, type, assoc_step_poss, out );
108 const value_type& mu_k = s.barrier_parameter().get_k(0);
111 if (filter_.exists_in(s))
113 if ( s.barrier_parameter().updated_k(-1) )
115 const value_type mu_km1 = s.barrier_parameter().get_k(-1);
118 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) )
120 out <<
"\nBarrier Parameter changed - resetting the filter ...\n";
123 MoochoPack::Filter_T &filter_k = filter_(s).set_k(0);
130 barrier_nlp_->
mu(s.barrier_parameter().get_k(0));
133 barrier_nlp_->
set_Gf( &(s.grad_barrier_obj().set_k(0)) );
134 barrier_nlp_->
calc_Gf(s.x().get_k(0),
true);
136 barrier_nlp_->
set_f( &(s.barrier_obj().set_k(0)) );
137 barrier_nlp_->
calc_f(s.x().get_k(0),
true);
142 value_type& alpha_k = s.alpha().set_k(0);
143 value_type& alpha_vl_k = s.alpha_vl().set_k(0);
144 value_type& alpha_vu_k = s.alpha_vu().set_k(0);
146 const Vector& x_k = s.x().get_k(0);
147 VectorMutable& x_kp1 = s.x().set_k(+1);
149 const Vector& d_k = s.d().get_k(0);
150 const Vector& dvl_k = s.dvl().get_k(0);
151 const Vector& dvu_k = s.dvu().get_k(0);
153 const Vector& vl_k = s.Vl().get_k(0).diag();
154 VectorMutable& vl_kp1 = s.Vl().set_k(+1).diag();
156 const Vector& vu_k = s.Vu().get_k(0).diag();
157 VectorMutable& vu_kp1 = s.Vu().set_k(+1).diag();
183 Vp_StV( &x_kp1, alpha_k, d_k);
185 alpha_vl_k = alpha_vu_k = min(alpha_vl_k, alpha_vu_k);
188 Vp_StV( &vl_kp1, alpha_vl_k, dvl_k);
191 Vp_StV( &vu_kp1, alpha_vu_k, dvu_k);
194 IterQuantityAccess<VectorMutable>
195 *c_iq = nlp.m() > 0 ? &s.c() : NULL;
197 if (assert_print_nan_inf(x_kp1,
"x",
true, NULL))
201 barrier_nlp_->
set_f( &s.barrier_obj().set_k(+1) );
203 barrier_nlp_->
set_c( &c_iq->set_k(+1) );
204 barrier_nlp_->
calc_c( x_kp1,
true );
206 barrier_nlp_->
calc_f( x_kp1,
false );
210 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) )
212 out <<
"\nalpha_vl_k = " << alpha_vl_k
213 <<
"\nalpha_vu_k = " << alpha_vu_k
214 <<
"\nalpha_k = " << alpha_k
218 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_VECTORS) )
220 out <<
"\nvl_kp1 = \n" << vl_kp1
221 <<
"\nvu_kp1 = \n" << vu_kp1
222 <<
"\nx_kp1 = \n" << x_kp1;
228 void PreProcessBarrierLineSearch_Step::print_step(
229 const Algorithm& _algo, poss_type step_poss, IterationPack::EDoStepType type
230 ,poss_type assoc_step_poss, std::ostream& out,
const std::string& L
235 out << L <<
"*** calculate alpha max by the fraction to boundary rule\n"
236 << L <<
"ToDo: Complete documentation\n";
241 const int local_num_options = 1;
248 const char* local_SOptions[local_num_options] =
256 PreProcessBarrierLineSearch_StepSetOptions::PreProcessBarrierLineSearch_StepSetOptions(
257 PreProcessBarrierLineSearch_Step* target
258 ,
const char opt_grp_name[] )
260 OptionsFromStreamPack::SetOptionsFromStreamNode(
261 opt_grp_name, local_num_options, local_SOptions ),
262 OptionsFromStreamPack::SetOptionsToTargetBase< PreProcessBarrierLineSearch_Step >( target )
265 void PreProcessBarrierLineSearch_StepSetOptions::setOption(
266 int option_num,
const std::string& option_value )
268 typedef PreProcessBarrierLineSearch_Step target_t;
269 switch( (local_EOptions)option_num )
271 case TAU_BOUNDARY_FRAC:
272 target().tau_boundary_frac(std::atof(option_value.c_str()));
void calc_f(const Vector &x, bool newx=true) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
T_To & dyn_cast(T_From &from)
rSQP Algorithm control class.
virtual void unset_quantities()
void mu(const value_type mu)
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
virtual std::ostream & journal_out() const
void set_c(VectorMutable *c)
AlgorithmTracker & track()
value_type fraction_to_boundary(const value_type tau, const Vector &x, const Vector &d, const Vector &xl, const Vector &xu)
value_type fraction_to_zero_boundary(const value_type tau, const Vector &x, const Vector &d)
void calc_c(const Vector &x, bool newx=true) const
void set_Gf(VectorMutable *Gf)
void set_f(value_type *f)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
PreProcessBarrierLineSearch_Step(Teuchos::RCP< NLPInterfacePack::NLPBarrier > barrier_nlp, const value_type tau_boundary_frac=0.99)
Constructor.
void calc_Gf(const Vector &x, bool newx=true) const