46 #ifndef ROL_CONSTRAINT_SERIALSIMOPT_HPP
47 #define ROL_CONSTRAINT_SERIALSIMOPT_HPP
78 template<
typename Real>
100 const V&
partition(
const V& x )
const {
return static_cast<const PV&
>(x); }
121 virtual void value(
V& c,
const V& u,
const V& z, Real& tol )
override {
128 con_->value( *(cp.get(0)), *
ui_, *(zp.get(0)), tol );
131 con_->value( *(cp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)), tol );
135 virtual void solve(
V& c,
V& u,
const V& z, Real& tol )
override {
142 con_->solve( *(cp.get(0)), *
ui_, *(zp.get(0)), tol );
144 for(
size_type k=1, k<cp.numVectors(), ++k ) {
145 con_->solve( *(cp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)), tol );
156 con_->applyJacobian_1_new( *(jvp.get(0)), *(vp.get(0)), *
u0_, *(up.get(0)), *(zp.get(0)), tol );
159 con_->applyJacobian_1_new( *(jvp.get(k)), *(vp.get(k)), *(up.get(k)), *(up.get(k-1)), *(zp.get(k)), tol );
160 con_->applyJacobian_1_old( *tmp, *(vp.get(k)), *(up.get(k)), *(up.get(k-1)), *(zp.get(k)), tol );
171 con_->applyJacobian_2( *(jvp.get(k)), *(vp.get(k)), *(up.get(k)), *(up.get(k-1)), *(zp.get(k)), tol );
177 const V& z, Real& tol )
override {
183 con_->applyInverseJacobian_1_new( *(ijvp.get(0)), *(vp.get(0), *
u0_, *(up.get(0)), *(zp.get(0)), tol );
185 auto tmp = workspace.clone( vp.get(0) );
187 for(
size_type k=1; k<ijvp.numVectors(); ++k ) {
189 con_->applyJacobian_1_old( *tmp, *(ijvp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)), tol );
191 tmp->plus( *(vp.get(k) );
193 con_->applyInverseJacobian_1_new( *(ijvp.get(k)), *tmp, *(up.get(k-1)), *(up.get(k)), *(zp.get(k)), tol );
200 const V& z, Real& tol)
override {
205 auto tmp = workspace.clone( ajvp.get(0) );
210 con_->applyAdjointJacobian_1_new( *(ajvp.get(0)), *(vp.get(0)), *
u0_, *(up.get(0)), *(zp.get(0)) );
211 con_->applyAdjointJacobian_1_old( *(ajvp.get(0)), *(vp.get(1)), *
u0_, *(up.get(0)), *(zp.get(0)) );
214 con_->applyAdjointJacobian_1_new( *(ajvp.get(k)), *(vp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)) );
215 con_->applyAdjointJacobian_1_old( *tmp, *(vp.get(k+1)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)) );
220 con_->applyAdjointJacobian_1_new( *(ajvp.get(k)), *(vp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)) );
227 const V& dualv, Real& tol)
override {
231 auto tmp = workspace.clone( ajvp.get(0) );
236 con_->applyAdjointJacobian_1_new( *(ajvp.get(0)), *(vp.get(0)), *
u0_, *(up.get(0)), *(zp.get(0)) );
237 con_->applyAdjointJacobian_1_old( *(ajvp.get(0)), *(vp.get(1)), *
u0_, *(up.get(0)), *(zp.get(0)) );
240 con_->applyAdjointJacobian_1_new( *(ajvp.get(k)), *(vp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)) );
241 con_->applyAdjointJacobian_1_old( *tmp, *(vp.get(k+1)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)) );
246 con_->applyAdjointJacobian_1_new( *(ajvp.get(k)), *(vp.get(k)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)) );
253 const V& z, Real& tol)
override {
257 for(
size_type k=0; k<jvp.numVectors(); ++k ) {
258 con_->applyAdjointJacobian_2_time( *(jvp.get(k)), *(vp.get(k)), *(up.get(k)), *(up.get(k-1)), *(zp.get(k)), tol );
264 const V& dualv, Real& tol)
override {
269 for(
size_type k=0; k<jvp.numVectors(); ++k ) {
270 con_->applyAdjointJacobian_2_time( *(jvp.get(k)), *(vp.get(k)), *(up.get(k)), *(up.get(k-1)), *(zp.get(k)), tol );
276 const V& z, Real& tol)
override {
284 con_->applyInverseAdjointJacobian_1_new( *(iajvp.get(N)), *(vp.get(N)), *(up.get(N-1)), *(up.get(N)), *(zp.get(N)), tol );
289 con_->applyAdjointJacobian_1_old( *tmp, *(iajvp.get(k+1)), *(up.get(k-1)), *(up.get(k)), *(zp.get(k)), tol );
292 tmp->plus( *(vp.get(k) );
294 con_->applyAdjointJacobian_1_new( *(iajvp.get(k)), *tmp, *(up.get(k-1)), *(up.get(k)), *(zp.get(k)), tol );
298 con_->applyAdjointJacobian_1_old( *tmp, *(iajvp.get(1)), *
u0_, *(up.get(0)), *(zp.get(0)), tol );
301 tmp->plus( *(vp.get(0) );
303 con_->applyAdjointJacobian_1_new( *(iajvp.get(0)), *tmp, *
u0_, *(up.get(0)), *(zp.get(0)), tol );
308 const V& u,
const V& z, Real& tol)
override {
314 const V& u,
const V& z, Real& tol)
override {
319 const V& u,
const V& z, Real& tol)
override {
324 const V& u,
const V& z, Real& tol)
override {
344 #endif // ROL_CONSTRAINT_SERIALSIMOPT_HPP
PartitionedVector< Real > PV
typename PV< Real >::size_type size_type
PV & partition(V &x) const
virtual void applyAdjointJacobian_1(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 the vector . This is the secondary int...
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 .