ROL
poisson-inversion/example_02.cpp
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"
17#include "ROL_Bounds.hpp"
18#include "ROL_Algorithm.hpp"
21#include "ROL_StatusTest.hpp"
22#include "ROL_Types.hpp"
24#include "ROL_Stream.hpp"
25#include "ROL_LAPACK.hpp"
26
27
28#include "ROL_GlobalMPISession.hpp"
29
30#include <fstream>
31#include <iostream>
32#include <algorithm>
33
34template<class Real>
36
37 typedef std::vector<Real> vector;
40
41 typedef typename vector::size_type uint;
42
43
44private:
47
48 Real hu_;
49 Real hz_;
50
51 Real u0_;
52 Real u1_;
53
54 Real alpha_;
55
57 Teuchos::SerialDenseMatrix<int, Real> H_;
58
59 ROL::Ptr<const vector> getVector( const V& x ) {
60
61 return dynamic_cast<const SV&>(x).getVector();
62 }
63
64 ROL::Ptr<vector> getVector( V& x ) {
65
66 return dynamic_cast<SV&>(x).getVector();
67 }
68
69public:
70
71 /* CONSTRUCTOR */
72 Objective_PoissonInversion(int nz = 32, Real alpha = 1.e-4)
73 : nz_(nz), u0_(1.0), u1_(0.0), alpha_(alpha), useCorrection_(false) {
74 nu_ = nz_-1;
75 hu_ = 1.0/((Real)nu_+1.0);
76 hz_ = hu_;
77 }
78
79 void apply_mass(std::vector<Real> &Mz, const std::vector<Real> &z ) {
80 Mz.resize(nu_,0.0);
81 for (uint i=0; i<nu_; i++) {
82 if ( i == 0 ) {
83 Mz[i] = hu_/6.0*(2.0*z[i] + z[i+1]);
84 }
85 else if ( i == nu_-1 ) {
86 Mz[i] = hu_/6.0*(z[i-1] + 2.0*z[i]);
87 }
88 else {
89 Mz[i] = hu_/6.0*(z[i-1] + 4.0*z[i] + z[i+1]);
90 }
91 }
92 }
93
94 Real evaluate_target(Real x) {
95 return (x <= 0.5) ? 1.0 : 0.0;
96 }
97
98 void apply_linearized_control_operator( std::vector<Real> &Bd, const std::vector<Real> &z,
99 const std::vector<Real> &d, const std::vector<Real> &u,
100 bool addBC = true ) {
101 Bd.clear();
102 Bd.resize(nu_,0.0);
103 for (uint i = 0; i < nu_; i++) {
104 if ( i == 0 ) {
105 Bd[i] = 1.0/hu_*( u[i]*d[i] + (u[i]-u[i+1])*d[i+1] );
106 }
107 else if ( i == nu_-1 ) {
108 Bd[i] = 1.0/hu_*( (u[i]-u[i-1])*d[i] + u[i]*d[i+1] );
109 }
110 else {
111 Bd[i] = 1.0/hu_*( (u[i]-u[i-1])*d[i] + (u[i]-u[i+1])*d[i+1] );
112 }
113 }
114 if ( addBC ) {
115 Bd[ 0] -= u0_*d[ 0]/hu_;
116 Bd[nu_-1] -= u1_*d[nz_-1]/hu_;
117 }
118 }
119
120 void apply_transposed_linearized_control_operator( std::vector<Real> &Bd, const std::vector<Real> &z,
121 const std::vector<Real> &d, const std::vector<Real> &u,
122 bool addBC = true ) {
123 Bd.clear();
124 Bd.resize(nz_,0.0);
125 for (uint i = 0; i < nz_; i++) {
126 if ( i == 0 ) {
127 Bd[i] = 1.0/hu_*u[i]*d[i];
128 }
129 else if ( i == nz_-1 ) {
130 Bd[i] = 1.0/hu_*u[i-1]*d[i-1];
131 }
132 else {
133 Bd[i] = 1.0/hu_*( (u[i]-u[i-1])*(d[i]-d[i-1]) );
134 }
135 }
136 if ( addBC ) {
137 Bd[ 0] -= u0_*d[ 0]/hu_;
138 Bd[nz_-1] -= u1_*d[nu_-1]/hu_;
139 }
140 }
141
142 /* STATE AND ADJOINT EQUATION DEFINTIONS */
143 void solve_state_equation(std::vector<Real> &u, const std::vector<Real> &z) {
144 // Get Diagonal and Off-Diagonal Entries of PDE Jacobian
145 std::vector<Real> d(nu_,1.0);
146 std::vector<Real> o(nu_-1,1.0);
147 for ( uint i = 0; i < nu_; i++ ) {
148 d[i] = (z[i] + z[i+1])/hu_;
149 if ( i < nu_-1 ) {
150 o[i] *= -z[i+1]/hu_;
151 }
152 }
153 // Set right hand side
154 u.clear();
155 u.resize(nu_,0.0);
156 u[ 0] = z[ 0]/hu_ * u0_;
157 u[nu_-1] = z[nz_-1]/hu_ * u1_;
158 // Solve Tridiagonal System Using LAPACK's SPD Tridiagonal Solver
159 ROL::LAPACK<int,Real> lp;
160 int info;
161 int ldb = nu_;
162 int nhrs = 1;
163 lp.PTTRF(nu_,&d[0],&o[0],&info);
164 lp.PTTRS(nu_,nhrs,&d[0],&o[0],&u[0],ldb,&info);
165 }
166
167 void solve_adjoint_equation(std::vector<Real> &p, const std::vector<Real> &u, const std::vector<Real> &z) {
168 // Get Diagonal and Off-Diagonal Entries of PDE Jacobian
169 vector d(nu_,1.0);
170 vector o(nu_-1,1.0);
171 for ( uint i = 0; i < nu_; i++ ) {
172 d[i] = (z[i] + z[i+1])/hu_;
173 if ( i < nu_-1 ) {
174 o[i] *= -z[i+1]/hu_;
175 }
176 }
177 // Set right hand side
178 vector r(nu_,0.0);
179 for (uint i = 0; i < nu_; i++) {
180 r[i] = -(u[i]-evaluate_target((Real)(i+1)*hu_));
181 }
182 p.clear();
183 p.resize(nu_,0.0);
184 apply_mass(p,r);
185 // Solve Tridiagonal System Using LAPACK's SPD Tridiagonal Solver
186 ROL::LAPACK<int,Real> lp;
187 int info;
188 int ldb = nu_;
189 int nhrs = 1;
190 lp.PTTRF(nu_,&d[0],&o[0],&info);
191 lp.PTTRS(nu_,nhrs,&d[0],&o[0],&p[0],ldb,&info);
192 }
193
194 void solve_state_sensitivity_equation(std::vector<Real> &w, const std::vector<Real> &v,
195 const std::vector<Real> &u, const std::vector<Real> &z) {
196 // Get Diagonal and Off-Diagonal Entries of PDE Jacobian
197 vector d(nu_,1.0);
198 vector o(nu_-1,1.0);
199 for ( uint i = 0; i < nu_; i++ ) {
200 d[i] = (z[i] + z[i+1])/hu_;
201 if ( i < nu_-1 ) {
202 o[i] *= -z[i+1]/hu_;
203 }
204 }
205 // Set right hand side
206 w.clear();
207 w.resize(nu_,0.0);
209 // Solve Tridiagonal System Using LAPACK's SPD Tridiagonal Solver
210 ROL::LAPACK<int,Real> lp;
211 int info;
212 int ldb = nu_;
213 int nhrs = 1;
214 lp.PTTRF(nu_,&d[0],&o[0],&info);
215 lp.PTTRS(nu_,nhrs,&d[0],&o[0],&w[0],ldb,&info);
216 }
217
218 void solve_adjoint_sensitivity_equation(std::vector<Real> &q, const std::vector<Real> &w,
219 const std::vector<Real> &v, const std::vector<Real> &p,
220 const std::vector<Real> &u, const std::vector<Real> &z) {
221 // Get Diagonal and Off-Diagonal Entries of PDE Jacobian
222 vector d(nu_,1.0);
223 vector o(nu_-1,1.0);
224 for ( uint i = 0; i < nu_; i++ ) {
225 d[i] = (z[i] + z[i+1])/hu_;
226 if ( i < nu_-1 ) {
227 o[i] *= -z[i+1]/hu_;
228 }
229 }
230 // Set right hand side
231 q.clear();
232 q.resize(nu_,0.0);
233 apply_mass(q,w);
234 std::vector<Real> res(nu_,0.0);
235 apply_linearized_control_operator(res,z,v,p,false);
236 for (uint i = 0; i < nu_; i++) {
237 q[i] -= res[i];
238 }
239 // Solve Tridiagonal System Using LAPACK's SPD Tridiagonal Solver
240 ROL::LAPACK<int,Real> lp;
241 int info;
242 int ldb = nu_;
243 int nhrs = 1;
244 lp.PTTRF(nu_,&d[0],&o[0],&info);
245 lp.PTTRS(nu_,nhrs,&d[0],&o[0],&q[0],ldb,&info);
246 }
247
248 void update(const ROL::Vector<Real> &z, bool flag, int iter) {
249
250
251
252 if ( flag && useCorrection_ ) {
253 Real tol = std::sqrt(ROL::ROL_EPSILON<Real>());
254 H_.shape(nz_,nz_);
255 ROL::Ptr<V> e = z.clone();
256 ROL::Ptr<V> h = z.clone();
257 for ( uint i = 0; i < nz_; i++ ) {
258 e = z.basis(i);
259 hessVec_true(*h,*e,z,tol);
260 for ( uint j = 0; j < nz_; j++ ) {
261 e = z.basis(j);
262 (H_)(j,i) = e->dot(*h);
263 }
264 }
265 std::vector<vector> eigenvals = ROL::computeEigenvalues<Real>(H_);
266 std::sort((eigenvals[0]).begin(), (eigenvals[0]).end());
267 Real inertia = (eigenvals[0])[0];
268 Real correction = 0.0;
269 if ( inertia <= 0.0 ) {
270 correction = (1.0+std::sqrt(ROL::ROL_EPSILON<Real>()))*std::abs(inertia);
271 if ( inertia == 0.0 ) {
272 uint cnt = 0;
273 while ( eigenvals[0][cnt] == 0.0 ) {
274 cnt++;
275 }
276 correction = std::sqrt(ROL::ROL_EPSILON<Real>())*eigenvals[0][cnt];
277 if ( cnt == nz_-1 ) {
278 correction = 1.0;
279 }
280 }
281 for ( uint i = 0; i < nz_; i++ ) {
282 (H_)(i,i) += correction;
283 }
284 }
285 }
286 }
287
288 /* OBJECTIVE FUNCTION DEFINITIONS */
289 Real value( const ROL::Vector<Real> &z, Real &tol ) {
290
291
292 ROL::Ptr<const vector> zp = getVector(z);
293
294 // SOLVE STATE EQUATION
295 vector u(nu_,0.0);
297
298 // EVALUATE OBJECTIVE
299 Real val = 0.0;
300 for (uint i=0; i<nz_;i++) {
301 val += hz_*alpha_*0.5*(*zp)[i]*(*zp)[i];
302 }
303 Real res = 0.0;
304 Real res1 = 0.0;
305 Real res2 = 0.0;
306 Real res3 = 0.0;
307 for (uint i=0; i<nu_; i++) {
308 if ( i == 0 ) {
309 res1 = u[i]-evaluate_target((Real)(i+1)*hu_);
310 res2 = u[i+1]-evaluate_target((Real)(i+2)*hu_);
311 res = hu_/6.0*(2.0*res1 + res2)*res1;
312 }
313 else if ( i == nu_-1 ) {
314 res1 = u[i-1]-evaluate_target((Real)i*hu_);
315 res2 = u[i]-evaluate_target((Real)(i+1)*hu_);
316 res = hu_/6.0*(res1 + 2.0*res2)*res2;
317 }
318 else {
319 res1 = u[i-1]-evaluate_target((Real)i*hu_);
320 res2 = u[i]-evaluate_target((Real)(i+1)*hu_);
321 res3 = u[i+1]-evaluate_target((Real)(i+2)*hu_);
322 res = hu_/6.0*(res1 + 4.0*res2 + res3)*res2;
323 }
324 val += 0.5*res;
325 }
326 return val;
327 }
328
329 void gradient( ROL::Vector<Real> &g, const ROL::Vector<Real> &z, Real &tol ) {
330
331
332
333 ROL::Ptr<const vector> zp = getVector(z);
334 ROL::Ptr<vector> gp = getVector(g);
335
336 // SOLVE STATE EQUATION
337 vector u(nu_,0.0);
339
340 // SOLVE ADJOINT EQUATION
341 vector p(nu_,0.0);
342 solve_adjoint_equation(p,u,*zp);
343
344 // Apply Transpose of Linearized Control Operator
346 // Build Gradient
347 for ( uint i = 0; i < nz_; i++ ) {
348 (*gp)[i] += hz_*alpha_*(*zp)[i];
349 }
350 }
351
352 void hessVec( ROL::Vector<Real> &hv, const ROL::Vector<Real> &v, const ROL::Vector<Real> &z, Real &tol ) {
353 if ( useCorrection_ ) {
354 hessVec_inertia(hv,v,z,tol);
355 }
356 else {
357 hessVec_true(hv,v,z,tol);
358 }
359 }
360
361 void activateInertia(void) {
362 useCorrection_ = true;
363 }
364
365 void deactivateInertia(void) {
366 useCorrection_ = false;
367 }
368
369 void hessVec_true( ROL::Vector<Real> &hv, const ROL::Vector<Real> &v, const ROL::Vector<Real> &z, Real &tol ) {
370
371
372
373 ROL::Ptr<const vector> vp = getVector(v);
374 ROL::Ptr<const vector> zp = getVector(z);
375 ROL::Ptr<vector> hvp = getVector(hv);
376
377 // SOLVE STATE EQUATION
378 vector u(nu_,0.0);
380
381 // SOLVE ADJOINT EQUATION
382 vector p(nu_,0.0);
383 solve_adjoint_equation(p,u,*zp);
384
385 // SOLVE STATE SENSITIVITY EQUATION
386 vector w(nu_,0.0);
388 // SOLVE ADJOINT SENSITIVITY EQUATION
389 vector q(nu_,0.0);
390 solve_adjoint_sensitivity_equation(q,w,*vp,p,u,*zp);
391
392 // Apply Transpose of Linearized Control Operator
394
395 // Apply Transpose of Linearized Control Operator
396 std::vector<Real> tmp(nz_,0.0);
398 for (uint i=0; i < nz_; i++) {
399 (*hvp)[i] -= tmp[i];
400 }
401 // Regularization hessVec
402 for (uint i=0; i < nz_; i++) {
403 (*hvp)[i] += hz_*alpha_*(*vp)[i];
404 }
405 }
406
407 void hessVec_inertia( ROL::Vector<Real> &hv, const ROL::Vector<Real> &v, const ROL::Vector<Real> &z, Real &tol ) {
408
409
410 using ROL::constPtrCast;
411
412 ROL::Ptr<vector> hvp = getVector(hv);
413
414
415 ROL::Ptr<vector> vp = ROL::constPtrCast<vector>(getVector(v));
416
417 Teuchos::SerialDenseVector<int, Real> hv_teuchos(Teuchos::View, &((*hvp)[0]), static_cast<int>(nz_));
418 Teuchos::SerialDenseVector<int, Real> v_teuchos(Teuchos::View, &(( *vp)[0]), static_cast<int>(nz_));
419 hv_teuchos.multiply(Teuchos::NO_TRANS, Teuchos::NO_TRANS, 1.0, H_, v_teuchos, 0.0);
420 }
421
422};
423
424
425
426typedef double RealT;
427
428int main(int argc, char *argv[]) {
429
430 typedef std::vector<RealT> vector;
431 typedef ROL::Vector<RealT> V;
432 typedef ROL::StdVector<RealT> SV;
433
434 typedef typename vector::size_type luint;
435
436
437
438 ROL::GlobalMPISession mpiSession(&argc, &argv);
439
440 // This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
441 int iprint = argc - 1;
442 ROL::Ptr<std::ostream> outStream;
443 ROL::nullstream bhs; // outputs nothing
444 if (iprint > 0)
445 outStream = ROL::makePtrFromRef(std::cout);
446 else
447 outStream = ROL::makePtrFromRef(bhs);
448
449 int errorFlag = 0;
450
451 // *** Example body.
452
453 try {
454
455 luint dim = 128; // Set problem dimension.
456 RealT alpha = 1.e-6;
458
459 // Iteration vector.
460 ROL::Ptr<vector> x_ptr = ROL::makePtr<vector>(dim, 0.0);
461 ROL::Ptr<vector> y_ptr = ROL::makePtr<vector>(dim, 0.0);
462
463 // Set initial guess.
464 for (luint i=0; i<dim; i++) {
465 (*x_ptr)[i] = (RealT)rand()/(RealT)RAND_MAX + 1.e2;
466 (*y_ptr)[i] = (RealT)rand()/(RealT)RAND_MAX + 1.e2;
467 }
468
469 SV x(x_ptr);
470 SV y(y_ptr);
471
472 obj.checkGradient(x,y,true);
473 obj.checkHessVec(x,y,true);
474
475 ROL::Ptr<vector> l_ptr = ROL::makePtr<vector>(dim,1.0);
476 ROL::Ptr<vector> u_ptr = ROL::makePtr<vector>(dim,10.0);
477
478 ROL::Ptr<V> lo = ROL::makePtr<SV>(l_ptr);
479 ROL::Ptr<V> up = ROL::makePtr<SV>(u_ptr);
480
481 ROL::Bounds<RealT> icon(lo,up);
482
483 ROL::ParameterList parlist;
484
485 // Krylov parameters.
486 parlist.sublist("General").sublist("Krylov").set("Absolute Tolerance",1.e-8);
487 parlist.sublist("General").sublist("Krylov").set("Relative Tolerance",1.e-4);
488 parlist.sublist("General").sublist("Krylov").set("Iteration Limit",static_cast<int>(dim));
489 // PDAS parameters.
490 parlist.sublist("Step").sublist("Primal Dual Active Set").set("Relative Step Tolerance",1.e-8);
491 parlist.sublist("Step").sublist("Primal Dual Active Set").set("Relative Gradient Tolerance",1.e-6);
492 parlist.sublist("Step").sublist("Primal Dual Active Set").set("Iteration Limit", 10);
493 parlist.sublist("Step").sublist("Primal Dual Active Set").set("Dual Scaling",(alpha>0.0)?alpha:1.e-4);
494 parlist.sublist("General").sublist("Secant").set("Use as Hessian",true);
495 // Status test parameters.
496 parlist.sublist("Status Test").set("Gradient Tolerance",1.e-12);
497 parlist.sublist("Status Test").set("Step Tolerance",1.e-14);
498 parlist.sublist("Status Test").set("Iteration Limit",100);
499
500 ROL::Ptr<ROL::Step<RealT>> step;
501 ROL::Ptr<ROL::StatusTest<RealT>> status;
502
503 // Define algorithm.
504 step = ROL::makePtr<ROL::PrimalDualActiveSetStep<RealT>>(parlist);
505 status = ROL::makePtr<ROL::StatusTest<RealT>>(parlist);
506 ROL::Algorithm<RealT> algo(step,status,false);
507
508 x.zero();
509 obj.deactivateInertia();
510 algo.run(x,obj,icon,true,*outStream);
511
512 // Output control to file.
513 std::ofstream file;
514 file.open("control_PDAS.txt");
515 for ( luint i = 0; i < dim; i++ ) {
516 file << (*x_ptr)[i] << "\n";
517 }
518 file.close();
519
520 // Projected Newtion.
521 // Define step.
522 parlist.sublist("General").sublist("Secant").set("Use as Hessian",false);
523 parlist.sublist("Step").sublist("Trust Region").set("Subproblem Solver", "Truncated CG");
524 parlist.sublist("Step").sublist("Trust Region").set("Initial Radius", 1e3);
525 parlist.sublist("Step").sublist("Trust Region").set("Maximum Radius", 1e8);
526 step = ROL::makePtr<ROL::TrustRegionStep<RealT>>(parlist);
527 status = ROL::makePtr<ROL::StatusTest<RealT>>(parlist);
528 ROL::Algorithm<RealT> algo_tr(step,status,false);
529 // Run Algorithm
530 y.zero();
531 obj.deactivateInertia();
532 algo_tr.run(y,obj,icon,true,*outStream);
533
534 std::ofstream file_tr;
535 file_tr.open("control_TR.txt");
536 for ( luint i = 0; i < dim; i++ ) {
537 file_tr << (*y_ptr)[i] << "\n";
538 }
539 file_tr.close();
540
541 std::vector<RealT> u;
542 obj.solve_state_equation(u,*y_ptr);
543 std::ofstream file_u;
544 file_u.open("state.txt");
545 for ( luint i = 0; i < (dim-1); i++ ) {
546 file_u << u[i] << "\n";
547 }
548 file_u.close();
549
550 ROL::Ptr<V> diff = x.clone();
551 diff->set(x);
552 diff->axpy(-1.0,y);
553 RealT error = diff->norm()/std::sqrt((RealT)dim-1.0);
554 std::cout << "\nError between PDAS solution and TR solution is " << error << "\n";
555 errorFlag = ((error > 1.e2*std::sqrt(ROL::ROL_EPSILON<RealT>())) ? 1 : 0);
556
557 }
558 catch (std::logic_error& err) {
559 *outStream << err.what() << "\n";
560 errorFlag = -1000;
561 }; // end try
562
563 if (errorFlag != 0)
564 std::cout << "End Result: TEST FAILED\n";
565 else
566 std::cout << "End Result: TEST PASSED\n";
567
568 return 0;
569
570}
571
Vector< Real > V
Contains definitions for helper functions in ROL.
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
Contains definitions of custom data types in ROL.
void solve_state_sensitivity_equation(std::vector< Real > &w, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z)
Teuchos::SerialDenseMatrix< int, Real > H_
void solve_state_equation(std::vector< Real > &u, const std::vector< Real > &z)
void solve_adjoint_equation(std::vector< Real > &p, const std::vector< Real > &u, const std::vector< Real > &z)
void update(const ROL::Vector< Real > &z, bool flag, int iter)
Update objective function.
void hessVec(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &z, Real &tol)
Apply Hessian approximation to vector.
void hessVec_inertia(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &z, Real &tol)
ROL::Ptr< const vector > getVector(const V &x)
void apply_transposed_linearized_control_operator(std::vector< Real > &Bd, const std::vector< Real > &z, const std::vector< Real > &d, const std::vector< Real > &u, bool addBC=true)
void hessVec_true(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &z, Real &tol)
Real value(const ROL::Vector< Real > &z, Real &tol)
Compute value.
Objective_PoissonInversion(int nz=32, Real alpha=1.e-4)
void gradient(ROL::Vector< Real > &g, const ROL::Vector< Real > &z, Real &tol)
Compute gradient.
void apply_linearized_control_operator(std::vector< Real > &Bd, const std::vector< Real > &z, const std::vector< Real > &d, const std::vector< Real > &u, bool addBC=true)
void apply_mass(std::vector< Real > &Mz, const std::vector< Real > &z)
void solve_adjoint_sensitivity_equation(std::vector< Real > &q, const std::vector< Real > &w, const std::vector< Real > &v, const std::vector< Real > &p, const std::vector< Real > &u, const std::vector< Real > &z)
Provides an interface to run optimization algorithms.
Provides the elementwise interface to apply upper and lower bound constraints.
Provides the interface to evaluate objective functions.
virtual std::vector< std::vector< Real > > checkGradient(const Vector< Real > &x, const Vector< Real > &d, const bool printToStream=true, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
Finite-difference gradient check.
virtual std::vector< std::vector< Real > > checkHessVec(const Vector< Real > &x, const Vector< Real > &v, const bool printToStream=true, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
Finite-difference Hessian-applied-to-vector check.
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 ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual ROL::Ptr< Vector > basis(const int i) const
Return i-th basis vector.
int main(int argc, char *argv[])
constexpr auto dim