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