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) );
83 parlist->set(
"Use Inexact Hessian-Times-A-Vector",
true);
85 parlist->set(
"Use Inexact Hessian-Times-A-Vector",
false);
89 RealT gtol = parlist->get(
"Gradient Tolerance",1.e-6);
90 RealT stol = parlist->get(
"Step Tolerance",1.e-12);
91 int maxit = parlist->get(
"Maximum Number of Iterations",100);
96 parlist->set(
"Initial Linesearch Parameter",1.e-4);
97 parlist->set(
"Initial Trust-Region Radius",-1.e1);
100 parlist->set(
"Initial Linesearch Parameter",1.0);
101 parlist->set(
"Initial Trust-Region Radius",-1.e3);
104 parlist->set(
"Initial Linesearch Parameter",1.0);
105 parlist->set(
"Initial Trust-Region Radius",-1.e1);
107 parlist->set(
"Scale for Epsilon Active Sets",1.0);
109 parlist->set(
"Scale for Epsilon Active Sets",1.e-2);
114 Teuchos::RCP<std::vector<RealT> > x0_rcp = Teuchos::rcp(
new std::vector<RealT> );
118 Teuchos::RCP<std::vector<RealT> > z_rcp = Teuchos::rcp(
new std::vector<RealT> );
122 Teuchos::RCP<ROL::Objective<RealT> > obj = Teuchos::null;
123 Teuchos::RCP<ROL::BoundConstraint<RealT> > con = Teuchos::null;
124 ROL::getTestObjectives<RealT>(obj,con,x0,z,prob);
127 int dim = Teuchos::rcp_const_cast<std::vector<RealT> >(
129 parlist->set(
"Maximum Number of Krylov Iterations", 2*dim);
138 Teuchos::RCP<std::vector<RealT> > x_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
143 Teuchos::RCP<std::vector<RealT> > e_rcp = Teuchos::rcp(
new std::vector<RealT> (dim, 0.0) );
162 std::vector<std::string> output = algo.
run(x, *obj, *con);
163 for (
unsigned i = 0; i < output.size(); i++ ) {
164 std::cout << output[i];
170 *outStream <<
"\nNorm of Error: " << e.
norm() <<
"\n";
173 catch (std::logic_error err) {
174 *outStream << err.what() <<
"\n";
179 std::cout <<
"End Result: TEST FAILED\n";
181 std::cout <<
"End Result: TEST PASSED\n";
ETestOptProblem
Enumeration of test optimization problems.
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.
std::string ETestOptProblemToString(ETestOptProblem to)
Provides an interface to check status of optimization algorithms.
int main(int argc, char *argv[])
void set(const Vector< Real > &x)
Set where .
ETrustRegion
Enumeration of trust-region solver types.
std::string ETrustRegionToString(ETrustRegion tr)
Provides the interface to compute optimization steps with trust regions.