ROL
ROL_DynamicObjective_CheckInterface.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #pragma once
11 #ifndef ROL_DYNAMICOBJECTIVE_CHECKINTERFACE_HPP
12 #define ROL_DYNAMICOBJECTIVE_CHECKINTERFACE_HPP
13 
14 #include <functional>
15 
16 #include "ROL_DynamicObjective.hpp"
17 #include "ROL_FunctionBindings.hpp"
18 
19 
20 namespace ROL {
21 namespace details {
22 
23 using namespace std;
24 namespace ph = std::placeholders;
25 
26 template<typename Real>
28 private:
29 
30  using V = Vector<Real>;
32 
34  Real tol_;
36 
37 public:
38 
40  ts_.t.resize(2);
41  ts_.t.at(0) = 0.0;
42  ts_.t.at(1) = 1.0;
43  ts_.k = 0;
44  }
45 
47  obj_(obj), ts_(ts) { }
48 
49 
50  f_update_t<Real> update_uo( const V& un, const V& z ) {
51  return bind( &Obj::update, &obj_, ph::_1, cref(un), cref(z), ts_ );
52  }
53 
54  f_update_t<Real> update_un( const V& uo, const V& z ) {
55  return bind( &Obj::update, &obj_, cref(uo), ph::_1, cref(z), ts_ );
56  }
57 
58  f_update_t<Real> update_z( const V& uo, const V& un ) {
59  return bind( &Obj::update, &obj_, cref(uo), cref(un), ph::_1, ts_ );
60  }
61 
62  //----------------------------------------------------------------------------
63 
64  f_scalar_t<Real> value_uo( const V& un, const V& z ) {
65  return bind( &Obj::value, &obj_, ph::_1, cref(un), cref(z), ts_ );
66  }
67 
68  f_scalar_t<Real> value_un( const V& uo, const V& z ) {
69  return bind( &Obj::value, &obj_, cref(uo), ph::_1, cref(z), ts_ );
70  }
71 
72  f_scalar_t<Real> value_z( const V& uo, const V& un ) {
73  return bind( &Obj::value, &obj_, cref(uo), cref(un), ph::_1, ts_ );
74  }
75 
76  //----------------------------------------------------------------------------
77 
78  f_vector_t<Real> gradient_uo( const V& un, const V& z ) {
79  return bind( &Obj::gradient_uo, &obj_, ph::_1, ph::_2, cref(un), cref(z), ts_ );
80  }
81 
82  f_vector_t<Real> gradient_un( const V& uo, const V& z ) {
83  return bind( &Obj::gradient_un, &obj_, ph::_1, cref(uo), ph::_2, cref(z), ts_ );
84  }
85 
86  f_vector_t<Real> gradient_z( const V& uo, const V& un ) {
87  return bind( &Obj::gradient_z, &obj_, ph::_1, cref(uo), cref(un), ph::_2, ts_ );
88  }
89 
90  // For hessian checks
91  f_vector_t<Real> gradient_uo_uo( const V& un, const V& z ) {
92  return bind( &Obj::gradient_uo, &obj_, ph::_1, ph::_2, cref(un), cref(z), ts_ );
93  }
94 
95  f_vector_t<Real> gradient_uo_un( const V& uo, const V& z ) {
96  return bind( &Obj::gradient_uo, &obj_, ph::_1, cref(uo), ph::_2, cref(z), ts_ );
97  }
98 
99  f_vector_t<Real> gradient_uo_z( const V& uo, const V& un ) {
100  return bind( &Obj::gradient_uo, &obj_, ph::_1, cref(uo), cref(un), ph::_2, ts_ );
101  }
102 
103  f_vector_t<Real> gradient_un_uo( const V& un, const V& z ) {
104  return bind( &Obj::gradient_un, &obj_, ph::_1, ph::_2, cref(un), cref(z), ts_ );
105  }
106 
107  f_vector_t<Real> gradient_un_un( const V& uo, const V& z ) {
108  return bind( &Obj::gradient_un, &obj_, ph::_1, cref(uo), ph::_2, cref(z), ts_ );
109  }
110 
111  f_vector_t<Real> gradient_un_z( const V& uo, const V& un ) {
112  return bind( &Obj::gradient_un, &obj_, ph::_1, cref(uo), cref(un), ph::_2, ts_ );
113  }
114 
115  f_vector_t<Real> gradient_z_uo( const V& un, const V& z ) {
116  return bind( &Obj::gradient_z, &obj_, ph::_1, ph::_2, cref(un), cref(z), ts_ );
117  }
118 
119  f_vector_t<Real> gradient_z_un( const V& uo, const V& z ) {
120  return bind( &Obj::gradient_z, &obj_, ph::_1, cref(uo), ph::_2, cref(z), ts_ );
121  }
122 
123  f_vector_t<Real> gradient_z_z( const V& uo, const V& un ) {
124  return bind( &Obj::gradient_z, &obj_, ph::_1, cref(uo), cref(un), ph::_2, ts_ );
125  }
126 
127  //----------------------------------------------------------------------------
128 
129  f_dderiv_t<Real> hessVec_uo_uo( const V& un, const V& z ) {
130  return bind( &Obj::hessVec_uo_uo, &obj_, ph::_1, ph::_2, ph::_3, cref(un), cref(z), ts_ );
131  }
132 
133  f_dderiv_t<Real> hessVec_uo_un( const V& uo, const V& z ) {
134  return bind( &Obj::hessVec_uo_un, &obj_, ph::_1, ph::_2, cref(uo), ph::_3, cref(z), ts_ );
135  }
136 
137  f_dderiv_t<Real> hessVec_uo_z( const V& uo, const V& un ) {
138  return bind( &Obj::hessVec_uo_z, &obj_, ph::_1, ph::_2, cref(uo), cref(un), ph::_3, ts_ );
139  }
140 
141  //----------------------------------------------------------------------------
142 
143  f_dderiv_t<Real> hessVec_un_uo( const V& un, const V& z ) {
144  return bind( &Obj::hessVec_un_uo, &obj_, ph::_1, ph::_2, ph::_3, cref(un), cref(z), ts_ );
145  }
146 
147  f_dderiv_t<Real> hessVec_un_un( const V& uo, const V& z ) {
148  return bind( &Obj::hessVec_un_un, &obj_, ph::_1, ph::_2, cref(uo), ph::_3, cref(z), ts_ );
149  }
150 
151  f_dderiv_t<Real> hessVec_un_z( const V& uo, const V& un ) {
152  return bind( &Obj::hessVec_un_z, &obj_, ph::_1, ph::_2, cref(uo), cref(un), ph::_3, ts_ );
153  }
154 
155  //----------------------------------------------------------------------------
156 
157  f_dderiv_t<Real> hessVec_z_uo( const V& un, const V& z ) {
158  return bind( &Obj::hessVec_z_uo, &obj_, ph::_1, ph::_2, ph::_3, cref(un), cref(z), ts_ );
159  }
160 
161  f_dderiv_t<Real> hessVec_z_un( const V& uo, const V& z ) {
162  return bind( &Obj::hessVec_z_un, &obj_, ph::_1, ph::_2, cref(uo), ph::_3, cref(z), ts_ );
163  }
164 
165  f_dderiv_t<Real> hessVec_z_z( const V& uo, const V& un ) {
166  return bind( &Obj::hessVec_z_z, &obj_, ph::_1, ph::_2, cref(uo), cref(un), ph::_3, ts_ );
167  }
168 
169 
170 }; // DynamicObjective_CheckInterface
171 
172 
173 } // namespace details
174 
175 using details::DynamicObjective_CheckInterface;
176 
177 template<typename Real>
178 DynamicObjective_CheckInterface<Real> make_check( DynamicObjective<Real>& obj ) {
179  return DynamicObjective_CheckInterface<Real>( obj );
180 }
181 
182 template<typename Real>
183 DynamicObjective_CheckInterface<Real> make_check( DynamicObjective<Real>& obj,
184  TimeStamp<Real>& ts ) {
185  return DynamicObjective_CheckInterface<Real>( obj, ts );
186 }
187 
188 
189 } // namespace ROL
190 
191 
192 #endif // ROL_DYNAMICOBJECTIVE_CHECKINTERFACE_HPP
193 
f_vector_t< Real > gradient_uo_uo(const V &un, const V &z)
f_dderiv_t< Real > hessVec_un_un(const V &uo, const V &z)
f_vector_t< Real > gradient_z(const V &uo, const V &un)
virtual void update(const Vector< Real > &u, const Vector< Real > &z, bool flag=true, int iter=-1) override
f_dderiv_t< Real > hessVec_uo_un(const V &uo, const V &z)
f_dderiv_t< Real > hessVec_z_un(const V &uo, const V &z)
f_vector_t< Real > gradient_uo_z(const V &uo, const V &un)
f_vector_t< Real > gradient_un_un(const V &uo, const V &z)
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
Defines the time-dependent objective function interface for simulation-based optimization. Computes time-local contributions of value, gradient, Hessian-vector product etc to a larger composite objective defined over the simulation time. In contrast to other objective classes Objective_TimeSimOpt has a default implementation of value which returns zero, as time-dependent simulation based optimization problems may have an objective value which depends only on the final state of the system.
f_dderiv_t< Real > hessVec_z_z(const V &uo, const V &un)
f_vector_t< Real > gradient_z_uo(const V &un, const V &z)
f_vector_t< Real > gradient_z_un(const V &uo, const V &z)
f_dderiv_t< Real > hessVec_un_z(const V &uo, const V &un)
f_vector_t< Real > gradient_un_uo(const V &un, const V &z)
f_update_t< Real > update_z(const V &uo, const V &un)
f_vector_t< Real > gradient_uo_un(const V &uo, const V &z)
f_vector_t< Real > gradient_un(const V &uo, const V &z)
f_vector_t< Real > gradient_uo(const V &un, const V &z)
void value(ROL::Vector< Real > &c, const ROL::Vector< Real > &sol, const Real &mu)
f_dderiv_t< Real > hessVec_z_uo(const V &un, const V &z)
f_dderiv_t< Real > hessVec_uo_uo(const V &un, const V &z)
f_vector_t< Real > gradient_z_z(const V &uo, const V &un)
f_scalar_t< Real > value_z(const V &uo, const V &un)
f_dderiv_t< Real > hessVec_uo_z(const V &uo, const V &un)
const Ptr< Obj > obj_
f_vector_t< Real > gradient_un_z(const V &uo, const V &un)
f_dderiv_t< Real > hessVec_un_uo(const V &un, const V &z)
DynamicConstraint_CheckInterface< Real > make_check(DynamicConstraint< Real > &con)