11 #ifndef ROL_CONSTRAINT_SERIALSIMOPT_HPP
12 #define ROL_CONSTRAINT_SERIALSIMOPT_HPP
43 template<
typename Real>
65 const V&
partition(
const V& x )
const {
return static_cast<const PV&
>(x); }
86 virtual void value(
V& c,
const V& u,
const V& z, Real& tol )
override {
93 con_->value( *(cp.get(0)), *
ui_, *(zp.get(0)), tol );
96 con_->value( *(cp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)), tol );
100 virtual void solve(
V& c,
V& u,
const V& z, Real& tol )
override {
107 con_->solve( *(cp.get(0)), *
ui_, *(zp.get(0)), tol );
109 for(
size_type k=1, k<cp.numVectors(), ++k ) {
110 con_->solve( *(cp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)), tol );
121 con_->applyJacobian_1_new( *(jvp.get(0)), *(vp.get(0)), *
u0_, *(up.get(0)), *(zp.get(0)), tol );
123 for(
size_type k=1; k<jvp.numVectors(); ++jvp ) {
124 con_->applyJacobian_1_new( *(jvp.get(k)), *(vp.get(k)), *(up.get(k)), *(up.get(k-1)), *(zp.get(k)), tol );
125 con_->applyJacobian_1_old( *tmp, *(vp.get(k)), *(up.get(k)), *(up.get(k-1)), *(zp.get(k)), tol );
135 for(
size_type k=0; k<jvp.numVectors(); ++k ) {
136 con_->applyJacobian_2( *(jvp.get(k)), *(vp.get(k)), *(up.get(k)), *(up.get(k-1)), *(zp.get(k)), tol );
142 const V& z, Real& tol )
override {
148 con_->applyInverseJacobian_1_new( *(ijvp.get(0)), *(vp.get(0), *
u0_, *(up.get(0)), *(zp.get(0)), tol );
150 auto tmp = workspace.clone( vp.get(0) );
154 con_->applyJacobian_1_old( *tmp, *(ijvp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)), tol );
156 tmp->plus( *(vp.get(k) );
158 con_->applyInverseJacobian_1_new( *(ijvp.get(k)), *tmp, *(up.get(k-1)), *(up.get(k)), *(zp.get(k)), tol );
165 const V& z, Real& tol)
override {
170 auto tmp = workspace.clone( ajvp.get(0) );
175 con_->applyAdjointJacobian_1_new( *(ajvp.get(0)), *(vp.get(0)), *
u0_, *(up.get(0)), *(zp.get(0)) );
176 con_->applyAdjointJacobian_1_old( *(ajvp.get(0)), *(vp.get(1)), *
u0_, *(up.get(0)), *(zp.get(0)) );
179 con_->applyAdjointJacobian_1_new( *(ajvp.get(k)), *(vp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)) );
180 con_->applyAdjointJacobian_1_old( *tmp, *(vp.get(k+1)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)) );
185 con_->applyAdjointJacobian_1_new( *(ajvp.get(k)), *(vp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)) );
192 const V& dualv, Real& tol)
override {
196 auto tmp = workspace.clone( ajvp.get(0) );
201 con_->applyAdjointJacobian_1_new( *(ajvp.get(0)), *(vp.get(0)), *
u0_, *(up.get(0)), *(zp.get(0)) );
202 con_->applyAdjointJacobian_1_old( *(ajvp.get(0)), *(vp.get(1)), *
u0_, *(up.get(0)), *(zp.get(0)) );
205 con_->applyAdjointJacobian_1_new( *(ajvp.get(k)), *(vp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)) );
206 con_->applyAdjointJacobian_1_old( *tmp, *(vp.get(k+1)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)) );
211 con_->applyAdjointJacobian_1_new( *(ajvp.get(k)), *(vp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)) );
218 const V& z, Real& tol)
override {
222 for(
size_type k=0; k<jvp.numVectors(); ++k ) {
223 con_->applyAdjointJacobian_2_time( *(jvp.get(k)), *(vp.get(k)), *(up.get(k)), *(up.get(k-1)), *(zp.get(k)), tol );
229 const V& dualv, Real& tol)
override {
234 for(
size_type k=0; k<jvp.numVectors(); ++k ) {
235 con_->applyAdjointJacobian_2_time( *(jvp.get(k)), *(vp.get(k)), *(up.get(k)), *(up.get(k-1)), *(zp.get(k)), tol );
241 const V& z, Real& tol)
override {
249 con_->applyInverseAdjointJacobian_1_new( *(iajvp.get(N)), *(vp.get(N)), *(up.get(N-1)), *(up.get(N)), *(zp.get(N)), tol );
254 con_->applyAdjointJacobian_1_old( *tmp, *(iajvp.get(k+1)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)), tol );
257 tmp->plus( *(vp.get(k) );
259 con_->applyAdjointJacobian_1_new( *(iajvp.get(k)), *tmp, *(up.get(k-1)), *(up.get(k)), *(zp.get(k)), tol );
263 con_->applyAdjointJacobian_1_old( *tmp, *(iajvp.get(1)), *
u0_, *(up.get(0)), *(zp.get(0)), tol );
266 tmp->plus( *(vp.get(0) );
268 con_->applyAdjointJacobian_1_new( *(iajvp.get(0)), *tmp, *
u0_, *(up.get(0)), *(zp.get(0)), tol );
273 const V& u,
const V& z, Real& tol)
override {
279 const V& u,
const V& z, Real& tol)
override {
284 const V& u,
const V& z, Real& tol)
override {
289 const V& u,
const V& z, Real& tol)
override {
309 #endif // ROL_CONSTRAINT_SERIALSIMOPT_HPP
typename PV< Real >::size_type size_type
PV & partition(V &x) const
virtual void applyJacobian_2(V &jv, const V &v, const V &u, const V &z, Real &tol) override
Apply the partial constraint Jacobian at , , to the vector .
Defines the linear algebra of vector space on a generic partitioned vector.
virtual void applyJacobian_1(V &jv, const V &v, const V &u, const V &z, Real &tol) override
Apply the partial constraint Jacobian at , , to the vector .
virtual void applyAdjointHessian_11(V &ahwv, const V &w, const V &v, const V &u, const V &z, Real &tol) override
Apply the simulation-space derivative of the adjoint of the constraint simulation-space Jacobian at ...
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
Defines the time dependent constraint operator interface for simulation-based optimization.
VectorWorkspace< Real > workspace_
virtual void applyAdjointJacobian_1(V &ajv, const V &v, const V &u, const V &z, Real &tol) override
Apply the adjoint of the partial constraint Jacobian at , , to the vector . This is the primary inter...
virtual void applyAdjointJacobian_2(V &ajv, const V &v, const V &u, const V &z, Real &tol) override
Apply the adjoint of the partial constraint Jacobian at , , to vector . This is the primary interface...
Unifies the constraint defined on a single time step that are defined through the Constraint_TimeSimO...
const V & partition(const V &x) const
virtual void applyAdjointJacobian_2(V &ajv, const V &v, const V &u, const V &z, const V &dualv, Real &tol) override
Apply the adjoint of the partial constraint Jacobian at , , to vector . This is the secondary interfa...
typename PV< Real >::size_type size_type
std::vector< PV >::size_type size_type
virtual void applyInverseAdjointJacobian_1(V &iajv, const V &v, const V &u, const V &z, Real &tol) override
Apply the inverse of the adjoint of the partial constraint Jacobian at , , to the vector ...
virtual void applyInverseJacobian_1(V &ijv, const V &v, const V &u, const V &z, Real &tol) override
Apply the inverse partial constraint Jacobian at , , to the vector .
virtual void solve(V &c, V &u, const V &z, Real &tol) override
Given , solve for .
Constraint_SerialSimOpt(const Ptr< Con > &con, const V &ui, const V &zi)
virtual void value(V &c, const V &u, const V &z, Real &tol) override
Evaluate the constraint operator at .