44 #ifndef ROL_MINIMAX3_HPP
45 #define ROL_MINIMAX3_HPP
49 #include "ROL_Ptr.hpp"
81 Real F = std::pow((*xp)[0],2.0) + std::pow((*xp)[1],2.0) + 2.0*std::pow((*xp)[2],2.0)
82 + std::pow((*xp)[3],2.0) - 5.0*(*xp)[0] - 5.0*(*xp)[1] - 21.0*(*xp)[2] + 7.0*(*xp)[3];
83 Real g2 = -std::pow((*xp)[0],2.0)-std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)-std::pow((*xp)[3],2.0)
84 -(*xp)[0]+(*xp)[1]-(*xp)[2]+(*xp)[3]+8.0;
85 Real g3 = -std::pow((*xp)[0],2.0)-2.0*std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)
86 -2.0*std::pow((*xp)[3],2.0)+(*xp)[0]+(*xp)[3]+10.0;
87 Real g4 = -std::pow((*xp)[0],2.0)-std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)
88 -2.0*(*xp)[0]+(*xp)[1]+(*xp)[3]+5.0;
89 Real a2 = 10.0, a3 = 10.0, a4 = 10.0;
90 return std::max(F,std::max(F-a2*g2,std::max(F-a3*g3,F-a4*g4)));
99 Real F = std::pow((*xp)[0],2.0) + std::pow((*xp)[1],2.0) + 2.0*std::pow((*xp)[2],2.0)
100 + std::pow((*xp)[3],2.0) - 5.0*(*xp)[0] - 5.0*(*xp)[1] - 21.0*(*xp)[2] + 7.0*(*xp)[3];
101 Real g2 = -std::pow((*xp)[0],2.0)-std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)-std::pow((*xp)[3],2.0)
102 -(*xp)[0]+(*xp)[1]-(*xp)[2]+(*xp)[3]+8.0;
103 Real g3 = -std::pow((*xp)[0],2.0)-2.0*std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)
104 -2.0*std::pow((*xp)[3],2.0)+(*xp)[0]+(*xp)[3]+10.0;
105 Real g4 = -std::pow((*xp)[0],2.0)-std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)
106 -2.0*(*xp)[0]+(*xp)[1]+(*xp)[3]+5.0;
107 Real a2 = 10.0, a3 = 10.0, a4 = 10.0;
109 (*gp)[0] = 2.0*(*xp)[0] - 5.0;
110 (*gp)[1] = 2.0*(*xp)[1] - 5.0;
111 (*gp)[2] = 4.0*(*xp)[2] - 21.0;
112 (*gp)[3] = 2.0*(*xp)[3] + 7.0;
113 if ( F-a2*g2 >= std::max(F,std::max(F-a3*g3,F-a4*g4)) ) {
114 (*gp)[0] += a2*(2.0*(*xp)[0] + 1.0);
115 (*gp)[1] += a2*(2.0*(*xp)[1] - 1.0);
116 (*gp)[2] += a2*(2.0*(*xp)[2] + 1.0);
117 (*gp)[3] += a2*(2.0*(*xp)[3] - 1.0);
119 else if ( F-a3*g3 >= std::max(F,std::max(F-a2*g2,F-a4*g4)) ) {
120 (*gp)[0] += a2*(2.0*(*xp)[0] - 1.0);
121 (*gp)[1] += a2*(4.0*(*xp)[1]);
122 (*gp)[2] += a2*(2.0*(*xp)[2]);
123 (*gp)[3] += a2*(4.0*(*xp)[3] - 1.0);
125 else if ( F-a4*g4 >= std::max(F,std::max(F-a2*g2,F-a3*g3)) ) {
126 (*gp)[0] += a2*(2.0*(*xp)[0] + 2.0);
127 (*gp)[1] += a2*(2.0*(*xp)[1] - 1.0);
128 (*gp)[2] += a2*(2.0*(*xp)[2]);
129 (*gp)[3] += a2*(-1.0);
140 return makePtr<Minimax3<Real>>();
144 ROL::Ptr<std::vector<Real> > x_ptr = ROL::makePtr<std::vector<Real>>(4, 0.0);
145 return makePtr<StdVector<Real>>(x_ptr);
149 ROL::Ptr<std::vector<Real> > z_ptr = ROL::makePtr<std::vector<Real>>(4, 0.0);
150 (*z_ptr)[0] = 0.0; (*z_ptr)[1] = 1.0;
151 (*z_ptr)[2] = 2.0; (*z_ptr)[3] = -1.0;
152 return makePtr<StdVector<Real>>(z_ptr);
Provides the interface to evaluate objective functions.
Ptr< Vector< Real > > getSolution(const int i=0) const
Ptr< Objective< Real > > getObjective(void) const
Defines the linear algebra or vector space interface.
ROL::Ptr< const vector > getVector(const V &x)
Contains definitions of test objective functions.
Real value(const Vector< Real > &x, Real &tol)
Compute value.
ROL::Ptr< vector > getVector(V &x)
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
std::vector< Real > vector
Ptr< Vector< Real > > getInitialGuess(void) const