// // Created by tudor on 07/01/24. // #ifndef C___NSGA_BENCHMARK_H #define C___NSGA_BENCHMARK_H #include "Individual.h" #include #include #include #include template class Benchmark { public: long long fitness_function_calls = 0; int n; int k = 0; //to debug int first_time_inner = -1; Benchmark(int _n) : n(_n) {} virtual bool is_pareto_front_complete(const std::vector> &pop) = 0; virtual std::array getCompute(const std::shared_ptr &x) { if(cachedCompute.count(x) == 0) cachedCompute[x] = compute(*x); return cachedCompute[x]; } // Custom hash function struct HashFunction { std::size_t operator()(const std::array& obj) const { std::size_t seed = 0; for (const int& i : obj) { seed ^= std::hash()(i) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } return seed; } }; private: virtual std::array compute(const Individual&) = 0; std::unordered_map, std::array> cachedCompute; }; #endif //C___NSGA_BENCHMARK_H