44#ifndef ROL_SERIALOBJECTIVE_HPP
45#define ROL_SERIALOBJECTIVE_HPP
69template<
typename Real>
77 Ptr<DynamicObjective<Real>>
obj_;
81 using size_type =
typename std::vector<Real>::size_type;
96 Real& tol )
override {
106 result +=
obj_->value( up[k-1], up[k], zp[k],
ts(k) );
114 Real& tol )
override {
120 auto tmp =
clone(gp[0]);
126 obj_->gradient_uo( x, up[0], up[1], zp[1],
ts(1) );
130 obj_->gradient_un( gp[k], up[k-1], up[k], zp[k],
ts(k) );
131 obj_->gradient_uo( x, up[k], up[k+1], zp[k+1],
ts(k+1) );
137 obj_->gradient_un( gp[N], up[N-1], up[N], zp[N],
ts(N) );
144 Real& tol )
override {
154 obj_->gradient_z( gp[k], up[k-1], up[k], zp[k],
ts(k) );
162 Real& tol )
override {
167 auto tmp =
clone(hvp[0]);
173 obj_->hessVec_uo_uo( x, vp[0], up[0], up[1], zp[1],
ts(1) );
177 obj_->hessVec_un_un( hvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
178 obj_->hessVec_uo_uo( x, vp[k], up[k], up[k+1], zp[k+1],
ts(k+1) );
184 obj_->hessVec_un_un( hvp[N], vp[N], up[N-1], up[N], zp[N],
ts(N) );
192 Real& tol )
override {
197 auto tmp =
clone(hvp[0]);
203 obj_->hessVec_uo_z( x, vp[0], up[0], up[1], zp[1],
ts(1) );
207 obj_->hessVec_un_z( hvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
208 obj_->hessVec_uo_z( x, vp[k], up[k], up[k+1], zp[k+1],
ts(k+1) );
214 obj_->hessVec_un_z( hvp[N], vp[N], up[N-1], up[N], zp[N],
ts(N) );
223 Real& tol )
override {
228 auto tmp =
clone(hvp[0]);
236 obj_->hessVec_z_un( hvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
237 obj_->hessVec_z_uo( x, vp[k-1], up[k-1], up[k], zp[k],
ts(k) );
247 Real& tol )
override {
256 obj_->hessVec_z_z( hvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
266template<
typename DynObj,
typename Real,
typename P = Ptr<SerialObjective<Real>> >
267inline typename std::enable_if<std::is_base_of<DynamicObjective<Real>,DynObj>
::value,P>::type
271 return makePtr<SerialObjective<Real>>(obj,u_initial,timeStampsPtr);
Defines the time-dependent objective function interface for simulation-based optimization....
Provides the interface to evaluate simulation-based objective functions.
Defines the linear algebra of vector space on a generic partitioned vector.
Provides behavior common to SerialObjective as SerialConstaint.
size_type numTimeSteps() const
const Vector< Real > & getInitialCondition() const
const Vector< Real > & getZeroState() const
bool getSkipInitialCondition() const
Ptr< Vector< Real > > clone(const Vector< Real > &x)
const TimeStamp< Real > & ts(size_type i) const
Evaluates ROL::DynamicObjective over a sequential set of time intervals.
Ptr< DynamicObjective< Real > > obj_
virtual void hessVec_22(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
virtual Real value(const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Compute value.
virtual void hessVec_12(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
virtual void hessVec_21(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)
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.
typename std::vector< Real >::size_type size_type
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.
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.
Defines the linear algebra or vector space interface.
ROL::Objective_SerialSimOpt Objective_SimOpt value(const V &u, const V &z, Real &tol) override
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)
Ptr< std::vector< TimeStamp< Real > > > TimeStampsPtr
PartitionedVector< Real > & partition(Vector< Real > &x)