53 #include "Teuchos_oblackholestream.hpp"
54 #include "Teuchos_GlobalMPISession.hpp"
55 #include "Teuchos_XMLParameterListHelpers.hpp"
61 int main(
int argc,
char *argv[]) {
63 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
66 int iprint = argc - 1;
67 Teuchos::RCP<std::ostream> outStream;
68 Teuchos::oblackholestream bhs;
70 outStream = Teuchos::rcp(&std::cout,
false);
72 outStream = Teuchos::rcp(&bhs,
false);
80 std::string filename =
"input.xml";
81 Teuchos::RCP<Teuchos::ParameterList> parlist = Teuchos::rcp(
new Teuchos::ParameterList() );
82 Teuchos::updateParametersFromXmlFile( filename, Teuchos::Ptr<Teuchos::ParameterList>(&*parlist) );
83 parlist->set(
"Use Inexact Hessian-Times-A-Vector",
true);
85 parlist->set(
"Use Inexact Hessian-Times-A-Vector",
false);
89 RealT gtol = parlist->get(
"Gradient Tolerance",1.e-8);
90 RealT stol = parlist->get(
"Step Tolerance",1.e-12);
91 int maxit = parlist->get(
"Maximum Number of Iterations",1000);
97 Teuchos::RCP<std::vector<RealT> > x0_rcp = Teuchos::rcp(
new std::vector<RealT> );
101 Teuchos::RCP<std::vector<RealT> > z_rcp = Teuchos::rcp(
new std::vector<RealT> );
105 Teuchos::RCP<ROL::Objective<RealT> > obj = Teuchos::null;
109 int dim = Teuchos::rcp_const_cast<std::vector<RealT> >(
111 parlist->set(
"Maximum Number of Krylov Iterations", 2*dim);
114 Teuchos::RCP<std::vector<RealT> > x_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
119 Teuchos::RCP<std::vector<RealT> > e_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
136 std::vector<std::string> output = algo.
run(x, *obj);
137 for (
unsigned i = 0; i < output.size(); i++ ) {
138 std::cout << output[i];
144 *outStream <<
"\nNorm of Error: " << e.
norm() <<
"\n";
150 catch (std::logic_error err) {
151 *outStream << err.what() <<
"\n";
156 std::cout <<
"End Result: TEST FAILED\n";
158 std::cout <<
"End Result: TEST PASSED\n";
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Contains definitions of test objective functions.
ELineSearch
Enumeration of line-search types.
std::string EDescentToString(EDescent tr)
virtual void zero()
Set to zero vector.
Provides the interface to compute optimization steps with line search.
Real norm() const
Returns where .
Provides the std::vector implementation of the ROL::Vector interface.
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.
std::string ELineSearchToString(ELineSearch ls)
Provides an interface to check status of optimization algorithms.
void set(const Vector< Real > &x)
Set where .
std::string ETestObjectivesToString(ETestObjectives to)
int main(int argc, char *argv[])
EDescent
Enumeration of descent direction types.