21 #include "Teuchos_GlobalMPISession.hpp"
27 int main(
int argc,
char *argv[]) {
29 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
32 int iprint = argc - 1;
33 ROL::Ptr<std::ostream> outStream;
36 outStream = ROL::makePtrFromRef(std::cout);
38 outStream = ROL::makePtrFromRef(bhs);
46 ROL::Ptr<ROL::Vector<RealT> > x0;
47 std::vector<ROL::Ptr<ROL::Vector<RealT> > > z;
48 ROL::Ptr<ROL::OptimizationProblem<RealT> > problem;
51 std::string filename =
"input.xml";
53 auto parlist = ROL::getParametersFromXmlFile( filename );
54 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
true);
56 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
false);
63 parlist->sublist(
"Step").set(
"Type",
"Interior Point");
64 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Initial Barrier Penalty",mu);
65 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Minimum Barrier Penalty",1e-8);
66 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Barrier Penalty Reduction Factor",factor);
67 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Subproblem Iteration Limit",30);
69 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Optimality System Solver").set(
"Nominal Relative Tolerance",1.e-4);
70 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Optimality System Solver").set(
"Fix Tolerance",
true);
71 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Tangential Subproblem Solver").set(
"Iteration Limit",20);
72 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Tangential Subproblem Solver").set(
"Relative Tolerance",1e-2);
73 parlist->sublist(
"Step").sublist(
"Composite Step").set(
"Output Level",0);
75 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-12);
76 parlist->sublist(
"Status Test").set(
"Constraint Tolerance",1.e-8);
77 parlist->sublist(
"Status Test").set(
"Step Tolerance",1.e-8);
78 parlist->sublist(
"Status Test").set(
"Iteration Limit",100);
81 ROL::Ptr<ROL::Step<RealT>>
82 step = ROL::makePtr<ROL::InteriorPointStep<RealT>>(*parlist);
83 ROL::Ptr<ROL::StatusTest<RealT>>
84 status = ROL::makePtr<ROL::StatusTest<RealT>>(*parlist);
86 algo.
run(optProb,
true, *outStream);
89 ROL::Ptr<ROL::Vector<RealT> > e = x0->clone();
91 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
98 err = std::min(err,e->norm());
101 *outStream << std::endl <<
"Norm of Error: " << err << std::endl;
103 catch (std::logic_error& err) {
104 *outStream << err.what() << std::endl;
109 std::cout <<
"End Result: TEST FAILED" << std::endl;
111 std::cout <<
"End Result: TEST PASSED" << std::endl;
virtual std::vector< std::string > run(Vector< Real > &x, Objective< Real > &obj, bool print=false, std::ostream &outStream=std::cout, bool printVectors=false, std::ostream &vectorStream=std::cout)
Run algorithm on unconstrained problems (Type-U). This is the primary Type-U interface.
Contains definitions of test objective functions.
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
Provides an interface to run optimization algorithms.
basic_nullstream< char, char_traits< char >> nullstream
int main(int argc, char *argv[])