44 #ifndef ROL_MINIMAX2_HPP
45 #define ROL_MINIMAX2_HPP
51 #include "Teuchos_RCP.hpp"
61 Teuchos::RCP<const std::vector<Real> > xp =
63 Real f1 = std::pow((*xp)[0],4.0) + std::pow((*xp)[1],2.0);
64 Real f2 = std::pow(2.0-(*xp)[0],2.0) + std::pow(2.0-(*xp)[1],2.0);
65 Real f3 = 2.0*std::exp(-(*xp)[0] + (*xp)[1]);
66 return std::max(f1,std::max(f2,f3));
70 Teuchos::RCP<const std::vector<Real> > xp =
72 Teuchos::RCP<std::vector<Real> > gp =
73 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(g)).getVector());
74 Real f1 = std::pow((*xp)[0],4.0) + std::pow((*xp)[1],2.0);
75 Real f2 = std::pow(2.0-(*xp)[0],2.0) + std::pow(2.0-(*xp)[1],2.0);
76 Real f3 = 2.0*std::exp(-(*xp)[0] + (*xp)[1]);
78 if ( f1 >= std::max(f2,f3) ) {
79 (*gp)[0] = 4.0*std::pow((*xp)[0],3.0);
80 (*gp)[1] = 2.0*(*xp)[1];
82 else if ( f2 >= std::max(f1,f3) ) {
83 (*gp)[0] = 2.0*(*xp)[0]-4.0;
84 (*gp)[1] = 2.0*(*xp)[1]-4.0;
86 else if ( f3 >= std::max(f1,f2) ) {
87 (*gp)[0] = -2.0*std::exp(-(*xp)[0]+(*xp)[1]);
88 (*gp)[1] = 2.0*std::exp(-(*xp)[0]+(*xp)[1]);
Provides the interface to evaluate objective functions.
Defines the linear algebra or vector space interface.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Provides the std::vector implementation of the ROL::Vector interface.
Real value(const Vector< Real > &x, Real &tol)
Compute value.