53 #include "Teuchos_GlobalMPISession.hpp"
61 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);
81 std::string filename =
"input.xml";
83 auto parlist = ROL::getParametersFromXmlFile( filename );
84 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
true);
86 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
false);
88 parlist->sublist(
"Step").set(
"Type",
"Trust Region");
92 ROL::Ptr<ROL::Vector<RealT> > x0;
93 std::vector<ROL::Ptr<ROL::Vector<RealT> > > z;
94 ROL::Ptr<ROL::OptimizationProblem<RealT> > problem;
95 ROL::GetTestProblem<RealT>(problem,x0,z,prob);
98 parlist->sublist(
"Step").sublist(
"Line Search").set(
"Initial Step Size",1.e-4);
99 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Initial Radius",-1.e1);
100 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Safeguard Size",1.e-4);
101 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-6);
104 parlist->sublist(
"Step").sublist(
"Line Search").set(
"Initial Step Size",1.0);
105 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Initial Radius",1.e3);
106 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Safeguard Size",1.e4);
107 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-8);
110 parlist->sublist(
"Step").sublist(
"Line Search").set(
"Initial Step Size",1.0);
111 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Initial Radius",-1.e1);
112 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Safeguard Size",1.e4);
113 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-6);
115 parlist->sublist(
"General").set(
"Scale for Epsilon Active Sets",1.0);
117 parlist->sublist(
"General").set(
"Scale for Epsilon Active Sets",1.e-2);
122 int dim = x0->dimension();
123 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 2*dim);
126 ROL::Ptr<ROL::Vector<RealT> > e = x0->clone();
141 solver.
solve(*outStream);
145 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
152 err = std::min(err,e->norm());
155 *outStream << std::endl <<
"Norm of Error: " << err << std::endl;
159 catch (std::logic_error err) {
160 *outStream << err.what() << std::endl;
165 std::cout <<
"End Result: TEST FAILED" << std::endl;
167 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)