11 #ifndef ROL_DYNAMICCONSTRAINTCHECK_HPP
12 #define ROL_DYNAMICCONSTRAINTCHECK_HPP
15 #include "ROL_ValidateFunction.hpp"
22 template<
typename Real>
26 ValidateFunction<Real>& validator,
30 const std::vector<std::string>& methods ) {
33 check( con_check, validator, uo, un, z, methods );
37 ValidateFunction<Real>& validator,
42 const std::vector<std::string>& methods ) {
45 check( con_check, validator, uo, un, z, methods );
48 static void check( DynamicConstraint_CheckInterface<Real>& con_check,
49 ValidateFunction<Real>& validator,
53 const std::vector<std::string>& methods ) {
58 auto l = uo.
dual().clone();
65 auto update_uo = con_check.update_uo( un, z );
66 auto update_un = con_check.update_un( uo, z );
67 auto update_z = con_check.update_z( un, uo );
69 auto value_uo = con_check.value_uo( un, z );
70 auto value_un = con_check.value_un( uo, z );
71 auto value_z = con_check.value_z( uo, un );
75 if( std::find(methods.begin(),methods.end(),
"applyJacobian_uo") != methods.end() ) {
76 auto J = con_check.jacobian_uo( un, z );
77 validator.derivative_check( value_uo, J, update_uo, *c, *vu, uo,
"norm(J_uo*vec)" );
80 if( std::find(methods.begin(),methods.end(),
"applyJacobian_un") != methods.end() ) {
81 auto J = con_check.jacobian_un( uo, z );
82 validator.derivative_check( value_un, J, update_un, *c, *vu, un,
"norm(J_un*vec)" );
85 if( std::find(methods.begin(),methods.end(),
"applyJacobian_z") != methods.end() ) {
86 auto J = con_check.jacobian_z( uo, un );
87 validator.derivative_check( value_z, J, update_z, *c, *vz, z,
"norm(J_z*vec)" );
93 if( std::find(methods.begin(),methods.end(),
"applyAdjointJacobian_uo") != methods.end() ) {
94 auto J = con_check.jacobian_uo( un, z );
95 auto aJ = con_check.adjointJacobian_uo( un, z );
96 validator.adjoint_consistency_check( J, aJ, update_uo, *c, *vu, uo,
97 "Jacobian with respect to uo",
"J_uo");
100 if( std::find(methods.begin(),methods.end(),
"applyAdjointJacobian_un") != methods.end() ) {
101 auto J = con_check.jacobian_un( uo, z );
102 auto aJ = con_check.adjointJacobian_un( uo, z );
103 validator.adjoint_consistency_check( J, aJ, update_un, *c, *vu, un,
104 "Jacobian with respect to un",
"J_un");
107 if( std::find(methods.begin(),methods.end(),
"applyAdjointJacobian_z") != methods.end() ) {
108 auto J = con_check.jacobian_z( uo, un );
109 auto aJ = con_check.adjointJacobian_z( uo, un );
110 validator.adjoint_consistency_check( J, aJ, update_z, *vz, *c, z,
111 "Jacobian with respect to z",
"J_z");
117 if( std::find(methods.begin(),methods.end(),
"solve") != methods.end() ) {
118 auto S = con_check.solve_un( uo, z );
119 validator.solve_check( S, value_un, update_un, *c, un,
"Dynamic Constraint");
123 if( std::find(methods.begin(),methods.end(),
"applyInverseJacobian_un") != methods.end() ) {
124 auto J = con_check.jacobian_un( uo, z );
125 auto iJ = con_check.inverseJacobian_un( uo, z );
126 validator.inverse_check( J, iJ, update_un, *vu, un,
127 "Jacobian with respect to un",
"J_un");
131 if( std::find(methods.begin(),methods.end(),
"applyInverseAdjointJacobian_un") != methods.end() ) {
132 auto aJ = con_check.adjointJacobian_un( uo, z );
133 auto iaJ = con_check.inverseAdjointJacobian_un( uo, z );
134 validator.inverse_check( aJ, iaJ, update_un, *vu, un,
135 "adjoint Jacobian with respect to un",
"aJ_un");
141 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_uo_uo") != methods.end() ) {
142 auto aJ = con_check.adjointJacobian_uo_uo( un, z );
143 auto aJl = fix_direction( aJ, *l );
144 auto aH = con_check.adjointHessian_uo_uo( un, z, *l );
145 validator.derivative_check( aJl, aH, update_uo, *c, *vu, uo,
"H_uo_uo");
148 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_uo_un") != methods.end() ) {
149 auto aJ = con_check.adjointJacobian_un_uo( un, z );
150 auto aJl = fix_direction( aJ, *l );
151 auto aH = con_check.adjointHessian_uo_un( un, z, *l );
152 validator.derivative_check( aJl, aH, update_uo, *c, *vu, uo,
"H_uo_un");
155 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_uo_z") != methods.end() ) {
156 auto aJ = con_check.adjointJacobian_z_uo( un, z );
157 auto aJl = fix_direction( aJ, *l );
158 auto aH = con_check.adjointHessian_uo_z( un, z, *l );
159 validator.derivative_check( aJl, aH, update_uo, *vz, *vu, uo,
"H_uo_z");
164 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_un_uo") != methods.end() ) {
165 auto aJ = con_check.adjointJacobian_uo_un( uo, z );
166 auto aJl = fix_direction( aJ, *l );
167 auto aH = con_check.adjointHessian_un_uo( uo, z, *l );
168 validator.derivative_check( aJl, aH, update_un, *c, *vu, un,
"H_un_uo");
171 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_un_un") != methods.end() ) {
172 auto aJ = con_check.adjointJacobian_un_un( uo, z );
173 auto aJl = fix_direction( aJ, *l );
174 auto aH = con_check.adjointHessian_un_un( uo, z, *l );
175 validator.derivative_check( aJl, aH, update_un, *c, *vu, un,
"H_un_un");
178 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_un_z") != methods.end() ) {
179 auto aJ = con_check.adjointJacobian_z_un( uo, z );
180 auto aJl = fix_direction( aJ, *l );
181 auto aH = con_check.adjointHessian_un_z( un, z, *l );
182 validator.derivative_check( aJl, aH, update_un, *vz, *vu, un,
"H_un_z");
187 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_z_uo") != methods.end() ) {
188 auto aJ = con_check.adjointJacobian_uo_z( uo, un );
189 auto aJl = fix_direction( aJ, *l );
190 auto aH = con_check.adjointHessian_z_uo( uo, un, *l );
191 validator.derivative_check( aJl, aH, update_z, *c, *vz, z,
"H_z_uo");
194 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_z_un") != methods.end() ) {
195 auto aJ = con_check.adjointJacobian_un_z( uo, un );
196 auto aJl = fix_direction( aJ, *l );
197 auto aH = con_check.adjointHessian_z_un( uo, un, *l );
198 validator.derivative_check( aJl, aH, update_z, *c, *vz, z,
"H_z_un");
201 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_z_z") != methods.end() ) {
202 auto aJ = con_check.adjointJacobian_z_z( uo, un );
203 auto aJl = fix_direction( aJ, *l );
204 auto aH = con_check.adjointHessian_z_z( uo, un, *l );
205 validator.derivative_check( aJl, aH, update_z, *vz, *vz, z,
"H_z_z");
211 ValidateFunction<Real>& validator,
215 std::vector<std::string> methods = {
"applyJacobian_uo",
218 "applyAdjointJacobian_uo",
219 "applyAdjointJacobian_un",
220 "applyAdjointJacobian_z",
222 "applyInverseJacobian_un",
223 "applyInverseAdjointJacobian_un",
224 "applyAdjointHessian_uo_uo",
225 "applyAdjointHessian_uo_un",
226 "applyAdjointHessian_uo_z",
227 "applyAdjointHessian_un_uo",
228 "applyAdjointHessian_un_un",
229 "applyAdjointHessian_un_z",
230 "applyAdjointHessian_z_uo",
231 "applyAdjointHessian_z_un",
232 "applyAdjointHessian_z_z"};
233 check(con, validator, uo, un, z, methods);
237 ValidateFunction<Real>& validator,
242 std::vector<std::string> methods = {
"applyJacobian_uo",
245 "applyAdjointJacobian_uo",
246 "applyAdjointJacobian_un",
247 "applyAdjointJacobian_z",
249 "applyInverseJacobian_un",
250 "applyInverseAdjointJacobian_un",
251 "applyAdjointHessian_uo_uo",
252 "applyAdjointHessian_uo_un",
253 "applyAdjointHessian_uo_z",
254 "applyAdjointHessian_un_uo",
255 "applyAdjointHessian_un_un",
256 "applyAdjointHessian_un_z",
257 "applyAdjointHessian_z_uo",
258 "applyAdjointHessian_z_un",
259 "applyAdjointHessian_z_z"};
260 check(con, validator, uo, un, z, ts, methods);
268 #endif // ROL_DYNAMICCONSTRAINTCHECK_HPP
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Defines the time-dependent constraint operator interface for simulation-based optimization.
static void check(DynamicConstraint_CheckInterface< Real > &con_check, ValidateFunction< Real > &validator, const Vector< Real > &uo, const Vector< Real > &un, const Vector< Real > &z, const std::vector< std::string > &methods)
Defines the linear algebra or vector space interface.
static void check(DynamicConstraint< Real > &con, ValidateFunction< Real > &validator, const Vector< Real > &uo, const Vector< Real > &un, const Vector< Real > &z)
static void check(DynamicConstraint< Real > &con, ValidateFunction< Real > &validator, const Vector< Real > &uo, const Vector< Real > &un, const Vector< Real > &z, const std::vector< std::string > &methods)
static void check(DynamicConstraint< Real > &con, ValidateFunction< Real > &validator, const Vector< Real > &uo, const Vector< Real > &un, const Vector< Real > &z, TimeStamp< Real > &timeStamp, const std::vector< std::string > &methods)
static void check(DynamicConstraint< Real > &con, ValidateFunction< Real > &validator, const Vector< Real > &uo, const Vector< Real > &un, const Vector< Real > &z, TimeStamp< Real > &ts)
DynamicConstraint_CheckInterface< Real > make_check(DynamicConstraint< Real > &con)