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 ) {
68 check( obj_check, validator, uo, un, z, methods );
72 ValidateFunction<Real>& validator,
77 const std::vector<std::string>& methods ) {
80 check( obj_check, validator, uo, un, z, methods );
83 static void check( DynamicObjective_CheckInterface<Real>& obj_check,
84 ValidateFunction<Real>& validator,
88 const std::vector<std::string>& methods ) {
90 auto gu = uo.
dual().clone();
91 auto gz = z.
dual().clone();
101 if( std::find(methods.begin(),methods.end(),
"gradient_uo") != methods.end() ) {
102 auto value = obj_check.value_uo( un, z );
103 auto grad = obj_check.gradient_uo( un, z );
104 auto update = obj_check.update_uo( un, z );
105 validator.derivative_check(
value, grad,
update, *gu, *vu, uo,
"grad_uo'*dir" );
107 if( std::find(methods.begin(),methods.end(),
"gradient_un") != methods.end() ) {
108 auto value = obj_check.value_un( uo, z );
109 auto grad = obj_check.gradient_un( uo, z );
110 auto update = obj_check.update_un( uo, z );
111 validator.derivative_check(
value, grad,
update, *gu, *vu, un,
"grad_un'*dir" );
113 if( std::find(methods.begin(),methods.end(),
"gradient_z") != methods.end() ) {
114 auto value = obj_check.value_z( uo, un );
115 auto grad = obj_check.gradient_z( uo, un );
116 auto update = obj_check.update_z( uo, un );
117 validator.derivative_check(
value, grad,
update, *gz, *vz, z,
"grad_z'*dir" );
122 if( std::find(methods.begin(),methods.end(),
"hessVec_uo_uo") != methods.end() ) {
123 auto grad = obj_check.gradient_uo_uo( un, z );
124 auto hessVec = obj_check.hessVec_uo_uo( un, z );
125 auto update = obj_check.update_uo( un, z );
126 validator.derivative_check( grad, hessVec,
update, *gu, *vu, uo,
"norm(H_uo_uo*vec)" );
129 if( std::find(methods.begin(),methods.end(),
"hessVec_uo_un") != methods.end() ) {
130 auto grad = obj_check.gradient_uo_un( uo, z );
131 auto hessVec = obj_check.hessVec_uo_un( uo, z );
132 auto update = obj_check.update_un( uo, z );
133 validator.derivative_check( grad, hessVec,
update, *gu, *vu, un,
"norm(H_uo_un*vec)" );
136 if( std::find(methods.begin(),methods.end(),
"hessVec_uo_z") != methods.end() ) {
137 auto grad = obj_check.gradient_uo_z( uo, un );
138 auto hessVec = obj_check.hessVec_uo_z( uo, un );
139 auto update = obj_check.update_z( uo, un );
140 validator.derivative_check( grad, hessVec,
update, *gu, *vz, z,
"norm(H_uo_z*vec)" );
145 if( std::find(methods.begin(),methods.end(),
"hessVec_un_uo") != methods.end() ) {
146 auto grad = obj_check.gradient_un_uo( un, z );
147 auto hessVec = obj_check.hessVec_un_uo( un, z );
148 auto update = obj_check.update_uo( un, z );
149 validator.derivative_check( grad, hessVec,
update, *gu, *vu, uo,
"norm(H_un_uo*vec)" );
152 if( std::find(methods.begin(),methods.end(),
"hessVec_un_un") != methods.end() ) {
153 auto grad = obj_check.gradient_un_un( uo, z );
154 auto hessVec = obj_check.hessVec_un_un( uo, z );
155 auto update = obj_check.update_un( uo, z );
156 validator.derivative_check( grad, hessVec,
update, *gu, *vu, un,
"norm(H_un_un*vec)" );
159 if( std::find(methods.begin(),methods.end(),
"hessVec_un_z") != methods.end() ) {
160 auto grad = obj_check.gradient_un_z( uo, un );
161 auto hessVec = obj_check.hessVec_un_z( uo, un );
162 auto update = obj_check.update_z( uo, un );
163 validator.derivative_check( grad, hessVec,
update, *gu, *vz, z,
"norm(H_un_z*vec)" );
168 if( std::find(methods.begin(),methods.end(),
"hessVec_z_uo") != methods.end() ) {
169 auto grad = obj_check.gradient_z_uo( un, z );
170 auto hessVec = obj_check.hessVec_z_uo( un, z );
171 auto update = obj_check.update_uo( un, z );
172 validator.derivative_check( grad, hessVec,
update, *gz, *vu, uo,
"norm(H_z_uo*vec)" );
175 if( std::find(methods.begin(),methods.end(),
"hessVec_z_un") != methods.end() ) {
176 auto grad = obj_check.gradient_z_un( uo, z );
177 auto hessVec = obj_check.hessVec_z_un( uo, z );
178 auto update = obj_check.update_un( uo, z );
179 validator.derivative_check( grad, hessVec,
update, *gz, *vu, un,
"norm(H_z_un*vec)" );
182 if( std::find(methods.begin(),methods.end(),
"hessVec_z_z") != methods.end() ) {
183 auto grad = obj_check.gradient_z_z( uo, un );
184 auto hessVec = obj_check.hessVec_z_z( uo, un );
185 auto update = obj_check.update_z( uo, un );
186 auto H = obj_check.hessVec_z_z(uo,un);
187 validator.derivative_check( grad, hessVec,
update, *gz, *vz, z,
"norm(H_z_z*vec)" );
192 ValidateFunction<Real>& validator,
196 std::vector<std::string> methods = {
"gradient_uo",
208 check(obj, validator, uo, un, z, methods);
214 #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
static void check(DynamicObjective< Real > &obj, ValidateFunction< Real > &validator, const Vector< Real > &uo, const Vector< Real > &un, const Vector< Real > &z, TimeStamp< Real > &timeStamp, const std::vector< std::string > &methods)
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.
static void check(DynamicObjective_CheckInterface< Real > &obj_check, 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)