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