45 #ifndef ROL_DYNAMICOBJECTIVECHECK_HPP
46 #define ROL_DYNAMICOBJECTIVECHECK_HPP
49 #include "ROL_ValidateFunction.hpp"
57 template<
typename Real>
61 ValidateFunction<Real>& validator,
65 const std::vector<std::string>& methods ) {
67 auto gu = uo.
dual().clone();
68 auto gz = z.
dual().clone();
79 if( std::find(methods.begin(),methods.end(),
"gradient_uo") != methods.end() ) {
80 auto value = obj_check.value_uo( un, z );
81 auto grad = obj_check.gradient_uo( un, z );
82 auto update = obj_check.update_uo( un, z );
83 validator.derivative_check(
value, grad,
update, *gu, *vu, uo,
"grad_uo'*dir" );
85 if( std::find(methods.begin(),methods.end(),
"gradient_un") != methods.end() ) {
86 auto value = obj_check.value_un( uo, z );
87 auto grad = obj_check.gradient_un( uo, z );
88 auto update = obj_check.update_un( uo, z );
89 validator.derivative_check(
value, grad,
update, *gu, *vu, un,
"grad_un'*dir" );
91 if( std::find(methods.begin(),methods.end(),
"gradient_z") != methods.end() ) {
92 auto value = obj_check.value_z( uo, un );
93 auto grad = obj_check.gradient_z( uo, un );
94 auto update = obj_check.update_z( uo, un );
95 validator.derivative_check(
value, grad,
update, *gz, *vz, z,
"grad_z'*dir" );
100 if( std::find(methods.begin(),methods.end(),
"hessVec_uo_uo") != methods.end() ) {
101 auto grad = obj_check.gradient_uo_uo( un, z );
102 auto hessVec = obj_check.hessVec_uo_uo( un, z );
103 auto update = obj_check.update_uo( un, z );
104 validator.derivative_check( grad, hessVec,
update, *gu, *vu, uo,
"norm(H_uo_uo*vec)" );
107 if( std::find(methods.begin(),methods.end(),
"hessVec_uo_un") != methods.end() ) {
108 auto grad = obj_check.gradient_uo_un( uo, z );
109 auto hessVec = obj_check.hessVec_uo_un( uo, z );
110 auto update = obj_check.update_un( uo, z );
111 validator.derivative_check( grad, hessVec,
update, *gu, *vu, un,
"norm(H_uo_un*vec)" );
114 if( std::find(methods.begin(),methods.end(),
"hessVec_uo_z") != methods.end() ) {
115 auto grad = obj_check.gradient_uo_z( uo, un );
116 auto hessVec = obj_check.hessVec_uo_z( uo, un );
117 auto update = obj_check.update_z( uo, un );
118 validator.derivative_check( grad, hessVec,
update, *gu, *vz, z,
"norm(H_uo_z*vec)" );
123 if( std::find(methods.begin(),methods.end(),
"hessVec_un_uo") != methods.end() ) {
124 auto grad = obj_check.gradient_un_uo( un, z );
125 auto hessVec = obj_check.hessVec_un_uo( un, z );
126 auto update = obj_check.update_uo( un, z );
127 validator.derivative_check( grad, hessVec,
update, *gu, *vu, uo,
"norm(H_un_uo*vec)" );
130 if( std::find(methods.begin(),methods.end(),
"hessVec_un_un") != methods.end() ) {
131 auto grad = obj_check.gradient_un_un( uo, z );
132 auto hessVec = obj_check.hessVec_un_un( uo, z );
133 auto update = obj_check.update_un( uo, z );
134 validator.derivative_check( grad, hessVec,
update, *gu, *vu, un,
"norm(H_un_un*vec)" );
137 if( std::find(methods.begin(),methods.end(),
"hessVec_un_z") != methods.end() ) {
138 auto grad = obj_check.gradient_un_z( uo, un );
139 auto hessVec = obj_check.hessVec_un_z( uo, un );
140 auto update = obj_check.update_z( uo, un );
141 validator.derivative_check( grad, hessVec,
update, *gu, *vz, z,
"norm(H_un_z*vec)" );
146 if( std::find(methods.begin(),methods.end(),
"hessVec_z_uo") != methods.end() ) {
147 auto grad = obj_check.gradient_z_uo( un, z );
148 auto hessVec = obj_check.hessVec_z_uo( un, z );
149 auto update = obj_check.update_uo( un, z );
150 validator.derivative_check( grad, hessVec,
update, *gz, *vu, uo,
"norm(H_z_uo*vec)" );
153 if( std::find(methods.begin(),methods.end(),
"hessVec_z_un") != methods.end() ) {
154 auto grad = obj_check.gradient_z_un( uo, z );
155 auto hessVec = obj_check.hessVec_z_un( uo, z );
156 auto update = obj_check.update_un( uo, z );
157 validator.derivative_check( grad, hessVec,
update, *gz, *vu, un,
"norm(H_z_un*vec)" );
160 if( std::find(methods.begin(),methods.end(),
"hessVec_z_z") != methods.end() ) {
161 auto grad = obj_check.gradient_z_z( uo, un );
162 auto hessVec = obj_check.hessVec_z_z( uo, un );
163 auto update = obj_check.update_z( uo, un );
164 auto H = obj_check.hessVec_z_z(uo,un);
165 validator.derivative_check( grad, hessVec,
update, *gz, *vz, z,
"norm(H_z_z*vec)" );
170 ValidateFunction<Real>& validator,
174 std::vector<std::string> methods = {
"gradient_uo",
186 check(obj, validator, uo, un, z, methods);
192 #endif // ROL_DYNAMICOBJECTIVECHECK_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.
static void check(DynamicObjective< Real > &obj, ValidateFunction< Real > &validator, const Vector< Real > &uo, const Vector< Real > &un, const Vector< Real > &z, const std::vector< std::string > &methods)
virtual void update(const Vector< Real > &u, const Vector< Real > &z, bool flag=true, int iter=-1) override
static void check(DynamicObjective< Real > &obj, ValidateFunction< Real > &validator, const Vector< Real > &uo, const Vector< Real > &un, const Vector< Real > &z)
ROL::Objective_SimOpt value
Defines the linear algebra or vector space interface.
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.
DynamicConstraint_CheckInterface< Real > make_check(DynamicConstraint< Real > &con)