Debian Codegraph @

packages/rol/adapters/sacado/test/HS/HS_Problem_036.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_036_HPP
11 #define HS_PROBLEM_036_HPP
12
13 #include "ROL_NonlinearProgram.hpp"
14
15 namespace HS {
16
17 namespace HS_036 {
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]*x[1]*x[2];
24 }
25 };
26
27 template<class Real>
28 class InCon {
29 public:
30 template<class ScalarT>
31 void value( std::vector<ScalarT> &c,
32 const std::vector<ScalarT> &x,
33 Real &tol ) {
34
35 c[0] = 72.0 - x[0] - 2.0*x[1] - 2.0*x[2];
36
37 }
38 };
39 } // namespace HS_036
40
41
42 template<class Real>
43 class Problem_036 : 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_036() : NP( dimension_x() ) {
55 NP::setLower(0, 0.0);
56 NP::setUpper(0, 20.0);
57 NP::setLower(1, 0.0);
58 NP::setUpper(1, 11.0);
59 NP::setLower(2, 0.0);
60 NP::setUpper(2, 42.0);
61 }
62
63 int dimension_x() { return 3; }
64 int dimension_ci() { return 1; }
65
66 const ROL::Ptr<OBJ> getObjective() {
67 return ROL::makePtr<ROL::Sacado_StdObjective<Real,HS_036::Obj>>();
68 }
69
70 const ROL::Ptr<CON> getInequalityConstraint() {
71 return ROL::makePtr<ROL::Sacado_StdConstraint<Real,HS_036::InCon>>();
72 }
73
74 const ROL::Ptr<const V> getInitialGuess() {
75 Real x[] = {10.0,10.0,10.0};
76 return NP::createOptVector(x);
77 };
78
79 bool initialGuessIsFeasible() { return true; }
80
81 Real getInitialObjectiveValue() {
82 return Real(-1000.0);
83 }
84
85 Real getSolutionObjectiveValue() {
86 return Real(-3300.0);
87 }
88
89 ROL::Ptr<const V> getSolutionSet() {
90 Real x[] = { 20.0, 11.0, 15.0 };
91
92 return ROL::CreatePartitionedVector(NP::createOptVector(x));
93 }
94
95 };
96
97 } // namespace HS
98
99 #endif // HS_PROBLEM_036_HPP