ROL
ROL_DynamicObjective_CheckInterface.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 Objtract 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 Objditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of Objditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of Objditions 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 // Objtributors 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 // ObjTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR ObjSEQUENTIAL 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 ObjTRACT, 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? Objtact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 
45 #pragma once
46 #ifndef ROL_DYNAMICOBJECTIVE_CHECKINTERFACE_HPP
47 #define ROL_DYNAMICOBJECTIVE_CHECKINTERFACE_HPP
48 
49 #include <functional>
50 
51 #include "ROL_DynamicObjective.hpp"
52 #include "ROL_FunctionBindings.hpp"
53 
54 
55 namespace ROL {
56 namespace details {
57 
58 using namespace std;
59 namespace ph = std::placeholders;
60 
61 template<typename Real>
63 private:
64 
65  using V = Vector<Real>;
67 
69  Real tol_;
71 
72 public:
73 
75  ts_.t.resize(2);
76  ts_.t.at(0) = 0.0;
77  ts_.t.at(1) = 1.0;
78  ts_.k = 0;
79  }
80 
82  obj_(obj), ts_(ts) { }
83 
84 
85  f_update_t<Real> update_uo( const V& un, const V& z ) {
86  return bind( &Obj::update, &obj_, ph::_1, cref(un), cref(z), ts_ );
87  }
88 
89  f_update_t<Real> update_un( const V& uo, const V& z ) {
90  return bind( &Obj::update, &obj_, cref(uo), ph::_1, cref(z), ts_ );
91  }
92 
93  f_update_t<Real> update_z( const V& uo, const V& un ) {
94  return bind( &Obj::update, &obj_, cref(uo), cref(un), ph::_1, ts_ );
95  }
96 
97  //----------------------------------------------------------------------------
98 
99  f_scalar_t<Real> value_uo( const V& un, const V& z ) {
100  return bind( &Obj::value, &obj_, ph::_1, cref(un), cref(z), ts_ );
101  }
102 
103  f_scalar_t<Real> value_un( const V& uo, const V& z ) {
104  return bind( &Obj::value, &obj_, cref(uo), ph::_1, cref(z), ts_ );
105  }
106 
107  f_scalar_t<Real> value_z( const V& uo, const V& un ) {
108  return bind( &Obj::value, &obj_, cref(uo), cref(un), ph::_1, ts_ );
109  }
110 
111  //----------------------------------------------------------------------------
112 
113  f_vector_t<Real> gradient_uo( const V& un, const V& z ) {
114  return bind( &Obj::gradient_uo, &obj_, ph::_1, ph::_2, cref(un), cref(z), ts_ );
115  }
116 
117  f_vector_t<Real> gradient_un( const V& uo, const V& z ) {
118  return bind( &Obj::gradient_un, &obj_, ph::_1, cref(uo), ph::_2, cref(z), ts_ );
119  }
120 
121  f_vector_t<Real> gradient_z( const V& uo, const V& un ) {
122  return bind( &Obj::gradient_z, &obj_, ph::_1, cref(uo), cref(un), ph::_2, ts_ );
123  }
124 
125  // For hessian checks
126  f_vector_t<Real> gradient_uo_uo( const V& un, const V& z ) {
127  return bind( &Obj::gradient_uo, &obj_, ph::_1, ph::_2, cref(un), cref(z), ts_ );
128  }
129 
130  f_vector_t<Real> gradient_uo_un( const V& uo, const V& z ) {
131  return bind( &Obj::gradient_uo, &obj_, ph::_1, cref(uo), ph::_2, cref(z), ts_ );
132  }
133 
134  f_vector_t<Real> gradient_uo_z( const V& uo, const V& un ) {
135  return bind( &Obj::gradient_uo, &obj_, ph::_1, cref(uo), cref(un), ph::_2, ts_ );
136  }
137 
138  f_vector_t<Real> gradient_un_uo( const V& un, const V& z ) {
139  return bind( &Obj::gradient_un, &obj_, ph::_1, ph::_2, cref(un), cref(z), ts_ );
140  }
141 
142  f_vector_t<Real> gradient_un_un( const V& uo, const V& z ) {
143  return bind( &Obj::gradient_un, &obj_, ph::_1, cref(uo), ph::_2, cref(z), ts_ );
144  }
145 
146  f_vector_t<Real> gradient_un_z( const V& uo, const V& un ) {
147  return bind( &Obj::gradient_un, &obj_, ph::_1, cref(uo), cref(un), ph::_2, ts_ );
148  }
149 
150  f_vector_t<Real> gradient_z_uo( const V& un, const V& z ) {
151  return bind( &Obj::gradient_z, &obj_, ph::_1, ph::_2, cref(un), cref(z), ts_ );
152  }
153 
154  f_vector_t<Real> gradient_z_un( const V& uo, const V& z ) {
155  return bind( &Obj::gradient_z, &obj_, ph::_1, cref(uo), ph::_2, cref(z), ts_ );
156  }
157 
158  f_vector_t<Real> gradient_z_z( const V& uo, const V& un ) {
159  return bind( &Obj::gradient_z, &obj_, ph::_1, cref(uo), cref(un), ph::_2, ts_ );
160  }
161 
162  //----------------------------------------------------------------------------
163 
164  f_dderiv_t<Real> hessVec_uo_uo( const V& un, const V& z ) {
165  return bind( &Obj::hessVec_uo_uo, &obj_, ph::_1, ph::_2, ph::_3, cref(un), cref(z), ts_ );
166  }
167 
168  f_dderiv_t<Real> hessVec_uo_un( const V& uo, const V& z ) {
169  return bind( &Obj::hessVec_uo_un, &obj_, ph::_1, ph::_2, cref(uo), ph::_3, cref(z), ts_ );
170  }
171 
172  f_dderiv_t<Real> hessVec_uo_z( const V& uo, const V& un ) {
173  return bind( &Obj::hessVec_uo_z, &obj_, ph::_1, ph::_2, cref(uo), cref(un), ph::_3, ts_ );
174  }
175 
176  //----------------------------------------------------------------------------
177 
178  f_dderiv_t<Real> hessVec_un_uo( const V& un, const V& z ) {
179  return bind( &Obj::hessVec_un_uo, &obj_, ph::_1, ph::_2, ph::_3, cref(un), cref(z), ts_ );
180  }
181 
182  f_dderiv_t<Real> hessVec_un_un( const V& uo, const V& z ) {
183  return bind( &Obj::hessVec_un_un, &obj_, ph::_1, ph::_2, cref(uo), ph::_3, cref(z), ts_ );
184  }
185 
186  f_dderiv_t<Real> hessVec_un_z( const V& uo, const V& un ) {
187  return bind( &Obj::hessVec_un_z, &obj_, ph::_1, ph::_2, cref(uo), cref(un), ph::_3, ts_ );
188  }
189 
190  //----------------------------------------------------------------------------
191 
192  f_dderiv_t<Real> hessVec_z_uo( const V& un, const V& z ) {
193  return bind( &Obj::hessVec_z_uo, &obj_, ph::_1, ph::_2, ph::_3, cref(un), cref(z), ts_ );
194  }
195 
196  f_dderiv_t<Real> hessVec_z_un( const V& uo, const V& z ) {
197  return bind( &Obj::hessVec_z_un, &obj_, ph::_1, ph::_2, cref(uo), ph::_3, cref(z), ts_ );
198  }
199 
200  f_dderiv_t<Real> hessVec_z_z( const V& uo, const V& un ) {
201  return bind( &Obj::hessVec_z_z, &obj_, ph::_1, ph::_2, cref(uo), cref(un), ph::_3, ts_ );
202  }
203 
204 
205 }; // DynamicObjective_CheckInterface
206 
207 
208 } // namespace details
209 
210 using details::DynamicObjective_CheckInterface;
211 
212 template<typename Real>
213 DynamicObjective_CheckInterface<Real> make_check( DynamicObjective<Real>& obj ) {
214  return DynamicObjective_CheckInterface<Real>( obj );
215 }
216 
217 template<typename Real>
218 DynamicObjective_CheckInterface<Real> make_check( DynamicObjective<Real>& obj,
219  TimeStamp<Real>& ts ) {
220  return DynamicObjective_CheckInterface<Real>( obj, ts );
221 }
222 
223 
224 } // namespace ROL
225 
226 
227 #endif // ROL_DYNAMICOBJECTIVE_CHECKINTERFACE_HPP
228 
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:80
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)
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_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)