|
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 QP_SCHUR_CONSTRAINTS_RELAXED_STD_H 00030 #define QP_SCHUR_CONSTRAINTS_RELAXED_STD_H 00031 00032 #include <list> 00033 00034 #include "ConstrainedOptPack_QPSchur.hpp" 00035 #include "AbstractLinAlgPack_MatrixOp.hpp" 00036 #include "AbstractLinAlgPack_VectorSpaceBlocked.hpp" 00037 00038 namespace ConstrainedOptPack { 00039 namespace QPSchurPack { 00040 00076 class ConstraintsRelaxedStd : public Constraints { 00077 public: 00078 00079 // ///////////////////////////////////////////// 00080 // Public types 00081 00092 class MatrixConstraints : public MatrixOp { 00093 public: 00094 00099 MatrixConstraints(); 00100 00110 void initialize( 00111 const VectorSpace::space_ptr_t &space_d_eta 00112 ,const size_type m_in 00113 ,const size_type m_eq 00114 ,const MatrixOp *E 00115 ,BLAS_Cpp::Transp trans_E 00116 ,const Vector *b 00117 ,const MatrixOp *F 00118 ,BLAS_Cpp::Transp trans_F 00119 ,const Vector *f 00120 ,size_type m_undecomp 00121 ,const size_type j_f_undecomp[] 00122 ); 00123 00126 00128 size_type nd() const 00129 { return nd_; } 00131 size_type m_in() const 00132 { return m_in_; } 00134 size_type m_eq() const 00135 { return m_eq_; } 00137 const MatrixOp* E() const 00138 { return E_; } 00140 BLAS_Cpp::Transp trans_E() const 00141 { return trans_E_; } 00143 const Vector* b() const 00144 { return b_; } 00146 const MatrixOp* F() const 00147 { return F_; } 00149 BLAS_Cpp::Transp trans_F() const 00150 { return trans_F_; } 00152 const Vector* f() const 00153 { return f_; } 00155 const GenPermMatrixSlice& P_u() const 00156 { return P_u_; } 00157 00159 00162 00164 const VectorSpace& space_cols() const; 00166 const VectorSpace& space_rows() const; 00168 MatrixOp& operator=(const MatrixOp& m); 00169 // /// 00170 // void Mp_StPtMtP( 00171 // DMatrixSlice* gms_lhs, value_type alpha 00172 // ,const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans 00173 // ,BLAS_Cpp::Transp M_trans 00174 // ,const GenPermMatrixSlice& P_rhs2, BLAS_Cpp::Transp P_rhs2_trans 00175 // ) const ; 00177 void Vp_StMtV( 00178 VectorMutable* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1 00179 ,const Vector& vs_rhs2, value_type beta 00180 ) const; 00182 void Vp_StPtMtV( 00183 VectorMutable* vs_lhs, value_type alpha 00184 ,const GenPermMatrixSlice& P_rhs1, BLAS_Cpp::Transp P_rhs1_trans 00185 ,BLAS_Cpp::Transp M_rhs2_trans 00186 ,const SpVectorSlice& sv_rhs3, value_type beta 00187 ) const; 00188 00190 00191 private: 00192 typedef std::vector<size_type> row_i_t; 00193 typedef std::vector<size_type> col_j_t; 00194 size_type nd_; // # unknowns d 00195 size_type m_in_; // # op(E)*d inequality constraints 00196 size_type m_eq_; // # op(F)*d equality constraints 00197 const MatrixOp *E_; // If NULL then no general inequalities 00198 BLAS_Cpp::Transp trans_E_; 00199 const Vector *b_; 00200 const MatrixOp *F_; // If NULL then no general equalities 00201 BLAS_Cpp::Transp trans_F_; 00202 const Vector *f_; 00203 GenPermMatrixSlice P_u_; 00204 row_i_t P_u_row_i_; 00205 col_j_t P_u_col_j_; 00206 VectorSpace::space_ptr_t space_cols_; 00207 VectorSpaceBlocked space_rows_; 00208 }; // end class MatrixConstraints 00209 00211 enum EInequalityPickPolicy { 00212 ADD_BOUNDS_THEN_MOST_VIOLATED_INEQUALITY 00213 ,ADD_BOUNDS_THEN_FIRST_VIOLATED_INEQUALITY 00214 ,ADD_MOST_VIOLATED_BOUNDS_AND_INEQUALITY 00215 }; 00216 00219 00222 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, bounds_tol ); 00223 00226 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, inequality_tol ); 00227 00230 STANDARD_MEMBER_COMPOSITION_MEMBERS( value_type, equality_tol ); 00231 00234 STANDARD_MEMBER_COMPOSITION_MEMBERS( EInequalityPickPolicy, inequality_pick_policy ); 00235 00237 ConstraintsRelaxedStd(); 00238 00282 void initialize( 00283 const VectorSpace::space_ptr_t &space_d_eta 00284 ,value_type etaL 00285 ,const Vector *dL 00286 ,const Vector *dU 00287 ,const MatrixOp *E 00288 ,BLAS_Cpp::Transp trans_E 00289 ,const Vector *b 00290 ,const Vector *eL 00291 ,const Vector *eU 00292 ,const MatrixOp *F 00293 ,BLAS_Cpp::Transp trans_F 00294 ,const Vector *f 00295 ,size_type m_undecomp 00296 ,const size_type j_f_undecomp[] 00297 ,VectorMutable *Ed 00298 ,bool check_F = true 00299 ,value_type bounds_tol = 1e-10 00300 ,value_type inequality_tol = 1e-10 00301 ,value_type equality_tol = 1e-10 00302 ); 00303 00305 const MatrixConstraints& A_bar_relaxed() const; 00306 00308 00311 00313 size_type n() const; 00315 size_type m_breve() const; 00324 const MatrixOp& A_bar() const; 00326 void pick_violated_policy( EPickPolicy pick_policy ); 00328 EPickPolicy pick_violated_policy() const; 00369 void pick_violated( 00370 const DVectorSlice& x, size_type* j_viol, value_type* constr_val 00371 ,value_type* viol_bnd_val, value_type* norm_2_constr, EBounds* bnd, bool* can_ignore 00372 ) const; 00374 void ignore( size_type j ); 00376 value_type get_bnd( size_type j, EBounds bnd ) const; 00377 00379 00380 private: 00381 00382 // ////////////////////////////// 00383 // Private types 00384 00385 typedef std::list<size_type> passed_over_equalities_t; 00386 00387 // ////////////////////////////// 00388 // Private data members 00389 00390 MatrixConstraints A_bar_; 00391 value_type etaL_; 00392 const Vector *dL_; // If NULL then no simple bounds 00393 const Vector *dU_; 00394 const Vector *eL_; 00395 const Vector *eU_; 00396 VectorMutable *Ed_; 00397 bool check_F_; 00398 mutable size_type last_added_j_; // Remember the last bound added so that 00399 mutable value_type last_added_bound_; // we can save our selfs some work. 00400 mutable EBounds last_added_bound_type_; // ... 00401 mutable size_type next_undecomp_f_k_; 00402 // Determines the next constraint [P_u'*op(F)*d + (1 - eta) * P_u'*f](next_undecomp_f_k) 00403 // to be checked to see if it is violated. If next_undecomp_f_k > P_u.nz() then all 00404 // of the constriants have been checked. 00405 mutable passed_over_equalities_t passed_over_equalities_; 00406 // This is a list that keeps track of those equality constraints that were checked 00407 // for being violated but were within tolerance and therefore passed over and not added. 00408 // This list can be traversed again and again to check these constraints. Specifically, the 00409 // indexes of f(k) are sorted, not the indexes in P_u'. 00410 00411 // ////////////////////////////// 00412 // Private member functions 00413 00415 void cache_last_added( 00416 size_type last_added_j, value_type last_added_bound 00417 ,EBounds last_added_bound_type 00418 ) const; 00419 00420 }; // end class ConstraintsRelaxedStd 00421 00422 } // end namespace QPSchurPack 00423 } // end namespace ConstrainedOptPack 00424 00425 #endif // QP_SCHUR_CONSTRAINTS_RELAXED_STD_H
1.7.4