67 #include "Teuchos_oblackholestream.hpp"
68 #include "Teuchos_GlobalMPISession.hpp"
69 #include "Teuchos_XMLParameterListHelpers.hpp"
73 int main(
int argc,
char *argv[]) {
75 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
78 int iprint = argc - 1;
79 Teuchos::RCP<std::ostream> outStream;
80 Teuchos::oblackholestream bhs;
82 outStream = Teuchos::rcp(&std::cout,
false);
84 outStream = Teuchos::rcp(&bhs,
false);
94 Teuchos::ParameterList parlist;
96 std::string jsonFileName(
"parameters.json");
97 parlist.setName(
"Imported from " + jsonFileName);
102 Teuchos::RCP<ROL::Step<RealT> > step;
103 ROL::stepFactory<RealT>(parlist,step);
106 RealT gtol = parlist.get(
"Gradient Tolerance",1e-12);
107 RealT stol = parlist.get(
"Step Tolerance",1e-14);
108 int maxit = parlist.get(
"Maximum Number of Iterations",100);
113 Teuchos::RCP<std::vector<RealT> > x_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 1.0) );
114 Teuchos::RCP<std::vector<RealT> > k_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
119 for(
int i=0;i<dim;++i) {
126 std::vector<std::string> output = algo.
run(x, obj,
false);
127 for (
unsigned i = 0; i < output.size(); i++ ) {
128 std::cout << output[i];
132 Teuchos::RCP<std::vector<RealT> > xtrue_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
138 *outStream << std::scientific <<
"\n Absolute Error: " << abserr;
144 Teuchos::writeParameterListToXmlFile(parlist,
"parameters.xml");
147 catch (std::logic_error err) {
148 *outStream << err.what() <<
"\n";
153 std::cout <<
"End Result: TEST FAILED\n";
155 std::cout <<
"End Result: TEST PASSED\n";
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
int main(int argc, char *argv[])
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.
Contains definitions for the Zakharov function as evaluated using only the ROL::Vector interface...
void JSON_Parameters(const std::string &jsonFileName, Teuchos::ParameterList &parlist)
Read a JSON file and store all parameters in a Teuchos::ParameterList. Checks for a key called "Algor...
static const double ROL_EPSILON
Platform-dependent machine epsilon.