Debian Codegraph @

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