46 #include "AbstractLinAlgPack_MatrixSymDiagStd.hpp"
47 #include "AbstractLinAlgPack_VectorStdOps.hpp"
48 #include "AbstractLinAlgPack_VectorOut.hpp"
49 #include "AbstractLinAlgPack_VectorAuxiliaryOps.hpp"
50 #include "AbstractLinAlgPack_assert_print_nan_inf.hpp"
51 #include "NLPInterfacePack_NLPFirstOrder.hpp"
52 #include "IterationPack_print_algorithm_step.hpp"
53 #include "MoochoPack_IpState.hpp"
54 #include "MoochoPack_PreEvalNewPointBarrier_Step.hpp"
55 #include "MoochoPack_moocho_algo_conversion.hpp"
57 #include "OptionsFromStreamPack_StringToBool.hpp"
59 #include "Teuchos_dyn_cast.hpp"
61 namespace MoochoPack {
64 const value_type relative_bound_push,
65 const value_type absolute_bound_push
68 relative_bound_push_(relative_bound_push),
69 absolute_bound_push_(absolute_bound_push)
78 using IterationPack::print_algorithm_step;
83 NLP &nlp = algo.nlp();
84 NLPFirstOrder *nlp_foi =
dynamic_cast<NLPFirstOrder*
>(&nlp);
86 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
89 if(!nlp.is_initialized())
90 nlp.initialize(algo.algo_cntr().check_results());
93 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_ALGORITHM_STEPS) )
95 using IterationPack::print_algorithm_step;
96 print_algorithm_step( _algo, step_poss, type, assoc_step_poss, out );
99 IterQuantityAccess<value_type> &barrier_parameter_iq = s.barrier_parameter();
100 IterQuantityAccess<VectorMutable> &x_iq = s.x();
102 if( x_iq.last_updated() == IterQuantity::NONE_UPDATED )
104 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_ALGORITHM_STEPS) )
106 out <<
"\nInitialize x with x_k = nlp.xinit() ...\n"
107 <<
" and push x_k within bounds.\n";
109 VectorMutable& x_k = x_iq.set_k(0) = nlp.xinit();
113 absolute_bound_push_,
119 IterQuantityAccess<value_type>
121 IterQuantityAccess<VectorMutable>
123 *c_iq = nlp.m() > 0 ? &s.c() : NULL;
124 IterQuantityAccess<MatrixOp>
125 *Gc_iq = nlp_foi ? &s.Gc() : NULL;
127 using AbstractLinAlgPack::assert_print_nan_inf;
128 assert_print_nan_inf(x_k,
"x",
true, NULL);
131 if(f_iq.updated_k(0))
132 f_iq.set_not_updated_k(0);
133 if(Gf_iq.updated_k(0))
134 Gf_iq.set_not_updated_k(0);
137 if(c_iq->updated_k(0))
138 c_iq->set_not_updated_k(0);
142 if(Gc_iq->updated_k(0))
143 Gc_iq->set_not_updated_k(0);
147 if (barrier_parameter_iq.last_updated() == IterQuantity::NONE_UPDATED)
149 barrier_parameter_iq.set_k(-1) = 0.1;
153 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_VECTORS) )
155 out <<
"x_k =\n" << x_iq.get_k(0);
162 void PreEvalNewPointBarrier_Step::print_step(
163 const Algorithm& _algo, poss_type step_poss, IterationPack::EDoStepType type
164 ,poss_type assoc_step_poss, std::ostream& out,
const std::string& L
169 out << L <<
"# Evaluate information specific to primal / dual barrier algorithms\n"
170 << L <<
"if (x never updated) then\n"
171 << L <<
" x_k = nlp.xinit()\n"
172 << L <<
" force_in_bounds(x_k)\n"
173 << L <<
" set f_k not updated\n"
174 << L <<
" set Gf_k not updated\n"
175 << L <<
" if (m > 0) then\n"
176 << L <<
" set c_k not updated\n"
177 << L <<
" set Gc_k not updated\n"
184 const int local_num_options = 2;
192 const char* local_SOptions[local_num_options] =
194 "relative_bound_push",
195 "absolute_bound_push"
201 PreEvalNewPointBarrier_StepSetOptions::PreEvalNewPointBarrier_StepSetOptions(
202 PreEvalNewPointBarrier_Step* target
203 ,
const char opt_grp_name[] )
205 OptionsFromStreamPack::SetOptionsFromStreamNode(
206 opt_grp_name, local_num_options, local_SOptions ),
207 OptionsFromStreamPack::SetOptionsToTargetBase< PreEvalNewPointBarrier_Step >( target )
211 void PreEvalNewPointBarrier_StepSetOptions::setOption(
212 int option_num,
const std::string& option_value )
214 using OptionsFromStreamPack::StringToBool;
216 typedef PreEvalNewPointBarrier_Step target_t;
217 switch( (local_EOptions)option_num )
219 case RELATIVE_BOUND_PUSH:
220 target().relative_bound_push(std::atof(option_value.c_str()));
222 case ABSOLUTE_BOUND_PUSH:
223 target().absolute_bound_push(std::atof(option_value.c_str()));
PreEvalNewPointBarrier_Step(const value_type relative_bound_push=0.01, const value_type absolute_bound_push=0.001)
void force_in_bounds_buffer(const value_type rel_push, const value_type abs_push, const Vector &xl, const Vector &xu, VectorMutable *x)
T_To & dyn_cast(T_From &from)
rSQP Algorithm control class.
virtual std::ostream & journal_out() const
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
AlgorithmTracker & track()
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)