2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
11 * Created on December 17, 2018, 2:02 PM
17 #include "classlist.h"
18 #include "cppvector.h"
19 #include "hashtable.h"
21 #define TUNERUNSETVALUE -1
22 #define AUTOTUNERFACTOR 0.3
26 Problem(const char *problem);
27 char *getProblem() {return problem;}
28 inline int getResult() {return result;}
29 inline int getProblemNumber() {return problemnumber;}
30 inline void setResult(int res) {result = res;}
31 inline void setProblemNumber(int probNum) {problemnumber = probNum;}
32 inline long long getBestTime() {return besttime ;}
33 inline void setBestTime(long long time) {besttime = time;}
45 TunerRecord(SearchTuner *_tuner) : tuner(_tuner), tunernumber(-1), isduplicate(false) {}
46 TunerRecord(SearchTuner *_tuner, int _tunernumber) : tuner(_tuner), tunernumber(_tunernumber), isduplicate(false) {}
47 SearchTuner *getTuner() {return tuner;}
48 void inline addProblem(Problem *problem) {problems.push(problem);}
49 TunerRecord *changeTuner(SearchTuner *_newtuner);
50 void updateTuner(SearchTuner *_newtuner) {tuner = _newtuner;}
51 long long getTime(Problem *problem);
52 void setTime(Problem *problem, long long time);
53 inline void setTunerNumber(int numb) {tunernumber = numb;}
54 inline int getTunerNumber() {return tunernumber;}
55 inline uint problemsSize() {return problems.getSize();}
56 inline void setDuplicate(bool _duplicate) { isduplicate = _duplicate;}
57 inline bool isDuplicate() {return isduplicate;}
58 inline Problem *getProblem(uint index) {return problems.get(index);}
60 void printProblemsInfo();
64 Vector<Problem *> problems;
65 Hashtable<Problem *, long long, uint64_t> timetaken;
67 friend void clearVector(Vector<TunerRecord *> *tunerV);
73 BasicTuner(uint _budget, uint _timeout);
74 void addProblem(const char *filename);
75 void addTuner(SearchTuner *tuner);
77 virtual ~BasicTuner();
78 virtual void tune() = 0;
81 long long evaluate(Problem *problem, TunerRecord *tuner);
83 * returns the index of the tuner which is subtune of
88 int subTunerIndex(SearchTuner *newTuner);
89 bool tunerExists(TunerRecord *tunerRec);
90 SearchTuner *mutateTuner(SearchTuner *oldTuner, uint k);
91 void updateTimeout(Problem *problem, long long metric);
92 Vector<TunerRecord *> allTuners;
93 Vector<TunerRecord *> explored;
94 Vector<Problem *> problems;
95 Vector<TunerRecord *> tuners;
101 #endif/* BASICTUNER_H */