44 #include "MoochoPack_CheckDescentQuasiNormalStep_Step.hpp"
45 #include "MoochoPack_Exceptions.hpp"
46 #include "MoochoPack_moocho_algo_conversion.hpp"
47 #include "IterationPack_print_algorithm_step.hpp"
48 #include "AbstractLinAlgPack_VectorSpace.hpp"
49 #include "AbstractLinAlgPack_VectorMutable.hpp"
50 #include "AbstractLinAlgPack_VectorOut.hpp"
51 #include "AbstractLinAlgPack_VectorStdOps.hpp"
52 #include "AbstractLinAlgPack_MatrixOp.hpp"
53 #include "AbstractLinAlgPack_LinAlgOpPack.hpp"
54 #include "Teuchos_Assert.hpp"
56 namespace MoochoPack {
59 const calc_fd_prod_ptr_t& calc_fd_prod
61 :calc_fd_prod_(calc_fd_prod)
71 using LinAlgOpPack::V_MtV;
73 NLPAlgo &algo = rsqp_algo(_algo);
75 NLP &nlp = algo.nlp();
76 const Range1D equ_decomp = s.equ_decomp();
78 EJournalOutputLevel olevel = algo.algo_cntr().journal_output_level();
82 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
83 using IterationPack::print_algorithm_step;
84 print_algorithm_step( algo, step_poss, type, assoc_step_poss, out );
88 nb = nlp.num_bounded_x();
91 IterQuantityAccess<VectorMutable>
94 const Vector::vec_ptr_t
95 cd_k = c_iq.get_k(0).sub_view(equ_decomp);
97 &Ypy_k = Ypy_iq.get_k(0);
99 value_type descent_c = -1.0;
101 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
102 out <<
"\nGc_k exists; compute descent_c = c_k(equ_decomp)'*Gc_k(:,equ_decomp)'*Ypy_k ...\n";
104 const MatrixOp::mat_ptr_t
105 Gcd_k = s.Gc().get_k(0).sub_view(Range1D(),equ_decomp);
106 VectorSpace::vec_mut_ptr_t
107 t = cd_k->space().create_member();
109 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_VECTORS) ) {
110 out <<
"\nGc_k(:,equ_decomp)'*Ypy_k =\n" << *t;
112 descent_c =
dot( *cd_k, *t );
115 if( static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
116 out <<
"\nGc_k does not exist; compute descent_c = c_k(equ_decomp)'*FDGc_k(:,equ_decomp)'*Ypy_k "
117 <<
"using finite differences ...\n";
119 VectorSpace::vec_mut_ptr_t
120 t = nlp.space_c()->create_member();
121 calc_fd_prod().calc_deriv_product(
122 s.x().get_k(0),nb?&nlp.xl():NULL,nb?&nlp.xu():NULL
123 ,Ypy_k,NULL,&c_iq.get_k(0),
true,&nlp
125 ,
static_cast<int>(olevel) >= static_cast<int>(PRINT_ALGORITHM_STEPS) ? &out : NULL
127 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_VECTORS) ) {
128 out <<
"\nFDGc_k(:,equ_decomp)'*Ypy_k =\n" << *t->sub_view(equ_decomp);
130 descent_c =
dot( *cd_k, *t->sub_view(equ_decomp) );
133 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
134 out <<
"\ndescent_c = " << descent_c << std::endl;
137 if( descent_c > 0.0 ) {
138 if( static_cast<int>(olevel) >=
static_cast<int>(PRINT_ALGORITHM_STEPS) ) {
139 out <<
"\nError, descent_c > 0.0; this is not a descent direction\n"
140 <<
"Throw TestFailed and terminate the algorithm ...\n";
144 ,
"CheckDescentQuasiNormalStep_Step::do_step(...) : Error, descent for the decomposed constraints "
145 "with respect to the quasi-normal step c_k(equ_decomp)'*FDGc_k(:,equ_decomp)'*Ypy_k = "
146 << descent_c <<
" > 0.0; This is not a descent direction!\n" );
154 ,
poss_type assoc_step_poss, std::ostream& out,
const std::string& L
158 << L <<
"*** Check for descent in the decomposed equality constraints for the quasi-normal step\n"
159 << L <<
"if Gc_k exists then\n"
160 << L <<
" descent_c = c_k(equ_decomp)'*Gc_k(:,equ_decomp)'*Ypy_k\n"
162 << L <<
" descent_c = c_k(equ_decomp)'*FDGc(:,equ_decomp)'*Ypy_k (finite diff.)\n"
164 << L <<
"if descent > 0.0 then\n"
165 << L <<
" throw TestFailed exception!\n"
CheckDescentQuasiNormalStep_Step(const calc_fd_prod_ptr_t &calc_fd_prod)
Constructor.
void print_step(const Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss, std::ostream &out, const std::string &leading_str) const
Thrown if a runtime test failed.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
rSQP Algorithm control class.
virtual std::ostream & journal_out() const
Reduced space SQP state encapsulation interface.
AlgorithmTracker & track()
virtual iq_id_type get_iter_quant_id(const std::string &iq_name) const
value_type dot(const Vector &v_rhs1, const Vector &v_rhs2)
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
NLPAlgoState & rsqp_state()
<<std aggr>="">> members for algo_cntr