MoochoPack : Framework for Large-Scale Optimization Algorithms  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MoochoPack_QuasiRangeSpaceStepTailoredApproach_Strategy.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 "MoochoPack_QuasiRangeSpaceStepTailoredApproach_Strategy.hpp"
45 #include "MoochoPack_MoochoAlgorithmStepNames.hpp"
46 #include "MoochoPack_NLPAlgo.hpp"
47 #include "MoochoPack_NLPAlgoState.hpp"
48 #include "MoochoPack/src/NLPrSQPTailoredApproach.h"
49 #include "MoochoPack_EvalNewPointTailoredApproach_Step.hpp"
50 #include "ConstrainedOptPack/src/DenseIdentVertConcatMatrixSubclass.h"
51 #include "AbstractLinAlgPack/src/AbstractLinAlgPack_MatrixOp.hpp"
52 #include "DenseLinAlgPack_LinAlgOpPack.hpp"
53 #include "MiWorkspacePack.h"
54 #include "Midynamic_cast_verbose.h"
55 
56 namespace LinAlgOpPack {
58 }
59 
60 namespace MoochoPack {
61 
63  std::ostream& out, EJournalOutputLevel olevel, NLPAlgo *algo, NLPAlgoState *s
64  ,const DVectorSlice& xo, const DVectorSlice& c_xo, DVectorSlice* v
65  )
66 {
67  using Teuchos::dyn_cast;
68  using Teuchos::Workspace;
70 
71  // Get NLP reference
72 #ifdef _WINDOWS
73  NLPrSQPTailoredApproach
74  &nlp = dynamic_cast<NLPrSQPTailoredApproach&>(algo->nlp());
75 #else
76  NLPrSQPTailoredApproach
77  &nlp = dyn_cast<NLPrSQPTailoredApproach>(algo->nlp());
78 #endif
79 
80  // Get D for Z_k = [ D; I ]
81  const MatrixOp
82  &Z_k = s->Z().get_k(0);
83 #ifdef _WINDOWS
84  const DenseIdentVertConcatMatrixSubclass
85  &cZ_k = dynamic_cast<const DenseIdentVertConcatMatrixSubclass&>(Z_k);
86 #else
87  const DenseIdentVertConcatMatrixSubclass
88  &cZ_k = dyn_cast<const DenseIdentVertConcatMatrixSubclass>(Z_k);
89 #endif
90  const DMatrixSlice
91  D = cZ_k.m().D();
92 
93  // Get reference to EvalNewPoint step
94 #ifdef _WINDOWS
95  EvalNewPointTailoredApproach_Step
96  &eval_tailored = dynamic_cast<EvalNewPointTailoredApproach_Step&>(
97  *algo->get_step(algo->get_step_poss(EvalNewPoint_name)));
98 #else
99  EvalNewPointTailoredApproach_Step
100  &eval_tailored = dyn_cast<EvalNewPointTailoredApproach_Step>(
101  *algo->get_step(algo->get_step_poss(EvalNewPoint_name)));
102 #endif
103 
104  // Compute an approximate newton step for constriants wy
105  DVector c_xo_tmp = c_xo, vy_tmp; // This is hacked. This sucks!
106  nlp.calc_semi_newton_step(xo,&c_xo_tmp,false,&vy_tmp);
107 
108  // Compute wy, Ywy
109  eval_tailored.recalc_py_Ypy(D,&vy_tmp(),v,olevel,out);
110 
111  return true;
112 }
113 
114 void QuasiRangeSpaceStepTailoredApproach_Strategy::print_step( std::ostream& out, const std::string& L ) const
115 {
116  out << L << "*** Compute the approximate range space step by calling on the \"Tailored Approach\" NLP interface:\n"
117  << L << "Compute vy s.t. ||Gc_k'*Y_k*vy + c_xo|| << ||c_xo|| (nlp.calc_semi_newton_step(...))\n"
118  << L << "update vy and compute v = Yvy from EvalNewPointTailoredApproach_Step::recalc_py_Ypy(...)\n";
119  ;
120 }
121 
122 } // end namespace MoochoPack
123 
124 #endif // 0
T_To & dyn_cast(T_From &from)
bool solve_quasi_range_space_step(std::ostream &out, EJournalOutputLevel olevel, NLPAlgo *algo, NLPAlgoState *s, const DVectorSlice &xo, const DVectorSlice &c_xo, DVectorSlice *v)
Calls the NLPrSQPTailoredApproach iterface to compute the step.
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 print_step(std::ostream &out, const std::string &leading_str) const
TEUCHOSCORE_LIB_DLL_EXPORT Teuchos::RCP< WorkspaceStore > get_default_workspace_store()