44 #ifndef ROL_REDUCED_OBJECTIVE_SIMOPT_H 45 #define ROL_REDUCED_OBJECTIVE_SIMOPT_H 64 Teuchos::RCP<Objective_SimOpt<Real> >
obj_;
65 Teuchos::RCP<EqualityConstraint_SimOpt<Real> >
con_;
89 if (!is_state_computed_ || !storage_) {
90 con_->solve(*dualadjoint_,*state_,x,tol);
92 obj_->update(*state_,x,flag,iter);
94 con_->update(*state_,x,flag,iter);
96 is_state_computed_ =
true;
106 if(!is_adjoint_computed_ || !storage_) {
108 obj_->gradient_1(*dualstate_,*state_,x,tol);
110 con_->applyInverseAdjointJacobian_1(*adjoint_,*dualstate_,*state_,x,tol);
111 adjoint_->scale(-1.0);
113 is_adjoint_computed_ =
true;
123 con_->applyJacobian_2(*dualadjoint_,v,*state_,x,tol);
124 dualadjoint_->scale(-1.0);
125 con_->applyInverseJacobian_1(*state_sens_,*dualadjoint_,*state_,x,tol);
137 obj_->hessVec_11(*dualstate_,*state_sens_,*state_,x,tol);
138 obj_->hessVec_12(*dualstate1_,v,*state_,x,tol);
139 dualstate_->plus(*dualstate1_);
141 con_->applyAdjointHessian_11(*dualstate1_,*adjoint_,*state_sens_,*state_,x,tol);
142 dualstate_->plus(*dualstate1_);
143 con_->applyAdjointHessian_21(*dualstate1_,*adjoint_,v,*state_,x,tol);
144 dualstate_->plus(*dualstate1_);
146 dualstate_->scale(-1.0);
147 con_->applyInverseAdjointJacobian_1(*adjoint_sens_,*dualstate_,*state_,x,tol);
165 bool storage =
true,
bool useFDhessVec =
false)
166 : obj_(obj), con_(con),
167 state_(state), state_sens_(state->clone()),
168 dualstate_(state->dual().clone()), dualstate1_(state->dual().clone()),
169 adjoint_(adjoint), adjoint_sens_(adjoint->clone()),
170 dualadjoint_(adjoint->dual().clone()), dualcontrol_(Teuchos::null),
171 storage_(storage), is_state_computed_(false), is_adjoint_computed_(false),
172 is_initialized_(false), useFDhessVec_(useFDhessVec) {}
192 bool storage =
true,
bool useFDhessVec =
false)
193 : obj_(obj), con_(con),
194 state_(state), state_sens_(state->clone()),
195 dualstate_(dualstate), dualstate1_(dualstate->clone()),
196 adjoint_(adjoint), adjoint_sens_(adjoint->clone()),
197 dualadjoint_(dualadjoint), dualcontrol_(Teuchos::null),
198 storage_(storage), is_state_computed_(false), is_adjoint_computed_(false),
199 is_initialized_(false), useFDhessVec_(useFDhessVec) {}
205 is_state_computed_ =
false;
206 is_adjoint_computed_ =
false;
222 return obj_->value(*state_,x,tol);
231 if (!is_initialized_) {
232 dualcontrol_ = g.
clone();
233 is_initialized_ =
true;
240 obj_->gradient_2(*dualcontrol_,*state_,x,tol);
242 con_->applyAdjointJacobian_2(g,*adjoint_,*state_,x,tol);
243 g.
plus(*dualcontrol_);
250 if ( useFDhessVec_ ) {
254 if (!is_initialized_) {
255 dualcontrol_ = hv.
clone();
256 is_initialized_ =
true;
267 con_->applyAdjointJacobian_2(hv,*adjoint_sens_,*state_,x,tol);
268 obj_->hessVec_21(*dualcontrol_,*state_sens_,*state_,x,tol);
269 hv.
plus(*dualcontrol_);
270 obj_->hessVec_22(*dualcontrol_,v,*state_,x,tol);
271 hv.
plus(*dualcontrol_);
272 con_->applyAdjointHessian_12(*dualcontrol_,*adjoint_,*state_sens_,*state_,x,tol);
273 hv.
plus(*dualcontrol_);
274 con_->applyAdjointHessian_22(*dualcontrol_,*adjoint_,v,*state_,x,tol);
275 hv.
plus(*dualcontrol_);
Teuchos::RCP< Objective_SimOpt< Real > > obj_
SimOpt objective function.
Provides the interface to evaluate objective functions.
Provides the interface to evaluate simulation-based objective functions.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
virtual void plus(const Vector &x)=0
Compute , where .
virtual void precond(Vector< Real > &Pv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply a reduced Hessian preconditioner.
void solve_adjoint_sensitivity(const ROL::Vector< Real > &v, const ROL::Vector< Real > &x, Real &tol)
Given , the adjoint variable , and a direction , solve the adjoint sensitvity equation for ...
bool storage_
Flag whether or not to store computed quantities.
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
Teuchos::RCP< Vector< Real > > state_
Storage for the state variable.
Teuchos::RCP< Vector< Real > > adjoint_sens_
Storage for the adjoint sensitivity variable.
Teuchos::RCP< Vector< Real > > state_sens_
Storage for the state sensitivity variable.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Reduced_Objective_SimOpt(const Teuchos::RCP< Objective_SimOpt< Real > > &obj, const Teuchos::RCP< EqualityConstraint_SimOpt< Real > > &con, const Teuchos::RCP< Vector< Real > > &state, const Teuchos::RCP< Vector< Real > > &adjoint, bool storage=true, bool useFDhessVec=false)
Primary constructor.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Given , evaluate the gradient of the objective function where solves .
void solve_adjoint_equation(const ROL::Vector< Real > &x, Real &tol)
Given which solves the state equation, solve the adjoint equation for .
Defines the linear algebra or vector space interface.
Defines the equality constraint operator interface for simulation-based optimization.
Teuchos::RCP< Vector< Real > > adjoint_
Storage for the adjoint variable.
Reduced_Objective_SimOpt(Teuchos::RCP< Objective_SimOpt< Real > > &obj, Teuchos::RCP< EqualityConstraint_SimOpt< Real > > &con, Teuchos::RCP< Vector< Real > > &state, Teuchos::RCP< Vector< Real > > &adjoint, Teuchos::RCP< Vector< Real > > &dualstate, Teuchos::RCP< Vector< Real > > &dualadjoint, bool storage=true, bool useFDhessVec=false)
Secondary, general constructor for use with dual optimization vector spaces where the user does not d...
void solve_state_equation(const ROL::Vector< Real > &x, Real &tol, bool flag=true, int iter=-1)
Given , solve the state equation for .
bool is_state_computed_
Flag whether or not to store the state variable.
Provides the interface to evaluate simulation-based reduced objective functions.
bool useFDhessVec_
Flag whether or not to use finite difference hessVec.
Teuchos::RCP< Vector< Real > > dualstate_
Dual state vector.
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Given , evaluate the Hessian of the objective function in the direction .
Real value(const Vector< Real > &x, Real &tol)
Given , evaluate the objective function where solves .
bool is_initialized_
Flag if dual control vector is initialized.
Teuchos::RCP< Vector< Real > > dualcontrol_
Dual control vector.
void solve_state_sensitivity(const ROL::Vector< Real > &v, const ROL::Vector< Real > &x, Real &tol)
Given which solves the state equation and a direction , solve the state senstivity equation for ...
virtual void set(const Vector &x)
Set where .
Teuchos::RCP< EqualityConstraint_SimOpt< Real > > con_
SimOpt equality constraint.
Teuchos::RCP< Vector< Real > > dualstate1_
Dual state vector.
Teuchos::RCP< Vector< Real > > dualadjoint_
Dual adjoint vector.
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update the SimOpt objective function and equality constraint.
static const double ROL_EPSILON
Platform-dependent machine epsilon.
bool is_adjoint_computed_
Flag whether or not to store the adjoint variable.