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