14 #include "Teuchos_GlobalMPISession.hpp"
22 int main(
int argc,
char *argv[]) {
27 typedef std::vector<RealT> vec;
29 typedef ROL::Ptr<ROL::Vector<RealT> > ROL::PtrV;
34 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
36 int iprint = argc - 1;
37 ROL::Ptr<std::ostream> outStream;
40 outStream = ROL::makePtrFromRef(std::cout);
42 outStream = ROL::makePtrFromRef(bhs);
53 ROL::Ptr<vec> x_exact_ptr = ROL::makePtr<vec>(xopt_dim,0.0);
54 (*x_exact_ptr)[xopt_dim-1] = 1.0;
56 ROL::Ptr<vec> xopt_ptr = ROL::makePtr<vec>(xopt_dim,0.0);
58 ROL::Ptr<vec> le_ptr = ROL::makePtr<vec>(ce_dim,0.0);
59 ROL::Ptr<vec> li_ptr = ROL::makePtr<vec>(ci_dim,0.0);
66 ROL::PtrV xopt = ROL::makePtr<SV>(xopt_ptr);
67 ROL::PtrV le = ROL::makePtr<SV>(le_ptr);
68 ROL::PtrV li = ROL::makePtr<SV>(li_ptr);
74 ROL::Ptr<ROL::Objective<RealT> > obj_hs32 = ROL::makePtr<Objective_HS32<RealT>>();
75 ROL::Ptr<ROL::EqualityConstraint<RealT> > eqcon_hs32 = ROL::makePtr<EqualityConstraint_HS32<RealT>>();
76 ROL::Ptr<ROL::InequalityConstraint<RealT> > incon_hs32 = ROL::makePtr<InequalityConstraint_HS32<RealT>>();
79 std::string stepname =
"Interior Point";
85 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Initial Barrier Penalty",mu);
86 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Minimium Barrier Penalty",1e-8);
87 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Barrier Penalty Reduction Factor",factor);
88 parlist->sublist(
"Step").sublist(
"Interior Point").set(
"Subproblem Iteration Limit",30);
90 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Optimality System Solver").set(
"Nominal Relative Tolerance",1.e-4);
91 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Optimality System Solver").set(
"Fix Tolerance",
true);
92 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Tangential Subproblem Solver").set(
"Iteration Limit",20);
93 parlist->sublist(
"Step").sublist(
"Composite Step").sublist(
"Tangential Subproblem Solver").set(
"Relative Tolerance",1e-2);
94 parlist->sublist(
"Step").sublist(
"Composite Step").set(
"Output Level",0);
96 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-12);
97 parlist->sublist(
"Status Test").set(
"Constraint Tolerance",1.e-8);
98 parlist->sublist(
"Status Test").set(
"Step Tolerance",1.e-8);
99 parlist->sublist(
"Status Test").set(
"Iteration Limit",100);
104 ROL::Ptr<ROL::Algorithm<RealT> > algo;
105 algo = ROL::makePtr<ROL::Algorithm<RealT>>(stepname,*parlist);
107 algo->run(problem,
true,*outStream);
109 *outStream << std::endl << std::setw(20) <<
"Computed Minimizer" << std::setw(20) <<
"Exact Minimizer" << std::endl;
110 for(
int i=0;i<xopt_dim;++i ) {
111 *outStream << std::setw(20) << (*xopt_ptr)[i] << std::setw(20) << (*x_exact_ptr)[i] << std::endl;
114 catch (std::logic_error& err) {
115 *outStream << err.what() <<
"\n";
120 std::cout <<
"End Result: TEST FAILED\n";
122 std::cout <<
"End Result: TEST PASSED\n";
basic_nullstream< char, std::char_traits< char >> nullstream
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
Contains definitions for W. Hock and K. Schittkowski 32nd test problem which contains both inequality...
int main(int argc, char *argv[])