ConstrainedOptPack: C++ Tools for Constrained (and Unconstrained) Optimization  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ConstrainedOptPack_QPSchurInitKKTSystemHessianRelaxed.cpp
1 #if 0
2 
3 // @HEADER
4 // ***********************************************************************
5 //
6 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
7 // Copyright (2003) Sandia Corporation
8 //
9 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
10 // license for use of this work by or on behalf of the U.S. Government.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are
14 // met:
15 //
16 // 1. Redistributions of source code must retain the above copyright
17 // notice, this list of conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution.
22 //
23 // 3. Neither the name of the Corporation nor the names of the
24 // contributors may be used to endorse or promote products derived from
25 // this software without specific prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 //
39 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
40 //
41 // ***********************************************************************
42 // @HEADER
43 
44 #include "ConstrainedOptPack_QPSchurInitKKTSystemHessianRelaxed.hpp"
45 #include "ConstrainedOptPack_MatrixSymHessianRelaxNonSing.hpp"
46 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_GenPermMatrixSlice.hpp"
47 #include "AbstractLinAlgPack_GenPermMatrixSliceOp.hpp"
48 #include "AbstractLinAlgPack_SpVectorOp.hpp"
49 #include "DenseLinAlgPack_LinAlgOpPack.hpp"
50 #include "Midynamic_cast_verbose.h"
51 
52 namespace LinAlgOpPack {
55 }
56 
57 namespace ConstrainedOptPack {
58 
60  const DVectorSlice& g
61  ,const MatrixOp& G
62  ,value_type etaL
63  ,const SpVectorSlice& dL
64  ,const SpVectorSlice& dU
65  ,const MatrixOp* F
66  ,BLAS_Cpp::Transp trans_F
67  ,const DVectorSlice* f
68  ,const DVectorSlice& d
69  ,const SpVectorSlice& nu
70  ,size_type* n_R
71  ,i_x_free_t* i_x_free
72  ,i_x_fixed_t* i_x_fixed
73  ,bnd_fixed_t* bnd_fixed
74  ,j_f_decomp_t* j_f_decomp
75  ,DVector* b_X
76  ,Ko_ptr_t* Ko
77  ,DVector* fo
78  ) const
79 {
80  using BLAS_Cpp::trans;
81 
82  // Validate type of and convert G
83  const MatrixSymHessianRelaxNonSing
84  *G_relax_ptr = dynamic_cast<const MatrixSymHessianRelaxNonSing*>(&G);
85 
86  if( G_relax_ptr == NULL ) {
87  init_kkt_full_.initialize_kkt_system(
88  g,G,etaL,dL,dU,F,trans_F,f,d,nu,n_R,i_x_free,i_x_fixed,bnd_fixed
89  ,j_f_decomp,b_X,Ko,fo);
90  return;
91  }
92 
93  const MatrixSymHessianRelaxNonSing
94  &G_relax = *G_relax_ptr;
95 
96  // get some stuff
97  const MatrixSymWithOpFactorized
98  &G_orig = G_relax.G(),
99  &M = G_relax.M();
100  const size_type
101  nd = g.size(),
102  no = G_orig.rows(),
103  nr = M.rows();
104  TEUCHOS_TEST_FOR_EXCEPT( !( no + nr == nd ) );
105 
106  // Setup output arguments
107 
108  // n_R = nd_R
109  *n_R = no;
110  // i_x_free.size() == 0 and i_x_free is implicitly identity
111  i_x_free->resize(no);
112  {for(size_type l = 1; l <= no; ++l ) {
113  (*i_x_free)[l-1] = l;
114  }}
115  // i_x_fixed[]
116  i_x_fixed->resize(nr+1);
117  if(nr) {
118  // i_x_fixed[l-1] = no + l, l = 1...nr
119  for( size_type l = 1; l <= nr; ++l )
120  (*i_x_fixed)[l-1] = no+l;
121  }
122  (*i_x_fixed)[nr] = nd+1; // extra relaxation is always initially active
123  // bnd_fixed[]
124  bnd_fixed->resize(nr+1);
125  if(nr) {
126  // bnd_fixed[l-1] = LOWER, l = 1...nr
127  std::fill_n( bnd_fixed->begin(), nr, LOWER );
128  }
129  (*bnd_fixed)[nr] = LOWER; // relaxation is always initially active
130  // j_f_decomp[]
131  j_f_decomp->resize(0);
132  // b_X
133  b_X->resize(nr+1);
134  if(nr) {
135  // b_X[l-1] = dL(no+l), l = 1...nr
136  LinAlgOpPack::assign( &(*b_X)(1,nr), dL(no+1,no+nr) );
137  }
138  (*b_X)[nr] = etaL; // relaxation is always initially active
139  // Ko = G.G
140  *Ko = G_relax.G_ptr(); // now B_RR is a shared object
141  // fo = - *g(1:no)
142  LinAlgOpPack::V_StV( fo, -1.0, g(1,no) );
143 
144 }
145 
146 } // end namesapce ConstrainedOptPack
147 
148 #endif // 0
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
void V_StV(VectorMutable *v_lhs, value_type alpha, const V &V_rhs)
void initialize_kkt_system(const DVectorSlice &g, const MatrixOp &G, value_type etaL, const SpVectorSlice &dL, const SpVectorSlice &dU, const MatrixOp *F, BLAS_Cpp::Transp trans_F, const DVectorSlice *f, const DVectorSlice &d, const SpVectorSlice &nu, size_type *n_R, i_x_free_t *i_x_free, i_x_fixed_t *i_x_fixed, bnd_fixed_t *bnd_fixed, j_f_decomp_t *j_f_decomp, DVector *b_X, Ko_ptr_t *Ko, DVector *fo) const
Initialize the KKT system where the original variables are initiallly free and all the relaxation var...
void assign(MatrixOp *M_lhs, const MatrixOp &M_rhs, BLAS_Cpp::Transp trans_rhs)
size_t size_type
void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta=1.0)
void initialize_kkt_system(const Vector &g, const MatrixOp &G, value_type etaL, const Vector *dL, const Vector *dU, const MatrixOp *F, BLAS_Cpp::Transp trans_F, const Vector *f, const Vector *d, const Vector *nu, size_type *n_R, i_x_free_t *i_x_free, i_x_fixed_t *i_x_fixed, bnd_fixed_t *bnd_fixed, j_f_decomp_t *j_f_decomp, DVector *b_X, Ko_ptr_t *Ko, DVector *fo) const
Initialize the KKT system where all variables (except the relaxation variable) are initially free and...
Transp
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)