74 int main(
int argc,
char **argv) {
77 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
80 int iprint = argc - 1;
81 Teuchos::RCP<std::ostream> outStream;
82 Teuchos::oblackholestream bhs;
84 outStream = Teuchos::rcp(&std::cout,
false);
86 outStream = Teuchos::rcp(&bhs,
false);
90 Teuchos::ParameterList parlist;
91 Teuchos::ParameterList gplist;
93 std::string paramfile =
"parameters.xml";
94 Teuchos::updateParametersFromXmlFile(paramfile,Teuchos::Ptr<Teuchos::ParameterList>(&gplist));
96 int nx = gplist.get(
"Interior Grid Points",100);
97 RealT gnl = gplist.get(
"Nonlinearity Coefficient g",50.0);
100 RealT dx = 1.0/(nx+1);
103 Teuchos::RCP<std::vector<RealT> > xi_rcp = Teuchos::rcp(
new std::vector<RealT> (nx, 0.0) );
105 for(
int i=0; i<nx; ++i) {
106 (*xi_rcp)[i] =
RealT(i+1)/(nx+1);
110 Teuchos::RCP<std::vector<RealT> > V_rcp = Teuchos::rcp(
new std::vector<RealT> (nx, 0.0) );
111 for(
int i=0; i<nx; ++i) {
112 (*V_rcp)[i] = 100.0*pow((*xi_rcp)[i]-0.5,2);
118 Teuchos::RCP<std::vector<RealT> > psi_rcp = Teuchos::rcp(
new std::vector<RealT> (nx, 0.0) );
122 RealT sqrt30 = sqrt(30);
124 for (
int i=0; i<nx; i++) {
125 (*psi_rcp)[i] = sqrt30*(*xi_rcp)[i]*(1.0-(*xi_rcp)[i]);
131 Teuchos::RCP<std::vector<RealT> > c_rcp = Teuchos::rcp(
new std::vector<RealT> (1, 0.0) );
135 Teuchos::RCP<std::vector<RealT> > lam_rcp = Teuchos::rcp(
new std::vector<RealT> (1, 0.0) );
139 Teuchos::RCP<std::vector<RealT> > g_rcp = Teuchos::rcp(
new std::vector<RealT> (nx, 0.0) );
149 std::string stepname =
"Composite Step";
150 parlist.sublist(
"Step").sublist(stepname).sublist(
"Optimality System Solver").set(
"Nominal Relative Tolerance",1e-4);
151 parlist.sublist(
"Step").sublist(stepname).sublist(
"Optimality System Solver").set(
"Fix Tolerance",
true);
152 parlist.sublist(
"Step").sublist(stepname).sublist(
"Tangential Subproblem Solver").set(
"Iteration Limit",20);
153 parlist.sublist(
"Step").sublist(stepname).sublist(
"Tangential Subproblem Solver").set(
"Relative Tolerance",1e-2);
154 parlist.sublist(
"Step").sublist(stepname).set(
"Output Level",0);
155 parlist.sublist(
"Status Test").set(
"Gradient Tolerance",1.e-12);
156 parlist.sublist(
"Status Test").set(
"Constraint Tolerance",1.e-12);
157 parlist.sublist(
"Status Test").set(
"Step Tolerance",1.e-14);
158 parlist.sublist(
"Status Test").set(
"Iteration Limit",100);
162 algo.
run(psi, g, lam, c, obj, constr,
true, *outStream);
170 std::cout <<
"End Result: TEST FAILED\n";
172 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.
Teuchos::RCP< const AlgorithmState< Real > > getState(void) const
Provides the std::vector implementation of the ROL::Vector interface.
Provides an interface to run optimization algorithms.
int main(int argc, char **argv)