72 typedef typename vector::size_type
uint;
77 Teuchos::RCP<const vector>
getVector(
const V& x ) {
78 using Teuchos::dyn_cast;
83 using Teuchos::dyn_cast;
97 Real h = 1.0/((Real)(dim_) + 1.0);
98 for ( uint i = 0; i <
dim_; i++ ) {
99 f = 2.0*(*ex)[i] + h*h*std::pow((*ex)[i] + (Real)(i+1)*h + 1.0,3.0)/2.0;
100 if ( i < (dim_-1) ) { f -= (*ex)[i+1]; }
101 if ( i > 0 ) { f -= (*ex)[i-1]; }
113 Real h = 1.0/((Real)(dim_) + 1.0);
116 for ( uint i = 0; i <
dim_; i++ ) {
117 f[i] = 2.0*(*ex)[i] + h*h*std::pow((*ex)[i] + (Real)(i+1)*h + 1.0,3.0)/2.0;
118 if ( i < (dim_-1) ) { f[i] -= (*ex)[i+1]; }
119 if ( i > 0) { f[i] -= (*ex)[i-1]; }
122 for ( uint i = 0; i <
dim_; i++ ) {
123 df = (2.0 + 3.0*h*h*std::pow((*ex)[i] + (Real)(i+1)*h + 1.0,2.0)/2.0)*f[i];
124 if ( i < (dim_-1) ) { df -= f[i+1]; }
125 if ( i > 0 ) { df -= f[i-1]; }
138 Real h = 1.0/((Real)(dim_) + 1.0);
139 Real f = 0.0, df = 0.0, dfn = 0.0, hf = 0.0;
140 for ( uint i = 0; i <
dim_; i++ ) {
141 f = 2.0*(*ex)[i] + h*h*std::pow((*ex)[i] + (Real)(i+1)*h + 1.0,3.0)/2.0;
142 df = 2.0 + 3.0/2.0 * h*h * std::pow((*ex)[i] + (Real)(i+1)*h + 1.0,2.0);
143 hf = 3.0 * h*h * ((*ex)[i] + (Real)(i+1)*h + 1.0);
144 if ( i < (dim_-2) ) {
145 (*ehv)[i] += 2.0*(*ev)[i+2];
147 if ( i < (dim_-1) ) {
149 dfn = 2.0 + 3.0/2.0 * h*h * std::pow((*ex)[i+1] + (Real)(i+2)*h + 1.0,2.0);
150 (*ehv)[i] -= 2.0*(df + dfn)*(*ev)[i+1];
151 (*ehv)[i] += 2.0*(*ev)[i];
155 dfn = 2.0 + 3.0/2.0 * h*h * std::pow((*ex)[i-1] + (Real)(i)*h + 1.0,2.0);
156 (*ehv)[i] -= 2.0*(df + dfn)*(*ev)[i-1];
157 (*ehv)[i] += 2.0*(*ev)[i];
160 (*ehv)[i] += 2.0*(*ev)[i-2];
162 (*ehv)[i] += 2.0*(hf*f + df*df)*(*ev)[i];
172 typedef std::vector<Real>
vector;
176 typedef typename vector::size_type
uint;
180 using Teuchos::dyn_cast;
183 RCP<vector> x0p = dyn_cast<SV>(x0).
getVector();
184 RCP<vector> xp = dyn_cast<SV>(x).
getVector();
196 RCP<vector> l_rcp = rcp(
new vector() );
197 RCP<vector> u_rcp = rcp(
new vector() );
199 RCP<V> l = rcp(
new SV(l_rcp) );
200 RCP<V> u = rcp(
new SV(u_rcp) );
202 std::vector<Real> val(n,0.0);
204 val[1] = -0.1*0.4520;
205 val[2] = -0.1*0.6588;
206 val[3] = -0.1*0.8514;
207 val[4] = -0.1*1.0288;
208 val[5] = -0.1*1.1985;
209 val[6] = -0.1*1.3322;
210 val[7] = -0.1*1.4553;
211 val[8] = -0.1*1.5571;
212 val[9] = -0.1*1.6354;
213 val[10] = -0.1*1.6881;
214 val[11] = -0.1*1.7127;
215 val[12] = -0.1*1.7060;
216 val[13] = -0.1*1.6650;
217 val[14] = -0.1*1.5856;
218 val[15] = -0.1*1.4636;
219 val[16] = -0.1*1.2938;
220 val[17] = -0.1*1.0702;
221 val[18] = -0.1*0.7858;
222 val[19] = -0.1*0.4323;
223 for ( uint i = 0; i < n; i++ ) {
225 l_rcp->push_back(std::max(-0.2*(Real)(n),val[i]+0.1));
226 u_rcp->push_back(std::min( 0.2*(Real)(n),val[i]+1.1));
229 l_rcp->push_back(-0.2*(Real)(n));
230 u_rcp->push_back( 0.2*(Real)(n));
236 Real h = 1.0/((Real)n + 1.0);
237 for ( uint i = 0; i < n; i++ ) {
238 (*x0p)[i] = (Real)(i+1)*h*((Real)(i+1)*h - 1.0);
242 (*xp)[0] = 1.2321000000000001e-01;
243 (*xp)[1] = 2.1743122909175336e-01;
244 (*xp)[2] = 2.8625218549543746e-01;
245 (*xp)[3] = 3.3309751851140840e-01;
246 (*xp)[4] = 3.6117201714254760e-01;
247 (*xp)[5] = 3.7342787212179440e-01;
248 (*xp)[6] = 3.7255212003706123e-01;
249 (*xp)[7] = 3.6096984201471016e-01;
250 (*xp)[8] = 3.4085861052124522e-01;
251 (*xp)[9] = 3.1417024791439530e-01;
252 (*xp)[10] = 2.8265678244892922e-01;
253 (*xp)[11] = 2.4789833165179542e-01;
254 (*xp)[12] = 2.1133139591375166e-01;
255 (*xp)[13] = 1.7427666644258599e-01;
256 (*xp)[14] = 1.3796594229036069e-01;
257 (*xp)[15] = 1.0356813245768780e-01;
258 (*xp)[16] = 7.2214621084083663e-02;
259 (*xp)[17] = 4.5024529114833199e-02;
260 (*xp)[18] = 2.3130648161534966e-02;
261 (*xp)[19] = 7.7070870882527927e-03;
Provides the interface to evaluate objective functions.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Teuchos::RCP< vector > getVector(V &x)
Teuchos::RCP< const vector > getVector(const V &x)
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
Provides the std::vector implementation of the ROL::Vector interface.
void getBVP(Teuchos::RCP< Objective< Real > > &obj, Teuchos::RCP< BoundConstraint< Real > > &con, Vector< Real > &x0, Vector< Real > &x)
The discrete boundary value problem.
Provides the interface to apply upper and lower bound constraints.
std::vector< Real > vector