ConstrainedOptPack_QPSchurInitKKTSystemHessianRelaxed.cpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00005 //                  Copyright (2003) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #include "ConstrainedOptPack_QPSchurInitKKTSystemHessianRelaxed.hpp"
00030 #include "ConstrainedOptPack_MatrixSymHessianRelaxNonSing.hpp"
00031 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_GenPermMatrixSlice.hpp"
00032 #include "AbstractLinAlgPack_GenPermMatrixSliceOp.hpp"
00033 #include "AbstractLinAlgPack_SpVectorOp.hpp"
00034 #include "DenseLinAlgPack_LinAlgOpPack.hpp"
00035 #include "Midynamic_cast_verbose.h"
00036 
00037 namespace LinAlgOpPack {
00038   using AbstractLinAlgPack::Vp_StV;
00039   using AbstractLinAlgPack::Vp_StMtV;
00040 }
00041 
00042 namespace ConstrainedOptPack {
00043 
00044 void QPSchurInitKKTSystemHessianRelaxed::initialize_kkt_system(
00045   const DVectorSlice&    g
00046   ,const MatrixOp&  G
00047   ,value_type           etaL
00048   ,const SpVectorSlice& dL
00049   ,const SpVectorSlice& dU
00050   ,const MatrixOp*  F
00051   ,BLAS_Cpp::Transp     trans_F
00052   ,const DVectorSlice*   f
00053   ,const DVectorSlice&   d
00054   ,const SpVectorSlice& nu
00055   ,size_type*           n_R
00056   ,i_x_free_t*          i_x_free
00057   ,i_x_fixed_t*         i_x_fixed
00058   ,bnd_fixed_t*         bnd_fixed
00059   ,j_f_decomp_t*        j_f_decomp
00060   ,DVector*              b_X
00061   ,Ko_ptr_t*            Ko
00062   ,DVector*              fo
00063   ) const
00064 {
00065   using BLAS_Cpp::trans;
00066 
00067   // Validate type of and convert G
00068   const MatrixSymHessianRelaxNonSing
00069     *G_relax_ptr = dynamic_cast<const MatrixSymHessianRelaxNonSing*>(&G);
00070 
00071   if( G_relax_ptr == NULL ) {
00072     init_kkt_full_.initialize_kkt_system(
00073       g,G,etaL,dL,dU,F,trans_F,f,d,nu,n_R,i_x_free,i_x_fixed,bnd_fixed
00074       ,j_f_decomp,b_X,Ko,fo);
00075     return;
00076   }
00077 
00078   const MatrixSymHessianRelaxNonSing
00079     &G_relax = *G_relax_ptr;
00080 
00081   // get some stuff
00082   const MatrixSymWithOpFactorized
00083     &G_orig = G_relax.G(),
00084     &M      = G_relax.M();
00085   const size_type
00086     nd = g.size(),
00087     no = G_orig.rows(),
00088     nr = M.rows();
00089   TEST_FOR_EXCEPT( !(  no + nr == nd  ) );
00090 
00091   // Setup output arguments
00092 
00093   // n_R = nd_R
00094   *n_R = no;
00095   // i_x_free.size() == 0 and i_x_free is implicitly identity
00096   i_x_free->resize(no);
00097   {for(size_type l = 1; l <= no; ++l ) {
00098     (*i_x_free)[l-1] = l;
00099   }}
00100   // i_x_fixed[]
00101   i_x_fixed->resize(nr+1);
00102   if(nr) {
00103     // i_x_fixed[l-1] = no + l, l = 1...nr
00104     for( size_type l = 1; l <= nr; ++l )
00105       (*i_x_fixed)[l-1] = no+l;
00106   }
00107   (*i_x_fixed)[nr] = nd+1; // extra relaxation is always initially active
00108   // bnd_fixed[]
00109   bnd_fixed->resize(nr+1);
00110   if(nr) {
00111     // bnd_fixed[l-1] = LOWER, l = 1...nr
00112     std::fill_n( bnd_fixed->begin(), nr, LOWER );
00113   }
00114   (*bnd_fixed)[nr] = LOWER; // relaxation is always initially active
00115   // j_f_decomp[]
00116   j_f_decomp->resize(0);
00117   // b_X
00118   b_X->resize(nr+1);
00119   if(nr) {
00120     // b_X[l-1] = dL(no+l), l = 1...nr
00121     LinAlgOpPack::assign( &(*b_X)(1,nr), dL(no+1,no+nr) );
00122   }
00123   (*b_X)[nr] = etaL; // relaxation is always initially active
00124   // Ko = G.G
00125   *Ko = G_relax.G_ptr(); // now B_RR is a shared object
00126   // fo = - *g(1:no)
00127   LinAlgOpPack::V_StV( fo, -1.0, g(1,no) );
00128 
00129 }
00130 
00131 } // end namesapce ConstrainedOptPack

Generated on Tue Oct 20 12:51:45 2009 for MOOCHO (Single Doxygen Collection) by doxygen 1.4.7