ROL
ROL_SimpleEqConstrained.hpp
Go to the documentation of this file.
1// @HEADER
2// ************************************************************************
3//
4// Rapid Optimization Library (ROL) Package
5// Copyright (2014) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact lead developers:
38// Drew Kouri (dpkouri@sandia.gov) and
39// Denis Ridzal (dridzal@sandia.gov)
40//
41// ************************************************************************
42// @HEADER
43
51#ifndef ROL_SIMPLEEQCONSTRAINED_HPP
52#define ROL_SIMPLEEQCONSTRAINED_HPP
53
54#include "ROL_TestProblem.hpp"
55#include "ROL_StdVector.hpp"
56#include "Teuchos_SerialDenseVector.hpp"
57#include "Teuchos_SerialDenseSolver.hpp"
58
59namespace ROL {
60namespace ZOO {
61
65 template< class Real, class XPrim=StdVector<Real>, class XDual=StdVector<Real> >
67
68 typedef std::vector<Real> vector;
69 typedef Vector<Real> V;
70
71 typedef typename vector::size_type uint;
72
73
74 private:
75
76 template<class VectorType>
77 ROL::Ptr<const vector> getVector( const V& x ) {
78
79 return dynamic_cast<const VectorType&>(x).getVector();
80 }
81
82 template<class VectorType>
83 ROL::Ptr<vector> getVector( V& x ) {
84
85 return dynamic_cast<VectorType&>(x).getVector();
86 }
87
88 public:
90
91 Real value( const Vector<Real> &x, Real &tol ) {
92
93
94 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
95
96 uint n = xp->size();
97 ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, objective value): "
98 "Primal vector x must be of length 5.");
99
100 Real x1 = (*xp)[0];
101 Real x2 = (*xp)[1];
102 Real x3 = (*xp)[2];
103 Real x4 = (*xp)[3];
104 Real x5 = (*xp)[4];
105
106 Real arg = x1*x2*x3*x4*x5;
107 Real val = -0.5*pow(pow(x1,3)+pow(x2,3)+1.0,2);
108 if (std::abs(arg) < 1e5) val += exp(x1*x2*x3*x4*x5);
109 else if (arg > 1e5) val += 1e10;
110 //Real val = exp(x1*x2*x3*x4*x5) - 0.5 * pow( (pow(x1,3)+pow(x2,3)+1.0), 2);
111
112 return val;
113 }
114
115 void gradient( Vector<Real> &g, const Vector<Real> &x, Real &tol ) {
116
117
118 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
119 ROL::Ptr<vector> gp = getVector<XDual>(g);
120
121 uint n = xp->size();
122 ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, objective gradient): "
123 " Primal vector x must be of length 5.");
124
125 n = gp->size();
126 ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, objective gradient): "
127 "Gradient vector g must be of length 5.");
128
129 Real x1 = (*xp)[0];
130 Real x2 = (*xp)[1];
131 Real x3 = (*xp)[2];
132 Real x4 = (*xp)[3];
133 Real x5 = (*xp)[4];
134
135 Real expxi = exp(x1*x2*x3*x4*x5);
136
137 (*gp)[0] = x2*x3*x4*x5 * expxi - 3*pow(x1,2) * (pow(x1,3) + pow(x2,3) + 1);
138 (*gp)[1] = x1*x3*x4*x5 * expxi - 3*pow(x2,2) * (pow(x1,3) + pow(x2,3) + 1);
139 (*gp)[2] = x1*x2*x4*x5 * expxi;
140 (*gp)[3] = x1*x2*x3*x5 * expxi;
141 (*gp)[4] = x1*x2*x3*x4 * expxi;
142 }
143
144 void hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
145
146
147 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
148 ROL::Ptr<const vector> vp = getVector<XPrim>(v);
149 ROL::Ptr<vector> hvp = getVector<XDual>(hv);
150
151 uint n = xp->size();
152 ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, objective hessVec): "
153 "Primal vector x must be of length 5.");
154
155 n = vp->size();
156 ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, objective hessVec): "
157 "Input vector v must be of length 5.");
158
159 n = hvp->size();
160 ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, objective hessVec): "
161 "Output vector hv must be of length 5.");
162
163 Real x1 = (*xp)[0];
164 Real x2 = (*xp)[1];
165 Real x3 = (*xp)[2];
166 Real x4 = (*xp)[3];
167 Real x5 = (*xp)[4];
168
169 Real v1 = (*vp)[0];
170 Real v2 = (*vp)[1];
171 Real v3 = (*vp)[2];
172 Real v4 = (*vp)[3];
173 Real v5 = (*vp)[4];
174
175 Real expxi = exp(x1*x2*x3*x4*x5);
176
177 (*hvp)[0] = ( pow(x2,2)*pow(x3,2)*pow(x4,2)*pow(x5,2)*expxi-9.0*pow(x1,4)-6.0*(pow(x1,3)+pow(x2,3)+1.0)*x1 ) * v1 +
178 ( x3*x4*x5*expxi+x2*pow(x3,2)*pow(x4,2)*pow(x5,2)*x1*expxi-9.0*pow(x2,2)*pow(x1,2) ) * v2 +
179 ( x2*x4*x5*expxi+pow(x2,2)*x3*pow(x4,2)*pow(x5,2)*x1*expxi ) * v3 +
180 ( x2*x3*x5*expxi+pow(x2,2)*pow(x3,2)*x4*pow(x5,2)*x1*expxi ) * v4 +
181 ( x2*x3*x4*expxi+pow(x2,2)*pow(x3,2)*pow(x4,2)*x5*x1*expxi ) * v5;
182
183 (*hvp)[1] = ( x3*x4*x5*expxi+x2*pow(x3,2)*pow(x4,2)*pow(x5,2)*x1*expxi-9.0*pow(x2,2)*pow(x1,2) ) * v1 +
184 ( pow(x1,2)*pow(x3,2)*pow(x4,2)*pow(x5,2)*expxi-9.0*pow(x2,4)-6.0*(pow(x1,3)+pow(x2,3)+1.0)*x2 ) * v2 +
185 ( x1*x4*x5*expxi+pow(x1,2)*x3*pow(x4,2)*pow(x5,2)*x2*expxi ) * v3 +
186 ( x1*x3*x5*expxi+pow(x1,2)*pow(x3,2)*x4*pow(x5,2)*x2*expxi ) * v4 +
187 ( x1*x3*x4*expxi+pow(x1,2)*pow(x3,2)*pow(x4,2)*x5*x2*expxi ) * v5;
188
189 (*hvp)[2] = ( x2*x4*x5*expxi+pow(x2,2)*x3*pow(x4,2)*pow(x5,2)*x1*expxi ) * v1 +
190 ( x1*x4*x5*expxi+pow(x1,2)*x3*pow(x4,2)*pow(x5,2)*x2*expxi ) * v2 +
191 ( pow(x1,2)*pow(x2,2)*pow(x4,2)*pow(x5,2)*expxi ) * v3 +
192 ( x1*x2*x5*expxi+pow(x1,2)*pow(x2,2)*x4*pow(x5,2)*x3*expxi ) * v4 +
193 ( x1*x2*x4*expxi+pow(x1,2)*pow(x2,2)*pow(x4,2)*x5*x3*expxi ) * v5;
194
195 (*hvp)[3] = ( x2*x3*x5*expxi+pow(x2,2)*pow(x3,2)*x4*pow(x5,2)*x1*expxi ) * v1 +
196 ( x1*x3*x5*expxi+pow(x1,2)*pow(x3,2)*x4*pow(x5,2)*x2*expxi ) * v2 +
197 ( x1*x2*x5*expxi+pow(x1,2)*pow(x2,2)*x4*pow(x5,2)*x3*expxi ) * v3 +
198 ( pow(x1,2)*pow(x2,2)*pow(x3,2)*pow(x5,2)*expxi ) * v4 +
199 ( x1*x2*x3*expxi+pow(x1,2)*pow(x2,2)*pow(x3,2)*x5*x4*expxi ) * v5;
200
201 (*hvp)[4] = ( x2*x3*x4*expxi+pow(x2,2)*pow(x3,2)*pow(x4,2)*x5*x1*expxi ) * v1 +
202 ( x1*x3*x4*expxi+pow(x1,2)*pow(x3,2)*pow(x4,2)*x5*x2*expxi ) * v2 +
203 ( x1*x2*x4*expxi+pow(x1,2)*pow(x2,2)*pow(x4,2)*x5*x3*expxi ) * v3 +
204 ( x1*x2*x3*expxi+pow(x1,2)*pow(x2,2)*pow(x3,2)*x5*x4*expxi ) * v4 +
205 ( pow(x1,2)*pow(x2,2)*pow(x3,2)*pow(x4,2)*expxi ) * v5;
206 }
207
208 };
209
210
216 template<class Real, class XPrim=StdVector<Real>, class XDual=StdVector<Real>, class CPrim=StdVector<Real>, class CDual=StdVector<Real> >
218
219 typedef std::vector<Real> vector;
221
222 typedef typename vector::size_type uint;
223
224 private:
225 template<class VectorType>
226 ROL::Ptr<const vector> getVector( const V& x ) {
227
228 return dynamic_cast<const VectorType&>(x).getVector();
229 }
230
231 template<class VectorType>
232 ROL::Ptr<vector> getVector( V& x ) {
233
234 return dynamic_cast<VectorType&>(x).getVector();
235 }
236
237 public:
239
240 void value( Vector<Real> &c, const Vector<Real> &x, Real &tol ) {
241
242
243 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
244 ROL::Ptr<vector> cp = getVector<CPrim>(c);
245
246 uint n = xp->size();
247 ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint value): "
248 "Primal vector x must be of length 5.");
249
250 uint m = cp->size();
251 ROL_TEST_FOR_EXCEPTION( (m != 3), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint value): "
252 "Constraint vector c must be of length 3.");
253
254 Real x1 = (*xp)[0];
255 Real x2 = (*xp)[1];
256 Real x3 = (*xp)[2];
257 Real x4 = (*xp)[3];
258 Real x5 = (*xp)[4];
259
260 (*cp)[0] = x1*x1+x2*x2+x3*x3+x4*x4+x5*x5 - 10.0;
261 (*cp)[1] = x2*x3 - 5.0*x4*x5;
262 (*cp)[2] = x1*x1*x1 + x2*x2*x2 + 1.0;
263 }
264
265 void applyJacobian( Vector<Real> &jv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
266
267
268 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
269 ROL::Ptr<const vector> vp = getVector<XPrim>(v);
270 ROL::Ptr<vector> jvp = getVector<CPrim>(jv);
271
272 uint n = xp->size();
273 ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyJacobian): "
274 "Primal vector x must be of length 5.");
275
276 uint d = vp->size();
277 ROL_TEST_FOR_EXCEPTION( (d != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyJacobian): "
278 "Input vector v must be of length 5.");
279 d = jvp->size();
280 ROL_TEST_FOR_EXCEPTION( (d != 3), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyJacobian): "
281 "Output vector jv must be of length 3.");
282
283 Real x1 = (*xp)[0];
284 Real x2 = (*xp)[1];
285 Real x3 = (*xp)[2];
286 Real x4 = (*xp)[3];
287 Real x5 = (*xp)[4];
288
289 Real v1 = (*vp)[0];
290 Real v2 = (*vp)[1];
291 Real v3 = (*vp)[2];
292 Real v4 = (*vp)[3];
293 Real v5 = (*vp)[4];
294
295 (*jvp)[0] = 2.0*(x1*v1+x2*v2+x3*v3+x4*v4+x5*v5);
296 (*jvp)[1] = x3*v2+x2*v3-5.0*x5*v4-5.0*x4*v5;
297 (*jvp)[2] = 3.0*x1*x1*v1+3.0*x2*x2*v2;
298
299 } //applyJacobian
300
301 void applyAdjointJacobian( Vector<Real> &ajv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
302
303
304 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
305 ROL::Ptr<const vector> vp = getVector<CDual>(v);
306 ROL::Ptr<vector> ajvp = getVector<XDual>(ajv);
307
308 uint n = xp->size();
309 ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointJacobian): "
310 "Primal vector x must be of length 5.");
311
312 uint d = vp->size();
313 ROL_TEST_FOR_EXCEPTION( (d != 3), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointJacobian): "
314 "Input vector v must be of length 3.");
315
316 d = ajvp->size();
317 ROL_TEST_FOR_EXCEPTION( (d != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointJacobian): "
318 "Output vector ajv must be of length 5.");
319
320 Real x1 = (*xp)[0];
321 Real x2 = (*xp)[1];
322 Real x3 = (*xp)[2];
323 Real x4 = (*xp)[3];
324 Real x5 = (*xp)[4];
325
326 Real v1 = (*vp)[0];
327 Real v2 = (*vp)[1];
328 Real v3 = (*vp)[2];
329
330 (*ajvp)[0] = 2.0*x1*v1+3.0*x1*x1*v3;
331 (*ajvp)[1] = 2.0*x2*v1+x3*v2+3.0*x2*x2*v3;
332 (*ajvp)[2] = 2.0*x3*v1+x2*v2;
333 (*ajvp)[3] = 2.0*x4*v1-5.0*x5*v2;
334 (*ajvp)[4] = 2.0*x5*v1-5.0*x4*v2;
335
336 } //applyAdjointJacobian
337
338 void applyAdjointHessian( Vector<Real> &ahuv, const Vector<Real> &u, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
339
340 ROL::Ptr<const vector> xp = getVector<XPrim>(x);
341 ROL::Ptr<const vector> up = getVector<CDual>(u);
342 ROL::Ptr<const vector> vp = getVector<XPrim>(v);
343 ROL::Ptr<vector> ahuvp = getVector<XDual>(ahuv);
344
345 uint n = xp->size();
346 ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointHessian): "
347 "Primal vector x must be of length 5.");
348
349 n = vp->size();
350 ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointHessian): "
351 "Direction vector v must be of length 5.");
352
353 n = ahuvp->size();
354 ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointHessian): "
355 "Output vector ahuv must be of length 5.");
356 uint d = up->size();
357 ROL_TEST_FOR_EXCEPTION( (d != 3), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointHessian): "
358 "Dual constraint vector u must be of length 3.");
359
360 Real x1 = (*xp)[0];
361 Real x2 = (*xp)[1];
362
363 Real v1 = (*vp)[0];
364 Real v2 = (*vp)[1];
365 Real v3 = (*vp)[2];
366 Real v4 = (*vp)[3];
367 Real v5 = (*vp)[4];
368
369 Real u1 = (*up)[0];
370 Real u2 = (*up)[1];
371 Real u3 = (*up)[2];
372
373 (*ahuvp)[0] = 2.0*u1*v1 + 6.0*u3*x1*v1;
374 (*ahuvp)[1] = 2.0*u1*v2 + u2*v3 + 6.0*u3*x2*v2;
375 (*ahuvp)[2] = 2.0*u1*v3 + u2*v2;
376 (*ahuvp)[3] = 2.0*u1*v4 - 5.0*u2*v5;
377 (*ahuvp)[4] = 2.0*u1*v5 - 5.0*u2*v4;
378
379 } //applyAdjointHessian
380
381 /*std::vector<Real> solveAugmentedSystem(Vector<Real> &v1, Vector<Real> &v2, const Vector<Real> &b1, const Vector<Real> &b2, const Vector<Real> &x, Real &tol) {
382 ROL::Ptr<std::vector<Real> > v1p =
383 ROL::constPtrCast<std::vector<Real> >((dynamic_cast<XPrim&>(v1)).getVector());
384 ROL::Ptr<std::vector<Real> > v2p =
385 ROL::constPtrCast<std::vector<Real> >((dynamic_cast<CDual&>(v2)).getVector());
386 ROL::Ptr<const std::vector<Real> > b1p =
387 (dynamic_cast<XDual>(const_cast<Vector<Real> &&>(b1))).getVector();
388 ROL::Ptr<const std::vector<Real> > b2p =
389 (dynamic_cast<CPrim>(const_cast<Vector<Real> &&>(b2))).getVector();
390 ROL::Ptr<const std::vector<Real> > xp =
391 (dynamic_cast<XPrim>(const_cast<Vector<Real> &&>(x))).getVector();
392
393 Real x1 = (*xp)[0];
394 Real x2 = (*xp)[1];
395 Real x3 = (*xp)[2];
396 Real x4 = (*xp)[3];
397 Real x5 = (*xp)[4];
398
399 int i = 0;
400
401 // Assemble augmented system.
402 Teuchos::SerialDenseMatrix<int, Real> augmat(8,8);
403 for (i=0; i<5; i++) {
404 augmat(i,i) = 1.0;
405 }
406 augmat(5,0) = 2.0*x1; augmat(5,1) = 2.0*x2; augmat(5,2) = 2.0*x3; augmat(5,3) = 2.0*x4; augmat(5,4) = 2.0*x5;
407 augmat(6,1) = x3; augmat(6,2) = x2; augmat(6,3) = -5.0*x5; augmat(6,4) = -5.0*x4;
408 augmat(7,0) = 3.0*x1*x1; augmat(7,1) = 3.0*x2*x2;
409 augmat(0,5) = 2.0*x1; augmat(1,5) = 2.0*x2; augmat(2,5) = 2.0*x3; augmat(3,5) = 2.0*x4; augmat(4,5) = 2.0*x5;
410 augmat(1,6) = x3; augmat(2,6) = x2; augmat(3,6) = -5.0*x5; augmat(4,6) = -5.0*x4;
411 augmat(0,7) = 3.0*x1*x1; augmat(1,7) = 3.0*x2*x2;
412 Teuchos::SerialDenseVector<int, Real> lhs(8);
413 Teuchos::SerialDenseVector<int, Real> rhs(8);
414 for (i=0; i<5; i++) {
415 rhs(i) = (*b1p)[i];
416 }
417 for (i=5; i<8; i++) {
418 rhs(i) = (*b2p)[i-5];
419 }
420
421 // Solve augmented system.
422 Teuchos::SerialDenseSolver<int, Real> augsolver;
423 augsolver.setMatrix(&augmat, false);
424 augsolver.setVectors(&lhs, false), Teuchos::&rhs, false;
425 augsolver.solve();
426
427 // Retrieve solution.
428 for (i=0; i<5; i++) {
429 (*v1p)[i] = lhs(i);
430 }
431 for (i=0; i<3; i++) {
432 (*v2p)[i] = lhs(i+5);
433 }
434
435 return std::vector<Real>(0);
436
437 }*/ //solveAugmentedSystem
438
439 };
440
441
442 template<class Real, class XPrim=StdVector<Real>, class XDual=StdVector<Real>, class CPrim=StdVector<Real>, class CDual=StdVector<Real> >
443 class getSimpleEqConstrained : public TestProblem<Real> {
444 typedef std::vector<Real> vector;
445 typedef typename vector::size_type uint;
446 public:
448
449 Ptr<Objective<Real>> getObjective(void) const {
450 // Instantiate objective function.
451 return ROL::makePtr<Objective_SimpleEqConstrained<Real,XPrim,XDual>>();
452 }
453
454 Ptr<Vector<Real>> getInitialGuess(void) const {
455 uint n = 5;
456 // Get initial guess.
457 Ptr<vector> x0p = makePtr<vector>(n,0);
458 (*x0p)[0] = -1.8;
459 (*x0p)[1] = 1.7;
460 (*x0p)[2] = 1.9;
461 (*x0p)[3] = -0.8;
462 (*x0p)[4] = -0.8;
463 return makePtr<XPrim>(x0p);
464 }
465
466 Ptr<Vector<Real>> getSolution(const int i = 0) const {
467 uint n = 5;
468 // Get solution.
469 Ptr<vector> solp = makePtr<vector>(n,0);
470 (*solp)[0] = -1.717143570394391e+00;
471 (*solp)[1] = 1.595709690183565e+00;
472 (*solp)[2] = 1.827245752927178e+00;
473 (*solp)[3] = -7.636430781841294e-01;
474 (*solp)[4] = -7.636430781841294e-01;
475 return makePtr<XPrim>(solp);
476 }
477
478 Ptr<Constraint<Real>> getEqualityConstraint(void) const {
479 // Instantiate constraints.
480 return ROL::makePtr<EqualityConstraint_SimpleEqConstrained<Real,XPrim,XDual,CPrim,CDual>>();
481 }
482
483 Ptr<Vector<Real>> getEqualityMultiplier(void) const {
484 Ptr<vector> lp = makePtr<vector>(3,0);
485 return makePtr<CDual>(lp);
486 }
487 };
488
489} // End ZOO Namespace
490} // End ROL Namespace
491
492#endif
Contains definitions of test objective functions.
Defines the general constraint operator interface.
Provides the interface to evaluate objective functions.
Defines the linear algebra or vector space interface.
Equality constraints c_i(x) = 0, where: c1(x) = x1^2+x2^2+x3^2+x4^2+x5^2 - 10 c2(x) = x2*x3-5*x4*x5 c...
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the derivative of the adjoint of the constraint Jacobian at to vector in direction ,...
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the constraint Jacobian at , , to vector .
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol)
Evaluate the constraint operator at .
void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the adjoint of the the constraint Jacobian at , , to vector .
Objective function: f(x) = exp(x1*x2*x3*x4*x5) + 0.5*(x1^3+x2^3+1)^2.
Real value(const Vector< Real > &x, Real &tol)
Compute value.
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
ROL::Ptr< const vector > getVector(const V &x)
Ptr< Vector< Real > > getSolution(const int i=0) const
Ptr< Vector< Real > > getInitialGuess(void) const
Ptr< Objective< Real > > getObjective(void) const
Ptr< Vector< Real > > getEqualityMultiplier(void) const
Ptr< Constraint< Real > > getEqualityConstraint(void) const