Debian Codegraph @

packages/rol/adapters/sacado/test/HS/HS_Problem_025.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_025_HPP
11 #define HS_PROBLEM_025_HPP
12
13 #include "ROL_NonlinearProgram.hpp"
14
15
16 namespace HS {
17
18 namespace HS_025 {
19 template<class Real>
20 class Obj {
21 private:
22 template<class ScalarT>
23 ScalarT f(int i, const std::vector<ScalarT> &x ) {
24 Real u = 25.0 + std::pow(-50.0*std::log(0.01*i),2.0/3.0);
25 return -0.01*i + std::exp( -std::pow(u-x[1],x[2]) /x[0] );
26 }
27 public:
28
29 template<class ScalarT>
30 ScalarT value( const std::vector<ScalarT> &x, Real &tol ) {
31 ScalarT a=0;
32 for(int i=1;i<100;++i) {
33 ScalarT b = f(i,x);
34 a = a+b*b;
35 }
36 return a;
37 }
38 };
39 }
40
41 template<class Real>
42 class Problem_025 : public ROL::NonlinearProgram<Real> {
43
44
45
46 typedef ROL::NonlinearProgram<Real> NP;
47 typedef ROL::Vector<Real> V;
48 typedef ROL::Objective<Real> OBJ;
49
50 private:
51 public:
52
53 Problem_025() : NP( dimension_x() ) {
54 NP::setLower(0,0.1);
55 NP::setUpper(0,100.0);
56
57 NP::setLower(1,0.0);
58 NP::setUpper(1,25.6);
59
60 NP::setLower(2,0.0);
61 NP::setUpper(2,5.0);
62 }
63
64 int dimension_x() { return 3; }
65
66 const ROL::Ptr<OBJ> getObjective() {
67 return ROL::makePtr<ROL::Sacado_StdObjective<Real,HS_025::Obj>>();
68 }
69
70 const ROL::Ptr<const V> getInitialGuess() {
71 Real x[] = {100,12.5,1.5};
72 return NP::createOptVector(x);
73 };
74
75 bool initialGuessIsFeasible() { return true; }
76
77 Real getInitialObjectiveValue() {
78 return Real(32.835);
79 }
80
81 Real getSolutionObjectiveValue() {
82 return Real(0);
83 }
84
85 ROL::Ptr<const V> getSolutionSet() {
86 const Real x[] = {50.0,25.0,1.5};
87 return ROL::CreatePartitionedVector(NP::createOptVector(x));
88 }
89
90 };
91
92 }
93
94 #endif // HS_PROBLEM_025_HPP