11 #include "Teuchos_GlobalMPISession.hpp" 
   22   Real 
value( 
const std::vector<Real> &x, Real &tol ) {
 
   23     Real half(0.5), quad(0);
 
   24     unsigned size = x.size();
 
   25     for ( 
unsigned i = 0; i < size; i++ ) {
 
   31   void gradient( std::vector<Real> &g, 
const std::vector<Real> &x, Real &tol ) {
 
   32     g.assign(x.begin(),x.end());
 
   35   void hessVec( std::vector<Real> &hv, 
const std::vector<Real> &v, 
const std::vector<Real> &x, Real &tol ) {
 
   36     hv.assign(v.begin(),v.end());
 
   43   Real 
value( 
const std::vector<Real> &x, Real &tol ) {
 
   45     unsigned size = x.size();
 
   46     for ( 
unsigned i = 0; i < size; i++ ) {
 
   52   void gradient( std::vector<Real> &g, 
const std::vector<Real> &x, Real &tol ) {
 
   56   void hessVec( std::vector<Real> &hv, 
const std::vector<Real> &v, 
const std::vector<Real> &x, Real &tol ) {
 
   57     hv.assign(x.size(),0);
 
   64   Real 
value( 
const std::vector<Real> &x, Real &tol ) {
 
   65     return std::log(x[0]) * std::exp(x[1]);
 
   68   void gradient( std::vector<Real> &g, 
const std::vector<Real> &x, Real &tol ) {
 
   69     g[0] = std::exp(x[1])/x[0];
 
   70     g[1] = std::exp(x[1]) * std::log(x[0]);
 
   73   void hessVec( std::vector<Real> &hv, 
const std::vector<Real> &v, 
const std::vector<Real> &x, Real &tol ) {
 
   74     Real H11 = -std::exp(x[1])/(x[0]*x[0]);
 
   75     Real H12 = std::exp(x[1])/x[0];
 
   76     Real H21 = std::exp(x[1])/x[0];
 
   77     Real H22 = std::exp(x[1]) * std::log(x[0]);
 
   78     hv[0] = H11*v[0] + H12*v[1];
 
   79     hv[1] = H21*v[0] + H22*v[1];
 
   84   unsigned dim = x.size();
 
   85   for ( 
unsigned i = 0; i < 
dim; i++ ) {
 
   90 int main(
int argc, 
char* argv[]) {
 
   92   Teuchos::GlobalMPISession mpiSession(&argc, &argv);
 
   95   int iprint     = argc - 1;
 
   96   ROL::Ptr<std::ostream> outStream;
 
   99     outStream = ROL::makePtrFromRef(std::cout);
 
  101     outStream = ROL::makePtrFromRef(bhs);
 
  111     ROL::Ptr<std::vector<RealT> > x_ptr = ROL::makePtr<std::vector<RealT>>(
dim,0.0);
 
  112     ROL::Ptr<ROL::Vector<RealT> > x = ROL::makePtr<ROL::StdVector<RealT>>(x_ptr);
 
  114     ROL::Ptr<std::vector<RealT> > d_ptr = ROL::makePtr<std::vector<RealT>>(
dim,0.0);
 
  115     ROL::Ptr<ROL::Vector<RealT> > d = ROL::makePtr<ROL::StdVector<RealT>>(d_ptr);
 
  118     std::vector<ROL::Ptr<ROL::Objective<RealT> > > vec_obj(2,ROL::nullPtr);
 
  119     vec_obj[0] = ROL::makePtr<ObjectiveFunctionTest07_1<RealT>>();
 
  120     vec_obj[1] = ROL::makePtr<ObjectiveFunctionTest07_2<RealT>>();
 
  121     ROL::Ptr<ROL::StdObjective<RealT> > obj_scalarize
 
  122       = ROL::makePtr<ObjectiveFunctionTest07_scalarize<RealT>>();
 
  123     ROL::Ptr<ROL::Objective<RealT> > obj
 
  124       = ROL::makePtr<ROL::CompositeObjective<RealT>>(vec_obj,obj_scalarize);
 
  126     *outStream << 
"Check Derivatives of CompositeObjective\n";
 
  127     obj->checkGradient(*x,*d,
true,*outStream);
 
  128     obj->checkHessVec(*x,*d,
true,*outStream);
 
  130   catch (std::logic_error& err) {
 
  131     *outStream << err.what() << 
"\n";
 
  136     std::cout << 
"End Result: TEST FAILED\n";
 
  138     std::cout << 
"End Result: TEST PASSED\n";
 
void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
void setRandomVector(std::vector< RealT > &x)
Real value(const std::vector< Real > &x, Real &tol)
Real value(const std::vector< Real > &x, Real &tol)
void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)
void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)
basic_nullstream< char, std::char_traits< char >> nullstream
Specializes the ROL::Objective interface for objective functions that operate on ROL::StdVector's. 
int main(int argc, char *argv[])
Real value(const std::vector< Real > &x, Real &tol)
void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)