21 #include "Teuchos_GlobalMPISession.hpp"
28 int main(
int argc,
char *argv[]) {
30 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
32 std::string filename =
"input.xml";
34 auto parlist = ROL::getParametersFromXmlFile( filename );
40 int iprint = argc - 1;
41 ROL::Ptr<std::ostream> outStream;
44 outStream = ROL::makePtrFromRef(std::cout);
46 outStream = ROL::makePtrFromRef(bhs);
50 oldFormatState.copyfmt(std::cout);
60 std::vector<ROL::Ptr<V> > sol;
61 ROL::Ptr<Opt> optProb;
63 SEC.
get( optProb, x, sol );
64 ROL::Ptr<V> error = x->clone();
68 optSolver.
solve(*outStream);
71 error->axpy(static_cast<RealT>(-1), *x);
72 RealT solnErr = error->norm();
74 *outStream <<
"Distance from true solution: " << solnErr <<
"\n";
76 errorFlag += (solnErr < static_cast<RealT>(1e-6)) ? 0 : 1;
78 catch (std::logic_error& err) {
79 *outStream << err.what() <<
"\n";
84 std::cout <<
"End Result: TEST FAILED\n";
86 std::cout <<
"End Result: TEST PASSED\n";
89 std::cout.copyfmt(oldFormatState);
Defines the linear algebra or vector space interface.
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
void get(Ptr< OptimizationProblem< Real >> &problem, Ptr< Vector< Real >> &x0, std::vector< Ptr< Vector< Real >>> &x) const
Contains definitions for the equality constrained NLP from Nocedal/Wright, 2nd edition, page 574, example 18.2; note the typo in reversing the initial guess and the solution.
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.