19 #include "Teuchos_GlobalMPISession.hpp"
27 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);
47 std::string filename =
"input.xml";
49 auto parlist = ROL::getParametersFromXmlFile( filename );
50 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
true);
52 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
false);
54 parlist->sublist(
"Step").set(
"Type",
"Trust Region");
58 ROL::Ptr<ROL::Vector<RealT> > x0;
59 std::vector<ROL::Ptr<ROL::Vector<RealT> > > z;
60 ROL::Ptr<ROL::OptimizationProblem<RealT> > problem;
61 ROL::GetTestProblem<RealT>(problem,x0,z,prob);
64 parlist->sublist(
"Step").sublist(
"Line Search").set(
"Initial Step Size",1.e-4);
65 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Initial Radius",-1.e1);
66 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Safeguard Size",1.e-4);
67 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-6);
70 parlist->sublist(
"Step").sublist(
"Line Search").set(
"Initial Step Size",1.0);
71 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Initial Radius",1.e3);
72 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Safeguard Size",1.e4);
73 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-8);
76 parlist->sublist(
"Step").sublist(
"Line Search").set(
"Initial Step Size",1.0);
77 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Initial Radius",-1.e1);
78 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Safeguard Size",1.e4);
79 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-6);
81 parlist->sublist(
"General").set(
"Scale for Epsilon Active Sets",1.0);
83 parlist->sublist(
"General").set(
"Scale for Epsilon Active Sets",1.e-2);
88 int dim = x0->dimension();
89 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 2*dim);
92 ROL::Ptr<ROL::Vector<RealT> > e = x0->clone();
107 solver.
solve(*outStream);
111 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
118 err = std::min(err,e->norm());
121 *outStream << std::endl <<
"Norm of Error: " << err << std::endl;
125 catch (std::logic_error& err) {
126 *outStream << err.what() << std::endl;
131 std::cout <<
"End Result: TEST FAILED" << std::endl;
133 std::cout <<
"End Result: TEST PASSED" << std::endl;
ETestOptProblem
Enumeration of test optimization problems.
Contains definitions of test objective functions.
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
std::string ETestOptProblemToString(ETestOptProblem to)
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[])
ETrustRegion
Enumeration of trust-region solver types.
int solve(const ROL::Ptr< StatusTest< Real > > &status=ROL::nullPtr, const bool combineStatus=true)
Solve optimization problem with no iteration output.
std::string ETrustRegionToString(ETrustRegion tr)