53 #include "Teuchos_GlobalMPISession.hpp"
60 int main(
int argc,
char *argv[]) {
62 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
65 int iprint = argc - 1;
66 ROL::Ptr<std::ostream> outStream;
69 outStream = ROL::makePtrFromRef(std::cout);
71 outStream = ROL::makePtrFromRef(bhs);
79 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);
88 parlist->sublist(
"General").sublist(
"Krylov").set(
"Type",
"Conjugate Residuals");
89 parlist->sublist(
"General").sublist(
"Krylov").set(
"Absolute Tolerance", 1.e-8);
90 parlist->sublist(
"General").sublist(
"Krylov").set(
"Relative Tolerance", 1.e-4);
91 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 50);
92 parlist->sublist(
"Step").set(
"Type",
"Primal Dual Active Set");
96 ROL::Ptr<ROL::Vector<RealT> > x0;
97 std::vector<ROL::Ptr<ROL::Vector<RealT> > > z;
98 ROL::Ptr<ROL::OptimizationProblem<RealT> > problem;
99 ROL::GetTestProblem<RealT>(problem,x0,z,prob);
109 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Step Tolerance",1.e-10);
110 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Gradient Tolerance",1.e-8);
111 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Iteration Limit",1);
112 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Dual Scaling",1.e8);
115 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Step Tolerance",1.e-10);
116 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Gradient Tolerance",1.e-8);
117 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Iteration Limit",10);
118 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Dual Scaling",1.e-2);
121 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Step Tolerance",1.e-10);
122 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Gradient Tolerance",1.e-8);
123 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Iteration Limit",10);
124 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Dual Scaling",1.e10);
127 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Step Tolerance",1.e-10);
128 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Gradient Tolerance",1.e-8);
129 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Iteration Limit",1);
130 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Dual Scaling",1.e-3);
133 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Step Tolerance",1.e-10);
134 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Relative Gradient Tolerance",1.e-8);
135 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Iteration Limit",1);
136 parlist->sublist(
"Step").sublist(
"Primal Dual Active Set").set(
"Dual Scaling",1.e0);
141 int dim = x0->dimension();
142 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 2*dim);
145 ROL::Ptr<ROL::Vector<RealT> > e = x0->clone();
152 solver.
solve(*outStream);
156 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
163 err = std::min(err,e->norm());
166 *outStream << std::endl <<
"Norm of Error: " << err << std::endl;
170 errorFlag += ((err < std::max(1.e-6*z[0]->norm(),1.e-8) || (state->gnorm < 1.e-6)) ? 0 : 1);
175 catch (std::logic_error& err) {
176 *outStream << err.what() << std::endl;
181 std::cout <<
"End Result: TEST FAILED" << std::endl;
183 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.
ROL::Ptr< const AlgorithmState< Real > > getAlgorithmState(void) const
Return the AlgorithmState.