53 #include "Teuchos_GlobalMPISession.hpp"
60 int main(
int argc,
char *argv[]) {
62 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
65 int iprint = argc - 1;
66 ROL::Ptr<std::ostream> outStream;
69 outStream = ROL::makePtrFromRef(std::cout);
71 outStream = ROL::makePtrFromRef(bhs);
79 std::string filename =
"input.xml";
81 auto parlist = ROL::getParametersFromXmlFile( filename );
82 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
true);
84 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
false);
86 parlist->sublist(
"Step").set(
"Type",
"Line Search");
91 parlist->sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method").set(
"Type",
ROL::EDescentToString(desc));
95 ROL::Ptr<ROL::Vector<RealT> > x0;
96 std::vector<ROL::Ptr<ROL::Vector<RealT> > > z;
97 ROL::Ptr<ROL::OptimizationProblem<RealT> > problem;
101 int dim = x0->dimension();
102 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 2*dim);
105 ROL::Ptr<ROL::Vector<RealT> > e = x0->clone();
109 parlist->sublist(
"Step").sublist(
"Line Search").sublist(
"Line-Search Method").set(
"Type",
ROL::ELineSearchToString(ls));
114 solver.
solve(*outStream);
118 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
125 err = std::min(err,e->norm());
128 *outStream << std::endl <<
"Norm of Error: " << err << std::endl;
133 catch (std::logic_error& err) {
134 *outStream << err.what() << std::endl;
139 std::cout <<
"End Result: TEST FAILED" << std::endl;
141 std::cout <<
"End Result: TEST PASSED" << std::endl;
Contains definitions of test objective functions.
ELineSearch
Enumeration of line-search types.
std::string EDescentToString(EDescent tr)
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
std::string ETestOptProblemToString(ETestOptProblem to)
std::string ELineSearchToString(ELineSearch ls)
Provides a simplified interface for solving a wide range of optimization problems.
basic_nullstream< char, char_traits< char >> nullstream
int main(int argc, char *argv[])
int solve(const ROL::Ptr< StatusTest< Real > > &status=ROL::nullPtr, const bool combineStatus=true)
Solve optimization problem with no iteration output.
EDescent
Enumeration of descent direction types.