17 #ifndef ROL_CANTILEVERBEAM_HPP
18 #define ROL_CANTILEVERBEAM_HPP
42 Real
value(
const std::vector<Real> &x, Real &tol ) {
44 for (
int i = 0; i <
nseg_; ++i) {
50 void gradient( std::vector<Real> &g,
const std::vector<Real> &x, Real &tol ) {
51 for (
int i = 0; i <
nseg_; ++i) {
57 void hessVec( std::vector<Real> &hv,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
58 for (
int i = 0; i <
nseg_; ++i) {
82 for (
int i = 0; i <
nseg_; ++i) {
83 suml_[i] =
static_cast<Real
>(i+1)*
l_[i];
89 void value( std::vector<Real> &c,
const std::vector<Real> &x, Real &tol ) {
90 const Real one(1), two(2), three(3), twelve(12), twenty(20);
92 Real Inertia(0), sigma(0), sumy1(0), sumypl(0);
93 for (
int i = 0; i <
nseg_; ++i) {
95 Inertia = x[i]*std::pow(x[i+nseg_],3)/twelve;
96 sigma =
M_[i]*(x[i+
nseg_]/two)/Inertia;
101 y1[i] =
P_*std::pow(
l_[i],2)/(two*
E_*Inertia) * (
len_ -
suml_[i] + two/three*
l_[i]);
106 for (
int i = 1; i <
nseg_; ++i) {
108 sumypl += yp[i-1]*
l_[i];
110 Real yN = sumy1 + sumypl;
115 const std::vector<Real> &x, Real &tol ) {
116 const Real two(2), three(3), six(6), twelve(12), twenty(20);
118 Real Inertia(0), dyN(0), sumW(0), sumH(0);
119 for (
int i = 0; i <
nseg_; ++i) {
121 jv[i] = -six/
Sigma_max_*
M_[i]*v[i]/std::pow(x[i]*x[i+nseg_],2)
126 Inertia = x[i]*std::pow(x[i+nseg_],3)/twelve;
132 jv[2*
nseg_] = sumW+sumH;
136 const std::vector<Real> &x, Real &tol ) {
137 const Real two(2), three(3), six(6), twelve(12), twenty(20);
139 Real Inertia(0), dyN(0);
140 for (
int i = 0; i <
nseg_; ++i) {
142 ajv[i] = -six/
Sigma_max_*
M_[i]*v[i]/std::pow(x[i]*x[i+nseg_],2);
145 ajv[i] += -twenty*v[i+
nseg_];
148 Inertia = x[i]*std::pow(x[i+nseg_],3)/twelve;
173 return makePtr<Objective_CantileverBeam<Real>>(
nseg_);
177 return makePtr<Constraint_CantileverBeam<Real>>(
nseg_);
182 Ptr<std::vector<Real>> lp = makePtr<std::vector<Real>>(2*
nseg_);
183 for (
int i = 0; i <
nseg_; ++i) {
184 (*lp)[i] =
static_cast<Real
>(1);
185 (*lp)[i+
nseg_] =
static_cast<Real
>(5);
189 Ptr<std::vector<Real>> up = makePtr<std::vector<Real>>(2*
nseg_,ROL_INF<Real>());
191 Ptr<Vector<Real>> l = makePtr<StdVector<Real>>(lp);
192 Ptr<Vector<Real>> u = makePtr<StdVector<Real>>(up);
194 return makePtr<Bounds<Real>>(l,u);
198 Ptr<std::vector<Real> > x0p = makePtr<std::vector<Real>>(2*
nseg_,0);
199 for (
int i = 0; i <
nseg_; ++i) {
200 (*x0p)[i] =
static_cast<Real
>(5);
201 (*x0p)[i+
nseg_] =
static_cast<Real
>(40);
204 return makePtr<StdVector<Real>>(x0p);
212 Ptr<std::vector<Real>> xp = makePtr<std::vector<Real>>(2*
nseg_);
213 for (
int i = 0; i <
nseg_; ++i) {
215 (*xp)[i+
nseg_] = std::sqrt(3.0);
218 return makePtr<StdVector<Real>>(xp);
222 Ptr<std::vector<Real> > lp = makePtr<std::vector<Real>>(2*
nseg_+1,0.0);
223 return makePtr<StdVector<Real>>(lp);
228 Ptr<std::vector<Real> > lp = makePtr<std::vector<Real>>(2*
nseg_+1,ROL_NINF<Real>());
231 Ptr<std::vector<Real> > up = makePtr<std::vector<Real>>(2*nseg_+1,0);
233 Ptr<Vector<Real> > l = makePtr<StdVector<Real>>(lp);
234 Ptr<Vector<Real> > u = makePtr<StdVector<Real>>(up);
236 return makePtr<Bounds<Real>>(l,u);
244 #endif // ROL_CANTILEVERBEAM_HPP
void applyJacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Ptr< BoundConstraint< Real > > getSlackBoundConstraint(void) const
Real value(const std::vector< Real > &x, Real &tol)
Ptr< Constraint< Real > > getInequalityConstraint(void) const
Defines the equality constraint operator interface for StdVectors.
Ptr< BoundConstraint< Real > > getBoundConstraint(void) const
Ptr< Objective< Real > > getObjective(void) const
Specializes the ROL::Objective interface for objective functions that operate on ROL::StdVector's.
getCantileverBeam(int nseg=5)
Contains definitions of test objective functions.
Constraint_CantileverBeam(const int nseg=5)
Objective_CantileverBeam(const int nseg=5)
std::vector< Real > suml_
Ptr< Vector< Real > > getSolution(const int i=0) const
Ptr< Vector< Real > > getInitialGuess(void) const
void hessVec(std::vector< Real > &hv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
Ptr< Vector< Real > > getInequalityMultiplier(void) const
void value(std::vector< Real > &c, const std::vector< Real > &x, Real &tol)
void applyAdjointJacobian(std::vector< Real > &ajv, const std::vector< Real > &v, const std::vector< Real > &x, Real &tol)
void gradient(std::vector< Real > &g, const std::vector< Real > &x, Real &tol)