55 #include "Teuchos_GlobalMPISession.hpp"
56 #include "Teuchos_LAPACK.hpp"
65 int main(
int argc,
char *argv[]) {
67 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
70 int iprint = argc - 1;
71 ROL::Ptr<std::ostream> outStream;
74 outStream = ROL::makePtrFromRef(std::cout);
76 outStream = ROL::makePtrFromRef(bhs);
90 ROL::ParameterList list;
91 list.sublist(
"SimOpt").sublist(
"Solve").set(
"Absolute Residual Tolerance",1.e2*ROL::ROL_EPSILON<RealT>());
94 ROL::Ptr<std::vector<RealT> > z_ptr = ROL::makePtr<std::vector<RealT>>(nx+2, 1.0);
95 ROL::Ptr<std::vector<RealT> > gz_ptr = ROL::makePtr<std::vector<RealT>>(nx+2, 1.0);
96 ROL::Ptr<std::vector<RealT> > yz_ptr = ROL::makePtr<std::vector<RealT>>(nx+2, 1.0);
97 for (
int i=0; i<nx+2; i++) {
104 ROL::Ptr<ROL::Vector<RealT> > zp = ROL::makePtrFromRef(z);
105 ROL::Ptr<ROL::Vector<RealT> > gzp = ROL::makePtrFromRef(z);
106 ROL::Ptr<ROL::Vector<RealT> > yzp = ROL::makePtrFromRef(yz);
108 ROL::Ptr<std::vector<RealT> > u_ptr = ROL::makePtr<std::vector<RealT>>(nx, 1.0);
109 ROL::Ptr<std::vector<RealT> > gu_ptr = ROL::makePtr<std::vector<RealT>>(nx, 1.0);
110 ROL::Ptr<std::vector<RealT> > yu_ptr = ROL::makePtr<std::vector<RealT>>(nx, 1.0);
111 for (
int i=0; i<nx; i++) {
118 ROL::Ptr<ROL::Vector<RealT> > up = ROL::makePtrFromRef(u);
119 ROL::Ptr<ROL::Vector<RealT> > gup = ROL::makePtrFromRef(gu);
120 ROL::Ptr<ROL::Vector<RealT> > yup = ROL::makePtrFromRef(yu);
122 ROL::Ptr<std::vector<RealT> > c_ptr = ROL::makePtr<std::vector<RealT>>(nx, 1.0);
123 ROL::Ptr<std::vector<RealT> > l_ptr = ROL::makePtr<std::vector<RealT>>(nx, 1.0);
139 ROL::Ptr<std::vector<RealT> > p_ptr = ROL::makePtr<std::vector<RealT>>(nx, 1.0);
141 ROL::Ptr<ROL::Vector<RealT> > pp = ROL::makePtrFromRef(p);
142 ROL::Ptr<ROL::Objective_SimOpt<RealT> > pobj = ROL::makePtrFromRef(obj);
143 ROL::Ptr<ROL::Constraint_SimOpt<RealT> > pcon = ROL::makePtrFromRef(con);
150 std::string filename =
"input.xml";
151 auto parlist = ROL::getParametersFromXmlFile( filename );
152 parlist->sublist(
"Status Test").set(
"Gradient Tolerance",1.e-14);
153 parlist->sublist(
"Status Test").set(
"Constraint Tolerance",1.e-14);
154 parlist->sublist(
"Status Test").set(
"Step Tolerance",1.e-16);
155 parlist->sublist(
"Status Test").set(
"Iteration Limit",1000);
158 RealT zerotol = std::sqrt(ROL::ROL_EPSILON<RealT>());
160 con.
solve(c,u,z,zerotol);
166 algo.
run(x, obj, con, l, *outStream);
168 ROL::Ptr<ROL::Vector<RealT> > zCS = z.
clone();
177 algo.
run(z, z.
dual(), robj, *outStream);
181 ROL::Ptr<ROL::Vector<RealT> > err = z.
clone();
182 err->set(*zCS); err->axpy(-1.,z);
183 errorFlag += ((err->norm()) > 1.e-8) ? 1 : 0;
185 catch (std::logic_error& err) {
186 *outStream << err.what() <<
"\n";
191 std::cout <<
"End Result: TEST FAILED\n";
193 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.