Debian Codegraph @

packages/rol/adapters/sacado/test/HS/HS_Problem_006.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_006_HPP
11 #define HS_PROBLEM_006_HPP
12
13 #include "ROL_NonlinearProgram.hpp"
14
15 namespace HS {
16
17 namespace HS_006 {
18 template<class Real>
19 class Obj {
20 public:
21 template<class ScalarT>
22 ScalarT value( const std::vector<ScalarT> &x, Real &tol ) {
23 ScalarT a = x[1]-x[0]*x[0];
24 ScalarT b = 1-x[0];
25 return 100*a*a+b*b;
26 }
27 };
28
29 template<class Real>
30 class EqCon {
31 public:
32 template<class ScalarT>
33 void value( std::vector<ScalarT> &c,
34 const std::vector<ScalarT> &x,
35 Real &tol ) {
36 c[0] = 10.0*(x[1]-x[0]*x[0]);
37 }
38 };
39 }
40
41
42 template<class Real>
43 class Problem_006 : public ROL::NonlinearProgram<Real> {
44
45
46
47 typedef ROL::NonlinearProgram<Real> NP;
48 typedef ROL::Vector<Real> V;
49 typedef ROL::Objective<Real> OBJ;
50 typedef ROL::Constraint<Real> CON;
51
52 public:
53
54 Problem_006() : NP( dimension_x() ) {
55 NP::noBound();
56 }
57
58 int dimension_x() { return 2; }
59 int dimension_ce() { return 1; }
60
61 const ROL::Ptr<OBJ> getObjective() {
62 return ROL::makePtr<ROL::Sacado_StdObjective<Real,HS_006::Obj>>();
63 }
64
65 const ROL::Ptr<CON> getEqualityConstraint() {
66 return ROL::makePtr<ROL::Sacado_StdConstraint<Real,HS_006::EqCon>>();
67 }
68
69 const ROL::Ptr<const V> getInitialGuess() {
70 Real x[] = {-1.2,1.0};
71 return NP::createOptVector(x);
72 };
73
74 bool initialGuessIsFeasible() { return false; }
75
76 Real getInitialObjectiveValue() {
77 return Real(4.84);
78 }
79
80 Real getSolutionObjectiveValue() {
81 return Real(0);
82 }
83
84 ROL::Ptr<const V> getSolutionSet() {
85 Real x[] = {1.0,1.0};
86 return ROL::CreatePartitionedVector(NP::createOptVector(x));
87 }
88
89 };
90
91 } // namespace HS
92
93 #endif // HS_PROBLEM_006_HPP