Debian Codegraph @

packages/rol/adapters/sacado/test/HS/HS_Problem_003.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_003_HPP
11 #define HS_PROBLEM_003_HPP
12
13 #include "ROL_NonlinearProgram.hpp"
14
15 namespace HS {
16
17 namespace HS_003 {
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];
24 return x[1]+a*a*1e-5;
25 }
26 };
27 }
28
29 template<class Real>
30 class Problem_003 : public ROL::NonlinearProgram<Real> {
31
32
33
34 typedef ROL::Objective<Real> OBJ;
35 typedef ROL::Vector<Real> V;
36 typedef ROL::NonlinearProgram<Real> NP;
37
38 public:
39
40 Problem_003() : NP( dimension_x() ) {
41 NP::setLower(1,0);
42 }
43
44 int dimension_x() { return 2; }
45
46 const ROL::Ptr<OBJ> getObjective() {
47 return ROL::makePtr<ROL::Sacado_StdObjective<Real,HS_003::Obj>>();
48 }
49
50 const ROL::Ptr<const V> getInitialGuess() {
51 Real x[] = {10.0,1.0};
52 return NP::createOptVector(x);
53 };
54
55 bool initialGuessIsFeasible() { return true; }
56
57 Real getInitialObjectiveValue() {
58 return Real(1.00081);
59 }
60
61 Real getSolutionObjectiveValue() {
62 return Real(0);
63 }
64
65 ROL::Ptr<const V> getSolutionSet() {
66 Real x[] = {0,0};
67 return ROL::CreatePartitionedVector(NP::createOptVector(x));
68 }
69
70 };
71
72 } // namespace HS
73
74 #endif // HS_PROBLEM_003_HPP