ROL
ROL_Constraint_PinTSimOpt.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 #ifndef ROL_CONSTRAINT_PINTSIMOPT_H
45 #define ROL_CONSTRAINT_PINTSIMOPT_H
46 
47 #include <cassert>
48 
49 #include "ROL_PinTVector.hpp"
51 
99 namespace ROL {
100 
101 
112 template <class Real>
113 Ptr<PinTVector<Real>>
114 buildPinTVector(const Ptr<const PinTCommunicators> & communicators,
115  int steps,
116  const std::vector<int> & stencil,
117  const Ptr<Vector<Real>> & localVector)
118 { return makePtr<PinTVector<Real>>(communicators,localVector,steps,stencil); }
119 
120 template <class Real>
122 private:
123  Ptr<Constraint_TimeSimOpt<Real>> stepConstraint_;
124 
125  // internal state members
126 
128 
131 
138  Ptr<const Vector<Real>> getVector(const PinTVector<double> & src,
139  int step,
140  ETimeAccessor accessor)
141  {
142  return getNonconstVector(src,step,accessor);
143  }
144 
151  Ptr<Vector<Real>> getNonconstVector(const PinTVector<double> & src,
152  int step,
153  ETimeAccessor accessor)
154  {
155  const std::vector<int> stencil = src.stencil();
156 
157  std::vector<Ptr<Vector<Real>>> vecs;
158  for(std::size_t i=0;i<stencil.size();i++) {
159 
160  // make sure this aligns with the accesor
161  bool valid = false;
162  if(accessor==PAST && stencil[i]<0)
163  valid = true;
164  if(accessor==CURRENT && stencil[i]==0)
165  valid = true;
166  if(accessor==FUTURE && stencil[i]>0)
167  valid = true;
168  if(accessor==ALL)
169  valid = true;
170 
171  // stencil entry matches with the accessor
172  if(valid)
173  vecs.push_back(src.getVectorPtr(step+stencil[i]));
174  }
175 
176  TEUCHOS_ASSERT(vecs.size()>0);
177 
178  if(vecs.size()==1)
179  return vecs[0];
180 
181  return makePtr<PartitionedVector<Real>>(vecs);
182  }
183 
184  Ptr<Vector<Real>> getStateVector(const PinTVector<double> & src,int step)
185  {
186  Ptr<Vector<Real>> u_old = getNonconstVector(src,step,PAST);
187  Ptr<Vector<Real>> u_now = getNonconstVector(src,step,CURRENT);
188 
189  // this is specified by the Constraint_TimeSimOpt class
190  std::vector<Ptr<Vector<Real>>> vecs;
191  vecs.push_back(u_old);
192  vecs.push_back(u_now);
193  return makePtr<PartitionedVector<Real>>(vecs);
194  }
195 
196 public:
197 
201  , isInitialized_(false)
202  { }
203 
219  , isInitialized_(false)
220  {
221  initialize(stepConstraint);
222  }
223 
227  void initialize(const Ptr<Constraint_TimeSimOpt<Real>> & stepConstraint)
228  {
229  // initialize user member variables
230  stepConstraint_ = stepConstraint;
231 
232  isInitialized_ = true;
233  }
234 
240  virtual void update_1( const Vector<Real> &u, bool flag = true, int iter = -1 ) {}
241 
247  virtual void update_2( const Vector<Real> &z, bool flag = true, int iter = -1 ) {}
248 
249  virtual void value(Vector<Real> &c,
250  const Vector<Real> &u,
251  const Vector<Real> &z,
252  Real &tol) override {
253 
254  PinTVector<Real> & pint_c = dynamic_cast<PinTVector<Real>&>(c);
255  const PinTVector<Real> & pint_u = dynamic_cast<const PinTVector<Real>&>(u);
256  const PinTVector<Real> & pint_z = dynamic_cast<const PinTVector<Real>&>(z);
257  // its possible we won't always want to cast to a PinT vector here
258 
259  TEUCHOS_ASSERT(pint_c.numOwnedSteps()==pint_u.numOwnedSteps());
260 
261  // communicate neighbors, these are block calls
262  pint_u.boundaryExchange();
263  pint_z.boundaryExchange();
264 
265  // build in the time continuity constraint, note that this just using the identity matrix
266  const std::vector<int> & stencil = pint_c.stencil();
267  for(size_t i=0;i<stencil.size();i++) {
268  int offset = stencil[i];
269  if(offset<0) {
270  pint_c.getVectorPtr(offset)->set(*pint_u.getVectorPtr(offset)); // this is the local value
271  pint_c.getVectorPtr(offset)->axpy(-1.0,*pint_u.getRemoteBufferPtr(offset)); // this is the remote value
272  }
273  }
274 
275  // now setup the residual for the time evolution
276  for(int i=0;i<pint_c.numOwnedSteps();i++) {
277  Ptr<const Vector<Real>> u_state = getStateVector(pint_u,i);
278  Ptr<const Vector<Real>> z_all = getVector(pint_z,i,ALL);
279 
280  Ptr<Vector<Real>> c_now = getNonconstVector(pint_c,i,CURRENT);
281 
282  stepConstraint_->value(*c_now,*u_state,*z_all,tol);
283  }
284  }
285 
286  virtual void solve(Vector<Real> &c,
287  Vector<Real> &u,
288  const Vector<Real> &z,
289  Real &tol) override {
290  // solve is weird because it serializes in time. But we want to get it
291  // working so that we can test, but it won't be a performant way to do this.
292  // We could do a parallel in time solve here but thats not really the focus.
293 
294  PinTVector<Real> & pint_c = dynamic_cast<PinTVector<Real>&>(c);
295  PinTVector<Real> & pint_u = dynamic_cast<PinTVector<Real>&>(u);
296  const PinTVector<Real> & pint_z = dynamic_cast<const PinTVector<Real>&>(z);
297  // its possible we won't always want to cast to a PinT vector here
298 
299  TEUCHOS_ASSERT(pint_c.numOwnedSteps()==pint_u.numOwnedSteps());
300 
301  pint_z.boundaryExchange();
302  pint_u.boundaryExchange(PinTVector<Real>::RECV_ONLY); // this is going to block
303 
304  // satisfy the time continuity constraint, note that this just using the identity matrix
305  const std::vector<int> & stencil = pint_c.stencil();
306  for(size_t i=0;i<stencil.size();i++) {
307  int offset = stencil[i];
308  if(offset<0) {
309 
310  // update the old time information
311  pint_u.getVectorPtr(offset)->set(*pint_u.getRemoteBufferPtr(offset)); // this is the local value
312 
313  // this should be zero!
314  pint_c.getVectorPtr(offset)->set(*pint_u.getVectorPtr(offset)); // this is the local value
315  pint_c.getVectorPtr(offset)->axpy(-1.0,*pint_u.getRemoteBufferPtr(offset)); // this is the remote value
316  }
317  }
318 
319  // solve the time steps
320  for(int i=0;i<pint_c.numOwnedSteps();i++) {
321  Ptr<const Vector<Real>> z_all = getVector(pint_z,i,ALL);
322 
323  Ptr<Vector<Real>> u_old = getNonconstVector(pint_u,i,PAST);
324  Ptr<Vector<Real>> u_now = getNonconstVector(pint_u,i,CURRENT);
325  Ptr<Vector<Real>> c_now = getNonconstVector(pint_c,i,CURRENT);
326 
327  // we solve for u_now
328  stepConstraint_->solve(*c_now,*u_old,*u_now,*z_all,tol);
329  }
330 
332  }
333 
334  virtual void applyJacobian_1(Vector<Real> &jv,
335  const Vector<Real> &v,
336  const Vector<Real> &u,
337  const Vector<Real> &z,
338  Real &tol) override {
339  PinTVector<Real> & pint_jv = dynamic_cast<PinTVector<Real>&>(jv);
340  const PinTVector<Real> & pint_v = dynamic_cast<const PinTVector<Real>&>(v);
341  const PinTVector<Real> & pint_u = dynamic_cast<const PinTVector<Real>&>(u);
342  const PinTVector<Real> & pint_z = dynamic_cast<const PinTVector<Real>&>(z);
343  // its possible we won't always want to cast to a PinT vector here
344 
345  TEUCHOS_ASSERT(pint_jv.numOwnedSteps()==pint_u.numOwnedSteps());
346  TEUCHOS_ASSERT(pint_jv.numOwnedSteps()==pint_v.numOwnedSteps());
347 
348  // communicate neighbors, these are block calls
349  pint_v.boundaryExchange();
350  pint_u.boundaryExchange();
351  pint_z.boundaryExchange();
352 
353  // differentiate the time continuity constraint, note that this just using the identity matrix
354  int timeRank = pint_u.communicators().getTimeRank();
355  const std::vector<int> & stencil = pint_jv.stencil();
356  for(size_t i=0;i<stencil.size();i++) {
357  int offset = stencil[i];
358  if(offset<0) {
359  pint_jv.getVectorPtr(offset)->set(*pint_v.getVectorPtr(offset)); // this is the local value
360 
361  // this is a hack to make sure that sensitivities with respect to the initial condition
362  // don't get accidentally included
363  if(timeRank>0)
364  pint_jv.getVectorPtr(offset)->axpy(-1.0,*pint_v.getRemoteBufferPtr(offset)); // this is the remote value
365  }
366  }
367 
368  for(int i=0;i<pint_jv.numOwnedSteps();i++) {
369  // pull out all the time steps required
370  Ptr<const Vector<Real>> v_state = getStateVector(pint_v,i);
371  Ptr<const Vector<Real>> u_state = getStateVector(pint_u,i);
372  Ptr<const Vector<Real>> z_all = getVector(pint_z,i,ALL);
373 
374  Ptr<Vector<Real>> jv_now = getNonconstVector(pint_jv,i,CURRENT);
375 
376  stepConstraint_->applyJacobian_1(*jv_now,*v_state,*u_state,*z_all,tol);
377  }
378  }
379 
380  virtual void applyJacobian_2(Vector<Real> &jv,
381  const Vector<Real> &v,
382  const Vector<Real> &u,
383  const Vector<Real> &z,
384  Real &tol) override {
385  PinTVector<Real> & pint_jv = dynamic_cast<PinTVector<Real>&>(jv);
386  const PinTVector<Real> & pint_v = dynamic_cast<const PinTVector<Real>&>(v);
387  const PinTVector<Real> & pint_u = dynamic_cast<const PinTVector<Real>&>(u);
388  const PinTVector<Real> & pint_z = dynamic_cast<const PinTVector<Real>&>(z);
389  // its possible we won't always want to cast to a PinT vector here
390 
391  TEUCHOS_ASSERT(pint_jv.numOwnedSteps()==pint_u.numOwnedSteps());
392  TEUCHOS_ASSERT(pint_jv.numOwnedSteps()==pint_v.numOwnedSteps());
393 
394  // communicate neighbors, these are block calls
395  pint_v.boundaryExchange();
396  pint_u.boundaryExchange();
397  pint_z.boundaryExchange();
398 
399  const std::vector<int> & stencil = pint_jv.stencil();
400  for(size_t i=0;i<stencil.size();i++) {
401  int offset = stencil[i];
402  if(offset<0) {
403  pint_jv.getVectorPtr(offset)->zero();
404  }
405  }
406 
407  for(int i=0;i<pint_jv.numOwnedSteps();i++) {
408  // pull out all the time steps required
409  Ptr<const Vector<Real>> u_state = getStateVector(pint_u,i);
410  Ptr<const Vector<Real>> v_control = getVector(pint_v,i,ALL);
411  Ptr<const Vector<Real>> z_all = getVector(pint_z,i,ALL);
412 
413  Ptr<Vector<Real>> jv_now = getNonconstVector(pint_jv,i,CURRENT);
414 
415  stepConstraint_->applyJacobian_2(*jv_now,*v_control,*u_state,*z_all,tol);
416  }
417  }
418 
420  const Vector<Real> &v,
421  const Vector<Real> &u,
422  const Vector<Real> &z,
423  Real &tol) override final {
424  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
425  "The method applyInverseJacobian_1 is used but not implemented!\n");
426  }
427 
429  const Vector<Real> &v,
430  const Vector<Real> &u,
431  const Vector<Real> &z,
432  Real &tol) override {
433 
434  PinTVector<Real> & pint_ajv = dynamic_cast<PinTVector<Real>&>(ajv);
435  const PinTVector<Real> & pint_v = dynamic_cast<const PinTVector<Real>&>(v);
436  const PinTVector<Real> & pint_u = dynamic_cast<const PinTVector<Real>&>(u);
437  const PinTVector<Real> & pint_z = dynamic_cast<const PinTVector<Real>&>(z);
438  // its possible we won't always want to cast to a PinT vector here
439 
440  TEUCHOS_ASSERT(pint_v.numOwnedSteps()==pint_u.numOwnedSteps());
441  TEUCHOS_ASSERT(pint_ajv.numOwnedSteps()==pint_u.numOwnedSteps());
442 
443  // we need to make sure this has all zeros to begin with (this includes boundary exchange components)
444  pint_ajv.zeroAll();
445 
446  // communicate neighbors, these are block calls
447  pint_v.boundaryExchange();
448  pint_u.boundaryExchange();
449  pint_z.boundaryExchange();
450 
451  Ptr<Vector<Real>> scratch;
452  for(int i=0;i<pint_ajv.numOwnedSteps();i++) {
453  // pull out all the time steps required
454  Ptr<const Vector<Real>> v_dual = getVector(pint_v,i,CURRENT);
455  Ptr<const Vector<Real>> u_state = getStateVector(pint_u,i);
456  Ptr<const Vector<Real>> z_all = getVector(pint_z,i,ALL);
457 
458  Ptr<Vector<Real>> ajv_now = getStateVector(pint_ajv,i);
459 
460  // this will lead to problems if problem size changes in time
461  if(scratch==ROL::nullPtr) {
462  scratch = ajv_now->clone();
463  }
464 
465  stepConstraint_->applyAdjointJacobian_1(*scratch,*v_dual,*u_state,*z_all,tol);
466 
467  ajv_now->axpy(1.0,*scratch);
468  }
469 
470  // handle the constraint adjoint
471  const std::vector<int> & stencil = pint_u.stencil();
472  for(size_t i=0;i<stencil.size();i++) {
473  int offset = stencil[i];
474  if(offset<0) {
475  pint_ajv.getVectorPtr(offset)->axpy(1.0,*pint_v.getVectorPtr(offset));
476  pint_ajv.getRemoteBufferPtr(offset)->set(*pint_v.getVectorPtr(offset)); // this will be sent to the remote processor
477  pint_ajv.getRemoteBufferPtr(offset)->scale(-1.0);
478  }
479  }
480 
481  // this sums from the remote buffer into the local buffer which is part of the vector
482  pint_ajv.boundaryExchangeSumInto();
483  }
484 
486  const Vector<Real> &v,
487  const Vector<Real> &u,
488  const Vector<Real> &z,
489  Real &tol) override {
490 
491  PinTVector<Real> & pint_ajv = dynamic_cast<PinTVector<Real>&>(ajv);
492  const PinTVector<Real> & pint_v = dynamic_cast<const PinTVector<Real>&>(v);
493  const PinTVector<Real> & pint_u = dynamic_cast<const PinTVector<Real>&>(u);
494  const PinTVector<Real> & pint_z = dynamic_cast<const PinTVector<Real>&>(z);
495  // its possible we won't always want to cast to a PinT vector here
496 
497  TEUCHOS_ASSERT(pint_v.numOwnedSteps()==pint_u.numOwnedSteps());
498  TEUCHOS_ASSERT(pint_ajv.numOwnedSteps()==pint_u.numOwnedSteps());
499 
500  // we need to make sure this has all zeros to begin with (this includes boundary exchange components)
501  pint_ajv.zeroAll();
502 
503  // communicate neighbors, these are block calls
504  pint_v.boundaryExchange();
505  pint_u.boundaryExchange();
506  pint_z.boundaryExchange();
507 
508  Ptr<Vector<Real>> scratch;
509  for(int i=0;i<pint_ajv.numOwnedSteps();i++) {
510  // pull out all the time steps required
511  Ptr<const Vector<Real>> v_dual = getVector(pint_v,i,CURRENT);
512  Ptr<const Vector<Real>> u_state = getStateVector(pint_u,i);
513  Ptr<const Vector<Real>> z_all = getVector(pint_z,i,ALL);
514 
515  Ptr<Vector<Real>> ajv_now = getNonconstVector(pint_ajv,i,ALL);
516 
517  stepConstraint_->applyAdjointJacobian_2(*ajv_now,*v_dual,*u_state,*z_all,tol);
518  }
519 
520  // no constraint for controls hanlding because that doesn't work yet!
521  }
522 
524  const Vector<Real> &v,
525  const Vector<Real> &u,
526  const Vector<Real> &z,
527  Real &tol) override final {
528  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
529  "The method applyInverseAdjointJacobian_1 is used but not implemented!\n");
530  };
531 
550  const Vector<Real> &w,
551  const Vector<Real> &v,
552  const Vector<Real> &u,
553  const Vector<Real> &z,
554  Real &tol) override
555  {
556  PinTVector<Real> & pint_ahwv = dynamic_cast<PinTVector<Real>&>(ahwv);
557  const PinTVector<Real> & pint_w = dynamic_cast<const PinTVector<Real>&>(w);
558  const PinTVector<Real> & pint_v = dynamic_cast<const PinTVector<Real>&>(v);
559  const PinTVector<Real> & pint_u = dynamic_cast<const PinTVector<Real>&>(u);
560  const PinTVector<Real> & pint_z = dynamic_cast<const PinTVector<Real>&>(z);
561  // its possible we won't always want to cast to a PinT vector here
562 
563  TEUCHOS_ASSERT(pint_ahwv.numOwnedSteps()==pint_u.numOwnedSteps());
564  TEUCHOS_ASSERT(pint_ahwv.numOwnedSteps()==pint_v.numOwnedSteps());
565 
566  // communicate neighbors, these are block calls
567  pint_w.boundaryExchange();
568  pint_v.boundaryExchange();
569  pint_u.boundaryExchange();
570  pint_z.boundaryExchange();
571 
572  // we need to make sure this has all zeros to begin with (this includes boundary exchange components)
573  pint_ahwv.zeroAll();
574 
575  Ptr<Vector<Real>> scratch;
576  for(int i=0;i<pint_ahwv.numOwnedSteps();i++) {
577  // pull out all the time steps required
578  Ptr<const Vector<Real>> w_dual = getVector(pint_w,i,CURRENT);
579  Ptr<const Vector<Real>> v_dual = getStateVector(pint_v,i);
580  Ptr<const Vector<Real>> u_state = getStateVector(pint_u,i);
581  Ptr<const Vector<Real>> z_all = getVector(pint_z,i,ALL);
582 
583  Ptr<Vector<Real>> ahwv_now = getStateVector(pint_ahwv,i);
584 
585  // this will lead to problems if problem size changes in time
586  if(scratch==ROL::nullPtr) {
587  scratch = ahwv_now->clone();
588  }
589 
590  stepConstraint_->applyAdjointHessian_11(*scratch,*w_dual,*v_dual,*u_state,*z_all,tol);
591 
592  ahwv_now->axpy(1.0,*scratch);
593  }
594 
595  // handle the constraint adjoint
596  // nothing to do here, as the constraint is linear,
597  }
598 
617  const Vector<Real> &w,
618  const Vector<Real> &v,
619  const Vector<Real> &u,
620  const Vector<Real> &z,
621  Real &tol) override
622  {
623  ahwv.zero();
624  }
625 
644  const Vector<Real> &w,
645  const Vector<Real> &v,
646  const Vector<Real> &u,
647  const Vector<Real> &z,
648  Real &tol) override {
649  ahwv.zero();
650  }
651 
670  const Vector<Real> &w,
671  const Vector<Real> &v,
672  const Vector<Real> &u,
673  const Vector<Real> &z,
674  Real &tol) override {
675  ahwv.zero();
676  }
677 
678 }; // class Constraint_SimOpt
679 
680 } // namespace ROL
681 
682 #endif
virtual void update_1(const Vector< Real > &u, bool flag=true, int iter=-1)
Update constraint functions with respect to Opt variable. u is the state variable, flag = true if optimization variable is changed, iter is the outer algorithm iterations count.
Ptr< Vector< Real > > getVectorPtr(int i) const
Ptr< PinTVector< Real > > buildPinTVector(const Ptr< const PinTCommunicators > &communicators, int steps, const std::vector< int > &stencil, const Ptr< Vector< Real >> &localVector)
virtual void applyInverseAdjointJacobian_1(Vector< Real > &iajv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) overridefinal
Apply the inverse of the adjoint of the partial constraint Jacobian at , , to the vector ...
void boundaryExchange(ESendRecv send_recv=SEND_AND_RECV) const
Exchange unknowns with neighboring processors.
int numOwnedSteps() const
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 ...
virtual void zeroAll()
Zeros all entries of the vector, including boundary exchange fields.
virtual void zero()
Set to zero vector.
Definition: ROL_Vector.hpp:165
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:78
const std::vector< int > & stencil() const
Defines the time dependent constraint operator interface for simulation-based optimization.
Constraint_PinTSimOpt()
Default constructor.
virtual void applyAdjointJacobian_1(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 the vector . This is the primary inter...
virtual void value(Vector< Real > &c, const Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Evaluate the constraint operator at .
Ptr< Vector< Real > > getStateVector(const PinTVector< double > &src, int step)
void initialize(const Ptr< Constraint_TimeSimOpt< Real >> &stepConstraint)
Initialize this class, setting up parallel distribution.
Defines a parallel in time vector.
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...
ETimeAccessor
Enumeration to define which components of a a vector are required.
virtual void applyInverseJacobian_1(Vector< Real > &ijv, const Vector< Real > &v, const Vector< Real > &u, const Vector< Real > &z, Real &tol) overridefinal
Apply the inverse partial constraint Jacobian at , , to the vector .
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 ...
Ptr< Vector< Real > > getNonconstVector(const PinTVector< double > &src, int step, ETimeAccessor accessor)
Build a vector composed of all vectors required by accessor.
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 .
void boundaryExchangeSumInto()
Exchange unknowns with neighboring processors using summation.
Ptr< const Vector< Real > > getVector(const PinTVector< double > &src, int step, ETimeAccessor accessor)
Build a vector composed of all vectors required by accessor.
Ptr< Vector< Real > > getRemoteBufferPtr(int i) const
Ptr< Constraint_TimeSimOpt< Real > > stepConstraint_
virtual void solve(Vector< Real > &c, Vector< Real > &u, const Vector< Real > &z, Real &tol) override
Given , solve for .
const PinTCommunicators & communicators() const
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...
Defines the constraint operator interface for simulation-based optimization.
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 .
Constraint_PinTSimOpt(const Ptr< Constraint_TimeSimOpt< Real >> &stepConstraint)
Constructor.
virtual void update_2(const Vector< Real > &z, bool flag=true, int iter=-1)
Update constraint functions with respect to Opt variable. z is the control variable, flag = true if optimization variable is changed, iter is the outer algorithm iterations count.
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...