Debian Codegraph @

packages/rol/adapters/sacado/test/HS/HS_Problem_039.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef HS_PROBLEM_039_HPP
11 #define HS_PROBLEM_039_HPP
12
13 #include "ROL_NonlinearProgram.hpp"
14
15 namespace HS {
16
17 namespace HS_039 {
18 template<class Real>
19 class Obj {
20 public:
21 template<class ScalarT>
22 ScalarT value( const std::vector<ScalarT> &x, Real &tol ) {
23 return -x[0];
24 }
25 };
26
27 template<class Real>
28 class EqCon {
29 public:
30 template<class ScalarT>
31 void value( std::vector<ScalarT> &c,
32 const std::vector<ScalarT> &x,
33 Real &tol ) {
34 c[0] = x[1] - x[0]*x[0]*x[0] - x[2]*x[2];
35 c[1] = x[0]*x[0] - x[1] - x[3]*x[3];
36 }
37 };
38 } // HS_039
39
40
41 template<class Real>
42 class Problem_039 : public ROL::NonlinearProgram<Real> {
43
44
45
46 typedef ROL::NonlinearProgram<Real> NP;
47 typedef ROL::Vector<Real> V;
48 typedef ROL::Objective<Real> OBJ;
49 typedef ROL::Constraint<Real> CON;
50
51 public:
52
53 Problem_039() : NP( dimension_x() ) {
54 NP::noBound();
55 }
56
57 int dimension_x() { return 4; }
58 int dimension_ce() { return 2; }
59
60 const ROL::Ptr<OBJ> getObjective() {
61 return ROL::makePtr<ROL::Sacado_StdObjective<Real,HS_039::Obj>>();
62 }
63
64 const ROL::Ptr<CON> getEqualityConstraint() {
65 return ROL::makePtr<ROL::Sacado_StdConstraint<Real,HS_039::EqCon>>();
66 }
67
68 const ROL::Ptr<const V> getInitialGuess() {
69 Real x[] = {2.0,2.0,2.0,2.0};
70 return NP::createOptVector(x);
71 };
72
73 bool initialGuessIsFeasible() { return false; }
74
75 Real getInitialObjectiveValue() {
76 return Real(-2.0);
77 }
78
79 Real getSolutionObjectiveValue() {
80 return Real(-1.0);
81 }
82
83 ROL::Ptr<const V> getSolutionSet() {
84 Real x[] = {1.0,1.0,0.0,0.0};
85 return ROL::CreatePartitionedVector(NP::createOptVector(x));
86 }
87
88 };
89
90 } // namespace HS
91
92 #endif // HS_PROBLEM_039_HPP