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 
51 namespace ROL {
52 
53 template<typename Real>
54 class Reduced_Objective_SimOpt : public Objective<Real> {
55 private:
56  const Ptr<Objective_SimOpt<Real>> obj_;
57  const Ptr<Constraint_SimOpt<Real>> con_;
58  Ptr<VectorController<Real>> stateStore_;
59  Ptr<VectorController<Real>> adjointStore_;
60 
61  // Primal vectors
62  Ptr<Vector<Real>> state_;
63  Ptr<Vector<Real>> adjoint_;
64  Ptr<Vector<Real>> state_sens_;
65  Ptr<Vector<Real>> adjoint_sens_;
66 
67  // Dual vectors
68  Ptr<Vector<Real>> dualstate_;
69  Ptr<Vector<Real>> dualstate1_;
70  Ptr<Vector<Real>> dualadjoint_;
71  Ptr<Vector<Real>> dualcontrol_;
72 
73  const bool storage_;
74  const bool useFDhessVec_;
75 
77  unsigned nstat_, nadjo_, nssen_, nasen_;
78 
82  bool newUpdate_;
83 
84 public:
96  const Ptr<Objective_SimOpt<Real>> &obj,
97  const Ptr<Constraint_SimOpt<Real>> &con,
98  const Ptr<Vector<Real>> &state,
99  const Ptr<Vector<Real>> &control,
100  const Ptr<Vector<Real>> &adjoint,
101  const bool storage = true,
102  const bool useFDhessVec = false);
103 
118  const Ptr<Objective_SimOpt<Real>> &obj,
119  const Ptr<Constraint_SimOpt<Real>> &con,
120  const Ptr<Vector<Real>> &state,
121  const Ptr<Vector<Real>> &control,
122  const Ptr<Vector<Real>> &adjoint,
123  const Ptr<Vector<Real>> &dualstate,
124  const Ptr<Vector<Real>> &dualcontrol,
125  const Ptr<Vector<Real>> &dualadjoint,
126  const bool storage = true,
127  const bool useFDhessVec = false);
128 
141  const Ptr<Objective_SimOpt<Real>> &obj,
142  const Ptr<Constraint_SimOpt<Real>> &con,
143  const Ptr<VectorController<Real>> &stateStore,
144  const Ptr<Vector<Real>> &state,
145  const Ptr<Vector<Real>> &control,
146  const Ptr<Vector<Real>> &adjoint,
147  const bool storage = true,
148  const bool useFDhessVec = false);
149 
165  const Ptr<Objective_SimOpt<Real>> &obj,
166  const Ptr<Constraint_SimOpt<Real>> &con,
167  const Ptr<VectorController<Real>> &stateStore,
168  const Ptr<Vector<Real>> &state,
169  const Ptr<Vector<Real>> &control,
170  const Ptr<Vector<Real>> &adjoint,
171  const Ptr<Vector<Real>> &dualstate,
172  const Ptr<Vector<Real>> &dualcontrol,
173  const Ptr<Vector<Real>> &dualadjoint,
174  const bool storage = true,
175  const bool useFDhessVec = false);
176 
179  void update( const Vector<Real> &z, bool flag = true, int iter = -1 ) override;
180  void update( const Vector<Real> &z, UpdateType type, int iter = -1 ) override;
181 
186  Real value( const Vector<Real> &z, Real &tol ) override;
187 
193  void gradient( Vector<Real> &g, const Vector<Real> &z, Real &tol ) override;
194 
198  void hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &z, Real &tol ) override;
199 
202  virtual void precond( Vector<Real> &Pv, const Vector<Real> &v, const Vector<Real> &z, Real &tol ) override;
203 
206  void summarize(std::ostream &stream) const;
207 
210  void reset();
211 
212 // For parametrized (stochastic) objective functions and constraints
213 public:
214  void setParameter(const std::vector<Real> &param) override;
215 
216 private:
217  void solve_state_equation(const Vector<Real> &z, Real &tol);
218 
223  void solve_adjoint_equation(const Vector<Real> &z, Real &tol);
224 
229  void solve_state_sensitivity(const Vector<Real> &v, const Vector<Real> &z, Real &tol);
230 
238  void solve_adjoint_sensitivity(const Vector<Real> &v, const Vector<Real> &z, Real &tol);
239 
240 }; // class Reduced_Objective_SimOpt
241 
242 } // namespace ROL
243 
245 
246 #endif
Provides the interface to evaluate objective functions.
Provides the interface to evaluate simulation-based objective functions.
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 summarize(std::ostream &stream) const
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 ...