| 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_038_HPP |
| 11 |
#define HS_PROBLEM_038_HPP |
| 12 |
|
| 13 |
#include "ROL_NonlinearProgram.hpp" |
| 14 |
|
| 15 |
namespace HS { |
| 16 |
|
| 17 |
namespace HS_038 { |
| 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 a1 = x[1]-x[0]*x[0]; |
| 24 |
ScalarT a2 = 1.0-x[1]; |
| 25 |
ScalarT a3 = x[3]-x[2]*x[2]; |
| 26 |
ScalarT a4 = 1.0-x[2]; |
| 27 |
ScalarT a5 = x[1]-1.0; |
| 28 |
ScalarT a6 = x[3]-1.0; |
| 29 |
|
| 30 |
return 100*a1*a1 + a2*a2 + 90*a3*a3 + a4*a4 + 10.1*(a5*a5+a6*a6) + 19.8*a5*a6; |
| 31 |
} |
| 32 |
}; |
| 33 |
} // namespace HS_038 |
| 34 |
|
| 35 |
template<class Real> |
| 36 |
class Problem_038 : public ROL::NonlinearProgram<Real> { |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
typedef ROL::NonlinearProgram<Real> NP; |
| 41 |
typedef ROL::Vector<Real> V; |
| 42 |
typedef ROL::Objective<Real> OBJ; |
| 43 |
|
| 44 |
public: |
| 45 |
|
| 46 |
Problem_038() : NP( dimension_x() ) { |
| 47 |
NP::setLower(0, -10.0); |
| 48 |
NP::setUpper(0, 10.0); |
| 49 |
NP::setLower(1, -10.0); |
| 50 |
NP::setUpper(1, 10.0); |
| 51 |
NP::setLower(2, -10.0); |
| 52 |
NP::setUpper(2, 10.0); |
| 53 |
NP::setLower(3, -10.0); |
| 54 |
NP::setUpper(3, 10.0); |
| 55 |
|
| 56 |
} |
| 57 |
|
| 58 |
int dimension_x() { return 4; } |
| 59 |
|
| 60 |
const ROL::Ptr<OBJ> getObjective() { |
| 61 |
return ROL::makePtr<ROL::Sacado_StdObjective<Real,HS_038::Obj>>(); |
| 62 |
} |
| 63 |
|
| 64 |
const ROL::Ptr<const V> getInitialGuess() { |
| 65 |
Real x[] = {-3.0,-1.0,-3.0,-1.0}; |
| 66 |
return NP::createOptVector(x); |
| 67 |
}; |
| 68 |
|
| 69 |
bool initialGuessIsFeasible() { return true; } |
| 70 |
|
| 71 |
Real getInitialObjectiveValue() { |
| 72 |
return Real(19192.0); |
| 73 |
} |
| 74 |
|
| 75 |
Real getSolutionObjectiveValue() { |
| 76 |
return Real(0.0); |
| 77 |
} |
| 78 |
|
| 79 |
ROL::Ptr<const V> getSolutionSet() { |
| 80 |
Real x[] = { 1.0, 1.0, 1.0, 1.0 }; |
| 81 |
|
| 82 |
return ROL::CreatePartitionedVector(NP::createOptVector(x)); |
| 83 |
} |
| 84 |
|
| 85 |
}; |
| 86 |
|
| 87 |
} // namespace HS |
| 88 |
|
| 89 |
#endif // HS_PROBLEM_038_HPP |