Debian Codegraph @

packages/rol/adapters/sacado/test/HS/HS_Problem_021.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_021_HPP
11 #define HS_PROBLEM_021_HPP
12
13 #include "ROL_NonlinearProgram.hpp"
14
15
16 namespace HS {
17
18 namespace HS_021 {
19 template<class Real>
20 class Obj {
21 public:
22 template<class ScalarT>
23 ScalarT value( const std::vector<ScalarT> &x, Real &tol ) {
24 return 0.01*x[0]*x[0]+x[1]*x[1]-100;
25 }
26 };
27
28 template<class Real>
29 class InCon {
30 public:
31 template<class ScalarT>
32 void value( std::vector<ScalarT> &c,
33 const std::vector<ScalarT> &x,
34 Real &told ) {
35 c[0] = 10*x[0]-x[1]-10;
36 }
37
38 };
39
40 }
41
42 template<class Real>
43 class Problem_021 : 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 private:
52 public:
53
54 Problem_021() : NP( dimension_x() ) {
55 NP::setLower(0, 2.0);
56 NP::setUpper(0, 50.0);
57 NP::setLower(1,-50.0);
58 NP::setUpper(1, 50.0);
59 }
60
61 int dimension_x() { return 2; }
62 int dimension_ci() { return 1; }
63
64 const ROL::Ptr<OBJ> getObjective() {
65 return ROL::makePtr<ROL::Sacado_StdObjective<Real,HS_021::Obj>>();
66 }
67
68 const ROL::Ptr<CON> getInequalityConstraint() {
69 return ROL::makePtr<ROL::Sacado_StdConstraint<Real,HS_021::InCon>>();
70 }
71
72 const ROL::Ptr<const V> getInitialGuess() {
73 Real x[] = {-1.0,-1.0};
74 return NP::createOptVector(x);
75 };
76
77 bool initialGuessIsFeasible() { return false; }
78
79 Real getInitialObjectiveValue() {
80 return Real(-98.99);
81 }
82
83 Real getSolutionObjectiveValue() {
84 return Real(-99.96);
85 }
86
87 ROL::Ptr<const V> getSolutionSet() {
88 const Real x[] = {2.0,0.0};
89 return ROL::CreatePartitionedVector(NP::createOptVector(x));
90 }
91
92 };
93
94 }
95
96 #endif // HS_PROBLEM_021_HPP