Debian Codegraph @

packages/rol/adapters/sacado/test/HS/HS_Problem_019.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_019_HPP
11 #define HS_PROBLEM_019_HPP
12
13 #include "ROL_NonlinearProgram.hpp"
14
15 namespace HS {
16
17 namespace HS_019 {
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[0]-10;
24 ScalarT b = x[1]-20;
25
26 return a*a*a + b*b*b;
27 }
28 };
29
30 template<class Real>
31 class InCon {
32 public:
33 template<class ScalarT>
34 void value( std::vector<ScalarT> &c,
35 const std::vector<ScalarT> &x,
36 Real &tol ) {
37 ScalarT a = x[0]-5;
38 ScalarT b = x[1]-5;
39 ScalarT d = x[0]-6;
40
41 c[0] = a*a + b*b - 100;
42 c[1] = -b*b - d*d + 82.81;
43 }
44 };
45 }
46
47
48 template<class Real>
49 class Problem_019 : public ROL::NonlinearProgram<Real> {
50
51
52
53 typedef ROL::Vector<Real> V;
54 typedef ROL::Objective<Real> OBJ;
55 typedef ROL::Constraint<Real> CON;
56 typedef ROL::NonlinearProgram<Real> NP;
57
58 public:
59
60 Problem_019() : NP( dimension_x() ) {
61 NP::setLower(0,13.0);
62 NP::setUpper(0,100.0);
63 NP::setLower(1,0.0);
64 NP::setUpper(1,100.0);
65 }
66
67 int dimension_x() { return 2; }
68 int dimension_ci() { return 2; }
69
70 const ROL::Ptr<OBJ> getObjective() {
71 return ROL::makePtr<ROL::Sacado_StdObjective<Real,HS_019::Obj>>();
72 }
73
74 const ROL::Ptr<CON> getInequalityConstraint() {
75 return ROL::makePtr<ROL::Sacado_StdConstraint<Real,HS_019::InCon>>();
76 }
77
78 const ROL::Ptr<const V> getInitialGuess() {
79 Real x[] = {20.1,5.84};
80 return NP::createOptVector(x);
81 };
82
83 bool initialGuessIsFeasible() { return false; }
84
85 Real getInitialObjectiveValue() {
86 return Real(-1808.858296);
87 }
88
89 Real getSolutionObjectiveValue() {
90 return -6961.81381;
91 }
92
93 ROL::Ptr<const V> getSolutionSet() {
94 Real x[] = {14.095,0.84296079};
95 return ROL::CreatePartitionedVector(NP::createOptVector(x));
96 }
97
98 };
99
100 } // namespace HS
101
102 #endif // HS_PROBLEM_019_HPP