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() );
84 parlist->sublist(
"General").sublist(
"Secant").set(
"Inexact Hessian-Times-A-Vector",
true);
86 parlist->sublist(
"General").sublist(
"Secant").set(
"Inexact Hessian-Times-A-Vector",
false);
96 Teuchos::RCP<std::vector<RealT> > x0_rcp = Teuchos::rcp(
new std::vector<RealT> );
100 Teuchos::RCP<std::vector<RealT> > z_rcp = Teuchos::rcp(
new std::vector<RealT> );
104 Teuchos::RCP<ROL::Objective<RealT> > obj = Teuchos::null;
105 ROL::getTestObjectives<RealT>(obj,x0,z,objFunc);
109 Teuchos::rcp_const_cast<std::vector<RealT> >((Teuchos::dyn_cast<
ROL::StdVector<RealT> >(x0)).getVector())->size();
110 parlist->sublist(
"General").sublist(
"Krylov").set(
"Iteration Limit", 2*dim);
113 Teuchos::RCP<std::vector<RealT> > x_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
118 Teuchos::RCP<std::vector<RealT> > e_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
123 parlist->sublist(
"Step").sublist(
"Line Search").sublist(
"Descent Method").set(
"Type",
ROL::EDescentToString(desc));
141 algo.
run(x, *obj,
true, *outStream);
146 *outStream <<
"\nNorm of Error: " << e.
norm() <<
"\n";
152 catch (std::logic_error err) {
153 *outStream << err.what() <<
"\n";
158 std::cout <<
"End Result: TEST FAILED\n";
160 std::cout <<
"End Result: TEST PASSED\n";
int main(int argc, char *argv[])
void axpy(const Real alpha, const Vector< Real > &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.
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.
EDescent
Enumeration of descent direction types.