44 #ifndef ROL_MINIMAX1_HPP
45 #define ROL_MINIMAX1_HPP
49 #include "ROL_Ptr.hpp"
76 Real f1 = std::pow((*xp)[0],2.0) + std::pow((*xp)[1],4.0);
77 Real f2 = std::pow(2.0-(*xp)[0],2.0) + std::pow(2.0-(*xp)[1],2.0);
78 Real f3 = 2.0*std::exp(-(*xp)[0] + (*xp)[1]);
79 return std::max(f1,std::max(f2,f3));
85 Real f1 = std::pow((*xp)[0],2.0) + std::pow((*xp)[1],4.0);
86 Real f2 = std::pow(2.0-(*xp)[0],2.0) + std::pow(2.0-(*xp)[1],2.0);
87 Real f3 = 2.0*std::exp(-(*xp)[0] + (*xp)[1]);
90 if( f1 >= std::max(f2,f3) ) {
91 (*gp)[0] = 2.0*(*xp)[0];
92 (*gp)[1] = 4.0*std::pow((*xp)[1],3.0);
94 else if ( f2 >= std::max(f1,f3) ) {
95 (*gp)[0] = 2.0*(*xp)[0]-4.0;
96 (*gp)[1] = 2.0*(*xp)[1]-4.0;
98 else if ( f3 >= std::max(f1,f2) ) {
99 (*gp)[0] = -2.0*std::exp(-(*xp)[0]+(*xp)[1]);
100 (*gp)[1] = 2.0*std::exp(-(*xp)[0]+(*xp)[1]);
111 return makePtr<Minimax1<Real>>();
115 Ptr<std::vector<Real> > x_ptr = makePtr<std::vector<Real>>(2, 0.0);
116 (*x_ptr)[0] = 1.0; (*x_ptr)[1] = -0.1;
117 return makePtr<StdVector<Real>>(x_ptr);
121 Ptr<std::vector<Real> > z_ptr = makePtr<std::vector<Real>>(2, 0.0);
122 (*z_ptr)[0] = 1.13904; (*z_ptr)[1] = 0.89956;
123 return makePtr<StdVector<Real>>(z_ptr);
Provides the interface to evaluate objective functions.
Ptr< vector > getVector(V &x)
Ptr< Vector< Real > > getSolution(const int i=0) const
Defines the linear algebra or vector space interface.
Contains definitions of test objective functions.
Ptr< Objective< Real > > getObjective(void) const
Ptr< Vector< Real > > getInitialGuess(void) const
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Ptr< const vector > getVector(const V &x)
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
std::vector< Real > vector