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-6);
90 RealT stol = parlist->get(
"Step Tolerance",1.e-12);
91 int maxit = parlist->get(
"Maximum Number of Iterations",100);
98 Teuchos::RCP<std::vector<RealT> > x0_rcp = Teuchos::rcp(
new std::vector<RealT> );
102 Teuchos::RCP<std::vector<RealT> > z_rcp = Teuchos::rcp(
new std::vector<RealT> );
106 Teuchos::RCP<ROL::Objective<RealT> > obj = Teuchos::null;
107 ROL::getTestObjectives<RealT>(obj,x0,z,objFunc);
111 Teuchos::rcp_const_cast<std::vector<RealT> >((Teuchos::dyn_cast<
ROL::StdVector<RealT> >(x0)).getVector())->size();
112 parlist->set(
"Maximum Number of Krylov Iterations", 2*dim);
115 Teuchos::RCP<std::vector<RealT> > x_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
120 Teuchos::RCP<std::vector<RealT> > e_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
143 std::vector<std::string> output = algo.
run(x, *obj);
144 for (
unsigned i = 0; i < output.size(); i++ ) {
145 std::cout << output[i];
151 *outStream <<
"\nNorm of Error: " << e.
norm() <<
"\n";
157 catch (std::logic_error err) {
158 *outStream << err.what() <<
"\n";
163 std::cout <<
"End Result: TEST FAILED\n";
165 std::cout <<
"End Result: TEST PASSED\n";
int main(int argc, char *argv[])
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Contains definitions of test objective functions.
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.
Provides an interface to check status of optimization algorithms.
ETestObjectives
Enumeration of test objective functions.
void set(const Vector< Real > &x)
Set where .
std::string ETestObjectivesToString(ETestObjectives to)
EDescent
Enumeration of descent direction types.