ROL
ROL_Reduced_Objective_SimOpt.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_REDUCED_OBJECTIVE_SIMOPT_H
45 #define ROL_REDUCED_OBJECTIVE_SIMOPT_H
46 
47 #include "ROL_Objective_SimOpt.hpp"
49 #include "ROL_VectorController.hpp"
50 #include "ROL_BatchManager.hpp"
51 
52 namespace ROL {
53 
54 template<typename Real>
55 class Reduced_Objective_SimOpt : public Objective<Real> {
56 private:
57  const Ptr<Objective_SimOpt<Real>> obj_;
58  const Ptr<Constraint_SimOpt<Real>> con_;
59  Ptr<VectorController<Real>> stateStore_;
60  Ptr<VectorController<Real>> adjointStore_;
61 
62  // Primal vectors
63  Ptr<Vector<Real>> state_;
64  Ptr<Vector<Real>> adjoint_;
65  Ptr<Vector<Real>> state_sens_;
66  Ptr<Vector<Real>> adjoint_sens_;
67 
68  // Dual vectors
69  Ptr<Vector<Real>> dualstate_;
70  Ptr<Vector<Real>> dualstate1_;
71  Ptr<Vector<Real>> dualadjoint_;
72  Ptr<Vector<Real>> dualcontrol_;
73 
74  const bool storage_;
75  const bool useFDhessVec_;
76 
78  unsigned nstat_, nadjo_, nssen_, nasen_;
79 
83  bool newUpdate_;
84  bool isUpdated_;
85 
86 public:
98  const Ptr<Objective_SimOpt<Real>> &obj,
99  const Ptr<Constraint_SimOpt<Real>> &con,
100  const Ptr<Vector<Real>> &state,
101  const Ptr<Vector<Real>> &control,
102  const Ptr<Vector<Real>> &adjoint,
103  const bool storage = true,
104  const bool useFDhessVec = false);
105 
120  const Ptr<Objective_SimOpt<Real>> &obj,
121  const Ptr<Constraint_SimOpt<Real>> &con,
122  const Ptr<Vector<Real>> &state,
123  const Ptr<Vector<Real>> &control,
124  const Ptr<Vector<Real>> &adjoint,
125  const Ptr<Vector<Real>> &dualstate,
126  const Ptr<Vector<Real>> &dualcontrol,
127  const Ptr<Vector<Real>> &dualadjoint,
128  const bool storage = true,
129  const bool useFDhessVec = false);
130 
143  const Ptr<Objective_SimOpt<Real>> &obj,
144  const Ptr<Constraint_SimOpt<Real>> &con,
145  const Ptr<VectorController<Real>> &stateStore,
146  const Ptr<Vector<Real>> &state,
147  const Ptr<Vector<Real>> &control,
148  const Ptr<Vector<Real>> &adjoint,
149  const bool storage = true,
150  const bool useFDhessVec = false);
151 
167  const Ptr<Objective_SimOpt<Real>> &obj,
168  const Ptr<Constraint_SimOpt<Real>> &con,
169  const Ptr<VectorController<Real>> &stateStore,
170  const Ptr<Vector<Real>> &state,
171  const Ptr<Vector<Real>> &control,
172  const Ptr<Vector<Real>> &adjoint,
173  const Ptr<Vector<Real>> &dualstate,
174  const Ptr<Vector<Real>> &dualcontrol,
175  const Ptr<Vector<Real>> &dualadjoint,
176  const bool storage = true,
177  const bool useFDhessVec = false);
178 
181  void update( const Vector<Real> &z, bool flag = true, int iter = -1 ) override;
182  void update( const Vector<Real> &z, UpdateType type, int iter = -1 ) override;
183 
188  Real value( const Vector<Real> &z, Real &tol ) override;
189 
195  void gradient( Vector<Real> &g, const Vector<Real> &z, Real &tol ) override;
196 
200  void hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &z, Real &tol ) override;
201 
204  virtual void precond( Vector<Real> &Pv, const Vector<Real> &v, const Vector<Real> &z, Real &tol ) override;
205 
208  void summarize(std::ostream &stream, const Ptr<BatchManager<Real>> &bman = nullPtr) const;
209 
212  void reset();
213 
214 // For parametrized (stochastic) objective functions and constraints
215 public:
216  void setParameter(const std::vector<Real> &param) override;
217 
218 private:
219  void solve_state_equation(const Vector<Real> &z, Real &tol);
220 
225  void solve_adjoint_equation(const Vector<Real> &z, Real &tol);
226 
231  void solve_state_sensitivity(const Vector<Real> &v, const Vector<Real> &z, Real &tol);
232 
240  void solve_adjoint_sensitivity(const Vector<Real> &v, const Vector<Real> &z, Real &tol);
241 
242 }; // class Reduced_Objective_SimOpt
243 
244 } // namespace ROL
245 
247 
248 #endif
Provides the interface to evaluate objective functions.
Provides the interface to evaluate simulation-based objective functions.
void summarize(std::ostream &stream, const Ptr< BatchManager< Real >> &bman=nullPtr) const
void solve_state_equation(const Vector< Real > &z, Real &tol)
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
Ptr< VectorController< Real > > adjointStore_
virtual void precond(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &z, Real &tol) override
Apply a reduced Hessian preconditioner.
void solve_adjoint_sensitivity(const Vector< Real > &v, const Vector< Real > &z, Real &tol)
Given , the adjoint variable , and a direction , solve the adjoint sensitvity equation for ...
Ptr< VectorController< Real > > stateStore_
Real value(const Vector< Real > &z, Real &tol) override
Given , evaluate the objective function where solves .
const Ptr< Objective_SimOpt< Real > > obj_
const Ptr< Constraint_SimOpt< Real > > con_
void update(const Vector< Real > &z, bool flag=true, int iter=-1) override
Update the SimOpt objective function and equality constraint.
void solve_adjoint_equation(const Vector< Real > &z, Real &tol)
Given which solves the state equation, solve the adjoint equation for .
void setParameter(const std::vector< Real > &param) override
void gradient(Vector< Real > &g, const Vector< Real > &z, Real &tol) override
Given , evaluate the gradient of the objective function where solves .
Defines the constraint operator interface for simulation-based optimization.
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &z, Real &tol) override
Given , evaluate the Hessian of the objective function in the direction .
Reduced_Objective_SimOpt(const Ptr< Objective_SimOpt< Real >> &obj, const Ptr< Constraint_SimOpt< Real >> &con, const Ptr< Vector< Real >> &state, const Ptr< Vector< Real >> &control, const Ptr< Vector< Real >> &adjoint, const bool storage=true, const bool useFDhessVec=false)
Constructor.
void solve_state_sensitivity(const Vector< Real > &v, const Vector< Real > &z, Real &tol)
Given which solves the state equation and a direction , solve the state senstivity equation for ...