11 #ifndef ROL_SERIALCONSTRAINT_HPP
12 #define ROL_SERIALCONSTRAINT_HPP
14 #include <type_traits>
29 template<
typename Real>
38 Ptr<DynamicConstraint<Real>>
con_;
57 Real& tol )
override {
67 con_->solve( cp[k], up[k-1], up[k], zp[k],
ts(k) );
79 con_->update( up[k-1], up[k], zp[k],
ts(k) );
87 Real& tol )
override {
97 con_->value( cp[k], up[k-1], up[k], zp[k],
ts(k) );
106 Real& tol )
override {
111 auto tmp =
clone(jvp[0]);
119 con_->applyJacobian_uo( x, vp[k-1], up[k-1], up[k], zp[k],
ts(k) );
120 con_->applyJacobian_un( jvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
132 Real& tol)
override {
137 auto tmp =
clone(ijvp[0]);
142 up[0], zp[0],
ts(0) );
146 con_->applyJacobian_uo( x, ijvp[k-1], up[k-1], up[k], zp[k],
ts(k) );
149 con_->applyInverseJacobian_un( ijvp[k], x, up[k-1], up[k], zp[k],
ts(k) );
162 Real& tol)
override {
167 auto tmp =
clone(ajvp[0]);
175 con_->applyAdjointJacobian_un( ajvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
176 con_->applyAdjointJacobian_uo( x, vp[k], up[k-1], up[k], zp[k],
ts(k) );
187 Real& tol)
override {
192 auto tmp =
clone(iajvp[0]);
197 con_->applyInverseAdjointJacobian_un( iajvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
201 con_->applyAdjointJacobian_uo( x, iajvp[k+1], up[k], up[k+1], zp[k+1],
ts(k+1) );
204 con_->applyInverseAdjointJacobian_un( iajvp[k], x, up[k-1], up[k], zp[k],
ts(k) );
208 con_->applyAdjointJacobian_uo( x, iajvp[1], up[0], up[1], zp[1],
ts(1) );
213 con_->applyInverseAdjointJacobian_un( iajvp[0], x,
getZeroState(), up[0], zp[0],
ts(0) );
216 else iajvp[0].set(x);
225 Real &tol )
override {
234 con_->applyJacobian_z( jvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
244 Real& tol )
override {
253 con_->applyAdjointJacobian_z( ajvp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
264 Real& tol)
override {
270 auto tmp =
clone(ahwvp[0]);
275 con_->applyAdjointHessian_un_un( ahwvp[0], wp[0], vp[0],
getZeroState(), up[0], zp[0],
ts(0) );
276 con_->applyAdjointHessian_un_uo( x, wp[1], vp[1], up[0], up[1], zp[1],
ts(1) );
278 con_->applyAdjointHessian_uo_uo( x, wp[1], vp[0], up[0], up[1], zp[1],
ts(1) );
285 con_->applyAdjointHessian_un_un( ahwvp[k], wp[k], vp[k], up[k-1], up[k], zp[k],
ts(k) );
286 con_->applyAdjointHessian_uo_un( x, wp[k], vp[k-1], up[k-1], up[k], zp[k],
ts(k) );
290 con_->applyAdjointHessian_un_uo( x, wp[k+1], vp[k+1], up[k], up[k+1], zp[k+1],
ts(k+1) );
292 con_->applyAdjointHessian_uo_uo( x, wp[k+1], vp[k], up[k], up[k+1], zp[k+1],
ts(k+1) );
306 Real& tol)
override {
315 Real& tol)
override {
323 Real& tol)
override {
329 up[0], zp[0],
ts(0) );
332 con_->applyAdjointHessian_z_z( ahwvp[k], wp[k], vp[k], up[k-1],
333 up[k], zp[k],
ts(k) );
343 template<
typename DynCon,
typename Real,
typename P = Ptr<SerialConstra
int<Real>>>
344 inline typename std::enable_if<std::is_base_of<DynamicConstraint<Real>,DynCon>
::value,P>::type
348 return makePtr<SerialConstraint<Real>>(con,u_initial,timeStampsPtr);
359 #endif // ROL_SERIALCONSTRAINT_HPP
PartitionedVector< Real > & partition(Vector< Real > &x)
const Vector< Real > & getInitialCondition() const
typename PV< Real >::size_type size_type
virtual void applyAdjointHessian_12(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the optimization-space derivative of the adjoint of the constraint simulation-space Jacobian at...
const Vector< Real > & getZeroState() const
Defines the time-dependent constraint operator interface for simulation-based optimization.
Defines the linear algebra of vector space on a generic partitioned vector.
virtual void applyAdjointHessian_21(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the simulation-space derivative of the adjoint of the constraint optimization-space Jacobian at...
virtual void update(const Vector< Real > &u, const Vector< Real > &z, bool flag=true, int iter=-1) override
Update constraint functions. x is the optimization variable, flag = true if optimization variable is ...
virtual void applyAdjointHessian_22(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the optimization-space derivative of the adjoint of the constraint optimization-space Jacobian ...
ROL::Objective_SimOpt value
size_type numTimeSteps() const
virtual void value(Vector< Real > &c, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Evaluate the constraint operator at .
Defines the linear algebra or vector space interface.
virtual void applyAdjointJacobian_1(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, const Vector< Real > &dualv, Real &tol) override
Apply the adjoint of the partial constraint Jacobian at , , to the vector . This is the secondary int...
virtual void applyJacobian_1(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the partial constraint Jacobian at , , to the vector .
virtual void applyJacobian_2(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the partial constraint Jacobian at , , to the vector .
std::enable_if< std::is_base_of< DynamicConstraint< Real >, DynCon >::value, P >::type make_SerialConstraint(const Ptr< DynCon > &con, const Vector< Real > &u_initial, const TimeStampsPtr< Real > timeStampsPtr)
Ptr< Vector< Real > > clone(const Vector< Real > &x)
typename std::vector< Real >::size_type size_type
virtual void applyAdjointJacobian_2(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the adjoint of the partial constraint Jacobian at , , to vector . This is the primary interface...
SerialConstraint(const Ptr< DynamicConstraint< Real >> &con, const Vector< Real > &u_initial, const TimeStampsPtr< Real > &timeStampsPtr)
void applyInverseAdjointJacobian_1(Vector< Real > &iajv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the inverse of the adjoint of the partial constraint Jacobian at , , to the vector ...
bool getSkipInitialCondition() const
Provides behavior common to SerialObjective as SerialConstaint.
virtual void applyAdjointHessian_11(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the simulation-space derivative of the adjoint of the constraint simulation-space Jacobian at ...
Ptr< DynamicConstraint< Real > > con_
Ptr< std::vector< TimeStamp< Real >>> TimeStampsPtr
virtual void solve(Vector< Real > &c, Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Given , solve for .
Evaluates ROL::DynamicConstraint over a sequential set of time intervals.
Defines the constraint operator interface for simulation-based optimization.
const TimeStamp< Real > & ts(size_type i) const
virtual void applyInverseJacobian_1(Vector< Real > &ijv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Apply the inverse partial constraint Jacobian at , , to the vector .