|
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 #include <assert.h> 00030 00031 #include "ConstrainedOptPack_DecompositionSystemCoordinate.hpp" 00032 #include "ConstrainedOptPack_MatrixIdentConcatStd.hpp" 00033 #include "AbstractLinAlgPack_MatrixOpNonsing.hpp" 00034 #include "AbstractLinAlgPack_MatrixOpSubView.hpp" 00035 #include "AbstractLinAlgPack_MatrixZero.hpp" 00036 #include "AbstractLinAlgPack_LinAlgOpPack.hpp" 00037 #include "Teuchos_AbstractFactoryStd.hpp" 00038 #include "Teuchos_dyn_cast.hpp" 00039 #include "Teuchos_TestForException.hpp" 00040 00041 namespace ConstrainedOptPack { 00042 00043 DecompositionSystemCoordinate::DecompositionSystemCoordinate( 00044 const VectorSpace::space_ptr_t &space_x 00045 ,const VectorSpace::space_ptr_t &space_c 00046 ,const basis_sys_ptr_t &basis_sys 00047 ,const basis_sys_tester_ptr_t &basis_sys_tester 00048 ,EExplicitImplicit D_imp 00049 ,EExplicitImplicit Uz_imp 00050 ) 00051 :DecompositionSystemVarReductImp( 00052 space_x, space_c, basis_sys, basis_sys_tester 00053 ,D_imp, Uz_imp ) 00054 {} 00055 00056 // Overridden from DecompositionSystem 00057 00058 const DecompositionSystem::mat_fcty_ptr_t 00059 DecompositionSystemCoordinate::factory_Y() const 00060 { 00061 namespace rcp = MemMngPack; 00062 return Teuchos::rcp( 00063 new Teuchos::AbstractFactoryStd<MatrixOp,MatrixIdentConcatStd>() 00064 ); 00065 } 00066 00067 const DecompositionSystem::mat_nonsing_fcty_ptr_t 00068 DecompositionSystemCoordinate::factory_R() const 00069 { 00070 if( basis_sys().get() ) 00071 return basis_sys()->factory_C(); 00072 return Teuchos::null; 00073 } 00074 00075 const DecompositionSystem::mat_fcty_ptr_t 00076 DecompositionSystemCoordinate::factory_Uy() const 00077 { 00078 return Teuchos::rcp( new Teuchos::AbstractFactoryStd<MatrixOp,MatrixOpSubView>() ); 00079 } 00080 00081 // Overridden from DecompositionSystemVarReductImp 00082 00083 DecompositionSystem::mat_nonsing_fcty_ptr_t::element_type::obj_ptr_t 00084 DecompositionSystemCoordinate::uninitialize_matrices( 00085 std::ostream *out 00086 ,EOutputLevel olevel 00087 ,MatrixOp *Y 00088 ,MatrixOpNonsing *R 00089 ,MatrixOp *Uy 00090 ) const 00091 { 00092 namespace rcp = MemMngPack; 00093 using Teuchos::dyn_cast; 00094 00095 // 00096 // Get pointers to concreate matrices 00097 // 00098 00099 MatrixOpSubView 00100 *Uy_sv = Uy ? &dyn_cast<MatrixOpSubView>(*Uy) : NULL; 00101 00102 // 00103 // Only uninitialize the sub_view matrices 00104 // 00105 00106 if(Uy_sv) 00107 Uy_sv->initialize(Teuchos::null); 00108 00109 // 00110 // Return the basis matrix object R == C as a smart pointer that is 00111 // not owned. This matrix object (if R != NULL) will get updated 00112 // by the basis_sys object as C in the method 00113 // 00114 // DecompositionSystemVarReductImp::update_decomp(...) 00115 // 00116 00117 return Teuchos::rcp(R,false); 00118 00119 } 00120 00121 void DecompositionSystemCoordinate::initialize_matrices( 00122 std::ostream *out 00123 ,EOutputLevel olevel 00124 ,const mat_nonsing_fcty_ptr_t::element_type::obj_ptr_t &C 00125 ,const mat_fcty_ptr_t::element_type::obj_ptr_t &D 00126 ,MatrixOp *Y 00127 ,MatrixOpNonsing *R 00128 ,MatrixOp *Uy 00129 ,EMatRelations mat_rel 00130 ) const 00131 { 00132 namespace rcp = MemMngPack; 00133 using Teuchos::dyn_cast; 00134 00135 const size_type 00136 n = this->n(), 00137 r = this->r(); 00138 const Range1D 00139 var_dep(1,r), 00140 var_indep(r+1,n); 00141 00142 // 00143 // Get pointers to concreate matrices 00144 // 00145 00146 MatrixIdentConcatStd 00147 *Y_coor = Y ? &dyn_cast<MatrixIdentConcatStd>(*Y) : NULL; 00148 MatrixOpSubView 00149 *Uy_sv = Uy ? &dyn_cast<MatrixOpSubView>(*Uy) : NULL; 00150 00151 // 00152 // Initialize the matrices 00153 // 00154 00155 if( Y_coor && Y_coor->D_ptr().get() == NULL ) { 00156 Y_coor->initialize( 00157 space_x() // space_cols 00158 ,space_x()->sub_space(var_dep)->clone() // space_rows 00159 ,MatrixIdentConcatStd::BOTTOM // top_or_bottom 00160 ,0.0 // alpha 00161 ,Teuchos::rcp( 00162 new MatrixZero( 00163 space_x()->sub_space(var_indep)->clone() 00164 ,space_x()->sub_space(var_dep)->clone() 00165 ) ) // D_ptr 00166 ,BLAS_Cpp::no_trans // D_trans 00167 ); 00168 } 00169 TEST_FOR_EXCEPT( !( Uy_sv == NULL ) ); // ToDo: Implement for undecomposed equalities 00170 00171 // The R = C matrix object should already be updateded 00172 00173 } 00174 00175 void DecompositionSystemCoordinate::print_update_matrices( 00176 std::ostream& out, const std::string& L ) const 00177 { 00178 out 00179 << L << "*** Coordinate decompositon Y, R and Uy matrices (class DecompositionSystemCoordinate)\n" 00180 << L << "Y = [ I; 0 ] (using class MatrixIdentConcatStd with MatrixZero)\n" 00181 << L << "R = Gc(var_dep,equ_decomp)' = C\n" 00182 << L << "Uy = Gc(var_dep,equ_undecomp)'\n" 00183 ; 00184 } 00185 00186 } // end namespace ConstrainedOptPack
1.7.4