51 #ifndef ROL_CANTILEVERBEAM_HPP
52 #define ROL_CANTILEVERBEAM_HPP
76 Real
value(
const std::vector<Real> &x, Real &tol ) {
78 for (
int i = 0; i <
nseg_; ++i) {
84 void gradient( std::vector<Real> &g,
const std::vector<Real> &x, Real &tol ) {
85 for (
int i = 0; i <
nseg_; ++i) {
91 void hessVec( std::vector<Real> &hv,
const std::vector<Real> &v,
const std::vector<Real> &x, Real &tol ) {
92 for (
int i = 0; i <
nseg_; ++i) {
110 const Real half(0.5);
116 for (
int i = 0; i <
nseg_; ++i) {
117 suml_[i] =
static_cast<Real
>(i+1)*
l_[i];
123 void value( std::vector<Real> &c,
const std::vector<Real> &x, Real &tol ) {
124 const Real one(1), two(2), three(3), twelve(12), twenty(20);
126 Real Inertia(0), sigma(0), sumy1(0), sumypl(0);
127 for (
int i = 0; i <
nseg_; ++i) {
129 Inertia = x[i]*std::pow(x[i+nseg_],3)/twelve;
130 sigma =
M_[i]*(x[i+
nseg_]/two)/Inertia;
135 y1[i] =
P_*std::pow(
l_[i],2)/(two*
E_*Inertia) * (
len_ -
suml_[i] + two/three*
l_[i]);
140 for (
int i = 1; i <
nseg_; ++i) {
142 sumypl += yp[i-1]*
l_[i];
144 Real yN = sumy1 + sumypl;
149 const std::vector<Real> &x, Real &tol ) {
150 const Real two(2), three(3), six(6), twelve(12), twenty(20);
152 Real Inertia(0), dyN(0), sumW(0), sumH(0);
153 for (
int i = 0; i <
nseg_; ++i) {
155 jv[i] = -six/
Sigma_max_*
M_[i]*v[i]/std::pow(x[i]*x[i+nseg_],2)
160 Inertia = x[i]*std::pow(x[i+nseg_],3)/twelve;
166 jv[2*
nseg_] = sumW+sumH;
170 const std::vector<Real> &x, Real &tol ) {
171 const Real two(2), three(3), six(6), twelve(12), twenty(20);
173 Real Inertia(0), dyN(0);
174 for (
int i = 0; i <
nseg_; ++i) {
176 ajv[i] = -six/
Sigma_max_*
M_[i]*v[i]/std::pow(x[i]*x[i+nseg_],2);
179 ajv[i] += -twenty*v[i+
nseg_];
182 Inertia = x[i]*std::pow(x[i+nseg_],3)/twelve;
207 return makePtr<Objective_CantileverBeam<Real>>(
nseg_);
211 return makePtr<Constraint_CantileverBeam<Real>>(
nseg_);
216 Ptr<std::vector<Real>> lp = makePtr<std::vector<Real>>(2*
nseg_);
217 for (
int i = 0; i <
nseg_; ++i) {
218 (*lp)[i] =
static_cast<Real
>(1);
219 (*lp)[i+
nseg_] =
static_cast<Real
>(5);
223 Ptr<std::vector<Real>> up = makePtr<std::vector<Real>>(2*
nseg_,ROL_INF<Real>());
225 Ptr<Vector<Real>> l = makePtr<StdVector<Real>>(lp);
226 Ptr<Vector<Real>> u = makePtr<StdVector<Real>>(up);
228 return makePtr<Bounds<Real>>(l,u);
232 Ptr<std::vector<Real> > x0p = makePtr<std::vector<Real>>(2*
nseg_,0);
233 for (
int i = 0; i <
nseg_; ++i) {
234 (*x0p)[i] =
static_cast<Real
>(5);
235 (*x0p)[i+
nseg_] =
static_cast<Real
>(40);
238 return makePtr<StdVector<Real>>(x0p);
246 Ptr<std::vector<Real>> xp = makePtr<std::vector<Real>>(2*
nseg_);
247 for (
int i = 0; i <
nseg_; ++i) {
249 (*xp)[i+
nseg_] = std::sqrt(3.0);
252 return makePtr<StdVector<Real>>(xp);
256 Ptr<std::vector<Real> > lp = makePtr<std::vector<Real>>(2*
nseg_+1,0.0);
257 return makePtr<StdVector<Real>>(lp);
262 Ptr<std::vector<Real> > lp = makePtr<std::vector<Real>>(2*
nseg_+1,ROL_NINF<Real>());
265 Ptr<std::vector<Real> > up = makePtr<std::vector<Real>>(2*nseg_+1,0);
267 Ptr<Vector<Real> > l = makePtr<StdVector<Real>>(lp);
268 Ptr<Vector<Real> > u = makePtr<StdVector<Real>>(up);
270 return makePtr<Bounds<Real>>(l,u);
278 #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)