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) ) {
162 lhist_.push_back(cvec->dual().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);
517 Real err(0), cnorm(0);
520 err =
static_cast<Real
>(0);
526 err = (cnorm > err ? cnorm : err);
551 obj_->gradient_un(*
udual_, uold, unew, z, ts);
552 con_->applyInverseAdjointJacobian_un(l, *
udual_, uold, unew, z, ts);
559 obj_->gradient_uo(rhs, uold, unew, z, ts);
560 con_->applyAdjointJacobian_uo(*
udual_, l, uold, unew, z, ts);
567 obj_->gradient_un(*
udual_, uold, unew, z, ts);
569 con_->applyInverseAdjointJacobian_un(l, rhs, uold, unew, z, ts);
635 obj_->gradient_z(g, uold, unew, z, ts);
636 con_->applyAdjointJacobian_z(*
zdual_, l, uold, unew, z, ts);
648 con_->applyJacobian_z(*
crhs_, v, uold, unew, z, ts);
649 con_->applyJacobian_uo(*
cprimal_, wold, uold, unew, z, ts);
651 con_->applyInverseJacobian_un(wnew, *
crhs_, uold, unew, z, ts);
664 con_->applyAdjointHessian_z_un(*
rhs_, l, v, uold, unew, z, ts);
665 obj_->hessVec_un_z(*
udual_, v, uold, unew, z, ts);
668 con_->applyAdjointHessian_un_un(*
udual_, l, wnew, uold, unew, z, ts);
670 obj_->hessVec_un_un(*
udual_, wnew, uold, unew, z, ts);
672 con_->applyAdjointHessian_uo_un(*
udual_, l, wold, uold, unew, z, ts);
674 obj_->hessVec_un_uo(*
udual_, wold, uold, unew, z, ts);
677 con_->applyInverseAdjointJacobian_un(p, *
rhs_, uold, unew, z, ts);
684 const bool sumInto =
false) {
688 obj_->hessVec_un_uo(Hv, wold, uold, unew, z, ts);
691 obj_->hessVec_un_uo(*
udual_, wold, uold, unew, z, ts);
694 con_->applyAdjointHessian_uo_un(*
udual_, l, wold, uold, unew, z, ts);
697 obj_->hessVec_un_un(*
udual_, wnew, uold, unew, z, ts);
699 con_->applyAdjointHessian_un_un(*
udual_, l, wnew, uold, unew, z, ts);
707 const bool sumInto =
false) {
711 con_->applyAdjointHessian_z_un(Hv, l, v, uold, unew, z, ts);
714 con_->applyAdjointHessian_z_un(*
udual_, l, v, uold, unew, z, ts);
717 obj_->hessVec_un_z(*
udual_, v, uold, unew, z, ts);
724 const bool sumInto =
false) {
727 con_->applyAdjointJacobian_uo(Hv, p, uold, unew, z, ts);
731 con_->applyAdjointJacobian_uo(*
udual_, p, uold, unew, z, ts);
740 const bool sumInto =
false) {
744 obj_->hessVec_uo_un(Hv, wnew, uold, unew, z, ts);
747 obj_->hessVec_uo_un(*
udual_, wnew, uold, unew, z, ts);
750 con_->applyAdjointHessian_un_uo(*
udual_, l, wnew, uold, unew, z, ts);
753 obj_->hessVec_uo_uo(*
udual_, wold, uold, unew, z, ts);
755 con_->applyAdjointHessian_uo_uo(*
udual_, l, wold, uold, unew, z, ts);
763 const bool sumInto =
false) {
767 con_->applyAdjointHessian_z_uo(Hv, l, v, uold, unew, z, ts);
770 con_->applyAdjointHessian_z_uo(*
udual_, l, v, uold, unew, z, ts);
773 obj_->hessVec_uo_z(*
udual_, v, uold, unew, z, ts);
781 con_->applyInverseAdjointJacobian_un(p, rhs, uold, unew, z, ts);
793 obj_->hessVec_z_z(Hv, v, uold, unew, z, ts);
794 con_->applyAdjointHessian_z_z(*
zdual_, l, v, uold, unew, z, ts);
804 obj_->hessVec_z_uo(*
zdual_, wold, uold, unew, z, ts);
806 con_->applyAdjointHessian_uo_z(*
zdual_, l, wold, uold, unew, z, ts);
809 obj_->hessVec_z_un(*
zdual_, wnew, uold, unew, z, ts);
811 con_->applyAdjointHessian_un_z(*
zdual_, l, wnew, uold, unew, z, ts);
818 con_->applyAdjointJacobian_z(*
zdual_, p, uold, unew, z, ts);
825 #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)
Defines the reduced time-dependent objective function interface for simulation-based optimization...
virtual void plus(const Vector &x)=0
Compute , where .
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.
Real updateSketch(const Vector< Real > &x, const Real tol)
typename std::vector< Real >::size_type size_type
PartitionedVector< Real > & partition(Vector< Real > &x) const
Ptr< Vector< Real > > makeDynamicVector(const Vector< Real > &x) const
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)
ROL::Ptr< const Vector< Real > > get(size_type i) const
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.
const PartitionedVector< Real > & partition(const Vector< Real > &x) const
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_