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