56 #include "Teuchos_GlobalMPISession.hpp"
62 int main(
int argc,
char *argv[]) {
64 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
67 int iprint = argc - 1;
68 ROL::Ptr<std::ostream> outStream;
71 outStream = ROL::makePtrFromRef(std::cout);
73 outStream = ROL::makePtrFromRef(bhs);
85 ROL::ParameterList parlist;
86 parlist.sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method").set(
"Type",
"Newton-Krylov");
87 parlist.sublist(
"Status Test").set(
"Gradient Tolerance",1.e-12);
88 parlist.sublist(
"Status Test").set(
"Step Tolerance",1.e-14);
89 parlist.sublist(
"Status Test").set(
"Iteration Limit",100);
92 ROL::Ptr<ROL::Step<RealT>>
93 step = ROL::makePtr<ROL::LineSearchStep<RealT>>(parlist);
94 ROL::Ptr<ROL::StatusTest<RealT>>
95 status = ROL::makePtr<ROL::StatusTest<RealT>>(parlist);
99 ROL::Ptr<std::vector<RealT> > x_ptr = ROL::makePtr<std::vector<RealT>>(
dim, 0.0);
101 for (
int i=0; i<dim/2; i++) {
102 (*x_ptr)[2*i] = -1.2;
103 (*x_ptr)[2*i+1] = 1.0;
108 algo.run(x, obj,
true, *outStream);
111 ROL::Ptr<std::vector<RealT> > xtrue_ptr = ROL::makePtr<std::vector<RealT>>(
dim, 1.0);
118 *outStream << std::scientific <<
"\n Absolute Error: " << abserr;
119 *outStream << std::scientific <<
"\n Relative Error: " << relerr <<
"\n";
120 if ( relerr > sqrt(ROL::ROL_EPSILON<RealT>()) ) {
124 catch (std::logic_error& err) {
125 *outStream << err.what() <<
"\n";
130 std::cout <<
"End Result: TEST FAILED\n";
132 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[])