/usr/include/trilinos/ConstrainedOptPack_DecompositionSystemVarReductImp.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 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | // @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 DECOMPOSITION_SYSTEM_VAR_REDUCT_IMP_H
#define DECOMPOSITION_SYSTEM_VAR_REDUCT_IMP_H
#include "ConstrainedOptPack_DecompositionSystemVarReduct.hpp"
#include "AbstractLinAlgPack_BasisSystemTester.hpp"
#include "AbstractLinAlgPack_VectorSpace.hpp"
#include "Teuchos_StandardCompositionMacros.hpp"
#include "Teuchos_StandardMemberCompositionMacros.hpp"
namespace ConstrainedOptPack {
/** \brief Specialization node implementation subclass of \c DecompositionSystem for
* variable reduction decompositions.
*
* This interface abstracts a variable reduction decomposition where:
*
\verbatim
Gc' = [ C N ]
[ E F ]
Z = [ D ]
[ I ]
Uz = F + E * D
where:
C = Gc(var_dep,equ_decomp)' [nonsingular]
N = Gc(var_indep,equ_decomp)'
E = Gc(var_dep,equ_undecomp)'
F = Gc(var_indep,equ_undecomp)'
D = -inv(C) * N
\endverbatim
*
* Above, \a C is a <tt>r x r</tt> nonsingular matrix. Subclasses define
* how \c Y is defined which in turn determines how \c R and \c Uy are
* defined.
*
* The implementation of this subclass is completly determined by an aggregate
* <tt>BasisSytem</tt> object. Since the <tt>BasisSystem</tt> interface does
* not allow any permutations of the basis to be performed ???.
*
* <b>Subclass implementors notes:</b>
*
* It is up to subclasses to override \c factory_R() and \c factory_Uy()
* in order to define the types for \c R and \c Uy
* respectively.
*
* ToDo: Finish documentation!
*/
class DecompositionSystemVarReductImp : public DecompositionSystemVarReduct {
public:
/** @name Public types */
//@{
/** \brief . */
typedef DecompositionSystem inherited;
/** \brief . */
typedef Teuchos::RCP<const BasisSystem> basis_sys_ptr_t;
//@}
/** @name Constructors / initializers */
//@{
/// Set the BasisSystem tester object
STANDARD_COMPOSITION_MEMBERS( BasisSystemTester, basis_sys_tester );
/** \brief Construct a variable reduction decomposition.
*
* Calls <tt>this->initialize()</tt>.
*
* Preconditions:<ul>
* <li> ???
* </ul>
*
* Postconditions:<ul>
* <li> <tt>this->factory_Z().get() != NULL</tt>
* </ul>
*/
DecompositionSystemVarReductImp(
const VectorSpace::space_ptr_t &space_x
,const VectorSpace::space_ptr_t &space_c
,const basis_sys_ptr_t &basis_sys
,const basis_sys_tester_ptr_t &basis_sys_tester
,EExplicitImplicit D_imp
,EExplicitImplicit Uz_imp
);
//@}
/** \brief Initialize.
*
* @param space_x
* [in] DVector space for variables \c x.
* @param space_c
* [in] DVector space for general equalities \c c.
* @param basis_sys
* [in] The <tt>BasisSystem</tt> object that defines the
* variable reduction that the decomposition is based on.
* This object must be fully initialized before this
* method is called. The object <tt>*basis_sys</tt> must
* not be altered while \c this is still using it. It is
* allowed for <tt>basis_sys.get() == NULL</tt> in which
* case \c this will not be fully initialized.
*
* Preconditions:<ul>
* <li> ToDo: Spell these out!
* </ul>
*
* Postconditions:<ul>
* <li> ToDo: Spell these out!
* </ul>
*/
void initialize(
const VectorSpace::space_ptr_t &space_x
,const VectorSpace::space_ptr_t &space_c
,const basis_sys_ptr_t &basis_sys
);
/** @name Access */
//@{
/** \brief . */
const VectorSpace::space_ptr_t& space_x() const;
/** \brief . */
const VectorSpace::space_ptr_t& space_c() const;
/** \brief . */
const basis_sys_ptr_t& basis_sys() const;
//@}
/** @name Basis manipulation */
//@{
/** \brief Called by client to uninitialize decomposition matrices in prepairation
* for selecting a different basis.
*
* @param Z [in/out] On output, \c Z will have all references to \c C and \c D removed.
* @param Y [in/out] On output, \c Y will have all references to \c C and \c D removed.
* @param R [in/out] On output, \c R will have all references to \c C and \c D removed.
* @param Uz [in/out] If <tt>this->Uz_imp() == MAT_IMP_IMPLICIT</tt> then on output,
* \c Uz will have all references to \c C and \c D removed. If
* <tt>this->Uz_imp() == MAT_IMP_EXPLICIT</tt> then \c Uz will be unaltered
* and it is expected that the client will initialize it properly before
* the next call to \c this->set_basis_matrices().
* @param Uy [in/out] On output, \c Uy will have all references to \c C and \c D removed.
* @param C_ptr [out] On output, <tt>C_ptr->get() != NULL</tt> will point to the basis matrix to
* be updated by the client before the next call to \c this->set_basis_matrices().
* It is guarrenteed that \c *C_ptr->get() will not be referenced by any other entity
* so that changing the basis matrix object will not impact other objects in
* unexpected ways.
* @param D_ptr [out] If <tt>this->D_imp() == MAT_IMP_IMPLICIT</tt> then on output,
* <tt>D_ptr == NULL</tt> must be true. If <tt>this->D_imp() == MAT_IMP_EXPLICIT</tt>
* then <tt>D_ptr->get() != NULL</tt> will point to the direct sensitivity matrix
* and it is expected that the client will initialize it properly before
* the next call to \c this->set_basis_matrices().
* It is guarrenteed that \c *D_ptr->get() will not be referenced by any other entity
* so that changing the basis matrix object will not impact other objects in
* unexpected ways.
*
* Preconditions:<ul>
* <li> [<tt>this->D_imp() == MAT_IMP_IMPLICIT</tt>] <tt>D_ptr == NULL</tt> (throw <tt>std::invalid_argument</tt>)
* <li> [<tt>this->D_imp() == MAT_IMP_EXPLICIT</tt>] <tt>D_ptr != NULL</tt> (throw <tt>std::invalid_argument</tt>)
* </ul>
*
* Postconditions:<ul>
* <li> <tt>C_ptr->get() != NULL</tt>
* <li> [<tt>this->D_imp() == MAT_IMP_EXPLICIT</tt>] <tt>D_ptr->get() != NULL</tt>
* </ul>
*/
void get_basis_matrices(
std::ostream *out
,EOutputLevel olevel
,ERunTests test_what
,MatrixOp *Z
,MatrixOp *Y
,MatrixOpNonsing *R
,MatrixOp *Uz
,MatrixOp *Uy
,Teuchos::RCP<MatrixOpNonsing> *C_ptr
,Teuchos::RCP<MatrixOp> *D_ptr
);
/** \brief Set updated basis matrices along with a possibly updated basis system object.
*
* @param C_ptr [in] <tt>C_ptr.get()</tt> points to basis matrix object returned from
* \c this->uninitialize_matrices() which must be updated to current basis
* for current Jacobian matrices.
* @param D_ptr [in] If <tt>this->D_imp() == MAT_IMP_EXPLICIT</tt>, then \c D_ptr->get()
* points to direct sensitivity matrix object returned from
* \c this->uninitialize_matrices() which must be updated to current basis
* for current Jacobian matrices. If <tt>this->D_imp() == MAT_IMP_IMPLICIT</tt>
* then \c D_ptr must be \c NULL.
* @param Uz [in] If <tt>this->D_imp() == MAT_IMP_EXPLICIT</tt>, then \c Uz points to the
* projected sensitivity matrix \c Uz which must be updated for the current
* basis for the current Jacobian matrices. If <tt>this->Uz_imp() == MAT_IMP_IMPLICIT</tt>
* then \c Uz must be \c NULL.
* @param basis_sys
* [in] If the basis system has changed then set <tt>basis_sys.get() != NULL</tt> to
* pass in this new basis system object.
*
* Preconditions:<ul>
* <li> <tt>C_ptr.get() != NULL</tt> (throw <tt>std::invalid_argument</tt>)
* <li> [<tt>this->D_imp() == MAT_IMP_IMPLICIT</tt>] <tt>D_ptr == NULL</tt> (throw <tt>std::invalid_argument</tt>)
* <li> [<tt>this->D_imp() == MAT_IMP_EXPLICIT</tt>] <tt>D_ptr != NULL</tt> (throw <tt>std::invalid_argument</tt>)
* <li> [<tt>this->D_imp() == MAT_IMP_EXPLICIT</tt>] <tt>D_ptr->get() != NULL</tt> (throw <tt>std::invalid_argument</tt>)
* </ul>
*
* It is expected that immediatly after this method is called that \c this->updated_decomp()
* will be called to update the rest of the decomposition matrices for these basis matrices.
*/
void set_basis_matrices(
std::ostream *out
,EOutputLevel olevel
,ERunTests test_what
,const Teuchos::RCP<MatrixOpNonsing> &C_ptr
,const Teuchos::RCP<MatrixOp> &D_ptr
,MatrixOp *Uz
,const basis_sys_ptr_t &basis_sys = Teuchos::null
);
/// Get the type of D matrix to be used or is being used (returns MAT_IMP_EXPLICIT or MAT_IMP_IMPLICIT only).
EExplicitImplicit D_imp_used() const;
//@}
/** @name Overridden from DecompositionSystem */
//@{
/// Returns <tt>this->space_x()->dim()</tt>.
size_type n() const;
/// Returns <tt>this->space_c()->dim()</tt>.
size_type m() const;
/// Returns <tt>this->basis_sys()->equ_decomp().size()</tt>.
size_type r() const;
/// Returns <tt>this->space_x()->sub_space(var_dep)</tt>
const VectorSpace::space_ptr_t space_range() const;
/// Returns <tt>this->space_x()->sub_space(var_indep)</tt>
const VectorSpace::space_ptr_t space_null() const;
/** \brief . */
const mat_fcty_ptr_t factory_Z() const;
/** \brief . */
const mat_fcty_ptr_t factory_Uz() const;
/** \brief
*
* Preconditions:<ul>
* <li> <tt>this->space_x().get() != NULL</tt> (throw <tt>std::logic_error</tt>)
* <li> <tt>this->space_c().get() != NULL</tt> (throw <tt>std::logic_error</tt>)
* <li> [<tt>test_what == TEST</tt>] <tt>this->basis_sys_tester().get() != NULL</tt> (throw <tt>std::logic_error</tt>)
* </ul>
*/
void update_decomp(
std::ostream *out
,EOutputLevel olevel
,ERunTests test_what
,const MatrixOp &Gc
,MatrixOp *Z
,MatrixOp *Y
,MatrixOpNonsing *R
,MatrixOp *Uz
,MatrixOp *Uy
,EMatRelations mat_rel
) const;
/** \brief . */
void print_update_decomp(
std::ostream& out, const std::string& leading_str ) const;
//@}
/** @name Overridden from DecompositionSystemVarReduct */
//@{
/** \brief . */
Range1D var_indep() const;
/** \brief . */
Range1D var_dep() const;
//@}
protected:
/// Update D_imp_used
virtual void update_D_imp_used(EExplicitImplicit *D_imp_used) const;
/** \brief Overridden by subclasses to uninitialized Y, R and Uy then return C if referenced.
*
* Note that the returned smart pointer to \c C may have <tt>return.has_ownership() == false</tt>
* in which case this will not be a shared resource with any other object (at least not
* on this level).
*
* ToDo: Finish documentatation!
` */
virtual mat_nonsing_fcty_ptr_t::element_type::obj_ptr_t uninitialize_matrices(
std::ostream *out
,EOutputLevel olevel
,MatrixOp *Y
,MatrixOpNonsing *R
,MatrixOp *Uy
) const = 0;
/** \brief Overridden by subclasses to initialize Y, R and Uy given C and D.
*
* If C_ptr.has_ownership() == false, then the subclass implementation of this
* method will use clone_mwons() to clone it so that the output matrices are
* independent.
*
* ToDo: Finish documentatation!
` */
virtual void initialize_matrices(
std::ostream *out
,EOutputLevel olevel
,const mat_nonsing_fcty_ptr_t::element_type::obj_ptr_t &C_ptr
,const mat_fcty_ptr_t::element_type::obj_ptr_t &D_ptr
,MatrixOp *Y
,MatrixOpNonsing *R
,MatrixOp *Uy
,EMatRelations mat_rel
) const = 0;
/** \brief Print the sub-algorithm by which the matrices Y, R, Uy and Uy are updated.
*
* ToDo: Finish documentatation!
*/
virtual void print_update_matrices(
std::ostream& out, const std::string& leading_str ) const = 0;
private:
// //////////////////////////////////
// Private data members
#ifdef DOXYGEN_COMPILE
AbstractLinAlgPack::BasisSystem *basis_sys;
VectorSpace *space_x;
VectorSpace *space_c;
VectorSpace *space_range;
VectorSpace *space_null;
#else
basis_sys_ptr_t basis_sys_;
VectorSpace::space_ptr_t space_x_;
VectorSpace::space_ptr_t space_c_;
VectorSpace::space_ptr_t space_range_;
VectorSpace::space_ptr_t space_null_;
mutable Teuchos::RCP<MatrixOpNonsing> C_ptr_;
mutable Teuchos::RCP<MatrixOp> D_ptr_;
mutable EExplicitImplicit D_imp_used_;
#endif
// //////////////////////////////////
// Private member functions
/// Allocate a new D_ptr matrix
void alloc_new_D_matrix(
std::ostream *out
,EOutputLevel olevel
,Teuchos::RCP<MatrixOp> *D_ptr
) const;
// not defined and not to be called!
DecompositionSystemVarReductImp(const DecompositionSystemVarReductImp&);
DecompositionSystemVarReductImp& operator=(const DecompositionSystemVarReductImp&);
}; // end class DecompositionSystemVarReductImp
// //////////////////////////////////////////
// Inline members
inline
const VectorSpace::space_ptr_t&
DecompositionSystemVarReductImp::space_x() const
{
return space_x_;
}
inline
const VectorSpace::space_ptr_t&
DecompositionSystemVarReductImp::space_c() const
{
return space_c_;
}
inline
const DecompositionSystemVarReductImp::basis_sys_ptr_t&
DecompositionSystemVarReductImp::basis_sys() const
{
return basis_sys_;
}
inline
DecompositionSystemVarReductImp::EExplicitImplicit
DecompositionSystemVarReductImp::D_imp_used() const
{
update_D_imp_used(&D_imp_used_);
return D_imp_used_;
}
} // end namespace ConstrainedOptPack
#endif // DECOMPOSITION_SYSTEM_VAR_REDUCT_IMP_H
|