Project
AlternativesPerformance.h
Go to the documentation of this file.
1 #ifndef AlternativesPerformance_H
2 #define AlternativesPerformance_H
3 
10 #include "Category.h"
11 #include "Criteria.h"
12 #include "PerformanceTable.h"
13 #include <iostream>
14 #include <iterator>
15 #include <ostream>
16 #include <string.h>
17 #include <unordered_map>
18 #include <vector>
19 
20 extern Category default_cat;
21 extern std::unordered_map<std::string, Category> default_map;
22 
36 public:
47  std::vector<std::vector<Perf>> &perf_vect,
48  std::unordered_map<std::string, Category> &alt_assignment = default_map);
49 
64  int nb_of_perfs, Criteria &crits, std::string prefix = "alt",
65  std::unordered_map<std::string, Category> &alt_assignment = default_map);
66 
77  const PerformanceTable &perf_table,
78  std::unordered_map<std::string, Category> &alt_assignment = default_map);
79 
86 
88 
89  friend std::ostream &operator<<(std::ostream &out,
90  const AlternativesPerformance &alt);
91 
97  std::unordered_map<std::string, Category> getAlternativesAssignments() const;
98 
99  // TODO Remove getter and setter
100  // Performance wise after some profiling we found that getter and setter can
101  // loose a lot of time compared to access directly the variable. Therefore in
102  // order to optimize the code, they should be removed.
109  std::unordered_map<std::string, Category> &alt_assignment);
110 
117  Category getAlternativeAssignment(std::string altName) const;
118 
125  void setAlternativeAssignment(std::string altName, Category &cat);
126 
133 
141  std::pair<float, float> getBoundaries();
142 
143 private:
144  // TODO: Memory could be optimize here, there is no need to store the Category
145  // object, we could use a reference instead.
146 
147  // Hashmap: key = Alternative Name, value = Category
148  std::unordered_map<std::string, Category> alt_assignment_;
149 };
150 
151 #endif
Datastructure representing a category.
Datastructure representing a set of criterion.
PerformanceTable data structure.
Dataset datastructure.
Definition: AlternativesPerformance.h:35
void setAlternativeAssignment(std::string altName, Category &cat)
std::unordered_map< std::string, Category > getAlternativesAssignments() const
AlternativesPerformance(int nb_of_perfs, Criteria &crits, std::string prefix="alt", std::unordered_map< std::string, Category > &alt_assignment=default_map)
AlternativesPerformance(const AlternativesPerformance &alt)
AlternativesPerformance(std::vector< std::vector< Perf >> &perf_vect, std::unordered_map< std::string, Category > &alt_assignment=default_map)
Category getAlternativeAssignment(std::string altName) const
void setAlternativesAssignments(std::unordered_map< std::string, Category > &alt_assignment)
AlternativesPerformance(const PerformanceTable &perf_table, std::unordered_map< std::string, Category > &alt_assignment=default_map)
std::pair< float, float > getBoundaries()
Category datastructure.
Definition: Category.h:20
Set of Criterion datastructure.
Definition: Criteria.h:25
PerformanceTable data structure.
Definition: PerformanceTable.h:37