44 #ifndef ROL_MINIMAX3_HPP
45 #define ROL_MINIMAX3_HPP
51 #include "Teuchos_RCP.hpp"
61 Teuchos::RCP<const std::vector<Real> > xp =
63 Real F = std::pow((*xp)[0],2.0) + std::pow((*xp)[1],2.0) + 2.0*std::pow((*xp)[2],2.0)
64 + std::pow((*xp)[3],2.0) - 5.0*(*xp)[0] - 5.0*(*xp)[1] - 21.0*(*xp)[2] + 7.0*(*xp)[3];
65 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)
66 -(*xp)[0]+(*xp)[1]-(*xp)[2]+(*xp)[3]+8.0;
67 Real g3 = -std::pow((*xp)[0],2.0)-2.0*std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)
68 -2.0*std::pow((*xp)[3],2.0)+(*xp)[0]+(*xp)[3]+10.0;
69 Real g4 = -std::pow((*xp)[0],2.0)-std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)
70 -2.0*(*xp)[0]+(*xp)[1]+(*xp)[3]+5.0;
71 Real a2 = 10.0, a3 = 10.0, a4 = 10.0;
72 return std::max(F,std::max(F-a2*g2,std::max(F-a3*g3,F-a4*g4)));
76 Teuchos::RCP<const std::vector<Real> > xp =
78 Teuchos::RCP<std::vector<Real> > gp =
79 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<
StdVector<Real> >(g)).getVector());
80 Real F = std::pow((*xp)[0],2.0) + std::pow((*xp)[1],2.0) + 2.0*std::pow((*xp)[2],2.0)
81 + std::pow((*xp)[3],2.0) - 5.0*(*xp)[0] - 5.0*(*xp)[1] - 21.0*(*xp)[2] + 7.0*(*xp)[3];
82 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)
83 -(*xp)[0]+(*xp)[1]-(*xp)[2]+(*xp)[3]+8.0;
84 Real g3 = -std::pow((*xp)[0],2.0)-2.0*std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)
85 -2.0*std::pow((*xp)[3],2.0)+(*xp)[0]+(*xp)[3]+10.0;
86 Real g4 = -std::pow((*xp)[0],2.0)-std::pow((*xp)[1],2.0)-std::pow((*xp)[2],2.0)
87 -2.0*(*xp)[0]+(*xp)[1]+(*xp)[3]+5.0;
88 Real a2 = 10.0, a3 = 10.0, a4 = 10.0;
90 (*gp)[0] = 2.0*(*xp)[0] - 5.0;
91 (*gp)[1] = 2.0*(*xp)[1] - 5.0;
92 (*gp)[2] = 4.0*(*xp)[2] - 21.0;
93 (*gp)[3] = 2.0*(*xp)[3] + 7.0;
94 if ( F-a2*g2 >= std::max(F,std::max(F-a3*g3,F-a4*g4)) ) {
95 (*gp)[0] += a2*(2.0*(*xp)[0] + 1.0);
96 (*gp)[1] += a2*(2.0*(*xp)[1] - 1.0);
97 (*gp)[2] += a2*(2.0*(*xp)[2] + 1.0);
98 (*gp)[3] += a2*(2.0*(*xp)[3] - 1.0);
100 else if ( F-a3*g3 >= std::max(F,std::max(F-a2*g2,F-a4*g4)) ) {
101 (*gp)[0] += a2*(2.0*(*xp)[0] - 1.0);
102 (*gp)[1] += a2*(4.0*(*xp)[1]);
103 (*gp)[2] += a2*(2.0*(*xp)[2]);
104 (*gp)[3] += a2*(4.0*(*xp)[3] - 1.0);
106 else if ( F-a4*g4 >= std::max(F,std::max(F-a2*g2,F-a3*g3)) ) {
107 (*gp)[0] += a2*(2.0*(*xp)[0] + 2.0);
108 (*gp)[1] += a2*(2.0*(*xp)[1] - 1.0);
109 (*gp)[2] += a2*(2.0*(*xp)[2]);
110 (*gp)[3] += a2*(-1.0);
Provides the interface to evaluate objective functions.
Defines the linear algebra or vector space interface.
Provides the std::vector implementation of the ROL::Vector interface.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Real value(const Vector< Real > &x, Real &tol)
Compute value.