45 #ifndef ROL_REDUCED_CONSTRAINT_SIMOPT_DEF_H
46 #define ROL_REDUCED_CONSTRAINT_SIMOPT_DEF_H
54 if (newUpdate_) conRed_->update_2(z,updateType_,updateIter_);
55 else conRed_->update_2(z,updateFlag_,updateIter_);
60 if (!isComputed || !storage_) {
62 conRed_->solve(*dualadjoint_,*state_,z,tol);
69 if (newUpdate_) conRed_->update_1(*state_,updateType_,updateIter_);
70 else conRed_->update_1(*state_,updateFlag_,updateIter_);
72 if (newUpdate_) conVal_->update(*state_,z,updateType_,updateIter_);
73 else conVal_->update(*state_,z,updateFlag_,updateIter_);
83 if (!isComputed || !storage_) {
85 conVal_->applyAdjointJacobian_1(*dualstate_,w,*state_,z,tol);
87 conRed_->applyInverseAdjointJacobian_1(*adjoint_,*dualstate_,*state_,z,tol);
88 adjoint_->scale(static_cast<Real>(-1));
98 conRed_->applyJacobian_2(*dualadjoint_,v,*state_,z,tol);
99 dualadjoint_->scale(static_cast<Real>(-1));
100 conRed_->applyInverseJacobian_1(*state_sens_,*dualadjoint_,*state_,z,tol);
107 conVal_->applyAdjointHessian_11(*dualstate_,w,*state_sens_,*state_,z,tol);
108 conVal_->applyAdjointHessian_21(*dualstate1_,w,v,*state_,z,tol);
109 dualstate_->plus(*dualstate1_);
111 conRed_->applyAdjointHessian_11(*dualstate1_,*adjoint_,*state_sens_,*state_,z,tol);
112 dualstate_->plus(*dualstate1_);
113 conRed_->applyAdjointHessian_21(*dualstate1_,*adjoint_,v,*state_,z,tol);
114 dualstate_->plus(*dualstate1_);
116 dualstate_->scale(static_cast<Real>(-1));
117 conRed_->applyInverseAdjointJacobian_1(*adjoint_sens_,*dualstate_,*state_,z,tol);
134 stateStore_( stateStore ),
136 state_( state->clone() ),
137 adjoint_( adjoint->clone() ),
138 residual_( residual->clone() ),
139 state_sens_( state->clone() ),
140 adjoint_sens_( adjoint->clone() ),
141 dualstate_( state->dual().clone() ),
142 dualstate1_( state->dual().clone() ),
143 dualadjoint_( adjoint->dual().clone() ),
144 dualcontrol_( control->dual().clone() ),
145 dualresidual_( residual->dual().clone() ),
146 storage_(storage), useFDhessVec_(useFDhessVec),
147 nupda_(0), nvalu_(0), njaco_(0), najac_(0), nhess_(0),
148 nstat_(0), nadjo_(0), nssen_(0), nasen_(0),
150 newUpdate_(false), isUpdated_(true) {}
169 stateStore_( stateStore ),
171 state_( state->clone() ),
172 adjoint_( adjoint->clone() ),
173 residual_( residual->clone() ),
174 state_sens_( state->clone() ),
175 adjoint_sens_( adjoint->clone() ),
176 dualstate_( dualstate->clone() ),
177 dualstate1_( dualstate->clone() ),
178 dualadjoint_( dualadjoint->clone() ),
179 dualcontrol_( dualcontrol->clone() ),
180 dualresidual_( dualresidual->clone() ),
181 storage_(storage), useFDhessVec_(useFDhessVec),
182 nupda_(0), nvalu_(0), njaco_(0), najac_(0), nhess_(0),
183 nstat_(0), nadjo_(0), nssen_(0), nasen_(0),
185 newUpdate_(false), isUpdated_(true) {}
189 int nupda(0), nvalu(0), njaco(0), najac(0), nhess(0), nstat(0), nadjo(0), nssen(0), nasen(0);
190 if (bman == nullPtr) {
202 auto sumAll = [bman](
int val) {
203 Real global(0), local(val);
204 bman->sumAll(&local,&global,1);
205 return static_cast<int>(global);
207 nupda = sumAll(nupda_);
208 nvalu = sumAll(nvalu_);
209 njaco = sumAll(njaco_);
210 najac = sumAll(najac_);
211 nhess = sumAll(nhess_);
212 nstat = sumAll(nstat_);
213 nadjo = sumAll(nadjo_);
214 nssen = sumAll(nssen_);
215 nasen = sumAll(nasen_);
218 stream << std::string(80,
'=') << std::endl;
219 stream <<
" ROL::Reduced_Objective_SimOpt::summarize" << std::endl;
220 stream <<
" Number of calls to update: " << nupda << std::endl;
221 stream <<
" Number of calls to value: " << nvalu << std::endl;
222 stream <<
" Number of calls to applyJacobian: " << njaco << std::endl;
223 stream <<
" Number of calls to applyAdjointJacobian: " << najac << std::endl;
224 stream <<
" Number of calls to hessvec: " << nhess << std::endl;
225 stream <<
" Number of state solves: " << nstat << std::endl;
226 stream <<
" Number of adjoint solves: " << nadjo << std::endl;
227 stream <<
" Number of state sensitivity solves: " << nssen << std::endl;
228 stream <<
" Number of adjoint sensitivity solves: " << nasen << std::endl;
229 stream << std::string(80,
'=') << std::endl;
235 nupda_ = 0; nvalu_ = 0; njaco_ = 0; najac_ = 0; nhess_ = 0;
236 nstat_ = 0; nadjo_ = 0; nssen_ = 0; nasen_ = 0;
244 stateStore_->constraintUpdate(
true);
245 adjointStore_->constraintUpdate(flag);
254 stateStore_->objectiveUpdate(type);
255 adjointStore_->objectiveUpdate(type);
262 solve_state_equation(z,tol);
264 conVal_->value(c,*state_,z,tol);
272 solve_state_equation(z,tol);
274 solve_state_sensitivity(v,z,tol);
276 conVal_->applyJacobian_1(*residual_,*state_sens_,*state_,z,tol);
278 conVal_->applyJacobian_2(jv,v,*state_,z,tol);
287 solve_state_equation(z,tol);
289 solve_adjoint_equation(w,z,tol);
291 conVal_->applyAdjointJacobian_2(*dualcontrol_,w,*state_,z,tol);
293 conRed_->applyAdjointJacobian_2(ajw,*adjoint_,*state_,z,tol);
294 ajw.
plus(*dualcontrol_);
302 if ( useFDhessVec_ ) {
307 solve_state_equation(z,tol);
309 solve_adjoint_equation(w,z,tol);
311 solve_state_sensitivity(v,z,tol);
313 solve_adjoint_sensitivity(w,v,z,tol);
315 conRed_->applyAdjointJacobian_2(ahwv,*adjoint_sens_,*state_,z,tol);
316 conVal_->applyAdjointHessian_12(*dualcontrol_,w,*state_sens_,*state_,z,tol);
317 ahwv.
plus(*dualcontrol_);
318 conVal_->applyAdjointHessian_22(*dualcontrol_,w,v,*state_,z,tol);
319 ahwv.
plus(*dualcontrol_);
320 conRed_->applyAdjointHessian_12(*dualcontrol_,*adjoint_,*state_sens_,*state_,z,tol);
321 ahwv.
plus(*dualcontrol_);
322 conRed_->applyAdjointHessian_22(*dualcontrol_,*adjoint_,v,*state_,z,tol);
323 ahwv.
plus(*dualcontrol_);
Reduced_Constraint_SimOpt(const ROL::Ptr< Constraint_SimOpt< Real >> &conVal, const ROL::Ptr< Constraint_SimOpt< Real >> &conRed, const ROL::Ptr< VectorController< Real >> &stateStore, const ROL::Ptr< Vector< Real >> &state, const ROL::Ptr< Vector< Real >> &control, const ROL::Ptr< Vector< Real >> &adjoint, const ROL::Ptr< Vector< Real >> &residual, bool storage=true, bool useFDhessVec=false)
Constructor.
virtual void plus(const Vector &x)=0
Compute , where .
void solve_state_sensitivity(const Vector< Real > &v, const Vector< Real > &z, Real &tol)
Given which solves the state equation and a direction , solve the state senstivity equation for ...
void applyAdjointHessian(Vector< Real > &ahwv, const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &z, Real &tol)
Given , evaluate the Hessian of the objective function in the direction .
void applyAdjointJacobian(Vector< Real > &ajw, const Vector< Real > &w, const Vector< Real > &z, Real &tol)
Apply the adjoint of the the constraint Jacobian at , , to vector .
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &z, Real &tol)
Given , apply the Jacobian to a vector where solves .
Defines the linear algebra or vector space interface.
void solve_state_equation(const Vector< Real > &z, Real &tol)
void value(Vector< Real > &c, const Vector< Real > &z, Real &tol)
Given , evaluate the equality constraint where solves .
void solve_adjoint_equation(const Vector< Real > &w, const Vector< Real > &z, Real &tol)
Given which solves the state equation, solve the adjoint equation for .
virtual void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the derivative of the adjoint of the constraint Jacobian at to vector in direction ...
void solve_adjoint_sensitivity(const Vector< Real > &w, const Vector< Real > &v, const Vector< Real > &z, Real &tol)
Given , the adjoint variable , and a direction , solve the adjoint sensitvity equation for ...
Defines the constraint operator interface for simulation-based optimization.
void update(const Vector< Real > &z, bool flag=true, int iter=-1)
Update the SimOpt objective function and equality constraint.
Defines the general constraint operator interface.
void summarize(std::ostream &stream, const Ptr< BatchManager< Real >> &bman=nullPtr) const