69 #include "Teuchos_GlobalMPISession.hpp" 70 #include "Teuchos_XMLParameterListHelpers.hpp" 74 int main(
int argc,
char *argv[]) {
76 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
79 int iprint = argc - 1;
80 ROL::Ptr<std::ostream> outStream;
83 outStream = ROL::makePtrFromRef(std::cout);
85 outStream = ROL::makePtrFromRef(bhs);
95 ROL::ParameterList parlist;
97 std::string jsonFileName(
"parameters.json");
98 parlist.setName(
"Imported from " + jsonFileName);
102 std::string stepname =
"Trust Region";
105 ROL::Ptr<ROL::Step<RealT> > step =
stepFactory.getStep(stepname, parlist);
108 RealT gtol = parlist.get(
"Gradient Tolerance",1e-12);
109 RealT stol = parlist.get(
"Step Tolerance",1e-14);
110 int maxit = parlist.get(
"Maximum Number of Iterations",100);
111 ROL::Ptr<ROL::StatusTest<RealT> > status = ROL::makePtr<ROL::StatusTest<RealT>>(gtol, stol, maxit);
115 ROL::Ptr<std::vector<RealT> > x_ptr = ROL::makePtr<std::vector<RealT>>(
dim, 1.0);
116 ROL::Ptr<std::vector<RealT> > k_ptr = ROL::makePtr<std::vector<RealT>>(
dim, 0.0);
119 ROL::Ptr<ROL::Vector<RealT> > k = ROL::makePtr<ROL::StdVector<RealT>>(k_ptr);
121 for(
int i=0;i<
dim;++i) {
128 algo.run(x, obj,
true, *outStream);
131 ROL::Ptr<std::vector<RealT> > xtrue_ptr = ROL::makePtr<std::vector<RealT>>(
dim, 0.0);
137 *outStream << std::scientific <<
"\n Absolute Error: " << abserr;
138 if ( abserr > sqrt(ROL::ROL_EPSILON<RealT>())) ) {
143 Teuchos::writeParameterListToXmlFile(parlist,
"parameters.xml");
146 catch (std::logic_error& err) {
147 *outStream << err.what() <<
"\n";
152 std::cout <<
"End Result: TEST FAILED\n";
154 std::cout <<
"End Result: TEST PASSED\n";
void axpy(const Real alpha, const Vector< Real > &x)
Compute where .
basic_nullstream< char, char_traits< char > > nullstream
void stepFactory(ROL::ParameterList &parlist, ROL::Ptr< ROL::Step< Real > > &step)
A minimalist step factory which specializes the Step Type depending on whether a Trust-Region or Line...
void JSON_Parameters(const std::string &jsonFileName, ROL::ParameterList &parlist)
Read a JSON file and store all parameters in a ROL::ParameterList. Checks for a key called "Algorithm...
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
int main(int argc, char *argv[])
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
Provides an interface to run optimization algorithms.
Contains definitions for the Zakharov function as evaluated using only the ROL::Vector interface...
Real norm() const
Returns where .