MOOCHO (Single Doxygen Collection) Version of the Day
ConstrainedOptPack_MatrixSymPosDefLBFGSSerial.hpp
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 // 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 "AbstractLinAlgPack_MatrixSymSecant.hpp"
00048 #include "AbstractLinAlgPack_MatrixSymAddDelUpdateable.hpp"
00049 #include "AbstractLinAlgPack/src/MatrixSymWithOpFactorized.hpp"
00050 #include "DenseLinAlgPack_DMatrixAsTriSym.hpp"
00051 #include "Teuchos_StandardMemberCompositionMacros.hpp"
00052 
00053 namespace ConstrainedOptPack {
00054 
00119 class MatrixSymPosDefLBFGS
00120   : public MatrixSymWithOpFactorized
00121   , public MatrixSymSecant
00122   , public MatrixSymAddDelUpdateable
00123 {
00124 public:
00125 
00126   // //////////////////////////////////////////////
00127   // Constructors and initializers
00128 
00130   MatrixSymPosDefLBFGS(
00131     size_type   max_size           = 0
00132       ,size_type  m                  = 10
00133     ,bool       maintain_original  = true
00134     ,bool       maintain_inverse   = true
00135     ,bool       auto_rescaling     = false
00136     );
00137 
00143   STANDARD_MEMBER_COMPOSITION_MEMBERS( bool, auto_rescaling );
00144 
00181    void initial_setup(
00182      size_type   max_size           = 0
00183      ,size_type  m                  = 10
00184      ,bool       maintain_original  = true
00185      ,bool       maintain_inverse   = true
00186      ,bool       auto_rescaling     = false
00187      );
00188 
00189   // //////////////////////////////////
00190   // Representation access
00191 
00193   size_type m() const;
00195   size_type m_bar() const;
00197   size_type k_bar() const;
00199   value_type gamma_k() const;
00201   const DMatrixSlice S() const;
00203   const DMatrixSlice Y() const;
00205   bool maintain_original() const;
00207   bool maintain_inverse() const;
00209   size_type num_secant_updates() const;
00210 
00211   // /////////////////////////////////////////////////////
00212   // Overridden from Matrix
00213 
00215   size_type rows() const;
00216 
00217   // /////////////////////////////////////////////////////////
00220 
00222   std::ostream& output(std::ostream& out) const;
00224   MatrixOp& operator=(const MatrixOp& m);
00226   void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
00227     , const DVectorSlice& vs_rhs2, value_type beta) const;
00228 
00230 
00231   // ////////////////////////////////////////////////////////////
00234 
00236   void V_InvMtV( DVectorSlice* v_lhs, BLAS_Cpp::Transp trans_rhs1
00237     , const DVectorSlice& vs_rhs2) const;
00238 
00240 
00241   // ///////////////////////////////////////////////////////////
00244 
00246   void init_identity( size_type n, value_type alpha );
00253   void init_diagonal( const DVectorSlice& diag );
00255   void secant_update(DVectorSlice* s, DVectorSlice* y, DVectorSlice* Bs);
00256 
00257   //    end Overridden from MatrixSymSecant
00259 
00260   // ////////////////////////////////////////////////////////
00263 
00265   void initialize(
00266     value_type         alpha
00267     ,size_type         max_size
00268     );
00270   void initialize(
00271     const DMatrixSliceSym      &A
00272     ,size_type         max_size
00273     ,bool              force_factorization
00274     ,Inertia           inertia
00275     ,PivotTolerances   pivot_tols
00276     );
00278   size_type max_size() const;
00280   Inertia inertia() const;
00282   void set_uninitialized();
00291   void augment_update(
00292     const DVectorSlice  *t
00293     ,value_type        alpha
00294     ,bool              force_refactorization
00295     ,EEigenValType     add_eigen_val
00296     ,PivotTolerances   pivot_tols
00297     );
00299   void delete_update(
00300     size_type          jd
00301     ,bool              force_refactorization
00302     ,EEigenValType     drop_eigen_val
00303     ,PivotTolerances   pivot_tols
00304     );
00305   
00307   
00308 private:
00309 
00310   // //////////////////////////////////
00311   // Private types
00312 
00313   // //////////////////////////////////
00314   // Private data members
00315 
00316   bool        maintain_original_;  // If true, qualities needed for Bk will be maintained
00317   bool        original_is_updated_;// If true, qualities needed for Bk are already updated
00318   bool        maintain_inverse_;   // If true, quantities needed for Hk will be maintained
00319   bool        inverse_is_updated_; // If true, quantities needed for Hk are already updated
00320 
00321   size_type n_max_, // The maximum size the matrix is allowed to become.
00322         n_,   // Size of the matrix.  If 0 then is uninitialized
00323         m_,   // Maximum number of update vectors that can be stored.
00324         m_bar_, // Current number of update vectors being stored.
00325             // 0 <= m_bar <= m
00326         k_bar_, // Position of the most recently stored update vector in S & Y
00327             // 1 <= k_bar <= m_bar
00328             num_secant_updates_; // Records the number of secant updates performed
00329   value_type  gamma_k_;// Scaling factor for Bo = (1/gamma_k) * I.
00330 
00331   DMatrix S_,   // (n_max x m) Matrix of stored update vectors = [ s1, ..., sm ]
00332             // S(:,k_bar) is the most recently stored s update vector
00333         Y_,   // (n_max x m) Matrix of stored update vectors = [ y1, ..., ym ]
00334             // Y(:,k_bar) is the most recently stored y update vector
00335         STY_, // (m x m) The matrix S'Y
00336         STSYTY_;// ((m+1) x (m+1)) The strictly upper triangular part stores the
00337             // upper triangular part Y'Y and the strictly lower triangular
00338             // part stores the lower triangular part of S'S.  The diagonal
00339             // can be used for workspace.
00340 
00341   mutable bool    Q_updated_; // True if Q has been updated for the most current update.
00342   mutable DMatrix QJ_;    // Used to store factorization of the schur complement of Q.
00343 
00344   mutable DVector   work_;  // workspace for performing operations.
00345 
00346   // //////////////////////////////////
00347   // Private member functions
00348 
00349   // Access to important matrices.
00350 
00352   const DMatrixSliceTri R() const;
00354   const DMatrixSliceTri Lb() const;
00356   DMatrixSlice STY();
00358   const DMatrixSlice STY() const;
00360   DMatrixSliceSym STS();
00362   const DMatrixSliceSym STS() const;
00364   DMatrixSliceSym YTY();
00366   const DMatrixSliceSym YTY() const;
00368   void V_invQtV( DVectorSlice* y, const DVectorSlice& x ) const;
00370   void Vp_DtV( DVectorSlice* y, const DVectorSlice& x ) const;
00371 
00372   // Updates
00373 
00375   void update_Q() const;
00376 
00378   void assert_initialized() const;
00379 
00380 };  // end class MatrixSymPosDefLBFGS
00381 
00382 // //////////////////////////////////////////////
00383 // Inline member functions
00384 
00385 inline
00386 size_type MatrixSymPosDefLBFGS::m() const
00387 {
00388   return m_;
00389 }
00390 
00391 inline
00392 size_type MatrixSymPosDefLBFGS::m_bar() const
00393 {
00394   return m_bar_;
00395 }
00396 
00397 inline
00398 size_type MatrixSymPosDefLBFGS::k_bar() const
00399 {
00400   return k_bar_;
00401 }
00402 
00403 inline
00404 value_type MatrixSymPosDefLBFGS::gamma_k() const
00405 {
00406   return gamma_k_;
00407 }
00408 
00409 inline
00410 const DMatrixSlice MatrixSymPosDefLBFGS::S() const
00411 {
00412   return S_(1,n_,1,m_bar_);
00413 }
00414 
00415 inline
00416 const DMatrixSlice MatrixSymPosDefLBFGS::Y() const
00417 {
00418   return Y_(1,n_,1,m_bar_);
00419 }
00420 
00421 inline
00422 bool MatrixSymPosDefLBFGS::maintain_original() const
00423 {
00424   return maintain_original_;
00425 }
00426 
00427 inline
00428 bool MatrixSymPosDefLBFGS::maintain_inverse() const
00429 {
00430   return maintain_inverse_;
00431 }
00432 
00433 inline
00434 size_type MatrixSymPosDefLBFGS::num_secant_updates() const
00435 {
00436   return num_secant_updates_;
00437 }
00438 
00439 
00440 } // end namespace ConstrainedOptPack 
00441 
00442 #endif  // MATRIX_SYM_POS_DEF_LBFGS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines