-
Notifications
You must be signed in to change notification settings - Fork 4
/
Solution.cpp
46 lines (41 loc) · 1.13 KB
/
Solution.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "Solution.h"
using namespace std;
// Construye una solución inicial
Solution::Solution(vector<int> &rlength,
vector<int> &lpiece,
vector<int> &dpiece) {
int M = lpiece.size();
size = M;
int i;
int j;
int k;
pair <int,int> target;
pair <int,int> ffdresult;
int minimum;
int left = 0;
vector<int>::iterator it;
for(i = 0; i < M; i++)
cgs.push_back(new vector<int>(M,0));
for(i = 0; i < M; i++) {
vector<int> pieceSet(M,0);
pieceSet[i] = dpiece[i];
target.first = MAX_INT;
target.second = -1;
// Se prueba con todos los tipos de rolls
// para ver donde se acomoda mejor la n cantidad
// de piezas del tipo i.
for(j = 0; j < rlength.size(); j++) {
ffdresult = FFD(rlength[j], lpiece, pieceSet);
minimum = min(target.first,ffdresult.first);
if (target.first != minimum){
target.first = minimum;
target.second = j;
left = ffdresult.second;
}
}
used_rolls.push_back(target.first);
leftover.push_back(left);
rollType.push_back(target.second);
cgs[i]->at(i) = dpiece[i];
}
}