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) );
85 RealT gtol = parlist->get(
"Gradient Tolerance",1.e-6);
86 RealT stol = parlist->get(
"Step Tolerance",1.e-12);
87 int maxit = parlist->get(
"Maximum Number of Iterations",100);
95 Teuchos::RCP<std::vector<RealT> > x0_rcp = Teuchos::rcp(
new std::vector<RealT> );
99 Teuchos::RCP<std::vector<RealT> > z_rcp = Teuchos::rcp(
new std::vector<RealT> );
103 Teuchos::RCP<ROL::Objective<RealT> > obj = Teuchos::null;
104 ROL::getTestObjectives<RealT>(obj,x0,z,objFunc);
108 Teuchos::rcp_const_cast<std::vector<RealT> >((Teuchos::dyn_cast<
ROL::StdVector<RealT> >(x0)).getVector())->size();
109 parlist->set(
"Maximum Number of Krylov Iterations", 2*dim);
112 Teuchos::RCP<std::vector<RealT> > x_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
117 Teuchos::RCP<std::vector<RealT> > e_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
125 parlist->set(
"Use Secant Hessian-Times-A-Vector",
true);
128 parlist->set(
"Use Secant Hessian-Times-A-Vector",
false);
139 std::vector<std::string> output = algo.
run(x, *obj);
140 for (
unsigned i = 0; i < output.size(); i++ ) {
141 std::cout << output[i];
147 *outStream <<
"\nNorm of Error: " << e.
norm() <<
"\n";
151 catch (std::logic_error err) {
152 *outStream << err.what() <<
"\n";
157 std::cout <<
"End Result: TEST FAILED\n";
159 std::cout <<
"End Result: TEST PASSED\n";
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Contains definitions of test objective functions.
virtual void zero()
Set to zero vector.
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)
ETrustRegion
Enumeration of trust-region solver types.
std::string ETrustRegionToString(ETrustRegion tr)
int main(int argc, char *argv[])
Provides the interface to compute optimization steps with trust regions.