19 #include "Teuchos_GlobalMPISession.hpp"
26 int main(
int argc,
char *argv[]) {
29 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
32 int iprint = argc - 1;
33 ROL::Ptr<std::ostream> outStream;
36 outStream = ROL::makePtrFromRef(std::cout);
38 outStream = ROL::makePtrFromRef(bhs);
46 std::string filename =
"input.xml";
47 auto parlist = ROL::getParametersFromXmlFile( filename );
48 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
true);
50 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
false);
52 parlist->sublist(
"Step").set(
"Type",
"Trust Region");
56 ROL::Ptr<ROL::Vector<RealT> > x0;
57 std::vector<ROL::Ptr<ROL::Vector<RealT> > > z;
58 ROL::Ptr<ROL::OptimizationProblem<RealT> > problem;
59 ROL::GetTestProblem<RealT>(problem,x0,z,prob);
62 parlist->sublist(
"Step").sublist(
"Line Search").set(
"Initial Step Size",1.e-4);
63 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Initial Radius",-1.e1);
64 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Safeguard Size",1.e-4);
65 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-6);
68 parlist->sublist(
"Step").sublist(
"Line Search").set(
"Initial Step Size",1.0);
69 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Initial Radius",1.e3);
70 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Safeguard Size",1.e4);
71 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-8);
74 parlist->sublist(
"Step").sublist(
"Line Search").set(
"Initial Step Size",1.0);
75 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Initial Radius",-1.e1);
76 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Safeguard Size",1.e4);
77 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-6);
79 parlist->sublist(
"General").set(
"Scale for Epsilon Active Sets",1.0);
81 parlist->sublist(
"General").set(
"Scale for Epsilon Active Sets",1.e-2);
86 int dim = x0->dimension();
87 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 2*dim);
90 ROL::Ptr<ROL::Vector<RealT> > e = x0->clone();
93 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Subproblem Solver",
"Lin-More");
94 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Subproblem Model",
"Lin-More");
95 *outStream << std::endl << std::endl <<
"Lin-More" << std::endl << std::endl;
101 solver.
solve(*outStream);
105 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
112 err = std::min(err,e->norm());
115 *outStream << std::endl <<
"Norm of Error: " << err << std::endl;
119 catch (std::logic_error& err) {
120 *outStream << err.what() << std::endl;
125 std::cout <<
"End Result: TEST FAILED" << std::endl;
127 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...
basic_nullstream< char, std::char_traits< char >> nullstream
std::string ETestOptProblemToString(ETestOptProblem to)
Provides a simplified interface for solving a wide range of optimization problems.
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.