59 #include "Teuchos_GlobalMPISession.hpp"
65 int main(
int argc,
char *argv[]) {
67 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
78 int iprint = argc - 1;
79 ROL::Ptr<std::ostream> outStream;
82 outStream = ROL::makePtrFromRef(std::cout);
84 outStream = ROL::makePtrFromRef(bhs);
88 oldFormatState.copyfmt(std::cout);
92 RealT tol = std::sqrt(ROL::ROL_EPSILON<RealT>());
102 ROL::Ptr<V> x = ROL::makePtr<StdV>( ROL::makePtr<std::vector<RealT>>(xdim) );
103 ROL::Ptr<V> c = ROL::makePtr<StdV>( ROL::makePtr<std::vector<RealT>>(cdim));
104 ROL::Ptr<V> e0 = c->basis(0);
105 ROL::Ptr<V> e1 = c->basis(1);
106 ROL::Ptr<V> e2 = c->basis(2);
109 ROL::Ptr<V> sol = x->clone();
110 ROL::Ptr<V> error = x->clone();
112 ROL::Ptr<Obj> obj = ROL::nullPtr;
113 ROL::Ptr<Con> con = ROL::nullPtr;
124 ROL::Ptr<Obj> obj_0 = ROL::makePtr<ROL::ObjectiveFromConstraint<RealT>>( con, *e0 );
125 ROL::Ptr<Obj> obj_1 = ROL::makePtr<ROL::ObjectiveFromConstraint<RealT>>( con, *e1 );
126 ROL::Ptr<Obj> obj_2 = ROL::makePtr<ROL::ObjectiveFromConstraint<RealT>>( con, *e2 );
129 ROL::Ptr<Con> con_0 = ROL::makePtr<ROL::ConstraintFromObjective<RealT>>( obj_0 );
130 ROL::Ptr<Con> con_1 = ROL::makePtr<ROL::ConstraintFromObjective<RealT>>( obj_1 );
131 ROL::Ptr<Con> con_2 = ROL::makePtr<ROL::ConstraintFromObjective<RealT>>( obj_2 );
133 std::vector<ROL::Ptr<Con>> con_array;
134 con_array.push_back(con_0);
135 con_array.push_back(con_1);
136 con_array.push_back(con_2);
139 ROL::Ptr<V> l0 = ROL::makePtr<ScalarV>(0);
140 ROL::Ptr<V> l1 = ROL::makePtr<ScalarV>(0);
141 ROL::Ptr<V> l2 = ROL::makePtr<ScalarV>(0);
143 std::vector<ROL::Ptr<V>> l_array;
144 l_array.push_back(l0);
145 l_array.push_back(l1);
146 l_array.push_back(l2);
154 opt.
check(*outStream);
157 ROL::ParameterList parlist;
158 std::string stepname =
"Composite Step";
159 parlist.sublist(
"Step").sublist(stepname).sublist(
"Optimality System Solver").set(
"Nominal Relative Tolerance",1.e-4);
160 parlist.sublist(
"Step").sublist(stepname).sublist(
"Optimality System Solver").set(
"Fix Tolerance",
true);
161 parlist.sublist(
"Step").sublist(stepname).sublist(
"Tangential Subproblem Solver").set(
"Iteration Limit",20);
162 parlist.sublist(
"Step").sublist(stepname).sublist(
"Tangential Subproblem Solver").set(
"Relative Tolerance",1e-2);
163 parlist.sublist(
"Step").sublist(stepname).set(
"Output Level",0);
164 parlist.sublist(
"Status Test").set(
"Gradient Tolerance",1.e-12);
165 parlist.sublist(
"Status Test").set(
"Constraint Tolerance",1.e-12);
166 parlist.sublist(
"Status Test").set(
"Step Tolerance",1.e-18);
167 parlist.sublist(
"Status Test").set(
"Iteration Limit",100);
171 solver.
solve( *outStream );
173 error->axpy(-1.0,*x);
174 RealT error_norm = error->norm();
176 *outStream <<
"\n\n Relative norm of final optimization vector error: " << error_norm << std::endl;
182 catch (std::logic_error& err) {
183 *outStream << err.what() <<
"\n";
188 std::cout <<
"End Result: TEST FAILED\n";
190 std::cout <<
"End Result: TEST PASSED\n";
193 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
Defines the general constraint operator interface.