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
17#include "ROL_FunctionBindings.hpp"
18
19
20namespace ROL {
21namespace details {
22
23namespace ph = std::placeholders;
24
25template<typename Real>
27private:
28
29 using V = Vector<Real>;
31
33 Real tol_;
35
36public:
37
39 ts_.t.resize(2);
40 ts_.t.at(0) = 0.0;
41 ts_.t.at(1) = 1.0;
42 ts_.k = 0;
43 }
44
47
48
49 f_update_t<Real> update_uo( const V& un, const V& z ) {
50 return std::bind( &Obj::update, &obj_, ph::_1, std::cref(un), std::cref(z), ts_ );
51 }
52
53 f_update_t<Real> update_un( const V& uo, const V& z ) {
54 return std::bind( &Obj::update, &obj_, std::cref(uo), ph::_1, std::cref(z), ts_ );
55 }
56
57 f_update_t<Real> update_z( const V& uo, const V& un ) {
58 return std::bind( &Obj::update, &obj_, std::cref(uo), std::cref(un), ph::_1, ts_ );
59 }
60
61 //----------------------------------------------------------------------------
62
63 f_scalar_t<Real> value_uo( const V& un, const V& z ) {
64 return std::bind( &Obj::value, &obj_, ph::_1, std::cref(un), std::cref(z), ts_ );
65 }
66
67 f_scalar_t<Real> value_un( const V& uo, const V& z ) {
68 return std::bind( &Obj::value, &obj_, std::cref(uo), ph::_1, std::cref(z), ts_ );
69 }
70
71 f_scalar_t<Real> value_z( const V& uo, const V& un ) {
72 return std::bind( &Obj::value, &obj_, std::cref(uo), std::cref(un), ph::_1, ts_ );
73 }
74
75 //----------------------------------------------------------------------------
76
77 f_vector_t<Real> gradient_uo( const V& un, const V& z ) {
78 return std::bind( &Obj::gradient_uo, &obj_, ph::_1, ph::_2, std::cref(un), std::cref(z), ts_ );
79 }
80
81 f_vector_t<Real> gradient_un( const V& uo, const V& z ) {
82 return std::bind( &Obj::gradient_un, &obj_, ph::_1, std::cref(uo), ph::_2, std::cref(z), ts_ );
83 }
84
85 f_vector_t<Real> gradient_z( const V& uo, const V& un ) {
86 return std::bind( &Obj::gradient_z, &obj_, ph::_1, std::cref(uo), std::cref(un), ph::_2, ts_ );
87 }
88
89 // For hessian checks
90 f_vector_t<Real> gradient_uo_uo( const V& un, const V& z ) {
91 return std::bind( &Obj::gradient_uo, &obj_, ph::_1, ph::_2, std::cref(un), std::cref(z), ts_ );
92 }
93
94 f_vector_t<Real> gradient_uo_un( const V& uo, const V& z ) {
95 return std::bind( &Obj::gradient_uo, &obj_, ph::_1, std::cref(uo), ph::_2, std::cref(z), ts_ );
96 }
97
98 f_vector_t<Real> gradient_uo_z( const V& uo, const V& un ) {
99 return std::bind( &Obj::gradient_uo, &obj_, ph::_1, std::cref(uo), std::cref(un), ph::_2, ts_ );
100 }
101
102 f_vector_t<Real> gradient_un_uo( const V& un, const V& z ) {
103 return std::bind( &Obj::gradient_un, &obj_, ph::_1, ph::_2, std::cref(un), std::cref(z), ts_ );
104 }
105
106 f_vector_t<Real> gradient_un_un( const V& uo, const V& z ) {
107 return std::bind( &Obj::gradient_un, &obj_, ph::_1, std::cref(uo), ph::_2, std::cref(z), ts_ );
108 }
109
110 f_vector_t<Real> gradient_un_z( const V& uo, const V& un ) {
111 return std::bind( &Obj::gradient_un, &obj_, ph::_1, std::cref(uo), std::cref(un), ph::_2, ts_ );
112 }
113
114 f_vector_t<Real> gradient_z_uo( const V& un, const V& z ) {
115 return std::bind( &Obj::gradient_z, &obj_, ph::_1, ph::_2, std::cref(un), std::cref(z), ts_ );
116 }
117
118 f_vector_t<Real> gradient_z_un( const V& uo, const V& z ) {
119 return std::bind( &Obj::gradient_z, &obj_, ph::_1, std::cref(uo), ph::_2, std::cref(z), ts_ );
120 }
121
122 f_vector_t<Real> gradient_z_z( const V& uo, const V& un ) {
123 return std::bind( &Obj::gradient_z, &obj_, ph::_1, std::cref(uo), std::cref(un), ph::_2, ts_ );
124 }
125
126 //----------------------------------------------------------------------------
127
128 f_dderiv_t<Real> hessVec_uo_uo( const V& un, const V& z ) {
129 return std::bind( &Obj::hessVec_uo_uo, &obj_, ph::_1, ph::_2, ph::_3, std::cref(un), std::cref(z), ts_ );
130 }
131
132 f_dderiv_t<Real> hessVec_uo_un( const V& uo, const V& z ) {
133 return std::bind( &Obj::hessVec_uo_un, &obj_, ph::_1, ph::_2, std::cref(uo), ph::_3, std::cref(z), ts_ );
134 }
135
136 f_dderiv_t<Real> hessVec_uo_z( const V& uo, const V& un ) {
137 return std::bind( &Obj::hessVec_uo_z, &obj_, ph::_1, ph::_2, std::cref(uo), std::cref(un), ph::_3, ts_ );
138 }
139
140 //----------------------------------------------------------------------------
141
142 f_dderiv_t<Real> hessVec_un_uo( const V& un, const V& z ) {
143 return std::bind( &Obj::hessVec_un_uo, &obj_, ph::_1, ph::_2, ph::_3, std::cref(un), std::cref(z), ts_ );
144 }
145
146 f_dderiv_t<Real> hessVec_un_un( const V& uo, const V& z ) {
147 return std::bind( &Obj::hessVec_un_un, &obj_, ph::_1, ph::_2, std::cref(uo), ph::_3, std::cref(z), ts_ );
148 }
149
150 f_dderiv_t<Real> hessVec_un_z( const V& uo, const V& un ) {
151 return std::bind( &Obj::hessVec_un_z, &obj_, ph::_1, ph::_2, std::cref(uo), std::cref(un), ph::_3, ts_ );
152 }
153
154 //----------------------------------------------------------------------------
155
156 f_dderiv_t<Real> hessVec_z_uo( const V& un, const V& z ) {
157 return std::bind( &Obj::hessVec_z_uo, &obj_, ph::_1, ph::_2, ph::_3, std::cref(un), std::cref(z), ts_ );
158 }
159
160 f_dderiv_t<Real> hessVec_z_un( const V& uo, const V& z ) {
161 return std::bind( &Obj::hessVec_z_un, &obj_, ph::_1, ph::_2, std::cref(uo), ph::_3, std::cref(z), ts_ );
162 }
163
164 f_dderiv_t<Real> hessVec_z_z( const V& uo, const V& un ) {
165 return std::bind( &Obj::hessVec_z_z, &obj_, ph::_1, ph::_2, std::cref(uo), std::cref(un), ph::_3, ts_ );
166 }
167
168
169}; // DynamicObjective_CheckInterface
170
171
172} // namespace details
173
175
176template<typename Real>
180
181template<typename Real>
186
187
188} // namespace ROL
189
190
191#endif // ROL_DYNAMICOBJECTIVE_CHECKINTERFACE_HPP
192
Defines the time-dependent objective function interface for simulation-based optimization....
virtual void hessVec_un_z(V &hv, const V &v, const V &uo, const V &un, const V &z, const TS &timeStamp) const
virtual void hessVec_z_uo(V &hv, const V &v, const V &uo, const V &un, const V &z, const TS &timeStamp) const
virtual void hessVec_un_uo(V &hv, const V &v, const V &uo, const V &un, const V &z, const TS &timeStamp) const
virtual void gradient_un(V &g, const V &uo, const V &un, const V &z, const TS &timeStamp) const
virtual void hessVec_z_z(V &hv, const V &v, const V &uo, const V &un, const V &z, const TS &timeStamp) const
virtual void hessVec_uo_uo(V &hv, const V &v, const V &uo, const V &un, const V &z, const TS &timeStamp) const
virtual Real value(const V &uo, const V &un, const V &z, const TS &timeStamp) const =0
virtual void gradient_z(V &g, const V &uo, const V &un, const V &z, const TS &timeStamp) const
virtual void hessVec_uo_un(V &hv, const V &v, const V &uo, const V &un, const V &z, const TS &timeStamp) const
virtual void hessVec_un_un(V &hv, const V &v, const V &uo, const V &un, const V &z, const TS &timeStamp) const
virtual void update(const V &uo, const V &un, const V &z, const TS &timeStamp)
virtual void gradient_uo(V &g, const V &uo, const V &un, const V &z, const TS &timeStamp) const
virtual void hessVec_z_un(V &hv, const V &v, const V &uo, const V &un, const V &z, const TS &timeStamp) const
virtual void hessVec_uo_z(V &hv, const V &v, const V &uo, const V &un, const V &z, const TS &timeStamp) const
Defines the linear algebra or vector space interface.
f_vector_t< Real > gradient_uo_uo(const V &un, const V &z)
f_dderiv_t< Real > hessVec_un_z(const V &uo, const V &un)
f_vector_t< Real > gradient_un_z(const V &uo, const V &un)
f_vector_t< Real > gradient_uo_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_z_z(const V &uo, const V &un)
f_vector_t< Real > gradient_z(const V &uo, const V &un)
f_dderiv_t< Real > hessVec_uo_z(const V &uo, const V &un)
DynamicConstraint_CheckInterface< Real > make_check(DynamicConstraint< Real > &con)
Contains local time step information.