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 ) {
70 auto l = uo.
dual().clone();
81 auto update_uo = con_check.update_uo( un, z );
82 auto update_un = con_check.update_un( uo, z );
83 auto update_z = con_check.update_z( un, uo );
85 auto value_uo = con_check.value_uo( un, z );
86 auto value_un = con_check.value_un( uo, z );
87 auto value_z = con_check.value_z( uo, un );
91 if( std::find(methods.begin(),methods.end(),
"applyJacobian_uo") != methods.end() ) {
92 auto J = con_check.jacobian_uo( un, z );
93 validator.derivative_check( value_uo, J, update_uo, *c, *vu, uo,
"norm(J_uo*vec)" );
96 if( std::find(methods.begin(),methods.end(),
"applyJacobian_un") != methods.end() ) {
97 auto J = con_check.jacobian_un( uo, z );
98 validator.derivative_check( value_un, J, update_un, *c, *vu, un,
"norm(J_un*vec)" );
101 if( std::find(methods.begin(),methods.end(),
"applyJacobian_z") != methods.end() ) {
102 auto J = con_check.jacobian_z( uo, un );
103 validator.derivative_check( value_z, J, update_z, *c, *vz, z,
"norm(J_z*vec)" );
109 if( std::find(methods.begin(),methods.end(),
"applyAdjointJacobian_uo") != methods.end() ) {
110 auto J = con_check.jacobian_uo( un, z );
111 auto aJ = con_check.adjointJacobian_uo( un, z );
112 validator.adjoint_consistency_check( J, aJ, update_uo, *c, *vu, uo,
113 "Jacobian with respect to uo",
"J_uo");
116 if( std::find(methods.begin(),methods.end(),
"applyAdjointJacobian_un") != methods.end() ) {
117 auto J = con_check.jacobian_un( uo, z );
118 auto aJ = con_check.adjointJacobian_un( uo, z );
119 validator.adjoint_consistency_check( J, aJ, update_un, *c, *vu, un,
120 "Jacobian with respect to un",
"J_un");
123 if( std::find(methods.begin(),methods.end(),
"applyAdjointJacobian_z") != methods.end() ) {
124 auto J = con_check.jacobian_z( uo, un );
125 auto aJ = con_check.adjointJacobian_z( uo, un );
126 validator.adjoint_consistency_check( J, aJ, update_z, *vz, *c, z,
127 "Jacobian with respect to z",
"J_z");
133 if( std::find(methods.begin(),methods.end(),
"solve") != methods.end() ) {
134 auto S = con_check.solve_un( uo, z );
135 validator.solve_check( S, value_un, update_un, *c, un,
"Dynamic Constraint");
139 if( std::find(methods.begin(),methods.end(),
"applyInverseJacobian_un") != methods.end() ) {
140 auto J = con_check.jacobian_un( uo, z );
141 auto iJ = con_check.inverseJacobian_un( uo, z );
142 validator.inverse_check( J, iJ, update_un, *vu, un,
143 "Jacobian with respect to un",
"J_un");
147 if( std::find(methods.begin(),methods.end(),
"applyInverseAdjointJacobian_un") != methods.end() ) {
148 auto aJ = con_check.adjointJacobian_un( uo, z );
149 auto iaJ = con_check.inverseAdjointJacobian_un( uo, z );
150 validator.inverse_check( aJ, iaJ, update_un, *vu, un,
151 "adjoint Jacobian with respect to un",
"aJ_un");
157 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_uo_uo") != methods.end() ) {
158 auto aJ = con_check.adjointJacobian_uo_uo( un, z );
159 auto aJl = fix_direction( aJ, *l );
160 auto aH = con_check.adjointHessian_uo_uo( un, z, *l );
161 validator.derivative_check( aJl, aH, update_uo, *c, *vu, uo,
"H_uo_uo");
164 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_uo_un") != methods.end() ) {
165 auto aJ = con_check.adjointJacobian_un_uo( un, z );
166 auto aJl = fix_direction( aJ, *l );
167 auto aH = con_check.adjointHessian_uo_un( un, z, *l );
168 validator.derivative_check( aJl, aH, update_uo, *c, *vu, uo,
"H_uo_un");
171 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_uo_z") != methods.end() ) {
172 auto aJ = con_check.adjointJacobian_z_uo( un, z );
173 auto aJl = fix_direction( aJ, *l );
174 auto aH = con_check.adjointHessian_uo_z( un, z, *l );
175 validator.derivative_check( aJl, aH, update_uo, *vz, *vu, uo,
"H_uo_z");
180 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_un_uo") != methods.end() ) {
181 auto aJ = con_check.adjointJacobian_uo_un( uo, z );
182 auto aJl = fix_direction( aJ, *l );
183 auto aH = con_check.adjointHessian_un_uo( uo, z, *l );
184 validator.derivative_check( aJl, aH, update_un, *c, *vu, un,
"H_un_uo");
187 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_un_un") != methods.end() ) {
188 auto aJ = con_check.adjointJacobian_un_un( uo, z );
189 auto aJl = fix_direction( aJ, *l );
190 auto aH = con_check.adjointHessian_un_un( uo, z, *l );
191 validator.derivative_check( aJl, aH, update_un, *c, *vu, un,
"H_un_un");
194 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_un_z") != methods.end() ) {
195 auto aJ = con_check.adjointJacobian_z_un( uo, z );
196 auto aJl = fix_direction( aJ, *l );
197 auto aH = con_check.adjointHessian_un_z( un, z, *l );
198 validator.derivative_check( aJl, aH, update_un, *vz, *vu, un,
"H_un_z");
203 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_z_uo") != methods.end() ) {
204 auto aJ = con_check.adjointJacobian_uo_z( uo, un );
205 auto aJl = fix_direction( aJ, *l );
206 auto aH = con_check.adjointHessian_z_uo( uo, un, *l );
207 validator.derivative_check( aJl, aH, update_z, *c, *vz, z,
"H_z_uo");
210 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_z_un") != methods.end() ) {
211 auto aJ = con_check.adjointJacobian_un_z( uo, un );
212 auto aJl = fix_direction( aJ, *l );
213 auto aH = con_check.adjointHessian_z_un( uo, un, *l );
214 validator.derivative_check( aJl, aH, update_z, *c, *vz, z,
"H_z_un");
217 if( std::find(methods.begin(),methods.end(),
"applyAdjointHessian_z_z") != methods.end() ) {
218 auto aJ = con_check.adjointJacobian_z_z( uo, un );
219 auto aJl = fix_direction( aJ, *l );
220 auto aH = con_check.adjointHessian_z_z( uo, un, *l );
221 validator.derivative_check( aJl, aH, update_z, *vz, *vz, z,
"H_z_z");
227 ValidateFunction<Real>& validator,
231 std::vector<std::string> methods = {
"applyJacobian_uo",
234 "applyAdjointJacobian_uo",
235 "applyAdjointJacobian_un",
236 "applyAdjointJacobian_z",
238 "applyInverseJacobian_un",
239 "applyInverseAdjointJacobian_un",
240 "applyAdjointHessian_uo_uo",
241 "applyAdjointHessian_uo_un",
242 "applyAdjointHessian_uo_z",
243 "applyAdjointHessian_un_uo",
244 "applyAdjointHessian_un_un",
245 "applyAdjointHessian_un_z",
246 "applyAdjointHessian_z_uo",
247 "applyAdjointHessian_z_un",
248 "applyAdjointHessian_z_z"};
249 check(con, validator, uo, un, z, methods);
257 #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.
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)
DynamicConstraint_CheckInterface< Real > make_check(DynamicConstraint< Real > &con)