| 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_034_HPP |
| 11 |
#define HS_PROBLEM_034_HPP |
| 12 |
|
| 13 |
#include "ROL_NonlinearProgram.hpp" |
| 14 |
|
| 15 |
namespace HS { |
| 16 |
|
| 17 |
namespace HS_034 { |
| 18 |
template<class Real> |
| 19 |
class Obj { |
| 20 |
public: |
| 21 |
template<class ScalarT> |
| 22 |
ScalarT value( const std::vector<ScalarT> &x, Real &tol ) { |
| 23 |
return -x[0]; |
| 24 |
} |
| 25 |
}; |
| 26 |
|
| 27 |
template<class Real> |
| 28 |
class InCon { |
| 29 |
public: |
| 30 |
template<class ScalarT> |
| 31 |
void value( std::vector<ScalarT> &c, |
| 32 |
const std::vector<ScalarT> &x, |
| 33 |
Real &tol ) { |
| 34 |
|
| 35 |
c[0] = x[1] - std::exp(x[0]); |
| 36 |
c[1] = x[2] - std::exp(x[1]); |
| 37 |
|
| 38 |
} |
| 39 |
}; |
| 40 |
} // namespace HS_034 |
| 41 |
|
| 42 |
|
| 43 |
template<class Real> |
| 44 |
class Problem_034 : public ROL::NonlinearProgram<Real> { |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
typedef ROL::NonlinearProgram<Real> NP; |
| 49 |
typedef ROL::Vector<Real> V; |
| 50 |
typedef ROL::Objective<Real> OBJ; |
| 51 |
typedef ROL::Constraint<Real> CON; |
| 52 |
|
| 53 |
public: |
| 54 |
|
| 55 |
Problem_034() : NP( dimension_x() ) { |
| 56 |
NP::setLower(0, 0.0); |
| 57 |
NP::setUpper(0, 100.0); |
| 58 |
NP::setLower(1, 0.0); |
| 59 |
NP::setUpper(1, 100.0); |
| 60 |
NP::setLower(2, 0.0); |
| 61 |
NP::setUpper(2, 10.0); |
| 62 |
} |
| 63 |
|
| 64 |
int dimension_x() { return 3; } |
| 65 |
int dimension_ci() { return 2; } |
| 66 |
|
| 67 |
const ROL::Ptr<OBJ> getObjective() { |
| 68 |
return ROL::makePtr<ROL::Sacado_StdObjective<Real,HS_034::Obj>>(); |
| 69 |
} |
| 70 |
|
| 71 |
const ROL::Ptr<CON> getInequalityConstraint() { |
| 72 |
return ROL::makePtr<ROL::Sacado_StdConstraint<Real,HS_034::InCon>>(); |
| 73 |
} |
| 74 |
|
| 75 |
const ROL::Ptr<const V> getInitialGuess() { |
| 76 |
Real x[] = {0.0,1.05,2.9}; |
| 77 |
return NP::createOptVector(x); |
| 78 |
}; |
| 79 |
|
| 80 |
bool initialGuessIsFeasible() { return true; } |
| 81 |
|
| 82 |
Real getInitialObjectiveValue() { |
| 83 |
return Real(0.0); |
| 84 |
} |
| 85 |
|
| 86 |
Real getSolutionObjectiveValue() { |
| 87 |
return -std::log(std::log(10)); |
| 88 |
} |
| 89 |
|
| 90 |
ROL::Ptr<const V> getSolutionSet() { |
| 91 |
Real x[] = { std::log(std::log(10)), std::log(10), 10.0 }; |
| 92 |
|
| 93 |
return ROL::CreatePartitionedVector(NP::createOptVector(x)); |
| 94 |
} |
| 95 |
|
| 96 |
}; |
| 97 |
|
| 98 |
} // namespace HS |
| 99 |
|
| 100 |
#endif // HS_PROBLEM_034_HPP |