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 // 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 #ifndef MATRIX_SYM_POS_DEF_LBFGS_H
00030 #define MATRIX_SYM_POS_DEF_LBFGS_H
00031 
00032 #include <vector>
00033 
00034 #include "AbstractLinAlgPack_MatrixSymSecant.hpp"
00035 #include "AbstractLinAlgPack_MatrixSymAddDelUpdateable.hpp"
00036 #include "AbstractLinAlgPack/src/MatrixSymWithOpFactorized.hpp"
00037 #include "DenseLinAlgPack_DMatrixAsTriSym.hpp"
00038 #include "Teuchos_StandardMemberCompositionMacros.hpp"
00039 
00040 namespace ConstrainedOptPack {
00041 
00106 class MatrixSymPosDefLBFGS
00107   : public MatrixSymWithOpFactorized
00108   , public MatrixSymSecant
00109   , public MatrixSymAddDelUpdateable
00110 {
00111 public:
00112 
00113   // //////////////////////////////////////////////
00114   // Constructors and initializers
00115 
00117   MatrixSymPosDefLBFGS(
00118     size_type   max_size           = 0
00119       ,size_type  m                  = 10
00120     ,bool       maintain_original  = true
00121     ,bool       maintain_inverse   = true
00122     ,bool       auto_rescaling     = false
00123     );
00124 
00130   STANDARD_MEMBER_COMPOSITION_MEMBERS( bool, auto_rescaling );
00131 
00168    void initial_setup(
00169      size_type   max_size           = 0
00170      ,size_type  m                  = 10
00171      ,bool       maintain_original  = true
00172      ,bool       maintain_inverse   = true
00173      ,bool       auto_rescaling     = false
00174      );
00175 
00176   // //////////////////////////////////
00177   // Representation access
00178 
00180   size_type m() const;
00182   size_type m_bar() const;
00184   size_type k_bar() const;
00186   value_type gamma_k() const;
00188   const DMatrixSlice S() const;
00190   const DMatrixSlice Y() const;
00192   bool maintain_original() const;
00194   bool maintain_inverse() const;
00196   size_type num_secant_updates() const;
00197 
00198   // /////////////////////////////////////////////////////
00199   // Overridden from Matrix
00200 
00202   size_type rows() const;
00203 
00204   // /////////////////////////////////////////////////////////
00207 
00209   std::ostream& output(std::ostream& out) const;
00211   MatrixOp& operator=(const MatrixOp& m);
00213   void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
00214     , const DVectorSlice& vs_rhs2, value_type beta) const;
00215 
00217 
00218   // ////////////////////////////////////////////////////////////
00221 
00223   void V_InvMtV( DVectorSlice* v_lhs, BLAS_Cpp::Transp trans_rhs1
00224     , const DVectorSlice& vs_rhs2) const;
00225 
00227 
00228   // ///////////////////////////////////////////////////////////
00231 
00233   void init_identity( size_type n, value_type alpha );
00240   void init_diagonal( const DVectorSlice& diag );
00242   void secant_update(DVectorSlice* s, DVectorSlice* y, DVectorSlice* Bs);
00243 
00244   //    end Overridden from MatrixSymSecant
00246 
00247   // ////////////////////////////////////////////////////////
00250 
00252   void initialize(
00253     value_type         alpha
00254     ,size_type         max_size
00255     );
00257   void initialize(
00258     const DMatrixSliceSym      &A
00259     ,size_type         max_size
00260     ,bool              force_factorization
00261     ,Inertia           inertia
00262     ,PivotTolerances   pivot_tols
00263     );
00265   size_type max_size() const;
00267   Inertia inertia() const;
00269   void set_uninitialized();
00278   void augment_update(
00279     const DVectorSlice  *t
00280     ,value_type        alpha
00281     ,bool              force_refactorization
00282     ,EEigenValType     add_eigen_val
00283     ,PivotTolerances   pivot_tols
00284     );
00286   void delete_update(
00287     size_type          jd
00288     ,bool              force_refactorization
00289     ,EEigenValType     drop_eigen_val
00290     ,PivotTolerances   pivot_tols
00291     );
00292   
00294   
00295 private:
00296 
00297   // //////////////////////////////////
00298   // Private types
00299 
00300   // //////////////////////////////////
00301   // Private data members
00302 
00303   bool        maintain_original_;  // If true, qualities needed for Bk will be maintained
00304   bool        original_is_updated_;// If true, qualities needed for Bk are already updated
00305   bool        maintain_inverse_;   // If true, quantities needed for Hk will be maintained
00306   bool        inverse_is_updated_; // If true, quantities needed for Hk are already updated
00307 
00308   size_type n_max_, // The maximum size the matrix is allowed to become.
00309         n_,   // Size of the matrix.  If 0 then is uninitialized
00310         m_,   // Maximum number of update vectors that can be stored.
00311         m_bar_, // Current number of update vectors being stored.
00312             // 0 <= m_bar <= m
00313         k_bar_, // Position of the most recently stored update vector in S & Y
00314             // 1 <= k_bar <= m_bar
00315             num_secant_updates_; // Records the number of secant updates performed
00316   value_type  gamma_k_;// Scaling factor for Bo = (1/gamma_k) * I.
00317 
00318   DMatrix S_,   // (n_max x m) Matrix of stored update vectors = [ s1, ..., sm ]
00319             // S(:,k_bar) is the most recently stored s update vector
00320         Y_,   // (n_max x m) Matrix of stored update vectors = [ y1, ..., ym ]
00321             // Y(:,k_bar) is the most recently stored y update vector
00322         STY_, // (m x m) The matrix S'Y
00323         STSYTY_;// ((m+1) x (m+1)) The strictly upper triangular part stores the
00324             // upper triangular part Y'Y and the strictly lower triangular
00325             // part stores the lower triangular part of S'S.  The diagonal
00326             // can be used for workspace.
00327 
00328   mutable bool    Q_updated_; // True if Q has been updated for the most current update.
00329   mutable DMatrix QJ_;    // Used to store factorization of the schur complement of Q.
00330 
00331   mutable DVector   work_;  // workspace for performing operations.
00332 
00333   // //////////////////////////////////
00334   // Private member functions
00335 
00336   // Access to important matrices.
00337 
00339   const DMatrixSliceTri R() const;
00341   const DMatrixSliceTri Lb() const;
00343   DMatrixSlice STY();
00345   const DMatrixSlice STY() const;
00347   DMatrixSliceSym STS();
00349   const DMatrixSliceSym STS() const;
00351   DMatrixSliceSym YTY();
00353   const DMatrixSliceSym YTY() const;
00355   void V_invQtV( DVectorSlice* y, const DVectorSlice& x ) const;
00357   void Vp_DtV( DVectorSlice* y, const DVectorSlice& x ) const;
00358 
00359   // Updates
00360 
00362   void update_Q() const;
00363 
00365   void assert_initialized() const;
00366 
00367 };  // end class MatrixSymPosDefLBFGS
00368 
00369 // //////////////////////////////////////////////
00370 // Inline member functions
00371 
00372 inline
00373 size_type MatrixSymPosDefLBFGS::m() const
00374 {
00375   return m_;
00376 }
00377 
00378 inline
00379 size_type MatrixSymPosDefLBFGS::m_bar() const
00380 {
00381   return m_bar_;
00382 }
00383 
00384 inline
00385 size_type MatrixSymPosDefLBFGS::k_bar() const
00386 {
00387   return k_bar_;
00388 }
00389 
00390 inline
00391 value_type MatrixSymPosDefLBFGS::gamma_k() const
00392 {
00393   return gamma_k_;
00394 }
00395 
00396 inline
00397 const DMatrixSlice MatrixSymPosDefLBFGS::S() const
00398 {
00399   return S_(1,n_,1,m_bar_);
00400 }
00401 
00402 inline
00403 const DMatrixSlice MatrixSymPosDefLBFGS::Y() const
00404 {
00405   return Y_(1,n_,1,m_bar_);
00406 }
00407 
00408 inline
00409 bool MatrixSymPosDefLBFGS::maintain_original() const
00410 {
00411   return maintain_original_;
00412 }
00413 
00414 inline
00415 bool MatrixSymPosDefLBFGS::maintain_inverse() const
00416 {
00417   return maintain_inverse_;
00418 }
00419 
00420 inline
00421 size_type MatrixSymPosDefLBFGS::num_secant_updates() const
00422 {
00423   return num_secant_updates_;
00424 }
00425 
00426 
00427 } // end namespace ConstrainedOptPack 
00428 
00429 #endif  // MATRIX_SYM_POS_DEF_LBFGS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines