/usr/include/trilinos/ConstrainedOptPack_MatrixKKTFullSpaceRelaxed.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | // @HEADER
// ***********************************************************************
//
// Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
// Copyright (2003) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
// Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
//
// ***********************************************************************
// @HEADER
#ifndef MATRIX_KKT_FULL_SPACE_RELAXED_H
#define MATRIX_KKT_FULL_SPACE_RELAXED_H
#include "ConstrainedOptPack_Types.hpp"
#include "AbstractLinAlgPack/src/MatrixWithOpFactorized.hpp"
#include "AbstractLinAlgPack/src/MatrixConvertToSparseFortranCompatible.hpp"
#include "Teuchos_StandardCompositionMacros.hpp"
namespace ConstrainedOptPack {
/** \brief Implementation of a KKT matrix factorized in the full space.
*
* This class is used to represent the KKT matrix of the following
* relaxed QP:
*
\begin{verbatim}
min [ g' M ] * [ d ] + 1/2 * [ d' eta ] * [ G ] * [ d ]
[ eta ] [ M ] [ eta ]
s.t. [ A' -c ] * [ d ] + c = 0
[ eta ]
\end{verbatim}
*
* The only matrix actually factorized is:
*
\begin{verbatim}
K_bar = [ G A ]
[ A' ]
\end{verbatim}
*
* The class has two modes.
*
* First mode is to not include the relaxation
* term and therefore the KKT matrix is:
*
\begin{verbatim}
K = [ G A ]
[ A' ]
\end{verbatim}
*
* The second mode is the use the relaxation and he represented matrix is:
*
\begin{verbatim}
[ G A ]
K = [ M -c' ]
[ A' -c ]
\end{verbatim}
*
* This class uses an aggregate DirectSparseFortranCompatibleSolver (DSFCS)
* object to factorize K above and then to solve for the linear systems
* involving K.
*/
class MatrixKKTFullSpaceRelaxed
: public MatrixWithOpFactorized
, public MatrixConvertToSparseFortranCompatible
{
public:
/** \brief . */
typedef AbstractLinAlgPack::DirectSparseFortranCompatibleSolver
DirectSparseFortranCompatibleSolver;
/** \brief . */
class NotInitializedException : public std::logic_error
{public: NotInitializedException (const std::string& what_arg) : std::logic_error(what_arg) {}};
/** \brief . */
class SingularMatrixException : public std::logic_error
{public: SingularMatrixException (const std::string& what_arg) : std::logic_error(what_arg) {}};
/** \brief . */
class InvalidMatrixType : public std::logic_error
{public: InvalidMatrixType (const std::string& what_arg) : std::logic_error(what_arg) {}};
/** \brief . */
enum ERunTests { RUN_TESTS, NO_TESTS };
/** \brief . */
enum EPrintMoreOrLess { PRINT_MORE, PRINT_LESS };
/// <<std comp>> members for the direct sparse linear solver
STANDARD_COMPOSITION_MEMBERS( DirectSparseFortranCompatibleSolver, direct_solver );
/** \brief . */
MatrixKKTFullSpaceRelaxed( const direct_solver_ptr_t& direct_solver = 0 );
/** @name Initialize the relaxed or unrelaxed KKT matrix.
*
* These operations will factorize the matrix K. If the matrix K
* is not full rank then a SingularMatrixException exception will
* be thrown. The objects G and A must support the
* MatrixConvertToSparseFortranCompatible (MCTSFC) interface or
* the exception InvalidMatrixType will be thrown.
*
* Some of the common arguments that these initialization methods share
* are:
*
* \begin{itemize}
* \item G [I] Hessian matrix ( must support MESFCE interface ).
* \item A [I] Gradient of constraints matrix ( must support MESFCE interface ).
* \item out [O] Output stream to print to. This stream may be used for
* output after initialization also so make sure that it remains valid
* as long as this matrix object is is use. For no output set out=NULL.
* \item run_test [I] If set the true then many (expensive) tests will be
* preformed to ensure that everything is working properly.
* \item print_more [I] If set the true then a lot more output may be produced
* expecially if some error occurs.
* \end{itemize}
*
* Important: It is vital that the definitions of G and A do not change
* externally while this object is being used. To do so may invalidate
* the behavior of this object (especially the MatrixOp functions).
*
* This class will try to reuse the factorization structure from the
* last call to initialze(...) or initialize_relaxed(...) when possible.
* Namely if G and A have the same dimensions and same number of nonzeros
* of the matrices previously factorized, it will be assumed that the
* structure will be the same. If this is not the case then the
* client should call release_memory(...) to wipe the slate clean and
* start over before calling initialize...(...) again.
*/
//@{
/** \brief Initialize the nonrelaxed matrix.
*
*/
void initialize( const MatrixOp& G, const MatrixOp& A
, std::ostream* out = 0, EPrintMoreOrLess print_what = PRINT_LESS
, ERunTests test_what = NO_TESTS );
/** \brief Initialize the relaxed matrix.
*
* If the unrelaxed QP is well scaled (near 1.0) then a reasonable
* value for bigM = M might be 1e+10 however this is problem specific.
*/
void initialize_relaxed( const MatrixOp& G, const MatrixOp& A
, const DVectorSlice& c, value_type bigM = 1e+10
, std::ostream* out = 0, EPrintMoreOrLess print_what = PRINT_LESS
, ERunTests test_what = NO_TESTS );
/** \brief Set the matrix to uninitialized.
*
* The purpose of this method is for the client to specifically state that
* it is done using this object for now. This is to avoid problems where
* the definitions of G and A might change and then another client unknowingly
* trys to use this object.
*
* Note that this does not erase storage of the factorization structure
* for example.
*/
void set_uninitialized();
/** \brief Clear all allocated storage.
*
* The client should call this routine if he wants the new KKT matrix
* to be reanalyze and factorized the next time initialize...(...) is
* called.
*/
void release_memory();
//@}
// /////////////////////////////////////////////////////
// Overridden from Matrix
/** \brief . */
size_type rows() const;
/** \brief . */
size_type cols() const;
// /////////////////////////////////////////////////////////
// Overridden from MatrixOp
/** \brief . */
std::ostream& output(std::ostream& out) const;
/** \brief . */
MatrixOp& operator=(const MatrixOp& m);
/// (2) vs_lhs = alpha * op(M_rhs1) * vs_rhs2 + beta * vs_lhs (BLAS xGEMV)
void Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
, const DVectorSlice& vs_rhs2, value_type beta) const;
// ////////////////////////////////////////////////////////////
// Overridden from MatrixFactorized
/// (1) v_lhs = inv(op(M_rhs1)) * vs_rhs2
void V_InvMtV( DVectorSlice* v_lhs, BLAS_Cpp::Transp trans_rhs1
, const DVectorSlice& vs_rhs2) const;
// ////////////////////////////////////////////////////////////
// Overridden from MatrixConvertToSparseFortranCompatible
/** \brief . */
FortranTypes::f_int num_nonzeros( EExtractRegion extract_region ) const;
/** \brief . */
void coor_extract_nonzeros(
EExtractRegion extract_region
, const FortranTypes::f_int len_Aval
, FortranTypes::f_dbl_prec Aval[]
, const FortranTypes::f_int len_Aij
, FortranTypes::f_int Arow[]
, FortranTypes::f_int Acol[]
, const FortranTypes::f_int row_offset
, const FortranTypes::f_int col_offset
) const;
private:
// //////////////////////////////
// Private data members
bool initialized_;
size_type n_; // Number of rows and columns in G and number of rows in A.
size_type m_; // Number of columns in A
bool use_relaxation_;
value_type bigM_;
EPrintMoreOrLess print_what_;
ERunTests test_what_;
std::ostream *out_;
const MatrixOp *G_;
const MatrixConvertToSparseFortranCompatible
*convG_;
size_type G_nz_; // Remember the number of nonzeros of G
const MatrixOp *A_;
const MatrixConvertToSparseFortranCompatible
*convA_;
size_type A_nz_; // Remember the number of nonzeros of A
// //////////////////////////////
// Private member functions
/** \brief . */
void assert_matrices_set() const;
/** \brief . */
void assert_initialized() const;
/** \brief Validate the types and sizes of G and A, set the member pointers G_ and A_
* and return the conversion interfaces convG and convA.
*/
void validate_and_set_matrices( const MatrixOp& G, const MatrixOp& A );
}; // end class MatrixKKTFullSpaceRelaxed
} // end namespace ConstrainedOptPack
#endif // MATRIX_KKT_FULL_SPACE_RELAXED_H
|