46 #ifndef ROL_DYNAMICCONSTRAINTCHECK_HPP
47 #define ROL_DYNAMICCONSTRAINTCHECK_HPP
50 #include "ROL_ValidateFunction.hpp"
57 template<
typename Real>
61 ValidateFunction<Real>& validator,
65 const std::vector<std::string>& methods ) {
68 check( con_check, validator, uo, un, z, methods );
73 ValidateFunction<Real>& validator,
78 const std::vector<std::string>& methods ) {
81 check( con_check, validator, uo, un, z, methods );
84 static void check( DynamicConstraint_CheckInterface<Real>& con_check,
85 ValidateFunction<Real>& validator,
89 const std::vector<std::string>& methods ) {
94 auto l = uo.
dual().clone();
101 auto update_uo = con_check.update_uo( un, z );
102 auto update_un = con_check.update_un( uo, z );
103 auto update_z = con_check.update_z( un, uo );
105 auto value_uo = con_check.value_uo( un, z );
106 auto value_un = con_check.value_un( uo, z );
107 auto value_z = con_check.value_z( uo, un );
111 if( std::find(methods.begin(),methods.end(),
"applyJacobian_uo") != methods.end() ) {
112 auto J = con_check.jacobian_uo( un, z );
113 validator.derivative_check( value_uo, J, update_uo, *c, *vu, uo,
"norm(J_uo*vec)" );
116 if( std::find(methods.begin(),methods.end(),
"applyJacobian_un") != methods.end() ) {
117 auto J = con_check.jacobian_un( uo, z );
118 validator.derivative_check( value_un, J, update_un, *c, *vu, un,
"norm(J_un*vec)" );
121 if( std::find(methods.begin(),methods.end(),
"applyJacobian_z") != methods.end() ) {
122 auto J = con_check.jacobian_z( uo, un );
123 validator.derivative_check( value_z, J, update_z, *c, *vz, z,
"norm(J_z*vec)" );
129 if( std::find(methods.begin(),methods.end(),
"applyAdjointJacobian_uo") != methods.end() ) {
130 auto J = con_check.jacobian_uo( un, z );
131 auto aJ = con_check.adjointJacobian_uo( un, z );
132 validator.adjoint_consistency_check( J, aJ, update_uo, *c, *vu, uo,
133 "Jacobian with respect to uo",
"J_uo");
136 if( std::find(methods.begin(),methods.end(),
"applyAdjointJacobian_un") != methods.end() ) {
137 auto J = con_check.jacobian_un( uo, z );
138 auto aJ = con_check.adjointJacobian_un( uo, z );
139 validator.adjoint_consistency_check( J, aJ, update_un, *c, *vu, un,
140 "Jacobian with respect to un",
"J_un");
143 if( std::find(methods.begin(),methods.end(),
"applyAdjointJacobian_z") != methods.end() ) {
144 auto J = con_check.jacobian_z( uo, un );
145 auto aJ = con_check.adjointJacobian_z( uo, un );
146 validator.adjoint_consistency_check( J, aJ, update_z, *vz, *c, z,
147 "Jacobian with respect to z",
"J_z");
153 if( std::find(methods.begin(),methods.end(),
"solve") != methods.end() ) {
154 auto S = con_check.solve_un( uo, z );
155 validator.solve_check( S, value_un, update_un, *c, un,
"Dynamic Constraint");
159 if( std::find(methods.begin(),methods.end(),
"applyInverseJacobian_un") != methods.end() ) {
160 auto J = con_check.jacobian_un( uo, z );
161 auto iJ = con_check.inverseJacobian_un( uo, z );
162 validator.inverse_check( J, iJ, update_un, *vu, un,
163 "Jacobian with respect to un",
"J_un");
167 if( std::find(methods.begin(),methods.end(),
"applyInverseAdjointJacobian_un") != methods.end() ) {
168 auto aJ = con_check.adjointJacobian_un( uo, z );
169 auto iaJ = con_check.inverseAdjointJacobian_un( uo, z );
170 validator.inverse_check( aJ, iaJ, update_un, *vu, un,
171 "adjoint Jacobian with respect to un",
"aJ_un");
177 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_uo_uo") != methods.end() ) {
178 auto aJ = con_check.adjointJacobian_uo_uo( un, z );
179 auto aJl = fix_direction( aJ, *l );
180 auto aH = con_check.adjointHessian_uo_uo( un, z, *l );
181 validator.derivative_check( aJl, aH, update_uo, *c, *vu, uo,
"H_uo_uo");
184 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_uo_un") != methods.end() ) {
185 auto aJ = con_check.adjointJacobian_un_uo( un, z );
186 auto aJl = fix_direction( aJ, *l );
187 auto aH = con_check.adjointHessian_uo_un( un, z, *l );
188 validator.derivative_check( aJl, aH, update_uo, *c, *vu, uo,
"H_uo_un");
191 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_uo_z") != methods.end() ) {
192 auto aJ = con_check.adjointJacobian_z_uo( un, z );
193 auto aJl = fix_direction( aJ, *l );
194 auto aH = con_check.adjointHessian_uo_z( un, z, *l );
195 validator.derivative_check( aJl, aH, update_uo, *vz, *vu, uo,
"H_uo_z");
200 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_un_uo") != methods.end() ) {
201 auto aJ = con_check.adjointJacobian_uo_un( uo, z );
202 auto aJl = fix_direction( aJ, *l );
203 auto aH = con_check.adjointHessian_un_uo( uo, z, *l );
204 validator.derivative_check( aJl, aH, update_un, *c, *vu, un,
"H_un_uo");
207 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_un_un") != methods.end() ) {
208 auto aJ = con_check.adjointJacobian_un_un( uo, z );
209 auto aJl = fix_direction( aJ, *l );
210 auto aH = con_check.adjointHessian_un_un( uo, z, *l );
211 validator.derivative_check( aJl, aH, update_un, *c, *vu, un,
"H_un_un");
214 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_un_z") != methods.end() ) {
215 auto aJ = con_check.adjointJacobian_z_un( uo, z );
216 auto aJl = fix_direction( aJ, *l );
217 auto aH = con_check.adjointHessian_un_z( un, z, *l );
218 validator.derivative_check( aJl, aH, update_un, *vz, *vu, un,
"H_un_z");
223 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_z_uo") != methods.end() ) {
224 auto aJ = con_check.adjointJacobian_uo_z( uo, un );
225 auto aJl = fix_direction( aJ, *l );
226 auto aH = con_check.adjointHessian_z_uo( uo, un, *l );
227 validator.derivative_check( aJl, aH, update_z, *c, *vz, z,
"H_z_uo");
230 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_z_un") != methods.end() ) {
231 auto aJ = con_check.adjointJacobian_un_z( uo, un );
232 auto aJl = fix_direction( aJ, *l );
233 auto aH = con_check.adjointHessian_z_un( uo, un, *l );
234 validator.derivative_check( aJl, aH, update_z, *c, *vz, z,
"H_z_un");
237 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_z_z") != methods.end() ) {
238 auto aJ = con_check.adjointJacobian_z_z( uo, un );
239 auto aJl = fix_direction( aJ, *l );
240 auto aH = con_check.adjointHessian_z_z( uo, un, *l );
241 validator.derivative_check( aJl, aH, update_z, *vz, *vz, z,
"H_z_z");
247 ValidateFunction<Real>& validator,
251 std::vector<std::string> methods = {
"applyJacobian_uo",
254 "applyAdjointJacobian_uo",
255 "applyAdjointJacobian_un",
256 "applyAdjointJacobian_z",
258 "applyInverseJacobian_un",
259 "applyInverseAdjointJacobian_un",
260 "applyAdjointHessian_uo_uo",
261 "applyAdjointHessian_uo_un",
262 "applyAdjointHessian_uo_z",
263 "applyAdjointHessian_un_uo",
264 "applyAdjointHessian_un_un",
265 "applyAdjointHessian_un_z",
266 "applyAdjointHessian_z_uo",
267 "applyAdjointHessian_z_un",
268 "applyAdjointHessian_z_z"};
269 check(con, validator, uo, un, z, methods);
277 #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)
DynamicConstraint_CheckInterface< Real > make_check(DynamicConstraint< Real > &con)