|
ConstrainedOptPack: C++ Tools for Constrained (and Unconstrained) Optimization
Version of the Day
|
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 // Redistribution and use in source and binary forms, with or without 00013 // modification, are permitted provided that the following conditions are 00014 // met: 00015 // 00016 // 1. Redistributions of source code must retain the above copyright 00017 // notice, this list of conditions and the following disclaimer. 00018 // 00019 // 2. Redistributions in binary form must reproduce the above copyright 00020 // notice, this list of conditions and the following disclaimer in the 00021 // documentation and/or other materials provided with the distribution. 00022 // 00023 // 3. Neither the name of the Corporation nor the names of the 00024 // contributors may be used to endorse or promote products derived from 00025 // this software without specific prior written permission. 00026 // 00027 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00028 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00029 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00030 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00031 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00032 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00033 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00034 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00035 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00036 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00037 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00038 // 00039 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00040 // 00041 // *********************************************************************** 00042 // @HEADER 00043 00044 #include "ConstrainedOptPack_QPSchurInitKKTSystemHessianRelaxed.hpp" 00045 #include "ConstrainedOptPack_MatrixSymHessianRelaxNonSing.hpp" 00046 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_GenPermMatrixSlice.hpp" 00047 #include "AbstractLinAlgPack_GenPermMatrixSliceOp.hpp" 00048 #include "AbstractLinAlgPack_SpVectorOp.hpp" 00049 #include "DenseLinAlgPack_LinAlgOpPack.hpp" 00050 #include "Midynamic_cast_verbose.h" 00051 00052 namespace LinAlgOpPack { 00053 using AbstractLinAlgPack::Vp_StV; 00054 using AbstractLinAlgPack::Vp_StMtV; 00055 } 00056 00057 namespace ConstrainedOptPack { 00058 00059 void QPSchurInitKKTSystemHessianRelaxed::initialize_kkt_system( 00060 const DVectorSlice& g 00061 ,const MatrixOp& G 00062 ,value_type etaL 00063 ,const SpVectorSlice& dL 00064 ,const SpVectorSlice& dU 00065 ,const MatrixOp* F 00066 ,BLAS_Cpp::Transp trans_F 00067 ,const DVectorSlice* f 00068 ,const DVectorSlice& d 00069 ,const SpVectorSlice& nu 00070 ,size_type* n_R 00071 ,i_x_free_t* i_x_free 00072 ,i_x_fixed_t* i_x_fixed 00073 ,bnd_fixed_t* bnd_fixed 00074 ,j_f_decomp_t* j_f_decomp 00075 ,DVector* b_X 00076 ,Ko_ptr_t* Ko 00077 ,DVector* fo 00078 ) const 00079 { 00080 using BLAS_Cpp::trans; 00081 00082 // Validate type of and convert G 00083 const MatrixSymHessianRelaxNonSing 00084 *G_relax_ptr = dynamic_cast<const MatrixSymHessianRelaxNonSing*>(&G); 00085 00086 if( G_relax_ptr == NULL ) { 00087 init_kkt_full_.initialize_kkt_system( 00088 g,G,etaL,dL,dU,F,trans_F,f,d,nu,n_R,i_x_free,i_x_fixed,bnd_fixed 00089 ,j_f_decomp,b_X,Ko,fo); 00090 return; 00091 } 00092 00093 const MatrixSymHessianRelaxNonSing 00094 &G_relax = *G_relax_ptr; 00095 00096 // get some stuff 00097 const MatrixSymWithOpFactorized 00098 &G_orig = G_relax.G(), 00099 &M = G_relax.M(); 00100 const size_type 00101 nd = g.size(), 00102 no = G_orig.rows(), 00103 nr = M.rows(); 00104 TEUCHOS_TEST_FOR_EXCEPT( !( no + nr == nd ) ); 00105 00106 // Setup output arguments 00107 00108 // n_R = nd_R 00109 *n_R = no; 00110 // i_x_free.size() == 0 and i_x_free is implicitly identity 00111 i_x_free->resize(no); 00112 {for(size_type l = 1; l <= no; ++l ) { 00113 (*i_x_free)[l-1] = l; 00114 }} 00115 // i_x_fixed[] 00116 i_x_fixed->resize(nr+1); 00117 if(nr) { 00118 // i_x_fixed[l-1] = no + l, l = 1...nr 00119 for( size_type l = 1; l <= nr; ++l ) 00120 (*i_x_fixed)[l-1] = no+l; 00121 } 00122 (*i_x_fixed)[nr] = nd+1; // extra relaxation is always initially active 00123 // bnd_fixed[] 00124 bnd_fixed->resize(nr+1); 00125 if(nr) { 00126 // bnd_fixed[l-1] = LOWER, l = 1...nr 00127 std::fill_n( bnd_fixed->begin(), nr, LOWER ); 00128 } 00129 (*bnd_fixed)[nr] = LOWER; // relaxation is always initially active 00130 // j_f_decomp[] 00131 j_f_decomp->resize(0); 00132 // b_X 00133 b_X->resize(nr+1); 00134 if(nr) { 00135 // b_X[l-1] = dL(no+l), l = 1...nr 00136 LinAlgOpPack::assign( &(*b_X)(1,nr), dL(no+1,no+nr) ); 00137 } 00138 (*b_X)[nr] = etaL; // relaxation is always initially active 00139 // Ko = G.G 00140 *Ko = G_relax.G_ptr(); // now B_RR is a shared object 00141 // fo = - *g(1:no) 00142 LinAlgOpPack::V_StV( fo, -1.0, g(1,no) ); 00143 00144 } 00145 00146 } // end namesapce ConstrainedOptPack 00147 00148 #endif // 0
1.7.6.1