19 #include "Teuchos_GlobalMPISession.hpp"
26 int main(
int argc,
char *argv[]) {
28 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
31 int iprint = argc - 1;
32 ROL::Ptr<std::ostream> outStream;
35 outStream = ROL::makePtrFromRef(std::cout);
37 outStream = ROL::makePtrFromRef(bhs);
45 std::string filename =
"input.xml";
47 auto parlist = ROL::getParametersFromXmlFile( filename );
48 parlist->sublist(
"Step").set(
"Type",
"Trust Region");
55 ROL::Ptr<ROL::Vector<RealT> > x0;
56 std::vector<ROL::Ptr<ROL::Vector<RealT> > > z;
57 ROL::Ptr<ROL::OptimizationProblem<RealT> > problem;
58 ROL::GetTestProblem<RealT>(problem,x0,z,objFunc);
67 int dim = x0->dimension();
68 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 5*dim);
71 ROL::Ptr<ROL::Vector<RealT> > e = x0->clone();
75 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Subproblem Solver",
ETrustRegionToString(tr));
81 solver.
solve(*outStream);
85 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
92 err = std::min(err,e->norm());
95 *outStream << std::endl <<
"Norm of Error: " << err << std::endl;
101 catch (std::logic_error& err) {
102 *outStream << err.what() << std::endl;
107 std::cout <<
"End Result: TEST FAILED" << std::endl;
109 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)