53 #include "Teuchos_GlobalMPISession.hpp"
60 int main(
int argc,
char *argv[]) {
63 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
66 int iprint = argc - 1;
67 ROL::Ptr<std::ostream> outStream;
70 outStream = ROL::makePtrFromRef(std::cout);
72 outStream = ROL::makePtrFromRef(bhs);
80 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",
"Trust Region");
90 ROL::Ptr<ROL::Vector<RealT> > x0;
91 std::vector<ROL::Ptr<ROL::Vector<RealT> > > z;
92 ROL::Ptr<ROL::OptimizationProblem<RealT> > problem;
93 ROL::GetTestProblem<RealT>(problem,x0,z,prob);
96 parlist->sublist(
"Step").sublist(
"Line Search").set(
"Initial Step Size",1.e-4);
97 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Initial Radius",-1.e1);
98 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Safeguard Size",1.e-4);
99 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-6);
102 parlist->sublist(
"Step").sublist(
"Line Search").set(
"Initial Step Size",1.0);
103 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Initial Radius",1.e3);
104 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Safeguard Size",1.e4);
105 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-8);
108 parlist->sublist(
"Step").sublist(
"Line Search").set(
"Initial Step Size",1.0);
109 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Initial Radius",-1.e1);
110 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Safeguard Size",1.e4);
111 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-6);
113 parlist->sublist(
"General").set(
"Scale for Epsilon Active Sets",1.0);
115 parlist->sublist(
"General").set(
"Scale for Epsilon Active Sets",1.e-2);
120 int dim = x0->dimension();
121 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 2*dim);
124 ROL::Ptr<ROL::Vector<RealT> > e = x0->clone();
127 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Subproblem Solver",
"Lin-More");
128 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Subproblem Model",
"Lin-More");
129 *outStream << std::endl << std::endl <<
"Lin-More" << std::endl << std::endl;
135 solver.
solve(*outStream);
139 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
146 err = std::min(err,e->norm());
149 *outStream << std::endl <<
"Norm of Error: " << err << std::endl;
153 catch (std::logic_error& err) {
154 *outStream << err.what() << std::endl;
159 std::cout <<
"End Result: TEST FAILED" << std::endl;
161 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[])
int solve(const ROL::Ptr< StatusTest< Real > > &status=ROL::nullPtr, const bool combineStatus=true)
Solve optimization problem with no iteration output.