11 #ifndef ROL_SERIALOBJECTIVE_HPP
12 #define ROL_SERIALOBJECTIVE_HPP
14 #include <type_traits>
36 template<
typename Real>
44 Ptr<DynamicObjective<Real>>
obj_;
63 Real& tol )
override {
73 result +=
obj_->value( up[k-1], up[k], zp[k],
ts(k) );
81 Real& tol )
override {
87 auto tmp =
clone(gp[0]);
93 obj_->gradient_uo( x, up[0], up[1], zp[1],
ts(1) );
97 obj_->gradient_un( gp[k], up[k-1], up[k], zp[k],
ts(k) );
98 obj_->gradient_uo( x, up[k], up[k+1], zp[k+1],
ts(k+1) );
104 obj_->gradient_un( gp[N], up[N-1], up[N], zp[N],
ts(N) );
111 Real& tol )
override {
121 obj_->gradient_z( gp[k], up[k-1], up[k], zp[k],
ts(k) );
129 Real& tol )
override {
134 auto tmp =
clone(hvp[0]);
140 obj_->hessVec_uo_uo( x, vp[0], up[0], up[1], zp[1],
ts(1) );
144 obj_->hessVec_un_un( hvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
145 obj_->hessVec_uo_uo( x, vp[k], up[k], up[k+1], zp[k+1],
ts(k+1) );
151 obj_->hessVec_un_un( hvp[N], vp[N], up[N-1], up[N], zp[N],
ts(N) );
159 Real& tol )
override {
164 auto tmp =
clone(hvp[0]);
170 obj_->hessVec_uo_z( x, vp[0], up[0], up[1], zp[1],
ts(1) );
174 obj_->hessVec_un_z( hvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
175 obj_->hessVec_uo_z( x, vp[k], up[k], up[k+1], zp[k+1],
ts(k+1) );
181 obj_->hessVec_un_z( hvp[N], vp[N], up[N-1], up[N], zp[N],
ts(N) );
190 Real& tol )
override {
195 auto tmp =
clone(hvp[0]);
203 obj_->hessVec_z_un( hvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
204 obj_->hessVec_z_uo( x, vp[k-1], up[k-1], up[k], zp[k],
ts(k) );
214 Real& tol )
override {
223 obj_->hessVec_z_z( hvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
233 template<
typename DynObj,
typename Real,
typename P = Ptr<SerialObjective<Real>> >
234 inline typename std::enable_if<std::is_base_of<DynamicObjective<Real>,DynObj>
::value,P>::type
238 return makePtr<SerialObjective<Real>>(obj,u_initial,timeStampsPtr);
244 #endif // ROL_SERIALOBJECTIVE_HPP
PartitionedVector< Real > & partition(Vector< Real > &x)
const Vector< Real > & getInitialCondition() const
Provides the interface to evaluate simulation-based objective functions.
typename PV< Real >::size_type size_type
virtual void gradient_2(Vector< Real > &g, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Compute gradient with respect to second component.
virtual void hessVec_11(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply Hessian approximation to vector.
Defines the linear algebra of vector space on a generic partitioned vector.
ROL::Objective_SimOpt value
size_type numTimeSteps() const
virtual Real value(const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Compute 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.
virtual void hessVec_22(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
SerialObjective(const Ptr< DynamicObjective< Real >> &obj, const Vector< Real > &u_initial, const TimeStampsPtr< Real > timeStampsPtr)
typename std::vector< Real >::size_type size_type
Ptr< Vector< Real > > clone(const Vector< Real > &x)
Ptr< DynamicObjective< Real > > obj_
Evaluates ROL::DynamicObjective over a sequential set of time intervals.
std::enable_if< std::is_base_of< DynamicObjective< Real >, DynObj >::value, P >::type make_SerialObjective(const Ptr< DynObj > &obj, const Vector< Real > &u_initial, const TimeStampsPtr< Real > timeStampsPtr)
bool getSkipInitialCondition() const
Provides behavior common to SerialObjective as SerialConstaint.
Ptr< std::vector< TimeStamp< Real >>> TimeStampsPtr
virtual void hessVec_12(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
const TimeStamp< Real > & ts(size_type i) const
virtual void gradient_1(Vector< Real > &g, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Compute gradient with respect to first component.
virtual void hessVec_21(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override