// @HEADER // ***************************************************************************** // Rapid Optimization Library (ROL) Package // // Copyright 2014 NTESS and the ROL contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef HS_PROBLEM_009_HPP #define HS_PROBLEM_009_HPP #include "ROL_NonlinearProgram.hpp" namespace HS { namespace HS_009 { template class Obj { public: template ScalarT value( const std::vector &x, Real &tol ) { Real pi = 3.14159265359; return std::sin(pi*x[0]/12.0)*std::cos(pi*x[1]/16.0); } }; template class EqCon { public: template void value( std::vector &c, const std::vector &x, Real &tol ) { c[0] = 4.0*x[0] - 3.0*x[1]; } }; } template class Problem_009 : public ROL::NonlinearProgram { typedef ROL::Vector V; typedef ROL::Objective OBJ; typedef ROL::Constraint CON; typedef ROL::NonlinearProgram NP; public: Problem_009() : NP( dimension_x() ) { NP::noBound(); } int dimension_x() { return 2; } int dimension_ce() { return 1; } const ROL::Ptr getObjective() { return ROL::makePtr>(); } const ROL::Ptr getEqualityConstraint() { return ROL::makePtr>(); } const ROL::Ptr getInitialGuess() { Real x[] = {0,0}; return NP::createOptVector(x); }; bool initialGuessIsFeasible() { return true; } Real getInitialObjectiveValue() { return Real(0.0); } Real getSolutionObjectiveValue() { return Real(-0.5); } // x* = (12k-3,16k-4) for all integer k ROL::Ptr getSolutionSet() { Real x1[] = {-15,-20}; Real x2[] = {-3, -4}; Real x3[] = { 9, 12}; return ROL::CreatePartitionedVector(NP::createOptVector(x1), NP::createOptVector(x2), NP::createOptVector(x3)); } }; } // namespace HS #endif // HS_PROBLEM_009_HPP