ROL
ROL_PrimalDualSystemStep.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 #ifndef ROL_PRIMALDUALSYSTEMSTEP_H
45 #define ROL_PRIMALDUALSYSTEMSTEP_H
46 
47 #include "ROL_NewtonKrylovStep.hpp"
49 #include "ROL_SchurComplememt.hpp"
50 
62 namespace ROL {
63 
64 template<class Real>
65 class PrimalDualSystemStep : public Step<Real> {
66 
67  typedef Vector<Real> V;
74 
79 
80 
81 private:
82 
83  // Block indices
84  static const size_type OPT = 0;
85  static const size_type EQUAL = 1;
86  static const size_type LOWER = 2;
87  static const size_type UPPER = 3;
88 
89  // Super block indices
90  static const size_type OPTMULT = 0; // Optimization and equality multiplier components
91  static const size_type BNDMULT = 1; // Bound multiplier components
92 
93  Teuchos::RCP<Secant<Real> > secant_;
94  Teuchos::RCP<Krylov<Real> > krylov_;
95  Teuchos::RCP<V> scratch1_; // scratch vector
96  Teuchos::RCP<V> scratch_;
97 
98  Teuchos::RCP<OP11> A_;
99  Teuchos::RCP<OP12> B_;
100  Teuchos::RCP<OP21> C_;
101  Teuchos::RCP<OP22> D_;
102 
103  Teuchos::RCP<SCHUR> schur_; // Allows partial decoupling of (x,lambda) and (zl,zu)
104  Teuchos::RCP<OP> op_; // Solve fully coupled system
105 
109 
112 
113 
114 
115  // Repartition (x,lambda,zl,zu) as (xlambda,z) = ((x,lambda),(zl,zu))
116  Teuchos::RCP<PV> repartition( V &x ) {
117  using Teuchos::RCP; using Teuchos::rcp;
118  PV &x_pv = Teuchos::dyn_cast<PV>(x);
119  RCP<V> xlambda = CreatePartitionedVector(x_pv.get(OPT),x_pv.get(EQUAL));
120  RCP<V> z = CreatePartitionedVector(x_pv.get(LOWER),x_pv.get(UPPER));
121 
122  RCP<V> temp[] = {xlambda,z};
123 
124  return rcp( new PV( std::vector<RCP<V> >(temp,temp+2) ) );
125 
126  }
127 
128  // Repartition (x,lambda,zl,zu) as (xlambda,z) = ((x,lambda),(zl,zu))
129  Teuchos::RCP<const PV> repartition( const V &x ) {
130  const PV &x_pv = Teuchos::dyn_cast<const PV>(x);
131  RCP<const V> xlambda = CreatePartitionedVector(x_pv.get(OPT),x_pv.get(EQUAL));
132  RCP<const V> z = CreatePartitionedVector(x_pv.get(LOWER),x_pv.get(UPPER));
133 
134  RCP<const V> temp[] = {xlambda,z};
135 
136  return rcp( new PV( std::vector<RCP<const V> >(temp,temp+2) ) );
137 
138  }
139 
140 public:
141 
143  using Step<Real>::compute;
144  using Step<Real>::update;
145 
146 
147  PrimalDualSystemStep( Teuchos::ParameterList &parlist,
148  const Teuchos::RCP<Krylov<Real> > &krylov,
149  const Teuchos::RCP<Secant<Real> > &secant,
150  Teuchos::RCP<V> &scratch1 ) : Step<Real>(),
151  krylov_(krylov), secant_(secant), scratch1_(scratch1), schur_(Teuchos::null),
152  op_(Teuchos::null), useSchurComplement_(false) {
153 
154  PL &iplist = parlist.sublist("Step").sublist("Primal Dual Interior Point");
155  PL &syslist = iplist.sublist("System Solver");
156 
157  useSchurComplement_ = syslist.get("Use Schur Complement",false);
158 
159  }
160 
161  PrimalDualSystemStep( Teuchos::ParameterList &parlist,
162  Teuchos::RCP<V> &scratch1_ ) : Step<Real>() {
163  PrimalDualSystemStep(parlist,Teuchos::null,Teuchos::null,scratch1);
164  }
165 
166  void initialize( V &x, const V &g, V &res, const V &c,
167  OBJ &obj, CON &con, BND &bnd, AS &algo_state ) {
168 
169  Step<Real>::initialize(x,g,res,c,obj,con,bnd,algo_state);
170 
171  using Teuchos::RCP;
172  using Teuchos::rcp;
173  using Teuchos::rcpFromRef;
174 
175  RCP<OBJ> pObj = rcpFromRef(obj);
176  RCP<CON> pCon = rcpFromRef(con);
177  RCP<BND> pBnd = rcpFromRef(bnd);
178 
179  RCP<PV> x_pv = repartition(x);
180 
181  RCP<V> xlambda = x_pv->get(OPTMULT);
182  RCP<V> z = x_pv->get(BNDMULT);
183 
184  A_ = rcp( new OP11( pObj, pCon, *xlambda, scratch1_ ) );
185  B_ = rcp( new OP12( ) );
186  C_ = rcp( new OP21( *z ) );
187  D_ = rcp( new OP22( pBnd, *xlambda ) );
188 
189  if( useSchurComplement_ ) {
190  schur_ = rcp( new SCHUR(A_,B_,C_,D_,scratch1_) );
191  }
192  else {
193  op_ = BlockOperator2<Real>(A_,B_,C_,D_);
194  }
195  }
196 
197  void compute( V &s, const V &x, const V &res, OBJ &obj, CON &con,
198  BND &bnd, AS &algo_state ) {
199 
200  Teuchos::RCP<StepState<Real> > step_state = Step<Real>::getState();
201 
202 
203  if( useSchurComplement_ ) {
204 
205  RCP<const PV> x_pv = repartition(x);
206  RCP<const PV> res_pv = repartition(res);
207  RCP<PV> s_pv = repartition(s);
208 
209 
210  // Decouple (x,lambda) from (zl,zu) so that s <- L
211 
212  RCP<V> sxl = s_pv->get(OPTMULT);
213  RCP<V> sz = s_pv->get(BNDMULT);
214 
215 
216 
217  }
218  else {
219 
220  }
221 
222  }
223 
224  void update( V &x, V &res, const V &s, OBJ &obj, CON &con,
225  BND &bnd, AS &algo_state ) {
226 
227  Teuchos::RCP<StepState<Real> > step_state = Step<Real>::getState();
228 
229 
230  }
231 
232 
233 };
234 
235 } // namespace ROL
236 
237 #endif // ROL_PRIMALDUALSYSTEMSTEP_H
Provides the interface to evaluate objective functions.
PrimalDualInteriorPointBlock22 OP22
PrimalDualInteriorPointBlock21 OP21
PrimalDualSystemStep(Teuchos::ParameterList &parlist, Teuchos::RCP< V > &scratch1_)
Provides the interface to compute optimization steps.
Definition: ROL_Step.hpp:69
Defines the linear algebra of vector space on a generic partitioned vector.
Teuchos::RCP< const PV > repartition(const V &x)
PartitionedVector< Real > PV
void initialize(V &x, const V &g, V &res, const V &c, OBJ &obj, CON &con, BND &bnd, AS &algo_state)
Initialize step with equality constraint.
Teuchos::RCP< StepState< Real > > getState(void)
Definition: ROL_Step.hpp:74
Teuchos::RCP< const Vector< Real > > get(size_type i) const
Teuchos::RCP< Vector< Real > > CreatePartitionedVector(const Teuchos::RCP< Vector< Real > > &a)
Provides the interface to compute approximate solutions to 2x2 block systems arising from primal-dual...
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:76
State for algorithm class. Will be used for restarts.
Definition: ROL_Types.hpp:91
Teuchos::RCP< PV > repartition(V &x)
int flagKrylov_
Termination flag for Krylov method (used for inexact Newton)
Defines the equality constraint operator interface.
Provides interface for and implements limited-memory secant operators.
Definition: ROL_Secant.hpp:70
void update(V &x, V &res, const V &s, OBJ &obj, CON &con, BND &bnd, AS &algo_state)
Update step, if successful (equality constraints).
PrimalDualSystemStep(Teuchos::ParameterList &parlist, const Teuchos::RCP< Krylov< Real > > &krylov, const Teuchos::RCP< Secant< Real > > &secant, Teuchos::RCP< V > &scratch1)
int iterKrylov_
Number of Krylov iterations (used for inexact Newton)
Provides definitions for Krylov solvers.
Definition: ROL_Krylov.hpp:57
Provides the interface to apply upper and lower bound constraints.
Provides the interface to apply a 2x2 block operator to a partitioned vector.
PrimalDualInteriorPointBlock12 OP12
virtual void initialize(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, BoundConstraint< Real > &con, AlgorithmState< Real > &algo_state)
Initialize step with bound constraint.
Definition: ROL_Step.hpp:89
Teuchos::RCP< Krylov< Real > > krylov_
EqualityConstraint< Real > CON
PrimalDualInteriorPointBlock11 OP11
Given a 2x2 block operator, perform the Schur reduction and return the decoupled system components...
void compute(V &s, const V &x, const V &res, OBJ &obj, CON &con, BND &bnd, AS &algo_state)
Compute step (equality constraints).
Teuchos::RCP< Secant< Real > > secant_