ROL
burgers-control/example_01.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Rapid Optimization Library (ROL) Package
4//
5// Copyright 2014 NTESS and the ROL contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
15#include "ROL_StdVector.hpp"
16#include "ROL_Objective.hpp"
18
19template<class Real>
21private:
22 Real alpha_; // Penalty Parameter
23
24 int nx_; // Number of interior nodes
25 Real dx_; // Mesh spacing (i.e. 1/(nx+1))
26
27/***************************************************************/
28/********** BEGIN PRIVATE MEMBER FUNCTION DECLARATION **********/
29/***************************************************************/
30 Real evaluate_target(Real x) {
31 Real val = 0.0;
32 int example = 2;
33 switch (example) {
34 case 1: val = ((x<0.5) ? 1.0 : 0.0); break;
35 case 2: val = 1.0; break;
36 case 3: val = std::abs(std::sin(8.0*M_PI*x)); break;
37 case 4: val = std::exp(-0.5*(x-0.5)*(x-0.5)); break;
38 }
39 return val;
40 }
41
42 Real compute_norm(const std::vector<Real> &r) {
43 return std::sqrt(this->dot(r,r));
44 }
45
46 Real dot(const std::vector<Real> &x, const std::vector<Real> &y) {
47 Real ip = 0.0;
48 Real c = (((int)x.size()==this->nx_) ? 4.0 : 2.0);
49 for (unsigned i=0; i<x.size(); i++) {
50 if ( i == 0 ) {
51 ip += this->dx_/6.0*(c*x[i] + x[i+1])*y[i];
52 }
53 else if ( i == x.size()-1 ) {
54 ip += this->dx_/6.0*(x[i-1] + c*x[i])*y[i];
55 }
56 else {
57 ip += this->dx_/6.0*(x[i-1] + 4.0*x[i] + x[i+1])*y[i];
58 }
59 }
60 return ip;
61 }
62
63 using ROL::Objective<Real>::update;
64
65 void update(std::vector<Real> &u, const std::vector<Real> &s, const Real alpha=1.0) {
66 for (unsigned i=0; i<u.size(); i++) {
67 u[i] += alpha*s[i];
68 }
69 }
70
71 void scale(std::vector<Real> &u, const Real alpha=0.0) {
72 for (unsigned i=0; i<u.size(); i++) {
73 u[i] *= alpha;
74 }
75 }
76
77 void apply_mass(std::vector<Real> &Mu, const std::vector<Real> &u ) {
78 Mu.resize(u.size(),0.0);
79 Real c = (((int)u.size()==this->nx_) ? 4.0 : 2.0);
80 for (unsigned i=0; i<u.size(); i++) {
81 if ( i == 0 ) {
82 Mu[i] = this->dx_/6.0*(c*u[i] + u[i+1]);
83 }
84 else if ( i == u.size()-1 ) {
85 Mu[i] = this->dx_/6.0*(u[i-1] + c*u[i]);
86 }
87 else {
88 Mu[i] = this->dx_/6.0*(u[i-1] + 4.0*u[i] + u[i+1]);
89 }
90 }
91 }
92
93 void compute_residual(std::vector<Real> &r, const std::vector<Real> &u,
94 const std::vector<Real> &z, const std::vector<Real> &param) {
95 r.clear();
96 r.resize(this->nx_,0.0);
97 Real nu = std::pow(10.0,param[0]-2.0);
98 Real f = param[1]/100.0;
99 Real u0 = 1.0+param[2]/1000.0;
100 Real u1 = param[3]/1000.0;
101 for (int i=0; i<this->nx_; i++) {
102 // Contribution from stiffness term
103 if ( i==0 ) {
104 r[i] = nu/this->dx_*(2.0*u[i]-u[i+1]);
105 }
106 else if (i==this->nx_-1) {
107 r[i] = nu/this->dx_*(2.0*u[i]-u[i-1]);
108 }
109 else {
110 r[i] = nu/this->dx_*(2.0*u[i]-u[i-1]-u[i+1]);
111 }
112 // Contribution from nonlinear term
113 if (i<this->nx_-1){
114 r[i] += u[i+1]*(u[i]+u[i+1])/6.0;
115 }
116 if (i>0) {
117 r[i] -= u[i-1]*(u[i-1]+u[i])/6.0;
118 }
119 // Contribution from control
120 r[i] -= this->dx_/6.0*(z[i]+4.0*z[i+1]+z[i+2]);
121 // Contribution from right-hand side
122 r[i] -= this->dx_*f;
123 }
124 // Contribution from Dirichlet boundary terms
125 r[0] -= u0*u[ 0]/6.0 + u0*u0/6.0 + nu*u0/this->dx_;
126 r[this->nx_-1] += u1*u[this->nx_-1]/6.0 + u1*u1/6.0 - nu*u1/this->dx_;
127 }
128
129 void compute_pde_jacobian(std::vector<Real> &dl, std::vector<Real> &d, std::vector<Real> &du,
130 const std::vector<Real> &u, const std::vector<Real> &param) {
131 Real nu = std::pow(10.0,param[0]-2.0);
132 Real u0 = 1.0+param[2]/1000.0;
133 Real u1 = param[3]/1000.0;
134 // Get Diagonal and Off-Diagonal Entries of linear PDE Jacobian
135 d.clear();
136 d.resize(this->nx_,nu*2.0/this->dx_);
137 dl.clear();
138 dl.resize(this->nx_-1,-nu/this->dx_);
139 du.clear();
140 du.resize(this->nx_-1,-nu/this->dx_);
141 // Contribution from nonlinearity
142 for (int i=0; i<this->nx_; i++) {
143 if (i<this->nx_-1) {
144 dl[i] += (-2.0*u[i]-u[i+1])/6.0;
145 d[i] += u[i+1]/6.0;
146 }
147 if (i>0) {
148 d[i] += -u[i-1]/6.0;
149 du[i-1] += (u[i-1]+2.0*u[i])/6.0;
150 }
151 }
152 // Contribution from Dirichlet boundary conditions
153 d[0] -= u0/6.0;
154 d[this->nx_-1] += u1/6.0;
155 }
156
157 void add_pde_hessian(std::vector<Real> &r, const std::vector<Real> &u, const std::vector<Real> &p,
158 const std::vector<Real> &s, Real alpha = 1.0) {
159 for (int i=0; i<this->nx_; i++) {
160 // Contribution from nonlinear term
161 if (i<this->nx_-1){
162 r[i] += alpha*(p[i]*s[i+1] - p[i+1]*(2.0*s[i]+s[i+1]))/6.0;
163 }
164 if (i>0) {
165 r[i] += alpha*(p[i-1]*(s[i-1]+2.0*s[i]) - p[i]*s[i-1])/6.0;
166 }
167 }
168 }
169
170 void linear_solve(std::vector<Real> &u, std::vector<Real> &dl, std::vector<Real> &d, std::vector<Real> &du,
171 const std::vector<Real> &r, const bool transpose = false) {
172 u.assign(r.begin(),r.end());
173 // Perform LDL factorization
174 Teuchos::LAPACK<int,Real> lp;
175 std::vector<Real> du2(this->nx_-2,0.0);
176 std::vector<int> ipiv(this->nx_,0);
177 int info;
178 int ldb = this->nx_;
179 int nhrs = 1;
180 lp.GTTRF(this->nx_,&dl[0],&d[0],&du[0],&du2[0],&ipiv[0],&info);
181 char trans = 'N';
182 if ( transpose ) {
183 trans = 'T';
184 }
185 lp.GTTRS(trans,this->nx_,nhrs,&dl[0],&d[0],&du[0],&du2[0],&ipiv[0],&u[0],ldb,&info);
186 }
187
188 void run_newton(std::vector<Real> &u, const std::vector<Real> &z, const std::vector<Real> &param) {
189 // Compute residual and residual norm
190 std::vector<Real> r(u.size(),0.0);
191 this->compute_residual(r,u,z,param);
192 Real rnorm = this->compute_norm(r);
193 // Define tolerances
194 Real tol = 1.e2*ROL::ROL_EPSILON<Real>();
195 Real maxit = 500;
196 // Initialize Jacobian storage
197 std::vector<Real> d(this->nx_,0.0);
198 std::vector<Real> dl(this->nx_-1,0.0);
199 std::vector<Real> du(this->nx_-1,0.0);
200 // Iterate Newton's method
201 Real alpha = 1.0, tmp = 0.0;
202 std::vector<Real> s(this->nx_,0.0);
203 std::vector<Real> utmp(this->nx_,0.0);
204 for (int i=0; i<maxit; i++) {
205 //std::cout << i << " " << rnorm << "\n";
206 // Get Jacobian
207 this->compute_pde_jacobian(dl,d,du,u,param);
208 // Solve Newton system
209 this->linear_solve(s,dl,d,du,r);
210 // Perform line search
211 tmp = rnorm;
212 alpha = 1.0;
213 utmp.assign(u.begin(),u.end());
214 this->update(utmp,s,-alpha);
215 this->compute_residual(r,utmp,z,param);
216 rnorm = this->compute_norm(r);
217 while ( rnorm > (1.0-1.e-4*alpha)*tmp && alpha > std::sqrt(ROL::ROL_EPSILON<Real>()) ) {
218 alpha /= 2.0;
219 utmp.assign(u.begin(),u.end());
220 this->update(utmp,s,-alpha);
221 this->compute_residual(r,utmp,z,param);
222 rnorm = this->compute_norm(r);
223 }
224 // Update iterate
225 u.assign(utmp.begin(),utmp.end());
226 if ( rnorm < tol ) {
227 break;
228 }
229 }
230 }
231/*************************************************************/
232/********** END PRIVATE MEMBER FUNCTION DECLARATION **********/
233/*************************************************************/
234
235public:
236
237 Objective_BurgersControl(Real alpha = 1.e-4, int nx = 128) : alpha_(alpha), nx_(nx) {
238 dx_ = 1.0/((Real)nx+1.0);
239 }
240
241 void solve_state(std::vector<Real> &u, const std::vector<Real> &z, const std::vector<Real> &param) {
242 u.clear();
243 u.resize(this->nx_,1.0);
244 this->run_newton(u,z,param);
245 }
246
247 void solve_adjoint(std::vector<Real> &p, const std::vector<Real> &u, const std::vector<Real> &param) {
248 // Initialize State Storage
249 p.clear();
250 p.resize(this->nx_);
251 // Get PDE Jacobian
252 std::vector<Real> d(this->nx_,0.0);
253 std::vector<Real> du(this->nx_-1,0.0);
254 std::vector<Real> dl(this->nx_-1,0.0);
255 this->compute_pde_jacobian(dl,d,du,u,param);
256 // Get Right Hand Side
257 std::vector<Real> r(this->nx_,0.0);
258 std::vector<Real> diff(this->nx_,0.0);
259 for (int i=0; i<this->nx_; i++) {
260 diff[i] = -(u[i]-this->evaluate_target((Real)(i+1)*this->dx_));
261 }
262 this->apply_mass(r,diff);
263 // Solve solve adjoint system at current time step
264 this->linear_solve(p,dl,d,du,r,true);
265 }
266
267 void solve_state_sensitivity(std::vector<Real> &v, const std::vector<Real> &u,
268 const std::vector<Real> &z, const std::vector<Real> &param) {
269 // Initialize State Storage
270 v.clear();
271 v.resize(this->nx_);
272 // Get PDE Jacobian
273 std::vector<Real> d(this->nx_,0.0);
274 std::vector<Real> dl(this->nx_-1,0.0);
275 std::vector<Real> du(this->nx_-1,0.0);
276 this->compute_pde_jacobian(dl,d,du,u,param);
277 // Get Right Hand Side
278 std::vector<Real> r(this->nx_,0.0);
279 for (int i=0; i<this->nx_; i++) {
280 r[i] = this->dx_/6.0*(z[i]+4.0*z[i+1]+z[i+2]);
281 }
282 // Solve solve state sensitivity system at current time step
283 this->linear_solve(v,dl,d,du,r);
284 }
285
286 void solve_adjoint_sensitivity(std::vector<Real> &q, const std::vector<Real> &u,
287 const std::vector<Real> &p, const std::vector<Real> &v,
288 const std::vector<Real> &z, const std::vector<Real> &param) {
289 // Initialize State Storage
290 q.clear();
291 q.resize(this->nx_);
292 // Get PDE Jacobian
293 std::vector<Real> d(this->nx_,0.0);
294 std::vector<Real> dl(this->nx_-1,0.0);
295 std::vector<Real> du(this->nx_-1,0.0);
296 this->compute_pde_jacobian(dl,d,du,u,param);
297 // Get Right Hand Side
298 std::vector<Real> r(this->nx_,0.0);
299 this->apply_mass(r,v);
300 this->scale(r,-1.0);
301 this->add_pde_hessian(r,u,p,v,-1.0);
302 // Solve Tridiagonal System Using LAPACK's SPD Tridiagonal Solver
303 this->linear_solve(q,dl,d,du,r,true);
304 }
305
306 Real value( const ROL::Vector<Real> &z, Real &tol ) {
307 ROL::Ptr<const std::vector<Real> > zp =
308 dynamic_cast<const ROL::StdVector<Real>&>(z).getVector();
309 // SOLVE STATE EQUATION
310 std::vector<Real> param(4,0.0);
311 std::vector<Real> u;
312 this->solve_state(u,*zp,param);
313 // COMPUTE RESIDUAL
314 Real val = this->alpha_*0.5*this->dot(*zp,*zp);
315 Real res = 0.0, res1 = 0.0, res2 = 0.0, res3 = 0.0;
316 for (int i=0; i<this->nx_; i++) {
317 if ( i == 0 ) {
318 res1 = u[i]-evaluate_target((Real)(i+1)*this->dx_);
319 res2 = u[i+1]-evaluate_target((Real)(i+2)*this->dx_);
320 res = this->dx_/6.0*(4.0*res1 + res2)*res1;
321 }
322 else if ( i == this->nx_-1 ) {
323 res1 = u[i-1]-evaluate_target((Real)i*this->dx_);
324 res2 = u[i]-evaluate_target((Real)(i+1)*this->dx_);
325 res = this->dx_/6.0*(res1 + 4.0*res2)*res2;
326 }
327 else {
328 res1 = u[i-1]-evaluate_target((Real)i*this->dx_);
329 res2 = u[i]-evaluate_target((Real)(i+1)*this->dx_);
330 res3 = u[i+1]-evaluate_target((Real)(i+2)*this->dx_);
331 res = this->dx_/6.0*(res1 + 4.0*res2 + res3)*res2;
332 }
333 val += 0.5*res;
334 }
335 return val;
336 }
337
338 void gradient( ROL::Vector<Real> &g, const ROL::Vector<Real> &z, Real &tol ) {
339 ROL::Ptr<const std::vector<Real> > zp =
340 dynamic_cast<const ROL::StdVector<Real>&>(z).getVector();
341 ROL::Ptr<std::vector<Real> > gp =
342 dynamic_cast<ROL::StdVector<Real>&>(g).getVector();
343 // SOLVE STATE EQUATION
344 std::vector<Real> param(4,0.0);
345 std::vector<Real> u;
346 this->solve_state(u,*zp,param);
347 // SOLVE ADJOINT EQUATION
348 std::vector<Real> p;
349 this->solve_adjoint(p,u,param);
350 // COMPUTE GRADIENT
351 for (int i=0; i<this->nx_+2; i++) {
352 if (i==0) {
353 (*gp)[i] = this->alpha_*this->dx_/6.0*(2.0*(*zp)[i]+(*zp)[i+1]);
354 (*gp)[i] -= this->dx_/6.0*(p[i]);
355 }
356 else if (i==this->nx_+1) {
357 (*gp)[i] = this->alpha_*this->dx_/6.0*(2.0*(*zp)[i]+(*zp)[i-1]);
358 (*gp)[i] -= this->dx_/6.0*(p[i-2]);
359 }
360 else {
361 (*gp)[i] = this->alpha_*this->dx_/6.0*((*zp)[i-1]+4.0*(*zp)[i]+(*zp)[i+1]);
362 if (i==1) {
363 (*gp)[i] -= this->dx_/6.0*(4.0*p[i-1]+p[i]);
364 }
365 else if (i==this->nx_) {
366 (*gp)[i] -= this->dx_/6.0*(4.0*p[i-1]+p[i-2]);
367 }
368 else {
369 (*gp)[i] -= this->dx_/6.0*(p[i-2]+4.0*p[i-1]+p[i]);
370 }
371 }
372 }
373 }
374
375 void hessVec( ROL::Vector<Real> &hv, const ROL::Vector<Real> &v, const ROL::Vector<Real> &z, Real &tol ) {
376 ROL::Ptr<const std::vector<Real> > zp =
377 dynamic_cast<const ROL::StdVector<Real>&>(z).getVector();
378 ROL::Ptr<const std::vector<Real> > vp =
379 dynamic_cast<const ROL::StdVector<Real>&>(v).getVector();
380 ROL::Ptr<std::vector<Real> > hvp =
381 dynamic_cast<ROL::StdVector<Real>&>(hv).getVector();
382 // SOLVE STATE EQUATION
383 std::vector<Real> param(4,0.0);
384 std::vector<Real> u;
385 this->solve_state(u,*zp,param);
386 // SOLVE ADJOINT EQUATION
387 std::vector<Real> p;
388 this->solve_adjoint(p,u,param);
389 // SOLVE STATE SENSITIVITY EQUATION
390 std::vector<Real> s;
391 this->solve_state_sensitivity(s,u,*vp,param);
392 // SOLVE ADJOINT SENSITIVITY EQUATION
393 std::vector<Real> q;
394 this->solve_adjoint_sensitivity(q,u,p,s,*vp,param);
395 // COMPUTE HESSVEC
396 for (int i=0; i<this->nx_+2; i++) {
397 if (i==0) {
398 (*hvp)[i] = this->alpha_*this->dx_/6.0*(2.0*(*vp)[i]+(*vp)[i+1]);
399 (*hvp)[i] -= this->dx_/6.0*(q[i]);
400 }
401 else if (i==this->nx_+1) {
402 (*hvp)[i] = this->alpha_*this->dx_/6.0*(2.0*(*vp)[i]+(*vp)[i-1]);
403 (*hvp)[i] -= this->dx_/6.0*(q[i-2]);
404 }
405 else {
406 (*hvp)[i] = this->alpha_*this->dx_/6.0*((*vp)[i-1]+4.0*(*vp)[i]+(*vp)[i+1]);
407 if (i==1) {
408 (*hvp)[i] -= this->dx_/6.0*(4.0*q[i-1]+q[i]);
409 }
410 else if (i==this->nx_) {
411 (*hvp)[i] -= this->dx_/6.0*(4.0*q[i-1]+q[i-2]);
412 }
413 else {
414 (*hvp)[i] -= this->dx_/6.0*(q[i-2]+4.0*q[i-1]+q[i]);
415 }
416 }
417 }
418 }
419};
420
421template<class Real>
423private:
424 int dim_;
425 std::vector<Real> x_lo_;
426 std::vector<Real> x_up_;
428public:
430 x_lo_.resize(dim_,0.0);
431 x_up_.resize(dim_,1.0);
432 }
433 bool isFeasible( const ROL::Vector<Real> &x ) {
434 ROL::Ptr<const std::vector<Real> > ex =
435 dynamic_cast<const ROL::StdVector<Real>&>(x).getVector();
436 bool val = true;
437 int cnt = 1;
438 for ( int i = 0; i < this->dim_; i++ ) {
439 if ( (*ex)[i] >= this->x_lo_[i] && (*ex)[i] <= this->x_up_[i] ) { cnt *= 1; }
440 else { cnt *= 0; }
441 }
442 if ( cnt == 0 ) { val = false; }
443 return val;
444 }
446 ROL::Ptr<std::vector<Real> > ex =
447 dynamic_cast<ROL::StdVector<Real>&>(x).getVector();
448 for ( int i = 0; i < this->dim_; i++ ) {
449 (*ex)[i] = std::max(this->x_lo_[i],std::min(this->x_up_[i],(*ex)[i]));
450 }
451 }
452 void pruneLowerActive(ROL::Vector<Real> &v, const ROL::Vector<Real> &x, Real eps = Real(0)) {
453 ROL::Ptr<const std::vector<Real> > ex =
454 dynamic_cast<const ROL::StdVector<Real>&>(x).getVector();
455 ROL::Ptr<std::vector<Real> > ev =
456 dynamic_cast<ROL::StdVector<Real>&>(v).getVector();
457 Real epsn = std::min(eps,this->min_diff_);
458 for ( int i = 0; i < this->dim_; i++ ) {
459 if ( ((*ex)[i] <= this->x_lo_[i]+epsn) ) {
460 (*ev)[i] = 0.0;
461 }
462 }
463 }
464 void pruneUpperActive(ROL::Vector<Real> &v, const ROL::Vector<Real> &x, Real eps = Real(0)) {
465 ROL::Ptr<const std::vector<Real> > ex =
466 dynamic_cast<const ROL::StdVector<Real>&>(x).getVector();
467 ROL::Ptr<std::vector<Real> > ev =
468 dynamic_cast<ROL::StdVector<Real>&>(v).getVector();
469 Real epsn = std::min(eps,this->min_diff_);
470 for ( int i = 0; i < this->dim_; i++ ) {
471 if ( ((*ex)[i] >= this->x_up_[i]-epsn) ) {
472 (*ev)[i] = 0.0;
473 }
474 }
475 }
476 void pruneLowerActive(ROL::Vector<Real> &v, const ROL::Vector<Real> &g, const ROL::Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0)) {
477 ROL::Ptr<const std::vector<Real> > ex =
478 dynamic_cast<ROL::StdVector<Real>&>(x).getVector();
479 ROL::Ptr<const std::vector<Real> > eg =
480 dynamic_cast<const ROL::StdVector<Real>&>(g).getVector();
481 ROL::Ptr<std::vector<Real> > ev =
482 dynamic_cast<ROL::StdVector<Real>&>(v).getVector();
483 Real epsn = std::min(xeps,this->min_diff_);
484 for ( int i = 0; i < this->dim_; i++ ) {
485 if ( ((*ex)[i] <= this->x_lo_[i]+epsn && (*eg)[i] > geps) ){
486 (*ev)[i] = 0.0;
487 }
488 }
489 }
490 void pruneUpperActive(ROL::Vector<Real> &v, const ROL::Vector<Real> &g, const ROL::Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0)) {
491 ROL::Ptr<const std::vector<Real> > ex =
492 dynamic_cast<const ROL::StdVector<Real>&>(x).getVector();
493 ROL::Ptr<const std::vector<Real> > eg =
494 dynamic_cast<const ROL::StdVector<Real>&>(g).getVector();
495 ROL::Ptr<std::vector<Real> > ev =
496 dynamic_cast<ROL::StdVector<Real>&>(v).getVector();
497 Real epsn = std::min(xeps,this->min_diff_);
498 for ( int i = 0; i < this->dim_; i++ ) {
499 if ( ((*ex)[i] >= this->x_up_[i]-epsn && (*eg)[i] < -geps) ) {
500 (*ev)[i] = 0.0;
501 }
502 }
503 }
505 ROL::Ptr<std::vector<Real> > us = ROL::makePtr<std::vector<Real>>(this->dim_,0.0);
506 us->assign(this->x_up_.begin(),this->x_up_.end());
507 ROL::Ptr<ROL::Vector<Real> > up = ROL::makePtr<ROL::StdVector<Real>>(us);
508 u.set(*up);
509 }
511 ROL::Ptr<std::vector<Real> > ls = ROL::makePtr<std::vector<Real>>(this->dim_,0.0);
512 ls->assign(this->x_lo_.begin(),this->x_lo_.end());
513 ROL::Ptr<ROL::Vector<Real> > lp = ROL::makePtr<ROL::StdVector<Real>>(ls);
514 l.set(*lp);
515 }
516};
void setVectorToUpperBound(ROL::Vector< Real > &u)
void pruneLowerActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &g, const ROL::Vector< Real > &x, Real xeps=Real(0), Real geps=Real(0))
Set variables to zero if they correspond to the -binding set.
bool isFeasible(const ROL::Vector< Real > &x)
Check if the vector, v, is feasible.
void project(ROL::Vector< Real > &x)
Project optimization variables onto the bounds.
void setVectorToLowerBound(ROL::Vector< Real > &l)
void pruneUpperActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &g, const ROL::Vector< Real > &x, Real xeps=Real(0), Real geps=Real(0))
Set variables to zero if they correspond to the upper -binding set.
void pruneLowerActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the lower -active set.
void pruneUpperActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the upper -active set.
void compute_residual(std::vector< Real > &r, const std::vector< Real > &u, const std::vector< Real > &z, const std::vector< Real > &param)
Real value(const ROL::Vector< Real > &z, Real &tol)
Compute value.
Real dot(const std::vector< Real > &x, const std::vector< Real > &y)
void apply_mass(std::vector< Real > &Mu, const std::vector< Real > &u)
void compute_pde_jacobian(std::vector< Real > &dl, std::vector< Real > &d, std::vector< Real > &du, const std::vector< Real > &u, const std::vector< Real > &param)
void hessVec(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &z, Real &tol)
Apply Hessian approximation to vector.
void solve_adjoint_sensitivity(std::vector< Real > &q, const std::vector< Real > &u, const std::vector< Real > &p, const std::vector< Real > &v, const std::vector< Real > &z, const std::vector< Real > &param)
void update(std::vector< Real > &u, const std::vector< Real > &s, const Real alpha=1.0)
void solve_state_sensitivity(std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z, const std::vector< Real > &param)
void gradient(ROL::Vector< Real > &g, const ROL::Vector< Real > &z, Real &tol)
Compute gradient.
void solve_state(std::vector< Real > &u, const std::vector< Real > &z, const std::vector< Real > &param)
Objective_BurgersControl(Real alpha=1.e-4, int nx=128)
void add_pde_hessian(std::vector< Real > &r, const std::vector< Real > &u, const std::vector< Real > &p, const std::vector< Real > &s, Real alpha=1.0)
void scale(std::vector< Real > &u, const Real alpha=0.0)
void linear_solve(std::vector< Real > &u, std::vector< Real > &dl, std::vector< Real > &d, std::vector< Real > &du, const std::vector< Real > &r, const bool transpose=false)
Real compute_norm(const std::vector< Real > &r)
void run_newton(std::vector< Real > &u, const std::vector< Real > &z, const std::vector< Real > &param)
void solve_adjoint(std::vector< Real > &p, const std::vector< Real > &u, const std::vector< Real > &param)
Provides the interface to apply upper and lower bound constraints.
Provides the interface to evaluate objective functions.
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
Defines the linear algebra or vector space interface.
virtual void set(const Vector &x)
Set where .
constexpr auto dim