30#ifndef SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_MULTIOBJECTIVEBENCHMARK_H
31#define SHARK_OBJECTIVEFUNCTIONS_BENCHMARK_MULTIOBJECTIVEBENCHMARK_H
41namespace shark {
namespace benchmarks{
45 template<
int...>
struct integer_sequence {
using type = integer_sequence; };
46 template<
typename T1,
typename T2>
struct integer_sequence_concat;
47 template<
int... I1,
int... I2>
struct integer_sequence_concat<integer_sequence<I1...>, integer_sequence<I2...>>: integer_sequence<I1..., (sizeof...(I1) + I2)...> {};
50 template<
int N>
struct generate_integer_sequence;
51 template<
int N>
struct generate_integer_sequence: integer_sequence_concat<typename generate_integer_sequence<N/2>::type, typename generate_integer_sequence<N-N/2>::type>::type {};
52 template <>
struct generate_integer_sequence<0>: integer_sequence<>{};
53 template <>
struct generate_integer_sequence<1>: integer_sequence<0>{};
70template<
class ... Objectives>
76 setupRotations(
typename detail::generate_integer_sequence<
sizeof...(Objectives)>::type());
78 for(
auto& f: m_rotations){
80 if(!f.hasFirstDerivative())
90 return generateName(
typename detail::generate_integer_sequence<
sizeof...(Objectives)>::type());
99 for(
auto& f: m_rotations){
106 return sizeof...(Objectives);
110 return get<0>().numberOfVariables();
114 typename std::tuple_element<N, std::tuple<Objectives...> >::type&
get(){
115 return std::get<N>(m_objectives);
118 typename std::tuple_element<N, std::tuple<Objectives...> >::type
const&
get()
const{
119 return std::get<N>(m_objectives);
124 m_translations.clear();
126 for(
auto& f: m_rotations)
129 for(
double& v: translation){
132 m_translations.push_back(translation);
142 for (std::size_t i = 0; i < x.size(); i++) {
153 for(std::size_t i = 0; i != value.size(); ++i){
154 value(i) = m_rotations[i].eval( x - m_translations[i]);
161 RealVector singleDerivative;
163 for(std::size_t i = 0; i != value.size(); ++i){
164 value(i) = m_rotations[i].evalDerivative( x - m_translations[i],singleDerivative);
165 noalias(row(derivative,i)) = singleDerivative;
173 void setupRotations(detail::integer_sequence<I...>){
174 m_rotations.insert(m_rotations.begin(), {RotatedObjectiveFunction(&std::get<I>(m_objectives))... });
178 std::string generateName(detail::integer_sequence<I...>)
const{
180 for(
auto const& fname:{std::get<I>(m_objectives).name()... }){
187 std::tuple<Objectives...> m_objectives;
188 std::vector<RotatedObjectiveFunction> m_rotations;
189 std::vector<RealVector> m_translations;