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  ROL::Ptr<Secant<Real> > secant_;
94  ROL::Ptr<Krylov<Real> > krylov_;
95  ROL::Ptr<V> scratch1_; // scratch vector
96  ROL::Ptr<V> scratch_;
97 
98  ROL::Ptr<OP11> A_;
99  ROL::Ptr<OP12> B_;
100  ROL::Ptr<OP21> C_;
101  ROL::Ptr<OP22> D_;
102 
103  ROL::Ptr<SCHUR> schur_; // Allows partial decoupling of (x,lambda) and (zl,zu)
104  ROL::Ptr<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  ROL::Ptr<PV> repartition( V &x ) {
117 
118  PV &x_pv = dynamic_cast<PV&>(x);
119  ROL::Ptr<V> xlambda = CreatePartitionedVector(x_pv.get(OPT),x_pv.get(EQUAL));
120  ROL::Ptr<V> z = CreatePartitionedVector(x_pv.get(LOWER),x_pv.get(UPPER));
121 
122  ROL::Ptr<V> temp[] = {xlambda,z};
123 
124  return ROL::makePtr<PV( std::vector<ROL::Ptr<V> >>(temp,temp+2) );
125 
126  }
127 
128  // Repartition (x,lambda,zl,zu) as (xlambda,z) = ((x,lambda),(zl,zu))
129  ROL::Ptr<const PV> repartition( const V &x ) {
130  const PV &x_pv = dynamic_cast<const PV&>(x);
131  ROL::Ptr<const V> xlambda = CreatePartitionedVector(x_pv.get(OPT),x_pv.get(EQUAL));
132  ROL::Ptr<const V> z = CreatePartitionedVector(x_pv.get(LOWER),x_pv.get(UPPER));
133 
134  ROL::Ptr<const V> temp[] = {xlambda,z};
135 
136  return ROL::makePtr<PV( std::vector<ROL::Ptr<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( ROL::ParameterList &parlist,
148  const ROL::Ptr<Krylov<Real> > &krylov,
149  const ROL::Ptr<Secant<Real> > &secant,
150  ROL::Ptr<V> &scratch1 ) : Step<Real>(),
151  krylov_(krylov), secant_(secant), scratch1_(scratch1), schur_(ROL::nullPtr),
152  op_(ROL::nullPtr), 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( ROL::ParameterList &parlist,
162  ROL::Ptr<V> &scratch1_ ) : Step<Real>() {
163  PrimalDualSystemStep(parlist,ROL::nullPtr,ROL::nullPtr,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 
172 
173  ;
174 
175  ROL::Ptr<OBJ> pObj = ROL::makePtrFromRef(obj);
176  ROL::Ptr<CON> pCon = ROL::makePtrFromRef(con);
177  ROL::Ptr<BND> pBnd = ROL::makePtrFromRef(bnd);
178 
179  ROL::Ptr<PV> x_pv = repartition(x);
180 
181  ROL::Ptr<V> xlambda = x_pv->get(OPTMULT);
182  ROL::Ptr<V> z = x_pv->get(BNDMULT);
183 
184  A_ = ROL::makePtr<OP11>( pObj, pCon, *xlambda, scratch1_ );
185  B_ = ROL::makePtr<OP12>( );
186  C_ = ROL::makePtr<OP21>( *z );
187  D_ = ROL::makePtr<OP22>( pBnd, *xlambda );
188 
189  if( useSchurComplement_ ) {
190  schur_ = ROL::makePtr<SCHUR>(A_,B_,C_,D_,scratch1_);
191  }
192  else {
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  ROL::Ptr<StepState<Real> > step_state = Step<Real>::getState();
201 
202 
203  if( useSchurComplement_ ) {
204 
205  ROL::Ptr<const PV> x_pv = repartition(x);
206  ROL::Ptr<const PV> res_pv = repartition(res);
207  ROL::Ptr<PV> s_pv = repartition(s);
208 
209 
210  // Decouple (x,lambda) from (zl,zu) so that s <- L
211 
212  ROL::Ptr<V> sxl = s_pv->get(OPTMULT);
213  ROL::Ptr<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  ROL::Ptr<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
ROL::Ptr< const PV > repartition(const V &x)
typename PV< Real >::size_type size_type
ROL::Ptr< const Vector< Real > > get(size_type i) const
Provides the interface to compute optimization steps.
Definition: ROL_Step.hpp:68
Defines the linear algebra of vector space on a generic partitioned vector.
ROL::Ptr< Vector< Real > > CreatePartitionedVector(const ROL::Ptr< Vector< Real >> &a)
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.
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:80
PrimalDualSystemStep(ROL::ParameterList &parlist, ROL::Ptr< V > &scratch1_)
State for algorithm class. Will be used for restarts.
Definition: ROL_Types.hpp:143
int flagKrylov_
Termination flag for Krylov method (used for inexact Newton)
PrimalDualSystemStep(ROL::ParameterList &parlist, const ROL::Ptr< Krylov< Real > > &krylov, const ROL::Ptr< Secant< Real > > &secant, ROL::Ptr< V > &scratch1)
ROL::Ptr< StepState< Real > > getState(void)
Definition: ROL_Step.hpp:73
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).
int iterKrylov_
Number of Krylov iterations (used for inexact Newton)
Provides definitions for Krylov solvers.
Definition: ROL_Krylov.hpp:58
Provides the interface to apply upper and lower bound constraints.
ROL::Ptr< Krylov< Real > > krylov_
Provides the interface to apply a 2x2 block operator to a partitioned vector.
PrimalDualInteriorPointBlock12 OP12
ROL::Ptr< Secant< Real > > secant_
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:88
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).
Defines the general constraint operator interface.