Project
PerformanceTable.h
Go to the documentation of this file.
1 #ifndef PERFORMANCETABLE_H
2 #define PERFORMANCETABLE_H
3 
10 #include "Criteria.h"
11 #include "Perf.h"
12 #include <ctime>
13 #include <iostream>
14 #include <vector>
15 
38 public:
47  PerformanceTable(std::vector<std::vector<Perf>> &perf_vect,
48  std::string mode = "alt");
49 
58  PerformanceTable(int nb_of_perfs, Criteria &crits,
59  std::string prefix = "alt");
60 
67 
69 
77  void generateRandomPerfValues(unsigned long int seed = time(NULL),
78  int lower_bound = 0, int upper_bound = 1);
79 
80  friend std::ostream &operator<<(std::ostream &out,
81  const PerformanceTable &perfs);
82 
83  // TODO Remove getter and setter
84  // Performance wise after some profiling we found that getter and setter can
85  // loose a lot of time compared to access directly the variable. Therefore in
86  // order to optimize the code, they should be removed.
92  std::vector<std::vector<Perf>> getPerformanceTable() const;
93 
99  std::string getMode() const;
100 
106  bool isSorted() const;
107 
118  std::vector<Perf> operator[](std::string name);
119 
127  Perf getPerf(std::string name, std::string crit);
128 
137  void sort(std::string mode = "crit");
138 
147  void changeMode(std::string mode);
148 
149  // TODO compare performance of sort + getAltBetweenSorted vs getAltBetween in
150  // the long run. This might be interesting to compare and could save some time
151  // in the overall pipeline.
163  std::vector<Perf> getAltBetweenSorted(std::string critId, float inf,
164  float sup);
165 
177  std::vector<Perf> getAltBetween(std::string critId, float inf, float sup);
178 
179  // TODO looks like this could be removed as it is never used
188  std::vector<Perf> getBestPerfByCrit(Criteria &crits);
189 
190  // TODO looks like this could be removed as it is never used
199  std::vector<Perf> getWorstPerfByCrit(Criteria &crits);
200 
208  bool isAltInTable(std::string altName);
209 
217 
224 
231  void display();
232 
239  bool operator==(const PerformanceTable &pt) const;
240 
241 protected:
242  std::vector<std::vector<Perf>> pt_;
243 
244  // mode_ indicates what is represented by rows: (alt or profiles) or criterias
245 
246  // TODO the mode_ attribute could be moved to the Profiles structure, as we
247  // didn't find use of it for the alternativesPerformance (datasets).
248  std::string mode_ = "alt"; // takes its value in {"crit", "alt"}
249 
250  // TODO the sorted_ parameter could be mode to the alternativesPerformance
251  // structure, as we didn't find use of it (and can be confusing) for Profiles
252  // objects.
253  bool sorted_ = false;
254 };
255 
256 #endif
Datastructure representing a set of criterion.
Perf (single performance) data structure.
Set of Criterion datastructure.
Definition: Criteria.h:25
Perf (single performance) data structure.
Definition: Perf.h:22
PerformanceTable data structure.
Definition: PerformanceTable.h:37
PerformanceTable(const PerformanceTable &perfs)
std::vector< Perf > getWorstPerfByCrit(Criteria &crits)
std::vector< Perf > getBestPerfByCrit(Criteria &crits)
void changeMode(std::string mode)
bool operator==(const PerformanceTable &pt) const
bool isAltInTable(std::string altName)
std::vector< Perf > getAltBetweenSorted(std::string critId, float inf, float sup)
void sort(std::string mode="crit")
std::vector< Perf > getAltBetween(std::string critId, float inf, float sup)
bool isSorted() const
PerformanceTable(int nb_of_perfs, Criteria &crits, std::string prefix="alt")
Perf getPerf(std::string name, std::string crit)
std::vector< std::vector< Perf > > getPerformanceTable() const
void generateRandomPerfValues(unsigned long int seed=time(NULL), int lower_bound=0, int upper_bound=1)
std::string getMode() const
std::vector< Perf > operator[](std::string name)
PerformanceTable(std::vector< std::vector< Perf >> &perf_vect, std::string mode="alt")