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);
95 ROL::Ptr<std::vector<RealT> > x_ptr = ROL::makePtr<std::vector<RealT>>(dim, 0.0);
97 for (
int i=0; i<dim/2; i++) {
99 (*x_ptr)[2*i+1] = 1.0;
104 algo.
run(x, obj,
true, *outStream);
107 ROL::Ptr<std::vector<RealT> > xtrue_ptr = ROL::makePtr<std::vector<RealT>>(dim, 1.0);
114 *outStream << std::scientific <<
"\n Absolute Error: " << abserr;
115 *outStream << std::scientific <<
"\n Relative Error: " << relerr <<
"\n";
116 if ( relerr > sqrt(ROL::ROL_EPSILON<RealT>()) ) {
120 catch (std::logic_error err) {
121 *outStream << err.what() <<
"\n";
126 std::cout <<
"End Result: TEST FAILED\n";
128 std::cout <<
"End Result: TEST PASSED\n";
void axpy(const Real alpha, const Vector< Real > &x)
Compute where .
Rosenbrock's function.
virtual std::vector< std::string > run(Vector< Real > &x, Objective< Real > &obj, bool print=false, std::ostream &outStream=std::cout, bool printVectors=false, std::ostream &vectorStream=std::cout)
Run algorithm on unconstrained problems (Type-U). This is the primary Type-U interface.
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[])