44 #include "ConstrainedOptPack_QPSchurInitKKTSystemHessianFixedFree.hpp"
45 #include "ConstrainedOptPack_initialize_Q_R_Q_X.hpp"
46 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_MatrixSymOp.hpp"
47 #include "AbstractLinAlgPack_sparse_bounds.hpp"
48 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_GenPermMatrixSlice.hpp"
49 #include "AbstractLinAlgPack_GenPermMatrixSliceOp.hpp"
50 #include "DenseLinAlgPack_LinAlgOpPack.hpp"
51 #include "Midynamic_cast_verbose.h"
52 #include "MiWorkspacePack.h"
53 #include "Miprofile_hack.h"
55 namespace LinAlgOpPack {
59 namespace ConstrainedOptPack {
65 ,
const SpVectorSlice& dL
66 ,
const SpVectorSlice& dU
69 ,
const DVectorSlice* f
70 ,
const DVectorSlice& d
71 ,
const SpVectorSlice& nu
74 ,i_x_fixed_t* i_x_fixed
75 ,bnd_fixed_t* bnd_fixed
76 ,j_f_decomp_t* j_f_decomp
84 namespace rcp = MemMngPack;
88 #ifdef PROFILE_HACK_ENABLED
95 G_sym =
dynamic_cast<const MatrixSymOp&
>(G);
98 G_sym =
dyn_cast<
const MatrixSymOp>(G);
104 Workspace<EBounds> x_frfx(wss,nd);
105 std::fill_n( &x_frfx[0], nd, FREE );
109 const value_type inf_bnd = std::numeric_limits<value_type>::max();
112 dL.begin(), dL.end(), dL.offset(),
113 dU.begin(), dU.end(), dU.offset(), inf_bnd );
114 SpVectorSlice::const_iterator
117 const SpVector::difference_type o = nu.offset();
118 while( !dLU_itr.at_end() || nu_itr != nu_end ) {
119 if( dLU_itr.at_end() ) {
120 for( ; nu_itr != nu_end; ++num_init_fixed, ++nu_itr )
121 x_frfx[nu_itr->indice() + o - 1] = ( nu_itr->value() > 0.0 ?
UPPER :
LOWER );
125 for( ; nu_itr != nu_end && nu_itr->indice() + o < dLU_itr.indice(); ++num_init_fixed, ++nu_itr )
126 x_frfx[nu_itr->indice() + o - 1] = ( nu_itr->value() > 0.0 ?
UPPER :
LOWER );
127 if( dLU_itr.lbound() == dLU_itr.ubound() ) {
129 x_frfx[dLU_itr.indice() - 1] = EQUALITY;
132 if( nu_itr != nu_end && nu_itr->indice() + o == dLU_itr.indice() )
142 *n_R = nd - num_init_fixed;
145 i_x_free->resize(*n_R);
146 i_x_fixed->resize(num_init_fixed+1);
147 bnd_fixed->resize(num_init_fixed+1);
148 b_X->resize(num_init_fixed+1);
150 const value_type inf_bnd = std::numeric_limits<value_type>::max();
153 dL.begin(), dL.end(), dL.offset(),
154 dU.begin(), dU.end(), dU.offset(), inf_bnd );
159 if( bnd_i == FREE ) {
160 (*i_x_free)[i_R] = i;
164 (*i_x_fixed)[i_X] = i;
165 (*bnd_fixed)[i_X] = bnd_i;
167 while( dLU_itr.indice() < i )
170 value_type b_X_val = 0.0;
174 b_X_val = dLU_itr.lbound();
177 b_X_val = dLU_itr.ubound();
182 (*b_X)[i_X] = b_X_val;
186 (*i_x_fixed)[i_X] = nd+1;
187 (*bnd_fixed)[i_X] =
LOWER;
193 j_f_decomp->resize(0);
199 Q_X_row_i(wss,num_init_fixed),
200 Q_X_col_j(wss,num_init_fixed);
204 *n_R,num_init_fixed,&(*i_x_free)[0],&(*i_x_fixed)[0],
false
205 ,&Q_R_row_i[0],&Q_R_col_j[0],&Q_R
206 ,&Q_X_row_i[0],&Q_X_col_j[0],&Q_X
214 DMatrix G_RR_dense(*n_R,*n_R);
215 DMatrixSliceSym sym_G_RR_dense(G_RR_dense(),BLAS_Cpp::lower);
217 &sym_G_RR_dense, 1.0, MatrixSymOp::DUMMY_ARG
222 G_RR_ptr =
new MatrixSymPosDefCholFactor();
223 G_RR_ptr->initialize(sym_G_RR_dense);
232 if( num_init_fixed ) {
234 AbstractLinAlgPack::V_MtV( &b_XX, Q_X,
BLAS_Cpp::no_trans, (*b_X)(1,num_init_fixed) );
void Vp_StPtMtV(VectorMutable *v_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, const MatrixOp &M_rhs2, BLAS_Cpp::Transp M_rhs2_trans, const Vector &v_rhs3, value_type beta=1.0)
T_To & dyn_cast(T_From &from)
void Mp_StPtMtP(MatrixOp *mwo_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs, const GenPermMatrixSlice &P_rhs2, BLAS_Cpp::Transp P_rhs2_trans)
const MatrixSymOpNonsing element_type
void V_mV(VectorMutable *v_lhs, const V &V_rhs)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void initialize_kkt_system(const DVectorSlice &g, const MatrixOp &G, value_type etaL, const SpVectorSlice &dL, const SpVectorSlice &dU, const MatrixOp *F, BLAS_Cpp::Transp trans_F, const DVectorSlice *f, const DVectorSlice &d, const SpVectorSlice &nu, size_type *n_R, i_x_free_t *i_x_free, i_x_fixed_t *i_x_fixed, bnd_fixed_t *bnd_fixed, j_f_decomp_t *j_f_decomp, DVector *b_X, Ko_ptr_t *Ko, DVector *fo) const
Initialize the KKT system where initially fixed variables are removed and no equality constraints are...
void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta=1.0)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
TEUCHOSCORE_LIB_DLL_EXPORT Teuchos::RCP< WorkspaceStore > get_default_workspace_store()