25 #include "Teuchos_GlobalMPISession.hpp"
31 int main(
int argc,
char *argv[]) {
33 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
44 int iprint = argc - 1;
45 ROL::Ptr<std::ostream> outStream;
48 outStream = ROL::makePtrFromRef(std::cout);
50 outStream = ROL::makePtrFromRef(bhs);
54 oldFormatState.copyfmt(std::cout);
58 RealT tol = std::sqrt(ROL::ROL_EPSILON<RealT>());
68 ROL::Ptr<V> x = ROL::makePtr<StdV>( ROL::makePtr<std::vector<RealT>>(xdim) );
69 ROL::Ptr<V> c = ROL::makePtr<StdV>( ROL::makePtr<std::vector<RealT>>(cdim));
70 ROL::Ptr<V> e0 = c->basis(0);
71 ROL::Ptr<V> e1 = c->basis(1);
72 ROL::Ptr<V> e2 = c->basis(2);
75 ROL::Ptr<V> sol = x->clone();
76 ROL::Ptr<V> error = x->clone();
78 ROL::Ptr<Obj> obj = ROL::nullPtr;
79 ROL::Ptr<Con> con = ROL::nullPtr;
90 ROL::Ptr<Obj> obj_0 = ROL::makePtr<ROL::ObjectiveFromConstraint<RealT>>( con, *e0 );
91 ROL::Ptr<Obj> obj_1 = ROL::makePtr<ROL::ObjectiveFromConstraint<RealT>>( con, *e1 );
92 ROL::Ptr<Obj> obj_2 = ROL::makePtr<ROL::ObjectiveFromConstraint<RealT>>( con, *e2 );
95 ROL::Ptr<Con> con_0 = ROL::makePtr<ROL::ConstraintFromObjective<RealT>>( obj_0 );
96 ROL::Ptr<Con> con_1 = ROL::makePtr<ROL::ConstraintFromObjective<RealT>>( obj_1 );
97 ROL::Ptr<Con> con_2 = ROL::makePtr<ROL::ConstraintFromObjective<RealT>>( obj_2 );
99 std::vector<ROL::Ptr<Con>> con_array;
100 con_array.push_back(con_0);
101 con_array.push_back(con_1);
102 con_array.push_back(con_2);
105 ROL::Ptr<V> l0 = ROL::makePtr<ScalarV>(0);
106 ROL::Ptr<V> l1 = ROL::makePtr<ScalarV>(0);
107 ROL::Ptr<V> l2 = ROL::makePtr<ScalarV>(0);
109 std::vector<ROL::Ptr<V>> l_array;
110 l_array.push_back(l0);
111 l_array.push_back(l1);
112 l_array.push_back(l2);
120 opt.
check(*outStream);
123 ROL::ParameterList parlist;
124 std::string stepname =
"Composite Step";
125 parlist.sublist(
"Step").sublist(stepname).sublist(
"Optimality System Solver").set(
"Nominal Relative Tolerance",1.e-4);
126 parlist.sublist(
"Step").sublist(stepname).sublist(
"Optimality System Solver").set(
"Fix Tolerance",
true);
127 parlist.sublist(
"Step").sublist(stepname).sublist(
"Tangential Subproblem Solver").set(
"Iteration Limit",20);
128 parlist.sublist(
"Step").sublist(stepname).sublist(
"Tangential Subproblem Solver").set(
"Relative Tolerance",1e-2);
129 parlist.sublist(
"Step").sublist(stepname).set(
"Output Level",0);
130 parlist.sublist(
"Status Test").set(
"Gradient Tolerance",1.e-12);
131 parlist.sublist(
"Status Test").set(
"Constraint Tolerance",1.e-12);
132 parlist.sublist(
"Status Test").set(
"Step Tolerance",1.e-18);
133 parlist.sublist(
"Status Test").set(
"Iteration Limit",100);
137 solver.
solve( *outStream );
139 error->axpy(-1.0,*x);
140 RealT error_norm = error->norm();
142 *outStream <<
"\n\n Relative norm of final optimization vector error: " << error_norm << std::endl;
148 catch (std::logic_error& err) {
149 *outStream << err.what() <<
"\n";
154 std::cout <<
"End Result: TEST FAILED\n";
156 std::cout <<
"End Result: TEST PASSED\n";
159 std::cout.copyfmt(oldFormatState);
Provides the interface to evaluate objective functions.
Ptr< Constraint< Real > > getEqualityConstraint(void) const
Objective_TimeSimOpt< Real > Obj
Defines the linear algebra or vector space interface.
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
Ptr< Objective< Real > > getObjective(void) const
Contains definitions for the equality constrained NLP from Nocedal/Wright, 2nd edition, page 574, example 18.2; note the typo in reversing the initial guess and the solution.
Provides a simplified interface for solving a wide range of optimization problems.
Ptr< Vector< Real > > getSolution(const int i=0) const
basic_nullstream< char, char_traits< char >> nullstream
int main(int argc, char *argv[])
void check(std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
int solve(const ROL::Ptr< StatusTest< Real > > &status=ROL::nullPtr, const bool combineStatus=true)
Solve optimization problem with no iteration output.
Ptr< Vector< Real > > getInitialGuess(void) const