Debian Codegraph @

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