55 #include "Teuchos_GlobalMPISession.hpp"
61 int main(
int argc,
char *argv[]) {
63 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
66 int iprint = argc - 1;
67 ROL::Ptr<std::ostream> outStream;
70 outStream = ROL::makePtrFromRef(std::cout);
72 outStream = ROL::makePtrFromRef(bhs);
80 ROL::Ptr<ROL::Vector<RealT> > x0;
81 std::vector<ROL::Ptr<ROL::Vector<RealT> > > z;
82 ROL::Ptr<ROL::OptimizationProblem<RealT> > problem;
85 std::string filename =
"input.xml";
87 auto parlist = ROL::getParametersFromXmlFile( filename );
88 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
true);
90 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
false);
97 parlist->sublist(
"Step").set(
"Type",
"Interior Point");
98 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Initial Barrier Penalty",mu);
99 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Minimum Barrier Penalty",1e-8);
100 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Barrier Penalty Reduction Factor",factor);
101 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Subproblem Iteration Limit",30);
103 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Optimality System Solver").set(
"Nominal Relative Tolerance",1.e-4);
104 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Optimality System Solver").set(
"Fix Tolerance",
true);
105 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Tangential Subproblem Solver").set(
"Iteration Limit",20);
106 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Tangential Subproblem Solver").set(
"Relative Tolerance",1e-2);
107 parlist->sublist(
"Step").sublist(
"Composite Step").set(
"Output Level",0);
109 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-12);
110 parlist->sublist(
"Status Test").set(
"Constraint Tolerance",1.e-8);
111 parlist->sublist(
"Status Test").set(
"Step Tolerance",1.e-8);
112 parlist->sublist(
"Status Test").set(
"Iteration Limit",100);
115 ROL::Ptr<ROL::Step<RealT>>
116 step = ROL::makePtr<ROL::InteriorPointStep<RealT>>(*parlist);
117 ROL::Ptr<ROL::StatusTest<RealT>>
118 status = ROL::makePtr<ROL::StatusTest<RealT>>(*parlist);
120 algo.
run(optProb,
true, *outStream);
123 ROL::Ptr<ROL::Vector<RealT> > e = x0->clone();
125 for (
int i = 0; i < static_cast<int>(z.size()); ++i) {
132 err = std::min(err,e->norm());
135 *outStream << std::endl <<
"Norm of Error: " << err << std::endl;
137 catch (std::logic_error& err) {
138 *outStream << err.what() << std::endl;
143 std::cout <<
"End Result: TEST FAILED" << std::endl;
145 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[])