52 #include "Teuchos_oblackholestream.hpp" 53 #include "Teuchos_GlobalMPISession.hpp" 54 #include "Teuchos_XMLParameterListHelpers.hpp" 60 int main(
int argc,
char *argv[]) {
62 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
65 int iprint = argc - 1;
66 Teuchos::RCP<std::ostream> outStream;
67 Teuchos::oblackholestream bhs;
69 outStream = Teuchos::rcp(&std::cout,
false);
71 outStream = Teuchos::rcp(&bhs,
false);
79 Teuchos::RCP<ROL::Vector<RealT> > x0, z;
80 Teuchos::RCP<ROL::Objective<RealT> > obj;
81 Teuchos::RCP<ROL::BoundConstraint<RealT> > con;
83 Teuchos::RCP<ROL::Vector<RealT> > x = x0->clone();;
86 std::string filename =
"input.xml";
87 Teuchos::RCP<Teuchos::ParameterList> parlist = Teuchos::rcp(
new Teuchos::ParameterList() );
88 Teuchos::updateParametersFromXmlFile( filename, parlist.ptr() );
89 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
true);
91 parlist->sublist(
"General").set(
"Inexact Hessian-Times-A-Vector",
false);
98 parlist->sublist(
"Step").set(
"Type",
"Interior Point");
99 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Initial Barrier Penalty",mu);
100 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Minimum Barrier Penalty",1e-8);
101 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Barrier Penalty Reduction Factor",factor);
102 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Subproblem Iteration Limit",30);
104 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Optimality System Solver").set(
"Nominal Relative Tolerance",1.e-4);
105 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Optimality System Solver").set(
"Fix Tolerance",
true);
106 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Tangential Subproblem Solver").set(
"Iteration Limit",20);
107 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Tangential Subproblem Solver").set(
"Relative Tolerance",1e-2);
108 parlist->sublist(
"Step").sublist(
"Composite Step").set(
"Output Level",0);
110 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-12);
111 parlist->sublist(
"Status Test").set(
"Constraint Tolerance",1.e-8);
112 parlist->sublist(
"Status Test").set(
"Step Tolerance",1.e-8);
113 parlist->sublist(
"Status Test").set(
"Iteration Limit",100);
118 algo.
run(optProb,
true, *outStream);
122 *outStream << std::endl <<
"Norm of Error: " << z->norm() << std::endl;
124 catch (std::logic_error err) {
125 *outStream << err.what() << std::endl;
130 std::cout <<
"End Result: TEST FAILED" << std::endl;
132 std::cout <<
"End Result: TEST PASSED" << std::endl;
Contains definitions of test objective functions.
int main(int argc, char *argv[])
Provides an interface to run optimization algorithms.
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.