88 int main(
int argc,
char **argv) {
92 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
95 int iprint = argc - 1;
96 Teuchos::RCP<std::ostream> outStream;
97 Teuchos::oblackholestream bhs;
99 outStream = Teuchos::rcp(&std::cout,
false);
101 outStream = Teuchos::rcp(&bhs,
false);
106 Teuchos::ParameterList parlist;
107 std::string paramfile =
"parameters.xml";
108 Teuchos::updateParametersFromXmlFile(paramfile,Teuchos::Ptr<Teuchos::ParameterList>(&parlist));
110 int nx = parlist.get(
"Interior Grid Points",100);
111 double gnl = parlist.get(
"Nonlinearity Coefficient g",50.0);
112 bool exactsolve = parlist.get(
"Solve Exact Augmented System",
false);
116 std::string input = argv[1];
117 std::transform(input.begin(), input.end(), input.begin(), ::tolower);
118 if(input==
"exactsolve") {
125 RealT dx = 1.0/(nx+1);
131 Teuchos::RCP<std::vector<RealT> > xi_rcp = Teuchos::rcp(
new std::vector<RealT> (nx, 0.0) );
133 for(
int i=0; i<nx; ++i) {
134 (*xi_rcp)[i] =
RealT(i+1)/(nx+1);
138 Teuchos::RCP<std::vector<RealT> > V_rcp = Teuchos::rcp(
new std::vector<RealT> (nx, 0.0) );
139 for(
int i=0; i<nx; ++i) {
140 (*V_rcp)[i] = 100.0*pow((*xi_rcp)[i]-0.5,2);
146 Teuchos::RCP<std::vector<RealT> > psi_rcp = Teuchos::rcp(
new std::vector<RealT> (nx, 0.0) );
150 double sqrt30 = sqrt(30);
152 for (
int i=0; i<nx; i++) {
153 (*psi_rcp)[i] = sqrt30*(*xi_rcp)[i]*(1.0-(*xi_rcp)[i]);
158 Teuchos::RCP<std::vector<RealT> > c_rcp = Teuchos::rcp(
new std::vector<RealT> (1, 0.0) );
162 Teuchos::RCP<std::vector<RealT> > lam_rcp = Teuchos::rcp(
new std::vector<RealT> (1, 0.0) );
166 Teuchos::RCP<std::vector<RealT> > g_rcp = Teuchos::rcp(
new std::vector<RealT> (nx, 0.0) );
178 parlist.set(
"Nominal SQP Optimality Solver Tolerance", 1.e-4);
179 parlist.set(
"Maximum Number of Krylov Iterations",80);
180 parlist.set(
"Absolute Krylov Tolerance",1e-4);
196 std::vector<std::string> output = algo.
run(psi, g, lam, c, obj, constr,
false);
198 for (
unsigned i = 0; i < output.size(); i++ ) {
199 *outStream << output[i];
207 std::cout <<
"End Result: TEST FAILED\n";
209 std::cout <<
"End Result: TEST PASSED\n";
Teuchos::RCP< const AlgorithmState< Real > > getState(void) const
Provides the std::vector implementation of the ROL::Vector interface.
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.
Implements the computation of optimization steps with composite-step trust-region SQP methods...
int main(int argc, char **argv)