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 Teuchos::RCP<ROL::BoundConstraint<RealT> > con = Teuchos::null;
108 ROL::getTestObjectives<RealT>(obj,con,x0,z,prob);
112 Teuchos::rcp_const_cast<std::vector<RealT> >((Teuchos::dyn_cast<
ROL::StdVector<RealT> >(x0)).getVector())->size();
113 parlist->set(
"Maximum Number of Krylov Iterations", 2*dim);
116 Teuchos::RCP<std::vector<RealT> > d_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 1.0) );
118 obj->checkGradient(x0,d);
119 obj->checkHessVec(x0,d);
122 Teuchos::RCP<std::vector<RealT> > x_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
127 Teuchos::RCP<std::vector<RealT> > e_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
144 std::vector<std::string> output = algo.
run(x, *obj, *con);
145 for (
unsigned i = 0; i < output.size(); i++ ) {
146 std::cout << output[i];
152 *outStream <<
"\nNorm of Error: " << e.
norm() <<
"\n";
155 catch (std::logic_error err) {
156 *outStream << err.what() <<
"\n";
161 std::cout <<
"End Result: TEST FAILED\n";
163 std::cout <<
"End Result: TEST PASSED\n";
ETestOptProblem
Enumeration of test optimization problems.
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.
std::string ETestOptProblemToString(ETestOptProblem to)
Provides an interface to check status of optimization algorithms.
int main(int argc, char *argv[])
virtual void set(const Vector &x)
Set where .
EDescent
Enumeration of descent direction types.