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(
"General").set(
"Inexact Hessian-Times-A-Vector",
true);
50 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
false);
54 parlist->sublist(
"General").sublist(
"Krylov").set(
"Type",
"Conjugate Residuals");
55 parlist->sublist(
"General").sublist(
"Krylov").set(
"Absolute Tolerance", 1.e-8);
56 parlist->sublist(
"General").sublist(
"Krylov").set(
"Relative Tolerance", 1.e-4);
57 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 50);
58 parlist->sublist(
"Step").set(
"Type",
"Primal Dual Active Set");
62 ROL::Ptr<ROL::Vector<RealT> > x0;
63 std::vector<ROL::Ptr<ROL::Vector<RealT> > > z;
64 ROL::Ptr<ROL::OptimizationProblem<RealT> > problem;
65 ROL::GetTestProblem<RealT>(problem,x0,z,prob);
75 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Step Tolerance",1.e-10);
76 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Gradient Tolerance",1.e-8);
77 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Iteration Limit",1);
78 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Dual Scaling",1.e8);
81 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Step Tolerance",1.e-10);
82 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Gradient Tolerance",1.e-8);
83 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Iteration Limit",10);
84 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Dual Scaling",1.e-2);
87 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Step Tolerance",1.e-10);
88 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Gradient Tolerance",1.e-8);
89 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Iteration Limit",10);
90 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Dual Scaling",1.e10);
93 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Step Tolerance",1.e-10);
94 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Gradient Tolerance",1.e-8);
95 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Iteration Limit",1);
96 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Dual Scaling",1.e-3);
99 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Step Tolerance",1.e-10);
100 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Gradient Tolerance",1.e-8);
101 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Iteration Limit",1);
102 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Dual Scaling",1.e0);
107 int dim = x0->dimension();
108 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 2*dim);
111 ROL::Ptr<ROL::Vector<RealT> > e = x0->clone();
118 solver.
solve(*outStream);
122 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
129 err = std::min(err,e->norm());
132 *outStream << std::endl <<
"Norm of Error: " << err << std::endl;
136 errorFlag += ((err < std::max(1.e-6*z[0]->norm(),1.e-8) || (state->gnorm < 1.e-6)) ? 0 : 1);
141 catch (std::logic_error& err) {
142 *outStream << err.what() << std::endl;
147 std::cout <<
"End Result: TEST FAILED" << std::endl;
149 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.
ROL::Ptr< const AlgorithmState< Real > > getAlgorithmState(void) const
Return the AlgorithmState.