1 /// \file IOHprofiler_suite.h 2 /// \brief Header file for the template class IOHprofiler_suite. 3 /// 4 /// \author Furong Ye 5 #ifndef _IOHPROFILER_SUITE_H 6 #define _IOHPROFILER_SUITE_H 7 8 #include "IOHprofiler_class_generator.h" 9 #include "IOHprofiler_problem.h" 10 11 typedef std::map<std::string, int> PROBLEM_NAME_ID; 12 typedef std::map<int, std::string> PROBLEM_ID_NAME; 13 14 /// \brief A base class for construct a suite for sets of IOHprofiler_problems. 15 /// 16 /// To specify available problems of a suite, registerProblem must be implemented in derived class. 17 /// The default lable of problems are string type. Integer type are also optional, but we highly 18 /// recommond registering problem with string lable and creating a map of string problem_name and integer problem_id. 19 template <class InputType> class IOHprofiler_suite : public IOHprofiler_problem<InputType>, public std::vector<std::shared_ptr<IOHprofiler_problem<InputType> > > { 20 public: 21 IOHprofiler_suite(std::vector<int> problem_id = std::vector<int>(0), std::vector<int> instance_id = std::vector<int>(0), std::vector<int> dimension = std::vector<int>(0)) : 22 suite_name("no suite"), 23 problem_list_index(0), 24 size_of_problem_list(0), 25 get_problem_flag(false), 26 load_problem_flag(false), 27 current_problem(nullptr) { 28 } ~IOHprofiler_suite()29 ~IOHprofiler_suite() {} 30 31 IOHprofiler_suite(const IOHprofiler_suite&) = delete; 32 IOHprofiler_suite &operator =(const IOHprofiler_suite&) = delete; 33 34 typedef std::shared_ptr<IOHprofiler_problem<InputType> > Problem_ptr; 35 36 /// \fn virtual void registerProblem() 37 /// \brief A virtual function for registering problems. 38 /// 39 /// This function implements interfaces of available problems of a suite. With those interface, 40 /// user are able to request problem together with problem_id, instance_id, and dimension. registerInSuite()41 virtual void registerInSuite() {} 42 43 /// \fn loadProblems() 44 /// \brief Allocating memeory and creating instances of problems to be included in the suite. 45 /// 46 /// Before acquiring a problem from the suite, this function must be invoked. 47 /// Otherwise the list of problem is empty. 48 void loadProblem(); 49 50 /// \fn std::shared_ptr<IOHprofiler_problem<InputType>> get_next_problem() 51 /// \brief An interface of requesting problems in suite. 52 /// 53 /// To request 'the next' problem in the suite of correponding problem_id, instance_id and dimension index. 54 Problem_ptr get_next_problem(); 55 56 /// \fn std::shared_ptr<IOHprofiler_problem<InputType>> get_current_problem() 57 /// \brief An interface of requesting problems in suite. 58 /// 59 /// To request 'the current' problem in the suite of correponding problem_id, instance_id and dimension index. 60 Problem_ptr get_current_problem(); 61 62 63 /// \fn Problem_ptr get_next_problem() 64 /// \brief An interface of requesting problems in suite. 65 /// 66 /// To request a specific problem with corresponding problem_id, instance_id and dimension, 67 /// without concerning the order of testing problems. 68 Problem_ptr get_problem(std::string problem_name, int instance, int dimension); 69 70 /// \fn Problem_ptr get_next_problem() 71 /// \brief An interface of requesting problems in suite. 72 /// 73 /// To request a specific problem with corresponding problem_id, instance_id and dimension, 74 /// without concerning the order of testing problems. 75 Problem_ptr get_problem(int problem_id, int instance, int dimension); 76 77 int IOHprofiler_suite_get_number_of_problems() const; 78 79 int IOHprofiler_suite_get_number_of_instances() const; 80 81 int IOHprofiler_suite_get_number_of_dimensions() const; 82 83 std::vector<int> IOHprofiler_suite_get_problem_id() const; 84 85 std::map<int, std::string> IOHprofiler_suite_get_problem_name() const; 86 87 //! Return a map of problem name to problem ID, for all the registered problem. 88 std::map<std::string, int> IOHprofiler_suite_get_problems() const; 89 90 std::vector<int> IOHprofiler_suite_get_instance_id() const; 91 92 std::vector<int> IOHprofiler_suite_get_dimension() const; 93 94 std::string IOHprofiler_suite_get_suite_name() const; 95 96 void IOHprofiler_set_suite_problem_id(const std::vector<int> &problem_id); 97 98 void IOHprofiler_set_suite_instance_id(const std::vector<int> &instance_id); 99 100 void IOHprofiler_set_suite_dimension(const std::vector<int> &dimension); 101 102 void IOHprofiler_set_suite_name(const std::string suite_name); 103 104 void mapIDTOName(const int id, const std::string name); 105 106 private: 107 std::string suite_name; 108 int number_of_problems; 109 int number_of_instances; 110 int number_of_dimensions; 111 112 std::vector<int> problem_id; 113 std::vector<int> instance_id; 114 std::vector<int> dimension; 115 116 PROBLEM_ID_NAME problem_id_name_map; 117 PROBLEM_NAME_ID problem_name_id_map; 118 119 size_t problem_list_index; 120 size_t size_of_problem_list; 121 bool get_problem_flag; 122 bool load_problem_flag; 123 124 Problem_ptr current_problem; 125 }; 126 127 #include "IOHprofiler_suite.hpp" 128 129 #endif // _IOHPROFILER_SUITE_HPP 130