44 #ifndef ROL_REDUCEDDYNAMICOBJECTIVE_HPP
45 #define ROL_REDUCEDDYNAMICOBJECTIVE_HPP
47 #include "ROL_Ptr.hpp"
78 template<
typename Real>
83 const Ptr<DynamicObjective<Real>>
obj_;
84 const Ptr<DynamicConstraint<Real>>
con_;
85 const Ptr<Vector<Real>>
u0_;
136 ROL::ParameterList &pl)
141 Nt_ ( timeStamp.size() ),
156 useSymHess_ ( pl.get(
"Use Only Sketched Sensitivity", true) ) {
160 uhist_.push_back(u0_->clone());
161 uhist_.push_back(u0_->clone());
162 lhist_.push_back(cvec->dual().clone());
166 whist_.push_back(u0_->clone());
167 whist_.push_back(u0_->clone());
168 phist_.push_back(cvec->dual().clone());
174 lhist_.push_back(cvec->dual().clone());
177 phist_.push_back(cvec->dual().clone());
182 crhs_ = cvec->clone();
185 zdual_ = zvec->dual().clone();
205 val_ =
static_cast<Real
>(0);
283 *
uhist_[uindex-1], *uhist_[uindex],
290 *uhist_[uindex-1], *uhist_[uindex],
297 uhist_[1]->set(*uhist_[0]);
299 uhist_[0]->set(*
u0_);
302 stateSketch_->reconstruct(*uhist_[0],static_cast<int>(k)-2);
314 *uhist_[uindex-1], *uhist_[uindex],
322 *uhist_[uindex-1], *uhist_[uindex],
361 *
uhist_[uindex-1], *uhist_[uindex],
366 *uhist_[uindex-1], *uhist_[uindex],
371 *
whist_[uindex-1], *whist_[uindex],
372 *uhist_[uindex-1], *uhist_[uindex],
379 uhist_[0]->set(*uhist_[1]);
402 *
whist_[uindex-1], *whist_[uindex],
403 *
uhist_[uindex-1], *uhist_[uindex],
408 *whist_[uindex-1], *whist_[uindex],
409 *uhist_[uindex-1], *uhist_[uindex],
414 *uhist_[uindex-1], *uhist_[uindex],
420 *whist_[uindex-1], *whist_[uindex],
421 *uhist_[uindex-1], *uhist_[uindex],
426 *uhist_[uindex-1], *uhist_[uindex],
430 *uhist_[uindex-1], *uhist_[uindex],
435 uhist_[1]->set(*uhist_[0]);
436 whist_[1]->set(*whist_[0]);
438 uhist_[0]->set(*
u0_);
442 stateSketch_->reconstruct(*uhist_[0],static_cast<int>(k)-2);
454 *whist_[uindex-1], *whist_[uindex],
455 *uhist_[uindex-1], *uhist_[uindex],
460 *uhist_[uindex-1], *uhist_[uindex],
465 *uhist_[uindex-1], *uhist_[uindex],
470 *whist_[uindex-1], *whist_[uindex],
471 *uhist_[uindex-1], *uhist_[uindex],
476 *uhist_[uindex-1], *uhist_[uindex],
519 Real err(0), cnorm(0);
522 err =
static_cast<Real
>(0);
528 err = (cnorm > err ? cnorm : err);
553 obj_->gradient_un(*
udual_, uold, unew, z, ts);
554 con_->applyInverseAdjointJacobian_un(l, *
udual_, uold, unew, z, ts);
561 obj_->gradient_uo(rhs, uold, unew, z, ts);
562 con_->applyAdjointJacobian_uo(*
udual_, l, uold, unew, z, ts);
569 obj_->gradient_un(*
udual_, uold, unew, z, ts);
571 con_->applyInverseAdjointJacobian_un(l, rhs, uold, unew, z, ts);
637 obj_->gradient_z(g, uold, unew, z, ts);
638 con_->applyAdjointJacobian_z(*
zdual_, l, uold, unew, z, ts);
650 con_->applyJacobian_z(*
crhs_, v, uold, unew, z, ts);
651 con_->applyJacobian_uo(*
cprimal_, wold, uold, unew, z, ts);
653 con_->applyInverseJacobian_un(wnew, *
crhs_, uold, unew, z, ts);
666 con_->applyAdjointHessian_z_un(*
rhs_, l, v, uold, unew, z, ts);
667 obj_->hessVec_un_z(*
udual_, v, uold, unew, z, ts);
670 con_->applyAdjointHessian_un_un(*
udual_, l, wnew, uold, unew, z, ts);
672 obj_->hessVec_un_un(*
udual_, wnew, uold, unew, z, ts);
674 con_->applyAdjointHessian_uo_un(*
udual_, l, wold, uold, unew, z, ts);
676 obj_->hessVec_un_uo(*
udual_, wold, uold, unew, z, ts);
679 con_->applyInverseAdjointJacobian_un(p, *
rhs_, uold, unew, z, ts);
686 const bool sumInto =
false) {
690 obj_->hessVec_un_uo(Hv, wold, uold, unew, z, ts);
693 obj_->hessVec_un_uo(*
udual_, wold, uold, unew, z, ts);
696 con_->applyAdjointHessian_uo_un(*
udual_, l, wold, uold, unew, z, ts);
699 obj_->hessVec_un_un(*
udual_, wnew, uold, unew, z, ts);
701 con_->applyAdjointHessian_un_un(*
udual_, l, wnew, uold, unew, z, ts);
709 const bool sumInto =
false) {
713 con_->applyAdjointHessian_z_un(Hv, l, v, uold, unew, z, ts);
716 con_->applyAdjointHessian_z_un(*
udual_, l, v, uold, unew, z, ts);
719 obj_->hessVec_un_z(*
udual_, v, uold, unew, z, ts);
726 const bool sumInto =
false) {
729 con_->applyAdjointJacobian_uo(Hv, p, uold, unew, z, ts);
733 con_->applyAdjointJacobian_uo(*
udual_, p, uold, unew, z, ts);
742 const bool sumInto =
false) {
746 obj_->hessVec_uo_un(Hv, wnew, uold, unew, z, ts);
749 obj_->hessVec_uo_un(*
udual_, wnew, uold, unew, z, ts);
752 con_->applyAdjointHessian_un_uo(*
udual_, l, wnew, uold, unew, z, ts);
755 obj_->hessVec_uo_uo(*
udual_, wold, uold, unew, z, ts);
757 con_->applyAdjointHessian_uo_uo(*
udual_, l, wold, uold, unew, z, ts);
765 const bool sumInto =
false) {
769 con_->applyAdjointHessian_z_uo(Hv, l, v, uold, unew, z, ts);
772 con_->applyAdjointHessian_z_uo(*
udual_, l, v, uold, unew, z, ts);
775 obj_->hessVec_uo_z(*
udual_, v, uold, unew, z, ts);
783 con_->applyInverseAdjointJacobian_un(p, rhs, uold, unew, z, ts);
795 obj_->hessVec_z_z(Hv, v, uold, unew, z, ts);
796 con_->applyAdjointHessian_z_z(*
zdual_, l, v, uold, unew, z, ts);
806 obj_->hessVec_z_uo(*
zdual_, wold, uold, unew, z, ts);
808 con_->applyAdjointHessian_uo_z(*
zdual_, l, wold, uold, unew, z, ts);
811 obj_->hessVec_z_un(*
zdual_, wnew, uold, unew, z, ts);
813 con_->applyAdjointHessian_un_z(*
zdual_, l, wnew, uold, unew, z, ts);
820 con_->applyAdjointJacobian_z(*
zdual_, p, uold, unew, z, ts);
827 #endif // ROL_REDUCEDDYNAMICOBJECTIVE_HPP
void advanceAdjointSens(Vector< Real > &p, Vector< Real > &rhs, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts)
Provides the interface to evaluate objective functions.
Ptr< Sketch< Real > > stateSensSketch_
static Ptr< PartitionedVector > create(std::initializer_list< Vp > vs)
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update objective function.
typename PV< Real >::size_type size_type
virtual void scale(const Real alpha)=0
Compute where .
void computeOldStateHessLag(Vector< Real > &Hv, const Vector< Real > &l, const Vector< Real > &wold, const Vector< Real > &wnew, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts, const bool sumInto=false)
const PartitionedVector< Real > & partition(const Vector< Real > &x) const
ROL::Ptr< const Vector< Real > > get(size_type i) const
Defines the reduced time-dependent objective function interface for simulation-based optimization...
virtual void plus(const Vector &x)=0
Compute , where .
Ptr< Vector< Real > > makeDynamicVector(const Vector< Real > &x) const
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Ptr< Vector< Real > > udual_
Defines the time-dependent constraint operator interface for simulation-based optimization.
void computeNewStateJacobian(Vector< Real > &Hv, const Vector< Real > &p, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts, const bool sumInto=false)
Defines the linear algebra of vector space on a generic partitioned vector.
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
void addAdjointSens(Vector< Real > &Hv, const Vector< Real > &p, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts)
Ptr< Vector< Real > > crhs_
const std::vector< TimeStamp< Real > > timeStamp_
Contains local time step information.
Ptr< Vector< Real > > zdual_
Defines the linear algebra or vector space interface.
Defines the time-dependent objective function interface for simulation-based optimization. Computes time-local contributions of value, gradient, Hessian-vector product etc to a larger composite objective defined over the simulation time. In contrast to other objective classes Objective_TimeSimOpt has a default implementation of value which returns zero, as time-dependent simulation based optimization problems may have an objective value which depends only on the final state of the system.
void advanceAdjoint(Vector< Real > &l, Vector< Real > &rhs, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts)
void computeNewStateHessLag(Vector< Real > &Hv, const Vector< Real > &l, const Vector< Real > &wold, const Vector< Real > &wnew, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts, const bool sumInto=false)
void solveState(const Vector< Real > &x)
Ptr< Sketch< Real > > adjointSketch_
Real value(const Vector< Real > &x, Real &tol)
Compute value.
PartitionedVector< Real > & partition(Vector< Real > &x) const
Real updateSketch(const Vector< Real > &x, const Real tol)
typename std::vector< Real >::size_type size_type
void computeNewMixedHessLag(Vector< Real > &Hv, const Vector< Real > &v, const Vector< Real > &l, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts, const bool sumInto=false)
const Ptr< DynamicObjective< Real > > obj_
Ptr< Vector< Real > > cprimal_
const Ptr< DynamicConstraint< Real > > con_
void advanceStateSens(Vector< Real > &wnew, const Vector< Real > &v, const Vector< Real > &wold, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts)
void computeControlHessLag(Vector< Real > &Hv, const Vector< Real > &v, const Vector< Real > &l, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts)
std::vector< Ptr< Vector< Real > > > whist_
void solveAdjoint(const Vector< Real > &x)
void setTerminalCondition(Vector< Real > &l, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts)
std::vector< Ptr< Vector< Real > > > uhist_
ReducedDynamicObjective(const Ptr< DynamicObjective< Real >> &obj, const Ptr< DynamicConstraint< Real >> &con, const Ptr< Vector< Real >> &u0, const Ptr< Vector< Real >> &zvec, const Ptr< Vector< Real >> &cvec, const std::vector< TimeStamp< Real >> &timeStamp, ROL::ParameterList &pl)
std::vector< Ptr< Vector< Real > > > lhist_
Ptr< Vector< Real > > rhs_
const Ptr< Vector< Real > > u0_
void setTerminalConditionHess(Vector< Real > &p, const Vector< Real > &v, const Vector< Real > &l, const Vector< Real > &wold, const Vector< Real > &wnew, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts)
std::vector< Ptr< Vector< Real > > > phist_
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
void computeAdjointRHS(Vector< Real > &rhs, const Vector< Real > &l, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts)
void computeOldMixedHessLag(Vector< Real > &Hv, const Vector< Real > &v, const Vector< Real > &l, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts, const bool sumInto=false)
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
void addMixedHessLag(Vector< Real > &Hv, const Vector< Real > &l, const Vector< Real > &wold, const Vector< Real > &wnew, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts)
void updateGradient(Vector< Real > &g, const Vector< Real > &l, const Vector< Real > &uold, const Vector< Real > &unew, const Vector< Real > &z, const TimeStamp< Real > &ts)
Ptr< Sketch< Real > > stateSketch_