21 #include "Teuchos_GlobalMPISession.hpp"
22 #include "Teuchos_LAPACK.hpp"
31 int main(
int argc,
char *argv[]) {
33 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
36 int iprint = argc - 1;
37 ROL::Ptr<std::ostream> outStream;
40 outStream = ROL::makePtrFromRef(std::cout);
42 outStream = ROL::makePtrFromRef(bhs);
56 ROL::ParameterList list;
57 list.sublist(
"SimOpt").sublist(
"Solve").set(
"Absolute Residual Tolerance",1.e2*ROL::ROL_EPSILON<RealT>());
60 ROL::Ptr<std::vector<RealT> > z_ptr = ROL::makePtr<std::vector<RealT>>(nx+2, 1.0);
61 ROL::Ptr<std::vector<RealT> > gz_ptr = ROL::makePtr<std::vector<RealT>>(nx+2, 1.0);
62 ROL::Ptr<std::vector<RealT> > yz_ptr = ROL::makePtr<std::vector<RealT>>(nx+2, 1.0);
63 for (
int i=0; i<nx+2; i++) {
70 ROL::Ptr<ROL::Vector<RealT> > zp = ROL::makePtrFromRef(z);
71 ROL::Ptr<ROL::Vector<RealT> > gzp = ROL::makePtrFromRef(z);
72 ROL::Ptr<ROL::Vector<RealT> > yzp = ROL::makePtrFromRef(yz);
74 ROL::Ptr<std::vector<RealT> > u_ptr = ROL::makePtr<std::vector<RealT>>(nx, 1.0);
75 ROL::Ptr<std::vector<RealT> > gu_ptr = ROL::makePtr<std::vector<RealT>>(nx, 1.0);
76 ROL::Ptr<std::vector<RealT> > yu_ptr = ROL::makePtr<std::vector<RealT>>(nx, 1.0);
77 for (
int i=0; i<nx; i++) {
84 ROL::Ptr<ROL::Vector<RealT> > up = ROL::makePtrFromRef(u);
85 ROL::Ptr<ROL::Vector<RealT> > gup = ROL::makePtrFromRef(gu);
86 ROL::Ptr<ROL::Vector<RealT> > yup = ROL::makePtrFromRef(yu);
88 ROL::Ptr<std::vector<RealT> > c_ptr = ROL::makePtr<std::vector<RealT>>(nx, 1.0);
89 ROL::Ptr<std::vector<RealT> > l_ptr = ROL::makePtr<std::vector<RealT>>(nx, 1.0);
105 ROL::Ptr<std::vector<RealT> > p_ptr = ROL::makePtr<std::vector<RealT>>(nx, 1.0);
107 ROL::Ptr<ROL::Vector<RealT> > pp = ROL::makePtrFromRef(p);
108 ROL::Ptr<ROL::Objective_SimOpt<RealT> > pobj = ROL::makePtrFromRef(obj);
109 ROL::Ptr<ROL::Constraint_SimOpt<RealT> > pcon = ROL::makePtrFromRef(con);
116 std::string filename =
"input.xml";
117 auto parlist = ROL::getParametersFromXmlFile( filename );
118 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-14);
119 parlist->sublist(
"Status Test").set(
"Constraint Tolerance",1.e-14);
120 parlist->sublist(
"Status Test").set(
"Step Tolerance",1.e-16);
121 parlist->sublist(
"Status Test").set(
"Iteration Limit",1000);
124 RealT zerotol = std::sqrt(ROL::ROL_EPSILON<RealT>());
126 con.
solve(c,u,z,zerotol);
132 algo.
run(x, obj, con, l, *outStream);
134 ROL::Ptr<ROL::Vector<RealT> > zCS = z.
clone();
143 algo.
run(z, z.
dual(), robj, *outStream);
147 ROL::Ptr<ROL::Vector<RealT> > err = z.
clone();
148 err->set(*zCS); err->axpy(-1.,z);
149 errorFlag += ((err->norm()) > 1.e-8) ? 1 : 0;
151 catch (std::logic_error& err) {
152 *outStream << err.what() <<
"\n";
157 std::cout <<
"End Result: TEST FAILED\n";
159 std::cout <<
"End Result: TEST PASSED\n";
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Defines the linear algebra or vector space interface for simulation-based optimization.
virtual std::vector< std::vector< Real > > checkApplyAdjointJacobian(const Vector< Real > &x, const Vector< Real > &v, const Vector< Real > &c, const Vector< Real > &ajv, const bool printToStream=true, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS)
Finite-difference check for the application of the adjoint of constraint Jacobian.
void solve(ROL::Vector< Real > &c, ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Given , solve for .
virtual void zero()
Set to zero vector.
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
virtual std::vector< std::vector< Real > > checkGradient(const Vector< Real > &x, const Vector< Real > &d, const bool printToStream=true, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
Finite-difference gradient check.
virtual void run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, Constraint< Real > &econ, Vector< Real > &emul, const Vector< Real > &eres, std::ostream &outStream=std::cout) override
Run algorithm on equality constrained problems (Type-E). This general interface supports the use of d...
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
Provides an interface to run equality constrained optimization algorithms using the Composite-Step Tr...
void run(Vector< Real > &x, const Vector< Real > &g, Objective< Real > &obj, std::ostream &outStream=std::cout) override
Run algorithm on unconstrained problems (Type-U). This general interface supports the use of dual opt...
virtual Ptr< Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
virtual std::vector< std::vector< Real > > checkApplyAdjointHessian(const Vector< Real > &x, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &hv, const std::vector< Real > &step, const bool printToScreen=true, std::ostream &outStream=std::cout, const int order=1)
Finite-difference check for the application of the adjoint of constraint Hessian. ...
virtual std::vector< std::vector< Real > > checkApplyJacobian(const Vector< Real > &x, const Vector< Real > &v, const Vector< Real > &jv, const std::vector< Real > &steps, const bool printToStream=true, std::ostream &outStream=std::cout, const int order=1)
Finite-difference check for the constraint Jacobian application.
basic_nullstream< char, char_traits< char >> nullstream
int main(int argc, char *argv[])
virtual std::vector< std::vector< Real > > checkHessVec(const Vector< Real > &x, const Vector< Real > &v, const bool printToStream=true, std::ostream &outStream=std::cout, const int numSteps=ROL_NUM_CHECKDERIV_STEPS, const int order=1)
Finite-difference Hessian-applied-to-vector check.
virtual void setSolveParameters(ParameterList &parlist)
Set solve parameters.
Provides an interface to run trust-region methods for unconstrained optimization algorithms.