-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevaluate.cpp
More file actions
31 lines (25 loc) · 952 Bytes
/
evaluate.cpp
File metadata and controls
31 lines (25 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "defs.hpp"
//Evaluate the best alternatives based on Qualiflex Method.
std::vector<alt> evaluate(std::vector<alt>& alternatives, std::vector<u>& weights, std::vector<u>& bounds) {
//Store the each alternatives' score.
std::vector<u> results(alternatives.size(), 0);
//Iterate over alternatives.
for(u i=0; i<alternatives.size(); i++) {
for(u j=0; j<alternatives[0].alt_cr.size(); j++) {
results[i] += (alternatives[i].alt_cr[j] >= bounds[j]) ? weights[j] : 0;
}
}
std::vector<u> indxs;
//Find max results and determine.
for(u i=0; i<alternatives.size(); i++) {
if(results[i] == *std::max_element(results.begin(), results.end())) {
indxs.push_back(i);
}
}
std::vector<alt> choose_best;
for(u i=0; i<indxs.size(); i++) {
choose_best.push_back(alternatives[indxs[i]]);
}
//Return best alternatives.
return choose_best;
}