10 #ifndef ROL_MINIMAX3_HPP
11 #define ROL_MINIMAX3_HPP
15 #include "ROL_Ptr.hpp"
47 Real F = std::pow((*xp)[0],2.0) + std::pow((*xp)[1],2.0) + 2.0*std::pow((*xp)[2],2.0)
48 + std::pow((*xp)[3],2.0) - 5.0*(*xp)[0] - 5.0*(*xp)[1] - 21.0*(*xp)[2] + 7.0*(*xp)[3];
49 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)
50 -(*xp)[0]+(*xp)[1]-(*xp)[2]+(*xp)[3]+8.0;
51 Real g3 = -std::pow((*xp)[0],2.0)-2.0*std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)
52 -2.0*std::pow((*xp)[3],2.0)+(*xp)[0]+(*xp)[3]+10.0;
53 Real g4 = -std::pow((*xp)[0],2.0)-std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)
54 -2.0*(*xp)[0]+(*xp)[1]+(*xp)[3]+5.0;
55 Real a2 = 10.0, a3 = 10.0, a4 = 10.0;
56 return std::max(F,std::max(F-a2*g2,std::max(F-a3*g3,F-a4*g4)));
65 Real F = std::pow((*xp)[0],2.0) + std::pow((*xp)[1],2.0) + 2.0*std::pow((*xp)[2],2.0)
66 + std::pow((*xp)[3],2.0) - 5.0*(*xp)[0] - 5.0*(*xp)[1] - 21.0*(*xp)[2] + 7.0*(*xp)[3];
67 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)
68 -(*xp)[0]+(*xp)[1]-(*xp)[2]+(*xp)[3]+8.0;
69 Real g3 = -std::pow((*xp)[0],2.0)-2.0*std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)
70 -2.0*std::pow((*xp)[3],2.0)+(*xp)[0]+(*xp)[3]+10.0;
71 Real g4 = -std::pow((*xp)[0],2.0)-std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)
72 -2.0*(*xp)[0]+(*xp)[1]+(*xp)[3]+5.0;
73 Real a2 = 10.0, a3 = 10.0, a4 = 10.0;
75 (*gp)[0] = 2.0*(*xp)[0] - 5.0;
76 (*gp)[1] = 2.0*(*xp)[1] - 5.0;
77 (*gp)[2] = 4.0*(*xp)[2] - 21.0;
78 (*gp)[3] = 2.0*(*xp)[3] + 7.0;
79 if ( F-a2*g2 >= std::max(F,std::max(F-a3*g3,F-a4*g4)) ) {
80 (*gp)[0] += a2*(2.0*(*xp)[0] + 1.0);
81 (*gp)[1] += a2*(2.0*(*xp)[1] - 1.0);
82 (*gp)[2] += a2*(2.0*(*xp)[2] + 1.0);
83 (*gp)[3] += a2*(2.0*(*xp)[3] - 1.0);
85 else if ( F-a3*g3 >= std::max(F,std::max(F-a2*g2,F-a4*g4)) ) {
86 (*gp)[0] += a2*(2.0*(*xp)[0] - 1.0);
87 (*gp)[1] += a2*(4.0*(*xp)[1]);
88 (*gp)[2] += a2*(2.0*(*xp)[2]);
89 (*gp)[3] += a2*(4.0*(*xp)[3] - 1.0);
91 else if ( F-a4*g4 >= std::max(F,std::max(F-a2*g2,F-a3*g3)) ) {
92 (*gp)[0] += a2*(2.0*(*xp)[0] + 2.0);
93 (*gp)[1] += a2*(2.0*(*xp)[1] - 1.0);
94 (*gp)[2] += a2*(2.0*(*xp)[2]);
95 (*gp)[3] += a2*(-1.0);
106 return makePtr<Minimax3<Real>>();
110 ROL::Ptr<std::vector<Real> > x_ptr = ROL::makePtr<std::vector<Real>>(4, 0.0);
111 return makePtr<StdVector<Real>>(x_ptr);
115 ROL::Ptr<std::vector<Real> > z_ptr = ROL::makePtr<std::vector<Real>>(4, 0.0);
116 (*z_ptr)[0] = 0.0; (*z_ptr)[1] = 1.0;
117 (*z_ptr)[2] = 2.0; (*z_ptr)[3] = -1.0;
118 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