74 int main(
int argc,
char **argv) {
77 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
80 int iprint = argc - 1;
81 ROL::Ptr<std::ostream> outStream;
84 outStream = ROL::makePtrFromRef(std::cout);
86 outStream = ROL::makePtrFromRef(bhs);
90 ROL::ParameterList parlist;
92 std::string paramfile =
"parameters.xml";
93 auto gplist = ROL::getParametersFromXmlFile( paramfile );
95 int nx = gplist ->
get(
"Interior Grid Points",100);
96 RealT gnl = gplist ->
get(
"Nonlinearity Coefficient g",50.0);
99 RealT dx = 1.0/(nx+1);
102 ROL::Ptr<std::vector<RealT> > xi_ptr = ROL::makePtr<std::vector<RealT>>(nx, 0.0);
104 for(
int i=0; i<nx; ++i) {
105 (*xi_ptr)[i] =
RealT(i+1)/(nx+1);
109 ROL::Ptr<std::vector<RealT> > V_ptr = ROL::makePtr<std::vector<RealT>>(nx, 0.0);
110 for(
int i=0; i<nx; ++i) {
111 (*V_ptr)[i] = 100.0*pow((*xi_ptr)[i]-0.5,2);
117 ROL::Ptr<std::vector<RealT> > psi_ptr = ROL::makePtr<std::vector<RealT>>(nx, 0.0);
121 RealT sqrt30 = sqrt(30);
123 for (
int i=0; i<nx; i++) {
124 (*psi_ptr)[i] = sqrt30*(*xi_ptr)[i]*(1.0-(*xi_ptr)[i]);
130 ROL::Ptr<std::vector<RealT> > c_ptr = ROL::makePtr<std::vector<RealT>>(1, 0.0);
134 ROL::Ptr<std::vector<RealT> > lam_ptr = ROL::makePtr<std::vector<RealT>>(1, 0.0);
138 ROL::Ptr<std::vector<RealT> > g_ptr = ROL::makePtr<std::vector<RealT>>(nx, 0.0);
148 std::string stepname =
"Composite Step";
149 parlist.sublist(
"Step").sublist(stepname).sublist(
"Optimality System Solver").set(
"Nominal Relative Tolerance",1e-4);
150 parlist.sublist(
"Step").sublist(stepname).sublist(
"Optimality System Solver").set(
"Fix Tolerance",
true);
151 parlist.sublist(
"Step").sublist(stepname).sublist(
"Tangential Subproblem Solver").set(
"Iteration Limit",20);
152 parlist.sublist(
"Step").sublist(stepname).sublist(
"Tangential Subproblem Solver").set(
"Relative Tolerance",1e-2);
153 parlist.sublist(
"Step").sublist(stepname).set(
"Output Level",0);
154 parlist.sublist(
"Status Test").set(
"Gradient Tolerance",1.e-12);
155 parlist.sublist(
"Status Test").set(
"Constraint Tolerance",1.e-12);
156 parlist.sublist(
"Status Test").set(
"Step Tolerance",1.e-14);
157 parlist.sublist(
"Status Test").set(
"Iteration Limit",100);
161 algo.
run(psi, g, lam, c, obj, constr,
true, *outStream);
169 std::cout <<
"End Result: TEST FAILED\n";
171 std::cout <<
"End Result: TEST PASSED\n";
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.
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
Provides an interface to run optimization algorithms.
ROL::Ptr< const AlgorithmState< Real > > getState(void) const
basic_nullstream< char, char_traits< char >> nullstream
int main(int argc, char *argv[])