17 #include "Teuchos_GlobalMPISession.hpp"
24 int main(
int argc,
char *argv[]) {
26 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
29 int iprint = argc - 1;
30 ROL::Ptr<std::ostream> outStream;
33 outStream = ROL::makePtrFromRef(std::cout);
35 outStream = ROL::makePtrFromRef(bhs);
42 std::string filename =
"input.xml";
44 auto parlist = ROL::getParametersFromXmlFile( filename );
47 ROL::Ptr<ROL::Vector<RealT> > x0;
48 std::vector<ROL::Ptr<ROL::Vector<RealT> > > z;
49 ROL::Ptr<ROL::OptimizationProblem<RealT> > optProblem;
50 ROL::Ptr<ROL::BoundConstraint<RealT> > bnd;
54 int dim = x0->dimension();
55 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 2*dim);
58 optProblem->check(*outStream);
61 ROL::Ptr<ROL::Vector<RealT> > e = x0->clone();
65 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",static_cast<RealT>(1e-6));
66 parlist->sublist(
"Step").set(
"Type",
"Moreau-Yosida Penalty");
68 optSolver.
solve(*outStream);
72 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
79 err = std::min(err,e->norm());
82 *outStream << std::endl <<
"Norm of Error: " << err << std::endl;
84 RealT tol =
static_cast<RealT>(1e-3)*std::max(z[0]->norm(),
static_cast<RealT>(1));
85 errorFlag += ((err < tol) ? 0 : 1);
87 catch (std::logic_error& err) {
88 *outStream << err.what() << std::endl;
93 std::cout <<
"End Result: TEST FAILED" << std::endl;
95 std::cout <<
"End Result: TEST PASSED" << std::endl;
Contains definitions of test objective functions.
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
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.