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 
59 namespace ROL {
60 namespace 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 val = exp(x1*x2*x3*x4*x5) - 0.5 * pow( (pow(x1,3)+pow(x2,3)+1.0), 2);
107 
108  return val;
109  }
110 
111  void gradient( Vector<Real> &g, const Vector<Real> &x, Real &tol ) {
112 
113 
114  ROL::Ptr<const vector> xp = getVector<XPrim>(x);
115  ROL::Ptr<vector> gp = getVector<XDual>(g);
116 
117  uint n = xp->size();
118  ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, objective gradient): "
119  " Primal vector x must be of length 5.");
120 
121  n = gp->size();
122  ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, objective gradient): "
123  "Gradient vector g must be of length 5.");
124 
125  Real x1 = (*xp)[0];
126  Real x2 = (*xp)[1];
127  Real x3 = (*xp)[2];
128  Real x4 = (*xp)[3];
129  Real x5 = (*xp)[4];
130 
131  Real expxi = exp(x1*x2*x3*x4*x5);
132 
133  (*gp)[0] = x2*x3*x4*x5 * expxi - 3*pow(x1,2) * (pow(x1,3) + pow(x2,3) + 1);
134  (*gp)[1] = x1*x3*x4*x5 * expxi - 3*pow(x2,2) * (pow(x1,3) + pow(x2,3) + 1);
135  (*gp)[2] = x1*x2*x4*x5 * expxi;
136  (*gp)[3] = x1*x2*x3*x5 * expxi;
137  (*gp)[4] = x1*x2*x3*x4 * expxi;
138  }
139 
140  void hessVec( Vector<Real> &hv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
141 
142 
143  ROL::Ptr<const vector> xp = getVector<XPrim>(x);
144  ROL::Ptr<const vector> vp = getVector<XPrim>(v);
145  ROL::Ptr<vector> hvp = getVector<XDual>(hv);
146 
147  uint n = xp->size();
148  ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, objective hessVec): "
149  "Primal vector x must be of length 5.");
150 
151  n = vp->size();
152  ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, objective hessVec): "
153  "Input vector v must be of length 5.");
154 
155  n = hvp->size();
156  ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, objective hessVec): "
157  "Output vector hv must be of length 5.");
158 
159  Real x1 = (*xp)[0];
160  Real x2 = (*xp)[1];
161  Real x3 = (*xp)[2];
162  Real x4 = (*xp)[3];
163  Real x5 = (*xp)[4];
164 
165  Real v1 = (*vp)[0];
166  Real v2 = (*vp)[1];
167  Real v3 = (*vp)[2];
168  Real v4 = (*vp)[3];
169  Real v5 = (*vp)[4];
170 
171  Real expxi = exp(x1*x2*x3*x4*x5);
172 
173  (*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 +
174  ( 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 +
175  ( x2*x4*x5*expxi+pow(x2,2)*x3*pow(x4,2)*pow(x5,2)*x1*expxi ) * v3 +
176  ( x2*x3*x5*expxi+pow(x2,2)*pow(x3,2)*x4*pow(x5,2)*x1*expxi ) * v4 +
177  ( x2*x3*x4*expxi+pow(x2,2)*pow(x3,2)*pow(x4,2)*x5*x1*expxi ) * v5;
178 
179  (*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 +
180  ( 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 +
181  ( x1*x4*x5*expxi+pow(x1,2)*x3*pow(x4,2)*pow(x5,2)*x2*expxi ) * v3 +
182  ( x1*x3*x5*expxi+pow(x1,2)*pow(x3,2)*x4*pow(x5,2)*x2*expxi ) * v4 +
183  ( x1*x3*x4*expxi+pow(x1,2)*pow(x3,2)*pow(x4,2)*x5*x2*expxi ) * v5;
184 
185  (*hvp)[2] = ( x2*x4*x5*expxi+pow(x2,2)*x3*pow(x4,2)*pow(x5,2)*x1*expxi ) * v1 +
186  ( x1*x4*x5*expxi+pow(x1,2)*x3*pow(x4,2)*pow(x5,2)*x2*expxi ) * v2 +
187  ( pow(x1,2)*pow(x2,2)*pow(x4,2)*pow(x5,2)*expxi ) * v3 +
188  ( x1*x2*x5*expxi+pow(x1,2)*pow(x2,2)*x4*pow(x5,2)*x3*expxi ) * v4 +
189  ( x1*x2*x4*expxi+pow(x1,2)*pow(x2,2)*pow(x4,2)*x5*x3*expxi ) * v5;
190 
191  (*hvp)[3] = ( x2*x3*x5*expxi+pow(x2,2)*pow(x3,2)*x4*pow(x5,2)*x1*expxi ) * v1 +
192  ( x1*x3*x5*expxi+pow(x1,2)*pow(x3,2)*x4*pow(x5,2)*x2*expxi ) * v2 +
193  ( x1*x2*x5*expxi+pow(x1,2)*pow(x2,2)*x4*pow(x5,2)*x3*expxi ) * v3 +
194  ( pow(x1,2)*pow(x2,2)*pow(x3,2)*pow(x5,2)*expxi ) * v4 +
195  ( x1*x2*x3*expxi+pow(x1,2)*pow(x2,2)*pow(x3,2)*x5*x4*expxi ) * v5;
196 
197  (*hvp)[4] = ( x2*x3*x4*expxi+pow(x2,2)*pow(x3,2)*pow(x4,2)*x5*x1*expxi ) * v1 +
198  ( x1*x3*x4*expxi+pow(x1,2)*pow(x3,2)*pow(x4,2)*x5*x2*expxi ) * v2 +
199  ( x1*x2*x4*expxi+pow(x1,2)*pow(x2,2)*pow(x4,2)*x5*x3*expxi ) * v3 +
200  ( x1*x2*x3*expxi+pow(x1,2)*pow(x2,2)*pow(x3,2)*x5*x4*expxi ) * v4 +
201  ( pow(x1,2)*pow(x2,2)*pow(x3,2)*pow(x4,2)*expxi ) * v5;
202  }
203 
204  };
205 
206 
212  template<class Real, class XPrim=StdVector<Real>, class XDual=StdVector<Real>, class CPrim=StdVector<Real>, class CDual=StdVector<Real> >
214 
215  typedef std::vector<Real> vector;
216  typedef Vector<Real> V;
217 
218  typedef typename vector::size_type uint;
219 
220  private:
221  template<class VectorType>
222  ROL::Ptr<const vector> getVector( const V& x ) {
223 
224  return dynamic_cast<const VectorType&>(x).getVector();
225  }
226 
227  template<class VectorType>
228  ROL::Ptr<vector> getVector( V& x ) {
229 
230  return dynamic_cast<VectorType&>(x).getVector();
231  }
232 
233  public:
235 
236  void value( Vector<Real> &c, const Vector<Real> &x, Real &tol ) {
237 
238 
239  ROL::Ptr<const vector> xp = getVector<XPrim>(x);
240  ROL::Ptr<vector> cp = getVector<CPrim>(c);
241 
242  uint n = xp->size();
243  ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint value): "
244  "Primal vector x must be of length 5.");
245 
246  uint m = cp->size();
247  ROL_TEST_FOR_EXCEPTION( (m != 3), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint value): "
248  "Constraint vector c must be of length 3.");
249 
250  Real x1 = (*xp)[0];
251  Real x2 = (*xp)[1];
252  Real x3 = (*xp)[2];
253  Real x4 = (*xp)[3];
254  Real x5 = (*xp)[4];
255 
256  (*cp)[0] = x1*x1+x2*x2+x3*x3+x4*x4+x5*x5 - 10.0;
257  (*cp)[1] = x2*x3 - 5.0*x4*x5;
258  (*cp)[2] = x1*x1*x1 + x2*x2*x2 + 1.0;
259  }
260 
261  void applyJacobian( Vector<Real> &jv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
262 
263 
264  ROL::Ptr<const vector> xp = getVector<XPrim>(x);
265  ROL::Ptr<const vector> vp = getVector<XPrim>(v);
266  ROL::Ptr<vector> jvp = getVector<CPrim>(jv);
267 
268  uint n = xp->size();
269  ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyJacobian): "
270  "Primal vector x must be of length 5.");
271 
272  uint d = vp->size();
273  ROL_TEST_FOR_EXCEPTION( (d != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyJacobian): "
274  "Input vector v must be of length 5.");
275  d = jvp->size();
276  ROL_TEST_FOR_EXCEPTION( (d != 3), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyJacobian): "
277  "Output vector jv must be of length 3.");
278 
279  Real x1 = (*xp)[0];
280  Real x2 = (*xp)[1];
281  Real x3 = (*xp)[2];
282  Real x4 = (*xp)[3];
283  Real x5 = (*xp)[4];
284 
285  Real v1 = (*vp)[0];
286  Real v2 = (*vp)[1];
287  Real v3 = (*vp)[2];
288  Real v4 = (*vp)[3];
289  Real v5 = (*vp)[4];
290 
291  (*jvp)[0] = 2.0*(x1*v1+x2*v2+x3*v3+x4*v4+x5*v5);
292  (*jvp)[1] = x3*v2+x2*v3-5.0*x5*v4-5.0*x4*v5;
293  (*jvp)[2] = 3.0*x1*x1*v1+3.0*x2*x2*v2;
294 
295  } //applyJacobian
296 
297  void applyAdjointJacobian( Vector<Real> &ajv, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
298 
299 
300  ROL::Ptr<const vector> xp = getVector<XPrim>(x);
301  ROL::Ptr<const vector> vp = getVector<CDual>(v);
302  ROL::Ptr<vector> ajvp = getVector<XDual>(ajv);
303 
304  uint n = xp->size();
305  ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointJacobian): "
306  "Primal vector x must be of length 5.");
307 
308  uint d = vp->size();
309  ROL_TEST_FOR_EXCEPTION( (d != 3), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointJacobian): "
310  "Input vector v must be of length 3.");
311 
312  d = ajvp->size();
313  ROL_TEST_FOR_EXCEPTION( (d != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointJacobian): "
314  "Output vector ajv must be of length 5.");
315 
316  Real x1 = (*xp)[0];
317  Real x2 = (*xp)[1];
318  Real x3 = (*xp)[2];
319  Real x4 = (*xp)[3];
320  Real x5 = (*xp)[4];
321 
322  Real v1 = (*vp)[0];
323  Real v2 = (*vp)[1];
324  Real v3 = (*vp)[2];
325 
326  (*ajvp)[0] = 2.0*x1*v1+3.0*x1*x1*v3;
327  (*ajvp)[1] = 2.0*x2*v1+x3*v2+3.0*x2*x2*v3;
328  (*ajvp)[2] = 2.0*x3*v1+x2*v2;
329  (*ajvp)[3] = 2.0*x4*v1-5.0*x5*v2;
330  (*ajvp)[4] = 2.0*x5*v1-5.0*x4*v2;
331 
332  } //applyAdjointJacobian
333 
334  void applyAdjointHessian( Vector<Real> &ahuv, const Vector<Real> &u, const Vector<Real> &v, const Vector<Real> &x, Real &tol ) {
335 
336  ROL::Ptr<const vector> xp = getVector<XPrim>(x);
337  ROL::Ptr<const vector> up = getVector<CDual>(u);
338  ROL::Ptr<const vector> vp = getVector<XPrim>(v);
339  ROL::Ptr<vector> ahuvp = getVector<XDual>(ahuv);
340 
341  uint n = xp->size();
342  ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointHessian): "
343  "Primal vector x must be of length 5.");
344 
345  n = vp->size();
346  ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointHessian): "
347  "Direction vector v must be of length 5.");
348 
349  n = ahuvp->size();
350  ROL_TEST_FOR_EXCEPTION( (n != 5), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointHessian): "
351  "Output vector ahuv must be of length 5.");
352  uint d = up->size();
353  ROL_TEST_FOR_EXCEPTION( (d != 3), std::invalid_argument, ">>> ERROR (ROL_SimpleEqConstrained, constraint applyAdjointHessian): "
354  "Dual constraint vector u must be of length 3.");
355 
356  Real x1 = (*xp)[0];
357  Real x2 = (*xp)[1];
358 
359  Real v1 = (*vp)[0];
360  Real v2 = (*vp)[1];
361  Real v3 = (*vp)[2];
362  Real v4 = (*vp)[3];
363  Real v5 = (*vp)[4];
364 
365  Real u1 = (*up)[0];
366  Real u2 = (*up)[1];
367  Real u3 = (*up)[2];
368 
369  (*ahuvp)[0] = 2.0*u1*v1 + 6.0*u3*x1*v1;
370  (*ahuvp)[1] = 2.0*u1*v2 + u2*v3 + 6.0*u3*x2*v2;
371  (*ahuvp)[2] = 2.0*u1*v3 + u2*v2;
372  (*ahuvp)[3] = 2.0*u1*v4 - 5.0*u2*v5;
373  (*ahuvp)[4] = 2.0*u1*v5 - 5.0*u2*v4;
374 
375  } //applyAdjointHessian
376 
377  /*std::vector<Real> solveAugmentedSystem(Vector<Real> &v1, Vector<Real> &v2, const Vector<Real> &b1, const Vector<Real> &b2, const Vector<Real> &x, Real &tol) {
378  ROL::Ptr<std::vector<Real> > v1p =
379  ROL::constPtrCast<std::vector<Real> >((dynamic_cast<XPrim&>(v1)).getVector());
380  ROL::Ptr<std::vector<Real> > v2p =
381  ROL::constPtrCast<std::vector<Real> >((dynamic_cast<CDual&>(v2)).getVector());
382  ROL::Ptr<const std::vector<Real> > b1p =
383  (dynamic_cast<XDual>(const_cast<Vector<Real> &&>(b1))).getVector();
384  ROL::Ptr<const std::vector<Real> > b2p =
385  (dynamic_cast<CPrim>(const_cast<Vector<Real> &&>(b2))).getVector();
386  ROL::Ptr<const std::vector<Real> > xp =
387  (dynamic_cast<XPrim>(const_cast<Vector<Real> &&>(x))).getVector();
388 
389  Real x1 = (*xp)[0];
390  Real x2 = (*xp)[1];
391  Real x3 = (*xp)[2];
392  Real x4 = (*xp)[3];
393  Real x5 = (*xp)[4];
394 
395  int i = 0;
396 
397  // Assemble augmented system.
398  Teuchos::SerialDenseMatrix<int, Real> augmat(8,8);
399  for (i=0; i<5; i++) {
400  augmat(i,i) = 1.0;
401  }
402  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;
403  augmat(6,1) = x3; augmat(6,2) = x2; augmat(6,3) = -5.0*x5; augmat(6,4) = -5.0*x4;
404  augmat(7,0) = 3.0*x1*x1; augmat(7,1) = 3.0*x2*x2;
405  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;
406  augmat(1,6) = x3; augmat(2,6) = x2; augmat(3,6) = -5.0*x5; augmat(4,6) = -5.0*x4;
407  augmat(0,7) = 3.0*x1*x1; augmat(1,7) = 3.0*x2*x2;
408  Teuchos::SerialDenseVector<int, Real> lhs(8);
409  Teuchos::SerialDenseVector<int, Real> rhs(8);
410  for (i=0; i<5; i++) {
411  rhs(i) = (*b1p)[i];
412  }
413  for (i=5; i<8; i++) {
414  rhs(i) = (*b2p)[i-5];
415  }
416 
417  // Solve augmented system.
418  Teuchos::SerialDenseSolver<int, Real> augsolver;
419  augsolver.setMatrix(&augmat, false);
420  augsolver.setVectors(&lhs, false), Teuchos::&rhs, false;
421  augsolver.solve();
422 
423  // Retrieve solution.
424  for (i=0; i<5; i++) {
425  (*v1p)[i] = lhs(i);
426  }
427  for (i=0; i<3; i++) {
428  (*v2p)[i] = lhs(i+5);
429  }
430 
431  return std::vector<Real>(0);
432 
433  }*/ //solveAugmentedSystem
434 
435  };
436 
437 
438  template<class Real, class XPrim=StdVector<Real>, class XDual=StdVector<Real>, class CPrim=StdVector<Real>, class CDual=StdVector<Real> >
439  class getSimpleEqConstrained : public TestProblem<Real> {
440  typedef std::vector<Real> vector;
441  typedef typename vector::size_type uint;
442  public:
444 
445  Ptr<Objective<Real>> getObjective(void) const {
446  // Instantiate objective function.
447  return ROL::makePtr<Objective_SimpleEqConstrained<Real,XPrim,XDual>>();
448  }
449 
450  Ptr<Vector<Real>> getInitialGuess(void) const {
451  uint n = 5;
452  // Get initial guess.
453  Ptr<vector> x0p = makePtr<vector>(n,0);
454  (*x0p)[0] = -1.8;
455  (*x0p)[1] = 1.7;
456  (*x0p)[2] = 1.9;
457  (*x0p)[3] = -0.8;
458  (*x0p)[4] = -0.8;
459  return makePtr<XPrim>(x0p);
460  }
461 
462  Ptr<Vector<Real>> getSolution(const int i = 0) const {
463  uint n = 5;
464  // Get solution.
465  Ptr<vector> solp = makePtr<vector>(n,0);
466  (*solp)[0] = -1.717143570394391e+00;
467  (*solp)[1] = 1.595709690183565e+00;
468  (*solp)[2] = 1.827245752927178e+00;
469  (*solp)[3] = -7.636430781841294e-01;
470  (*solp)[4] = -7.636430781841294e-01;
471  return makePtr<XPrim>(solp);
472  }
473 
474  Ptr<Constraint<Real>> getEqualityConstraint(void) const {
475  // Instantiate constraints.
476  return ROL::makePtr<EqualityConstraint_SimpleEqConstrained<Real,XPrim,XDual,CPrim,CDual>>();
477  }
478 
479  Ptr<Vector<Real>> getEqualityMultiplier(void) const {
480  Ptr<vector> lp = makePtr<vector>(3,0);
481  return makePtr<CDual>(lp);
482  }
483  };
484 
485 } // End ZOO Namespace
486 } // End ROL Namespace
487 
488 #endif
Provides the interface to evaluate objective functions.
typename PV< Real >::size_type size_type
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 value(Vector< Real > &c, const Vector< Real > &x, Real &tol)
Evaluate the constraint operator at .
Ptr< Constraint< Real > > getEqualityConstraint(void) const
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply the constraint Jacobian at , , to vector .
Ptr< Vector< Real > > getEqualityMultiplier(void) const
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
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 .
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
ROL::Ptr< const vector > getVector(const V &x)
Contains definitions of test objective functions.
Ptr< Objective< Real > > getObjective(void) const
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Ptr< Vector< Real > > getSolution(const int i=0) const
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 ...
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Ptr< Vector< Real > > getInitialGuess(void) const
Defines the general constraint operator interface.
Objective function: f(x) = exp(x1*x2*x3*x4*x5) + 0.5*(x1^3+x2^3+1)^2.