|
ConstrainedOptPack: C++ Tools for Constrained (and Unconstrained) Optimization
Version of the Day
|
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 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00038 // 00039 // *********************************************************************** 00040 // @HEADER 00041 00042 #ifndef MATRIX_SYM_POS_DEF_LBFGS_H 00043 #define MATRIX_SYM_POS_DEF_LBFGS_H 00044 00045 #include <vector> 00046 00047 #include "ConstrainedOptPack_Types.hpp" 00048 #include "AbstractLinAlgPack_MatrixSymSecant.hpp" 00049 #include "AbstractLinAlgPack_MatrixSymOpNonsing.hpp" 00050 #include "AbstractLinAlgPack_MultiVectorMutable.hpp" 00051 #include "AbstractLinAlgPack_VectorSpace.hpp" 00052 #include "DenseLinAlgPack_DMatrixAsTriSym.hpp" 00053 #include "Teuchos_StandardMemberCompositionMacros.hpp" 00054 00055 namespace ConstrainedOptPack { 00056 00110 class MatrixSymPosDefLBFGS 00111 : public AbstractLinAlgPack::MatrixSymOpNonsing // doxygen needs full path 00112 , public MatrixSymSecant 00113 { 00114 public: 00115 00118 00120 typedef Teuchos::RCP<const MultiVector> multi_vec_ptr_t; 00121 00124 class PostMod { 00125 public: 00127 PostMod( 00128 size_type m = 10 00129 ,bool maintain_original = true 00130 ,bool maintain_inverse = true 00131 ,bool auto_rescaling = false 00132 ) 00133 :m_(m) 00134 ,maintain_original_(maintain_original) 00135 ,maintain_inverse_(maintain_inverse) 00136 ,auto_rescaling_(auto_rescaling) 00137 {} 00139 void initialize(MatrixSymPosDefLBFGS* p) const 00140 { 00141 p->initial_setup(m_,maintain_original_,maintain_inverse_,auto_rescaling_); 00142 } 00143 private: 00144 size_type m_; 00145 bool maintain_original_; 00146 bool maintain_inverse_; 00147 bool auto_rescaling_; 00148 }; // end PostMod 00149 00151 00154 00156 MatrixSymPosDefLBFGS( 00157 size_type m = 10 00158 ,bool maintain_original = true 00159 ,bool maintain_inverse = true 00160 ,bool auto_rescaling = false 00161 ); 00162 00168 STANDARD_MEMBER_COMPOSITION_MEMBERS( bool, auto_rescaling ); 00169 00203 void initial_setup( 00204 size_type m = 10 00205 ,bool maintain_original = true 00206 ,bool maintain_inverse = true 00207 ,bool auto_rescaling = false 00208 ); 00209 00210 // ////////////////////////////////// 00211 // Representation access 00212 00214 size_type m() const; 00216 size_type m_bar() const; 00218 value_type gamma_k() const; 00220 const multi_vec_ptr_t S() const; 00222 const multi_vec_ptr_t Y() const; 00224 bool maintain_original() const; 00226 bool maintain_inverse() const; 00230 size_type num_secant_updates() const; 00231 00233 00236 00238 const VectorSpace& space_cols() const; 00240 std::ostream& output(std::ostream& out) const; 00242 MatrixOp& operator=(const MatrixOp& mwo); 00244 void Vp_StMtV( 00245 VectorMutable* v_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1 00246 , const Vector& v_rhs2, value_type beta ) const; 00247 00249 00252 00254 void V_InvMtV( 00255 VectorMutable* v_lhs, BLAS_Cpp::Transp trans_rhs1 00256 , const Vector& v_rhs2 ) const; 00257 00259 00262 00264 void init_identity( const VectorSpace& space_diag, value_type alpha ); 00271 void init_diagonal( const Vector& diag ); 00273 void secant_update( 00274 VectorMutable *s 00275 ,VectorMutable *y 00276 ,VectorMutable *Bs 00277 ); 00278 00280 00281 private: 00282 00283 // ////////////////////////////////// 00284 // Private types 00285 00286 typedef VectorSpace::multi_vec_mut_ptr_t multi_vec_mut_ptr_t; 00287 00288 // ////////////////////////////////// 00289 // Private data members 00290 00291 bool maintain_original_; // If true, qualities needed for Bk will be maintained 00292 bool original_is_updated_;// If true, qualities needed for Bk are already updated 00293 bool maintain_inverse_; // If true, quantities needed for Hk will be maintained 00294 bool inverse_is_updated_; // If true, quantities needed for Hk are already updated 00295 00296 VectorSpace::space_ptr_t 00297 vec_spc_; // The vector space that everything is based on. 00298 00299 size_type n_, // Size of the matrix. If 0 then is uninitialized 00300 m_, // Maximum number of update vectors that can be stored. 00301 m_bar_, // Current number of update vectors being stored. 00302 // 0 <= m_bar <= m 00303 num_secant_updates_; // Records the number of secant updates performed 00304 value_type gamma_k_;// Scaling factor for Bo = (1/gamma_k) * I. 00305 00306 multi_vec_mut_ptr_t 00307 S_, // (n x m) Matrix of stored update vectors = [ s1, ..., sm ] 00308 // S(:,m_bar) is the most recently stored s update vector 00309 Y_; // (n_max x m) Matrix of stored update vectors = [ y1, ..., ym ] 00310 // Y(:,k_bar) is the most recently stored y update vector 00311 DMatrix STY_, // (m x m) The matrix S'Y 00312 STSYTY_;// ((m+1) x (m+1)) The strictly upper triangular part stores the 00313 // upper triangular part Y'Y and the strictly lower triangular 00314 // part stores the lower triangular part of S'S. The diagonal 00315 // can be used for workspace. 00316 00317 mutable bool Q_updated_; // True if Q has been updated for the most current update. 00318 mutable DMatrix QJ_; // Used to store factorization of the schur complement of Q. 00319 00320 // ////////////////////////////////// 00321 // Private member functions 00322 00323 // Access to important matrices. 00324 00326 const DMatrixSliceTri R() const; 00328 const DMatrixSliceTri Lb() const; 00330 DMatrixSlice STY(); 00332 const DMatrixSlice STY() const; 00334 DMatrixSliceSym STS(); 00336 const DMatrixSliceSym STS() const; 00338 DMatrixSliceSym YTY(); 00340 const DMatrixSliceSym YTY() const; 00342 void V_invQtV( DVectorSlice* y, const DVectorSlice& x ) const; 00344 void Vp_DtV( DVectorSlice* y, const DVectorSlice& x ) const; 00345 00346 // Updates 00347 00349 void update_Q() const; 00350 00352 void assert_initialized() const; 00353 00354 }; // end class MatrixSymPosDefLBFGS 00355 00356 // ////////////////////////////////////////////// 00357 // Inline member functions 00358 00359 inline 00360 size_type MatrixSymPosDefLBFGS::m() const 00361 { 00362 return m_; 00363 } 00364 00365 inline 00366 size_type MatrixSymPosDefLBFGS::m_bar() const 00367 { 00368 return m_bar_; 00369 } 00370 00371 inline 00372 value_type MatrixSymPosDefLBFGS::gamma_k() const 00373 { 00374 return gamma_k_; 00375 } 00376 00377 inline 00378 const MatrixSymPosDefLBFGS::multi_vec_ptr_t 00379 MatrixSymPosDefLBFGS::S() const 00380 { 00381 return S_->mv_sub_view(1,n_,1,m_bar_); 00382 } 00383 00384 inline 00385 const MatrixSymPosDefLBFGS::multi_vec_ptr_t 00386 MatrixSymPosDefLBFGS::Y() const 00387 { 00388 return Y_->mv_sub_view(1,n_,1,m_bar_); 00389 } 00390 00391 inline 00392 bool MatrixSymPosDefLBFGS::maintain_original() const 00393 { 00394 return maintain_original_; 00395 } 00396 00397 inline 00398 bool MatrixSymPosDefLBFGS::maintain_inverse() const 00399 { 00400 return maintain_inverse_; 00401 } 00402 00403 inline 00404 size_type MatrixSymPosDefLBFGS::num_secant_updates() const 00405 { 00406 return num_secant_updates_; 00407 } 00408 00409 } // end namespace ConstrainedOptPack 00410 00411 #endif // MATRIX_SYM_POS_DEF_LBFGS_H
1.7.6.1