|
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 // 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_KKT_FULL_SPACE_RELAXED_H 00030 #define MATRIX_KKT_FULL_SPACE_RELAXED_H 00031 00032 #include "ConstrainedOptPack_Types.hpp" 00033 #include "AbstractLinAlgPack/src/MatrixWithOpFactorized.hpp" 00034 #include "AbstractLinAlgPack/src/MatrixConvertToSparseFortranCompatible.hpp" 00035 #include "Teuchos_StandardCompositionMacros.hpp" 00036 00037 namespace ConstrainedOptPack { 00038 00081 class MatrixKKTFullSpaceRelaxed 00082 : public MatrixWithOpFactorized 00083 , public MatrixConvertToSparseFortranCompatible 00084 { 00085 public: 00086 00088 typedef AbstractLinAlgPack::DirectSparseFortranCompatibleSolver 00089 DirectSparseFortranCompatibleSolver; 00090 00092 class NotInitializedException : public std::logic_error 00093 {public: NotInitializedException (const std::string& what_arg) : std::logic_error(what_arg) {}}; 00094 00096 class SingularMatrixException : public std::logic_error 00097 {public: SingularMatrixException (const std::string& what_arg) : std::logic_error(what_arg) {}}; 00098 00100 class InvalidMatrixType : public std::logic_error 00101 {public: InvalidMatrixType (const std::string& what_arg) : std::logic_error(what_arg) {}}; 00102 00104 enum ERunTests { RUN_TESTS, NO_TESTS }; 00105 00107 enum EPrintMoreOrLess { PRINT_MORE, PRINT_LESS }; 00108 00110 STANDARD_COMPOSITION_MEMBERS( DirectSparseFortranCompatibleSolver, direct_solver ); 00111 00113 MatrixKKTFullSpaceRelaxed( const direct_solver_ptr_t& direct_solver = 0 ); 00114 00151 00155 void initialize( const MatrixOp& G, const MatrixOp& A 00156 , std::ostream* out = 0, EPrintMoreOrLess print_what = PRINT_LESS 00157 , ERunTests test_what = NO_TESTS ); 00158 00164 void initialize_relaxed( const MatrixOp& G, const MatrixOp& A 00165 , const DVectorSlice& c, value_type bigM = 1e+10 00166 , std::ostream* out = 0, EPrintMoreOrLess print_what = PRINT_LESS 00167 , ERunTests test_what = NO_TESTS ); 00168 00179 void set_uninitialized(); 00180 00187 void release_memory(); 00188 00190 00191 // ///////////////////////////////////////////////////// 00192 // Overridden from Matrix 00193 00195 size_type rows() const; 00196 00198 size_type cols() const; 00199 00200 // ///////////////////////////////////////////////////////// 00201 // Overridden from MatrixOp 00202 00204 std::ostream& output(std::ostream& out) const; 00205 00207 MatrixOp& operator=(const MatrixOp& m); 00208 00210 void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1 00211 , const DVectorSlice& vs_rhs2, value_type beta) const; 00212 00213 // //////////////////////////////////////////////////////////// 00214 // Overridden from MatrixFactorized 00215 00217 void V_InvMtV( DVectorSlice* v_lhs, BLAS_Cpp::Transp trans_rhs1 00218 , const DVectorSlice& vs_rhs2) const; 00219 00220 // //////////////////////////////////////////////////////////// 00221 // Overridden from MatrixConvertToSparseFortranCompatible 00222 00224 FortranTypes::f_int num_nonzeros( EExtractRegion extract_region ) const; 00225 00227 void coor_extract_nonzeros( 00228 EExtractRegion extract_region 00229 , const FortranTypes::f_int len_Aval 00230 , FortranTypes::f_dbl_prec Aval[] 00231 , const FortranTypes::f_int len_Aij 00232 , FortranTypes::f_int Arow[] 00233 , FortranTypes::f_int Acol[] 00234 , const FortranTypes::f_int row_offset 00235 , const FortranTypes::f_int col_offset 00236 ) const; 00237 00238 private: 00239 00240 // ////////////////////////////// 00241 // Private data members 00242 00243 bool initialized_; 00244 size_type n_; // Number of rows and columns in G and number of rows in A. 00245 size_type m_; // Number of columns in A 00246 bool use_relaxation_; 00247 value_type bigM_; 00248 EPrintMoreOrLess print_what_; 00249 ERunTests test_what_; 00250 std::ostream *out_; 00251 const MatrixOp *G_; 00252 const MatrixConvertToSparseFortranCompatible 00253 *convG_; 00254 size_type G_nz_; // Remember the number of nonzeros of G 00255 const MatrixOp *A_; 00256 const MatrixConvertToSparseFortranCompatible 00257 *convA_; 00258 size_type A_nz_; // Remember the number of nonzeros of A 00259 00260 // ////////////////////////////// 00261 // Private member functions 00262 00264 void assert_matrices_set() const; 00265 00267 void assert_initialized() const; 00268 00272 void validate_and_set_matrices( const MatrixOp& G, const MatrixOp& A ); 00273 00274 }; // end class MatrixKKTFullSpaceRelaxed 00275 00276 } // end namespace ConstrainedOptPack 00277 00278 #endif // MATRIX_KKT_FULL_SPACE_RELAXED_H
1.7.4