|
- #ifndef SEARCHHEURISTIC_H
- #define SEARCHHEURISTIC_H
-
- #include <vector>
- #include "MasterMind.h"
-
- struct Point {
- Point() : Point(0,0) {};
- Point(int c, double v) : nb_calls{c}, value{v} {};
-
- int nb_calls;
- double value;
- };
-
- struct Candidate {
- Candidate(int* s, int v) {
- sol = s;
- value = v;
- }
-
- int* sol;
- int value;
- };
- void swap_candidates(Candidate** tab, unsigned int i, unsigned int j);
-
- struct {
- bool operator()(Candidate* a, Candidate* b) const {
- return a->value > b->value;
- }
- } cmp_candidates;
-
- struct Result {
- Result(int* s, int v, int c, bool a=false) {
- solution = s;
- v_solution = v;
- nb_calls = c;
- has_been_aborted = a;
- }
-
- int* solution;
- int v_solution;
- int nb_calls;
- bool has_been_aborted;
- };
-
- class SearchHeuristic
- {
- public:
- SearchHeuristic();
- virtual Result run() = 0;
- MasterMind* get_problem();
- void set_problem(MasterMind* problem);
- void set_abortion_limit(double l);
- void set_record(std::vector<Point>* m_record_tab);
- bool is_recording();
- void clear_record();
- void record(int nb_calls, double value);
- std::vector<Point>* get_record();
- void set_objective(double objective);
- virtual ~SearchHeuristic();
-
- protected:
- MasterMind* m_problem;
- double m_abortion_limit;
- std::vector<Point>* m_record;
- double m_objective; // 1=100% of the result
-
- private:
- };
-
- #endif // SEARCHHEURISTIC_H
|