55 #include "Teuchos_GlobalMPISession.hpp"
62 int main(
int argc,
char *argv[]) {
64 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
66 std::string filename =
"input.xml";
68 auto parlist = ROL::getParametersFromXmlFile( filename );
74 int iprint = argc - 1;
75 ROL::Ptr<std::ostream> outStream;
78 outStream = ROL::makePtrFromRef(std::cout);
80 outStream = ROL::makePtrFromRef(bhs);
84 oldFormatState.copyfmt(std::cout);
94 std::vector<ROL::Ptr<V> > sol;
95 ROL::Ptr<Opt> optProb;
97 SEC.
get( optProb, x, sol );
98 ROL::Ptr<V> error = x->clone();
102 optSolver.
solve(*outStream);
105 error->axpy(static_cast<RealT>(-1), *x);
106 RealT solnErr = error->norm();
108 *outStream <<
"Distance from true solution: " << solnErr <<
"\n";
110 errorFlag += (solnErr < static_cast<RealT>(1e-6)) ? 0 : 1;
112 catch (std::logic_error& err) {
113 *outStream << err.what() <<
"\n";
118 std::cout <<
"End Result: TEST FAILED\n";
120 std::cout <<
"End Result: TEST PASSED\n";
123 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...
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.
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.