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
ROL::PrimalDualSystemStep::schur_
ROL::Ptr< SCHUR > schur_
Definition: ROL_PrimalDualSystemStep.hpp:103
ROL::PrimalDualSystemStep::update
void update(V &x, V &res, const V &s, OBJ &obj, CON &con, BND &bnd, AS &algo_state)
Update step, if successful (equality constraints).
Definition: ROL_PrimalDualSystemStep.hpp:224
ROL::PrimalDualSystemStep::op_
ROL::Ptr< OP > op_
Definition: ROL_PrimalDualSystemStep.hpp:104
ROL::PrimalDualSystemStep::scratch1_
ROL::Ptr< V > scratch1_
Definition: ROL_PrimalDualSystemStep.hpp:95
ROL::PrimalDualSystemStep::PrimalDualSystemStep
PrimalDualSystemStep(ROL::ParameterList &parlist, const ROL::Ptr< Krylov< Real > > &krylov, const ROL::Ptr< Secant< Real > > &secant, ROL::Ptr< V > &scratch1)
Definition: ROL_PrimalDualSystemStep.hpp:147
ROL::PrimalDualSystemStep::repartition
ROL::Ptr< PV > repartition(V &x)
Definition: ROL_PrimalDualSystemStep.hpp:116
ROL::PrimalDualSystemStep::OPT
static const size_type OPT
Definition: ROL_PrimalDualSystemStep.hpp:84
ROL::PrimalDualSystemStep::OPTMULT
static const size_type OPTMULT
Definition: ROL_PrimalDualSystemStep.hpp:90
ROL::PrimalDualSystemStep::B_
ROL::Ptr< OP12 > B_
Definition: ROL_PrimalDualSystemStep.hpp:99
ROL::PrimalDualSystemStep::verbosity_
int verbosity_
Verbosity level.
Definition: ROL_PrimalDualSystemStep.hpp:108
ROL::Step
Provides the interface to compute optimization steps.
Definition: ROL_Step.hpp:69
ROL::PrimalDualSystemStep::OBJ
Objective< Real > OBJ
Definition: ROL_PrimalDualSystemStep.hpp:69
ROL::PrimalDualInteriorPointBlock21
Definition: ROL_PrimalDualInteriorPointOperator.hpp:187
ROL::AlgorithmState
State for algorithm class. Will be used for restarts.
Definition: ROL_Types.hpp:143
ROL::PrimalDualSystemStep::useSchurComplement_
bool useSchurComplement_
Definition: ROL_PrimalDualSystemStep.hpp:111
ROL_PrimalDualInteriorPointOperator.hpp
ROL::PrimalDualSystemStep::compute
void compute(V &s, const V &x, const V &res, OBJ &obj, CON &con, BND &bnd, AS &algo_state)
Compute step (equality constraints).
Definition: ROL_PrimalDualSystemStep.hpp:197
ROL::PartitionedVector
Defines the linear algebra of vector space on a generic partitioned vector.
Definition: ROL_PartitionedVector.hpp:60
ROL::PrimalDualSystemStep::V
Vector< Real > V
Definition: ROL_PrimalDualSystemStep.hpp:67
ROL::PrimalDualSystemStep::OP12
PrimalDualInteriorPointBlock12 OP12
Definition: ROL_PrimalDualSystemStep.hpp:76
ROL::PrimalDualInteriorPointBlock22
Definition: ROL_PrimalDualInteriorPointOperator.hpp:246
ROL::PrimalDualSystemStep
Provides the interface to compute approximate solutions to 2x2 block systems arising from primal-dual...
Definition: ROL_PrimalDualSystemStep.hpp:65
ROL::PrimalDualSystemStep::UPPER
static const size_type UPPER
Definition: ROL_PrimalDualSystemStep.hpp:87
ROL::SchurComplement
Given a 2x2 block operator, perform the Schur reduction and return the decoupled system components.
Definition: ROL_SchurComplement.hpp:72
ROL::PrimalDualSystemStep::PrimalDualSystemStep
PrimalDualSystemStep(ROL::ParameterList &parlist, ROL::Ptr< V > &scratch1_)
Definition: ROL_PrimalDualSystemStep.hpp:161
ROL::PrimalDualSystemStep::D_
ROL::Ptr< OP22 > D_
Definition: ROL_PrimalDualSystemStep.hpp:101
ROL::Step::getState
ROL::Ptr< StepState< Real > > getState(void)
Definition: ROL_Step.hpp:74
ROL::PrimalDualSystemStep::OP11
PrimalDualInteriorPointBlock11 OP11
Definition: ROL_PrimalDualSystemStep.hpp:75
ROL::PrimalDualSystemStep::A_
ROL::Ptr< OP11 > A_
Definition: ROL_PrimalDualSystemStep.hpp:98
ROL::Secant
Provides interface for and implements limited-memory secant operators.
Definition: ROL_Secant.hpp:70
ROL::PrimalDualSystemStep::flagKrylov_
int flagKrylov_
Termination flag for Krylov method (used for inexact Newton)
Definition: ROL_PrimalDualSystemStep.hpp:107
ROL::PrimalDualSystemStep::secant_
ROL::Ptr< Secant< Real > > secant_
Definition: ROL_PrimalDualSystemStep.hpp:93
ROL::PrimalDualSystemStep::repartition
ROL::Ptr< const PV > repartition(const V &x)
Definition: ROL_PrimalDualSystemStep.hpp:129
ROL::PrimalDualSystemStep::OP21
PrimalDualInteriorPointBlock21 OP21
Definition: ROL_PrimalDualSystemStep.hpp:77
ROL::PrimalDualInteriorPointBlock11
Definition: ROL_PrimalDualInteriorPointOperator.hpp:55
ROL::PrimalDualSystemStep::AS
AlgorithmState< Real > AS
Definition: ROL_PrimalDualSystemStep.hpp:72
ROL::Vector
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
ROL::PrimalDualSystemStep::CON
Constraint< Real > CON
Definition: ROL_PrimalDualSystemStep.hpp:71
ROL_NewtonKrylovStep.hpp
ROL::Constraint
Defines the general constraint operator interface.
Definition: ROL_Constraint.hpp:85
ROL::PrimalDualSystemStep::BND
BoundConstraint< Real > BND
Definition: ROL_PrimalDualSystemStep.hpp:70
ROL::PrimalDualSystemStep::scratch_
ROL::Ptr< V > scratch_
Definition: ROL_PrimalDualSystemStep.hpp:96
ROL::BlockOperator2
Provides the interface to apply a 2x2 block operator to a partitioned vector.
Definition: ROL_BlockOperator2.hpp:60
ROL::PrimalDualSystemStep::PV
PartitionedVector< Real > PV
Definition: ROL_PrimalDualSystemStep.hpp:68
ROL
Definition: ROL_ElementwiseVector.hpp:61
ROL::PrimalDualSystemStep::initialize
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.
Definition: ROL_PrimalDualSystemStep.hpp:166
ROL::PrimalDualInteriorPointBlock12
Definition: ROL_PrimalDualInteriorPointOperator.hpp:144
size_type
typename PV< Real >::size_type size_type
Definition: ROL_Objective_SerialSimOpt.hpp:142
ROL::PartitionedVector::get
ROL::Ptr< const Vector< Real > > get(size_type i) const
Definition: ROL_PartitionedVector.hpp:236
ROL::PrimalDualSystemStep::BNDMULT
static const size_type BNDMULT
Definition: ROL_PrimalDualSystemStep.hpp:91
ROL::PrimalDualSystemStep::SCHUR
SchurComplement< Real > SCHUR
Definition: ROL_PrimalDualSystemStep.hpp:73
ROL::BoundConstraint
Provides the interface to apply upper and lower bound constraints.
Definition: ROL_BoundConstraint.hpp:72
ROL::PrimalDualSystemStep::LOWER
static const size_type LOWER
Definition: ROL_PrimalDualSystemStep.hpp:86
ROL::CreatePartitionedVector
ROL::Ptr< Vector< Real > > CreatePartitionedVector(const ROL::Ptr< Vector< Real >> &a)
Definition: ROL_PartitionedVector.hpp:276
ROL::PrimalDualSystemStep::OP22
PrimalDualInteriorPointBlock22 OP22
Definition: ROL_PrimalDualSystemStep.hpp:78
ROL::PrimalDualSystemStep::useSecantPrecond_
bool useSecantPrecond_
Definition: ROL_PrimalDualSystemStep.hpp:110
ROL::Krylov
Provides definitions for Krylov solvers.
Definition: ROL_Krylov.hpp:58
ROL::Objective
Provides the interface to evaluate objective functions.
Definition: ROL_Objective.hpp:77
ROL::Step::initialize
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
ROL::PrimalDualSystemStep::iterKrylov_
int iterKrylov_
Number of Krylov iterations (used for inexact Newton)
Definition: ROL_PrimalDualSystemStep.hpp:106
ROL::PrimalDualSystemStep::krylov_
ROL::Ptr< Krylov< Real > > krylov_
Definition: ROL_PrimalDualSystemStep.hpp:94
ROL::PrimalDualSystemStep::EQUAL
static const size_type EQUAL
Definition: ROL_PrimalDualSystemStep.hpp:85
ROL::PrimalDualSystemStep::C_
ROL::Ptr< OP21 > C_
Definition: ROL_PrimalDualSystemStep.hpp:100