52 #include "ConstrainedOptPack/src/VectorWithNorms.h"
54 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_MatrixSymOp.hpp"
61 #include "Midynamic_cast_verbose.h"
63 namespace MoochoPack {
67 , poss_type assoc_step_poss)
74 using ConstrainedOptPack::NLPSecondOrder;
77 NLPAlgoState &s = algo.rsqp_state();
80 &nlp =
dynamic_cast<NLPSecondOrder&
>(algo.nlp());
82 &nlp =
dyn_cast<NLPSecondOrder>(algo.nlp());
85 *HL_sym_op =
dynamic_cast<MatrixSymOp*
>(&s.HL().get_k(0));
88 std::ostream&
out = algo.track().journal_out();
103 if( !s.lambda().updated_k(-1) ) {
105 out <<
"Initializing lambda_km1 = nlp.get_lambda_init ... \n";
107 nlp.get_init_lagrange_mult( &s.lambda().set_k(-1).v(), NULL );
109 out <<
"||lambda_km1||inf = " << s.lambda().get_k(-1).norm_inf() << std::endl;
111 if( static_cast<int>(olevel) >= static_cast<int>(
PRINT_VECTORS) ) {
112 out <<
"lambda_km1 = \n" << s.lambda().get_k(-1)();
116 nlp.set_HL( HL_sym_op );
117 nlp.calc_HL( s.x().get_k(0)(), s.lambda().get_k(-1)(),
false );
120 s.HL().get_k(0).output( out <<
"\nHL_k = \n" );
124 if( !s.rHL().updated_k(0) ) {
127 std::ostringstream omsg;
129 <<
"ReducedHessianExactStd_Step::do_step(...) : Error, "
130 <<
"The matrix HL with the concrete type "
131 <<
typeName(s.HL().get_k(0)) <<
" does not support the "
132 <<
"MatrixSymOp iterface";
133 throw std::logic_error( omsg.str() );
136 MatrixSymDenseInitialize
137 *rHL_sym_init =
dynamic_cast<MatrixSymDenseInitialize*
>(&s.rHL().set_k(0));
138 if( !rHL_sym_init ) {
139 std::ostringstream omsg;
141 <<
"ReducedHessianExactStd_Step::do_step(...) : Error, "
142 <<
"The matrix rHL with the concrete type "
143 <<
typeName(s.rHL().get_k(0)) <<
" does not support the "
144 <<
"MatrixSymDenseInitialize iterface";
145 throw std::logic_error( omsg.str() );
149 DMatrix rHL_sym_store(nind,nind);
151 Mp_StMtMtM( &rHL_sym, 1.0, MatrixSymOp::DUMMY_ARG, *HL_sym_op
155 out <<
"\nLower triangular partion of dense reduced Hessian (ignore nonzeros above diagonal):\nrHL_dense = \n" << rHL_sym_store();
159 rHL_sym_init->initialize( rHL_sym );
162 s.rHL().get_k(0).output( out <<
"\nrHL_k = \n" );
171 , poss_type assoc_step_poss, std::ostream& out,
const std::string& L )
const
174 << L <<
"*** Calculate the exact reduced Hessian of the Lagrangian\n"
175 << L <<
"if lambda_km1 is not updated then\n"
176 << L <<
" lambda_km1 = nlp.get_lambda_init\n"
178 << L <<
"HL_k = HL(x_k,lambda_km1) <: R^(n+m) -> R^(n x n)\n"
179 << L <<
"if rHL_k is not updated then\n"
180 << L <<
" rHL_dense = Z_k' * HL_k * Z_k (MatrixSymOp interface for HL_k)\n"
181 << L <<
" rHL_k = rHL_dense (MatrixSymDenseInitialize interface for rHL_k)\n"
AbstractLinAlgPack::size_type size_type
std::string typeName(const T &t)
Interface adding operations specific for a symmetric matrix {abstract}.
DMatrixSliceSym nonconst_sym(DMatrixSlice gms, BLAS_Cpp::Uplo uplo)
Return a symmetric matrix.
EJournalOutputLevel
enum for journal output.
void Mp_StMtMtM(MatrixSymOp *sym_lhs, value_type alpha, MatrixSymOp::EMatRhsPlaceHolder dummy_place_holder, const MatrixSymOp &M, const MatrixOp &mwo_rhs, BLAS_Cpp::Transp mwo_rhs_trans, value_type beta=1.0)
sym_lhs = alpha * op(mwo_rhs') * M * op(mwo_rhs) + beta * sym_lhs
T_To & dyn_cast(T_From &from)
void print_algorithm_step(const Algorithm &algo, Algorithm::poss_type step_poss, EDoStepType type, Algorithm::poss_type assoc_step_poss, std::ostream &out)
Prints to 'out' the algorithm step.
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
bool do_step(Algorithm &algo, poss_type step_poss, IterationPack::EDoStepType type, poss_type assoc_step_poss)
DenseLinAlgPack::DMatrixSliceSym DMatrixSliceSym
Mix-in Interface for initializing a matrix with a dense symmetric matrix.
NLPAlgo & rsqp_algo(Algorithm &algo)
Convert from a Algorithm to a NLPAlgo.