54 #include "Teuchos_oblackholestream.hpp" 55 #include "Teuchos_GlobalMPISession.hpp" 56 #include "Teuchos_XMLParameterListHelpers.hpp" 62 int main(
int argc,
char *argv[]) {
64 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
67 int iprint = argc - 1;
68 Teuchos::RCP<std::ostream> outStream;
69 Teuchos::oblackholestream bhs;
71 outStream = Teuchos::rcp(&std::cout,
false);
73 outStream = Teuchos::rcp(&bhs,
false);
81 std::string filename =
"input.xml";
82 Teuchos::RCP<Teuchos::ParameterList> parlist = Teuchos::rcp(
new Teuchos::ParameterList() );
83 Teuchos::updateParametersFromXmlFile( filename, parlist.ptr() );
93 Teuchos::RCP<std::vector<RealT> > x0_rcp = Teuchos::rcp(
new std::vector<RealT> );
97 Teuchos::RCP<std::vector<RealT> > z_rcp = Teuchos::rcp(
new std::vector<RealT> );
101 Teuchos::RCP<ROL::Objective<RealT> > obj = Teuchos::null;
102 ROL::getTestObjectives<RealT>(obj,x0,z,objFunc);
106 Teuchos::rcp_const_cast<std::vector<RealT> >((Teuchos::dyn_cast<
ROL::StdVector<RealT> >(x0)).getVector())->size();
107 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 2*dim);
110 Teuchos::RCP<std::vector<RealT> > x_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
115 Teuchos::RCP<std::vector<RealT> > e_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
121 parlist->sublist(
"Step").sublist(
"Trust Region").set(
"Subproblem Solver",
ETrustRegionToString(tr));
123 parlist->sublist(
"General").sublist(
"Secant").set(
"Secant Hessian-Times-A-Vector",
true);
126 parlist->sublist(
"General").sublist(
"Secant").set(
"Secant Hessian-Times-A-Vector",
false);
137 algo.
run(x, *obj,
true, *outStream);
142 *outStream <<
"\nNorm of Error: " << e.
norm() <<
"\n";
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 .
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.
Provides an interface to run optimization algorithms.
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)
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.
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.