22 #include "Teuchos_GlobalMPISession.hpp"
28 int main(
int argc,
char *argv[]) {
30 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
33 int iprint = argc - 1;
34 ROL::Ptr<std::ostream> outStream;
37 outStream = ROL::makePtrFromRef(std::cout);
39 outStream = ROL::makePtrFromRef(bhs);
51 ROL::ParameterList parlist;
52 parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method").set(
"Type",
"Newton-Krylov");
53 parlist.sublist(
"Status Test").set(
"Gradient Tolerance",1.e-12);
54 parlist.sublist(
"Status Test").set(
"Step Tolerance",1.e-14);
55 parlist.sublist(
"Status Test").set(
"Iteration Limit",100);
58 ROL::Ptr<ROL::Step<RealT>>
59 step = ROL::makePtr<ROL::LineSearchStep<RealT>>(parlist);
60 ROL::Ptr<ROL::StatusTest<RealT>>
61 status = ROL::makePtr<ROL::StatusTest<RealT>>(parlist);
65 ROL::Ptr<std::vector<RealT> > x_ptr = ROL::makePtr<std::vector<RealT>>(
dim, 0.0);
67 for (
int i=0; i<dim/2; i++) {
69 (*x_ptr)[2*i+1] = 1.0;
74 algo.run(x, obj,
true, *outStream);
77 ROL::Ptr<std::vector<RealT> > xtrue_ptr = ROL::makePtr<std::vector<RealT>>(
dim, 1.0);
84 *outStream << std::scientific <<
"\n Absolute Error: " << abserr;
85 *outStream << std::scientific <<
"\n Relative Error: " << relerr <<
"\n";
86 if ( relerr > sqrt(ROL::ROL_EPSILON<RealT>()) ) {
90 catch (std::logic_error& err) {
91 *outStream << err.what() <<
"\n";
96 std::cout <<
"End Result: TEST FAILED\n";
98 std::cout <<
"End Result: TEST PASSED\n";
void axpy(const Real alpha, const Vector< Real > &x)
Compute where .
Rosenbrock's function.
Contains definitions for Rosenbrock's function.
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
Real norm() const
Returns where .
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
Provides an interface to run optimization algorithms.
basic_nullstream< char, char_traits< char >> nullstream
int main(int argc, char *argv[])