52 #include "Teuchos_oblackholestream.hpp" 53 #include "Teuchos_GlobalMPISession.hpp" 54 #include "Teuchos_XMLParameterListHelpers.hpp" 60 int main(
int argc,
char *argv[]) {
62 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
65 int iprint = argc - 1;
66 Teuchos::RCP<std::ostream> outStream;
67 Teuchos::oblackholestream bhs;
69 outStream = Teuchos::rcp(&std::cout,
false);
71 outStream = Teuchos::rcp(&bhs,
false);
79 std::string filename =
"input.xml";
80 Teuchos::RCP<Teuchos::ParameterList> parlist = Teuchos::rcp(
new Teuchos::ParameterList() );
81 Teuchos::updateParametersFromXmlFile( filename, parlist.ptr() );
82 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
true);
84 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
false);
91 Teuchos::RCP<ROL::Vector<RealT> > x0, z;
92 Teuchos::RCP<ROL::Objective<RealT> > obj;
93 Teuchos::RCP<ROL::BoundConstraint<RealT> > con;
94 ROL::getTestObjectives<RealT>(obj,con,x0,z,prob);
95 Teuchos::RCP<ROL::Vector<RealT> > x = x0->clone();
98 int dim = x0->dimension();
99 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 2*dim);
102 obj->checkGradient(*x0,*z);
103 obj->checkHessVec(*x0,*z);
106 Teuchos::RCP<ROL::Vector<RealT> > e = x0->clone();
111 parlist->sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method").set(
"Type",
ROL::EDescentToString(desc));
119 algo.
run(*x, *obj, *con,
true, *outStream);
124 *outStream << std::endl <<
"Norm of Error: " << e->norm() << std::endl;
127 catch (std::logic_error err) {
128 *outStream << err.what() << std::endl;
133 std::cout <<
"End Result: TEST FAILED" << std::endl;
135 std::cout <<
"End Result: TEST PASSED" << std::endl;
ETestOptProblem
Enumeration of test optimization problems.
Contains definitions of test objective functions.
int main(int argc, char *argv[])
std::string EDescentToString(EDescent tr)
std::string ETestOptProblemToString(ETestOptProblem to)
Provides an interface to run optimization algorithms.
virtual std::vector< std::string > run(Vector< Real > &x, Objective< Real > &obj, bool print=false, std::ostream &outStream=std::cout)
Run algorithm on unconstrained problems (Type-U). This is the primary Type-U interface.
EDescent
Enumeration of descent direction types.