-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathADEIN.java
499 lines (477 loc) · 20.6 KB
/
ADEIN.java
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
package grmlsa.csa;
import java.util.List;
import network.Circuit;
import network.ControlPlane;
import util.IntersectionFreeSpectrum;
public class ADEIN implements CoreAndSpectrumAssignmentAlgorithmInterface {
private static final int COREQUANTITY = 7; // Quantidade de N�cleos na Fibra
private static final int CENTRALCOREID = 0; // ID do n�cleo Central
private static final int DEFAULTPOINTFORCENTRALCORE = 15; // PONTUAÇÃO INICIAL PARA NÚCLEO CENTRAL
private static final int DEFAULTPOINTFOROTHERCORE = 10; // PONTUAÇÃO INICIAL PARA NÚCLEOS DE BORDA
private int[] pointArray = new int[COREQUANTITY]; // Tabela de Pontua��o dos N�cleos
private int[] coreUse = new int[COREQUANTITY]; // Quantas vezes cada n�cleo foi usado.
// Inicializando tabela de pontos e definindo marca��es de espectro.
public ADEIN() {
for (int i = 0; i < COREQUANTITY; i++) {
pointArray[i] = DEFAULTPOINTFOROTHERCORE;
coreUse[i] = 0;
}
pointArray[0] = DEFAULTPOINTFORCENTRALCORE;
}
@Override
public boolean assignSpectrum(int numberOfSlots, Circuit circuit, ControlPlane cp) {
// Definindo N�cleo
int chosenCore = coreAssignment();
circuit.setIndexCore(chosenCore);
// Declarando Vari�vel de Espectro Escolhido.
int specChosen[] = null;
// Buscando Composi��o Espectral do N�cleo Escolhido.
List<int[]> composition = IntersectionFreeSpectrum.merge(circuit.getRoute(), circuit.getGuardBand(),
chosenCore);
// Realizando Tentativa de Aloca��o com Primeira Pol�tica.
specChosen = policy(numberOfSlots, composition, circuit, cp);
// Realizando Tentativa de Aloca��o com Segunda Pol�tica.
if (specChosen == null)
specChosen = policy2(numberOfSlots, composition, circuit, cp);
circuit.setSpectrumAssigned(specChosen);
if (specChosen == null)
return false;
else
return true;
}
@Override
public int coreAssignment() {
int chosenCore = checkPointTable(); // Escolhendo N�cleo Baseado na Tabela de Pontos.
pointTableUpdate(chosenCore); // Atualizando Tabela de Pontos.
return chosenCore;
}
private void pointTableUpdate(int currentCore) {
// N�cleo Central.
if (currentCore == CENTRALCOREID) {
pointArray[CENTRALCOREID] = DEFAULTPOINTFORCENTRALCORE;
for (int i = 1; i < COREQUANTITY; i++) {
pointArray[i]--;
}
// Outros N�cleos.
} else {
int oppositeCore;
int adjaLeftCore;
int adjaRightCore;
int adOposLeftCore;
int adOposRightCore;
// Definindo N�cleo Oposto
if (currentCore < 4)
oppositeCore = currentCore + 3;
else
oppositeCore = currentCore - 3;
// Definindo N�cleo Adjacente Esquerdo
if (currentCore == 1)
adjaLeftCore = 6;
else
adjaLeftCore = currentCore - 1;
// Definindo N�cleo Adjacente Direito
if (currentCore == 6)
adjaRightCore = 1;
else
adjaRightCore = currentCore + 1;
// Definindo N�cleo Adjacente Oposto Esquerdo
if (oppositeCore == 1)
adOposLeftCore = 6;
else
adOposLeftCore = oppositeCore - 1;
// Definindo N�cleo Adjacente Oposto Direito
if (oppositeCore == 6)
adOposRightCore = 1;
else
adOposRightCore = oppositeCore + 1;
// Verificando N�cleos para Reset
for (int i = 1; i < COREQUANTITY; i++) {
if (pointArray[i] <= 0)
pointArray[i] = DEFAULTPOINTFOROTHERCORE;
}
// Aplicando Tabela de Pontos
pointArray[currentCore] = pointArray[currentCore] + 1; // N�cleo Atual
pointArray[CENTRALCOREID] = pointArray[CENTRALCOREID] - 1; // N�cleo Central
pointArray[oppositeCore] = pointArray[oppositeCore] - 1; // N�cleo Oposto
pointArray[adjaLeftCore] = pointArray[adjaLeftCore] - 2; // N�cleo Adjacente Esquerdo
pointArray[adjaRightCore] = pointArray[adjaRightCore] - 2; // N�cleo Adjacente Direito
pointArray[adOposLeftCore] = pointArray[adOposLeftCore] - 3; // N�cleo Adjacente Oposto Esquerdo
pointArray[adOposRightCore] = pointArray[adOposRightCore] - 3; // N�cleo Adjacente Oposto Direito
}
}
// Retorna o ID do N�cleo Escolhido.
private int checkPointTable() {
int menorValor = 999999;
int coreID = -1;
for (int i = 0; i < COREQUANTITY; i++) {
if (pointArray[i] <= menorValor) {
menorValor = pointArray[i];
coreID = i;
}
}
coreUse[coreID]++;
return coreID;
}
// Primeira tentativa de aloca��o
@Override
public int[] policy(int numberOfSlots, List<int[]> freeSpectrumBands, Circuit circuit, ControlPlane cp) {
// Verificando se requisição está dentro dos limites de amplitude do sinal
int maxAmplitude = circuit.getPair().getSource().getTxs().getMaxSpectralAmplitude();
if (numberOfSlots > maxAmplitude)
return null;
// Setando Divisores de Espectro
int maxSpectrumSize = circuit.getRoute().getLink(0).getCore(0).getNumOfSlots();
int minSpectrumRange = maxSpectrumSize / COREQUANTITY;
int t1 = minSpectrumRange * 2;
int t2 = minSpectrumRange * 4;
int t3 = minSpectrumRange * 6;
// System.out.println("Spec Size [" + maxSpectrumSize + "] T1 [" + t1 + "] T2 ["
// + t2 + "] T3 [" + t3 + "]");
// System.out.println("[" + circuit.getIndexCore() + "]");
// System.out.println(
// "CENTRAL [" + coreUse[CENTRALCOREID] + "] 1 - [" + coreUse[1] + "] 2 - [" + coreUse[2] + "] 3 - ["
// + coreUse[3] + "] 4 - [" + coreUse[4] + "] 5 - [" + coreUse[5] + "] 6 - [" + coreUse[6] + "]");
// Escolhendo Espectro
int chosen[] = null;
// Core 1 - 4 (BLUE) First Fit
if (circuit.getIndexCore() == 1 || circuit.getIndexCore() == 4) {
for (int[] band : freeSpectrumBands) {
if (band[1] - band[0] + 1 >= numberOfSlots && (band[0] + numberOfSlots - 1) < t1) {
chosen = band.clone();
chosen[1] = chosen[0] + numberOfSlots - 1;
// System.out.println("1 - CORE [" + circuit.getIndexCore() + "] BLUE FIRST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1] + "] BandaCompleta ["
// + band[0] + " - " + band[1] + "]");
return chosen;
}
}
}
// Core 2 - 5 (ORANGE) Medium Fit
else if (circuit.getIndexCore() == 2 || circuit.getIndexCore() == 5) {
int reference = t1 + (t1 / 2);
int[] chosenBandLeft = null;
int[] chosenBandRight = null;
// Percorrendo Livres
for (int[] band : freeSpectrumBands) {
// Verificando se range aceita requisição
if (band[1] - band[0] + 1 >= numberOfSlots) {
// Cenário 1 - Esquerda - [0] [1] <= Reference
if (band[0] < reference && band[1] <= reference && band[1] - numberOfSlots + 1 >= t1) {
if (chosenBandLeft == null) {
chosenBandLeft = band.clone();
chosenBandLeft[0] = band[1] - numberOfSlots + 1;
} else {
if (reference - band[1] <= reference - chosenBandLeft[1]) {
chosenBandLeft[1] = band[1];
chosenBandLeft[0] = band[1] - numberOfSlots + 1;
}
}
}
// Cenário 2 - Dentro - [0] < Reference < [1]
else if (band[0] <= reference && band[1] >= reference) {
if ((reference - (numberOfSlots / 2)) > band[0]
&& (reference + (numberOfSlots / 2)) < band[1]) {
chosen = new int[2];
chosen[0] = reference - (numberOfSlots / 2);
chosen[1] = chosen[0] + numberOfSlots - 1;
// System.out.println(
// "1 - CORE [" + circuit.getIndexCore() + "] ORANGE IN MIDDLE FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1]
// + "] BandaCompleta [" + band[0] + " - " + band[1] + "]");
return chosen;
} else {
chosen = band.clone();
chosen[1] = chosen[0] + numberOfSlots - 1;
// System.out.println(
// "1 - CORE [" + circuit.getIndexCore() + "] ORANGE ELSE IN FIRST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1]
// + "] BandaCompleta [" + band[0] + " - " + band[1] + "]");
return chosen;
}
}
// Cenário 3 - Direita - Reference < [0] [1]
else if (band[0] >= reference && band[1] > reference && band[0] + numberOfSlots - 1 < t2) {
if (chosenBandRight == null) {
chosenBandRight = band.clone();
chosenBandRight[1] = band[0] + numberOfSlots - 1;
} else {
if (band[0] - reference <= chosenBandRight[0] - reference) {
chosenBandRight[0] = band[0];
chosenBandRight[1] = band[0] + numberOfSlots - 1;
}
}
}
}
}
// Verificando se usar� bloco da direita ou esquerda
if (chosenBandLeft == null && chosenBandRight == null) {
// System.out.println("LEFT AND RIGHT MIDDLE FIT NULL");
return null;
} else if (chosenBandLeft == null && chosenBandRight != null) {
chosen = chosenBandRight.clone();
// System.out.println(
// "1 - CORE [" + circuit.getIndexCore() + "] ORANGE RIGHT REFERENCE FIRST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1] + "]");
return chosen;
} else if (chosenBandRight == null && chosenBandLeft != null) {
chosen = chosenBandLeft.clone();
// System.out
// .println("1 - CORE [" + circuit.getIndexCore() + "] ORANGE LEFT REFERENCE LAST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1] + "]");
return chosen;
} else if (chosenBandLeft[1] - reference <= reference - chosenBandRight[0]) {
chosen = chosenBandLeft.clone();
// System.out
// .println("1 - CORE [" + circuit.getIndexCore() + "] ORANGE LEFT REFERENCE LAST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1] + "]");
return chosen;
} else if (chosenBandLeft[1] - reference >= reference - chosenBandRight[0]) {
chosen = chosenBandRight.clone();
// System.out.println(
// "1 - CORE [" + circuit.getIndexCore() + "] ORANGE RIGHT REFERENCE FIRST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1] + "]");
return chosen;
}
}
// Core 3 - 6 (GREEN) Last Fit
else if (circuit.getIndexCore() == 3 || circuit.getIndexCore() == 6) {
int band[] = null;
for (int i = freeSpectrumBands.size() - 1; i >= 0; i--) {
band = freeSpectrumBands.get(i);
if (band[1] - band[0] + 1 >= numberOfSlots) {
// System.out.println("T3 = " + t3 + " BandaCompleta [" + band[0] + " - " +
// band[1] + "] REQUISI��O [" + numberOfSlots + "]");
// Cenário 1 (Passa pelo T3) [0] < t3 < [1]
if (band[0] <= t3 && band[1] >= t3 && (t3 - numberOfSlots) >= band[0] && t3 - numberOfSlots >= t2) {
chosen = new int[2];
chosen[1] = t3 - 1;
chosen[0] = chosen[1] - numberOfSlots + 1;
// System.out.println("1 - CORE [" + circuit.getIndexCore() + "] GREEN IN T3 REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1] + "] BandaCompleta ["
// + band[0] + " - " + band[1] + "]");
return chosen;
// Cenário 2 (Antes de T3) [0] [1] < t3
} else if (band[1] < t3 && band[1] - numberOfSlots + 1 >= t2) {
chosen = band.clone();
chosen[0] = chosen[1] - numberOfSlots + 1;
// System.out.println("1 - CORE [" + circuit.getIndexCore() + "] GREEN BEFORE T3 REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1] + "] BandaCompleta ["
// + band[0] + " - " + band[1] + "]");
return chosen;
}
}
}
}
// Core 0 CENTRAL(BLACK) Last Fit
else if (circuit.getIndexCore() == 0) {
int band[] = null;
for (int i = freeSpectrumBands.size() - 1; i >= 0; i--) {
band = freeSpectrumBands.get(i);
if (band[1] - band[0] + 1 >= numberOfSlots) {
// Cen�rio 1 - Passando Dentro de T3
if (band[0] <= t3 && band[1] >= t3 && band[1] - numberOfSlots + 1 >= t3) {
chosen = band.clone();
chosen[0] = chosen[1] - numberOfSlots + 1;
// System.out.println("1 - CORE [" + circuit.getIndexCore() + "] BLACK LAST IN FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1] + "] BandaCompleta ["
// + band[0] + " - " + band[1] + "]");
return chosen;
// Cen�rio 2 - Passando depois de T3
} else if (band[0] >= t3) {
chosen = band.clone();
chosen[0] = chosen[1] - numberOfSlots + 1;
// System.out.println("1 - CORE [" + circuit.getIndexCore() + "] BLACK LAST AFTER FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1] + "] BandaCompleta ["
// + band[0] + " - " + band[1] + "]");
return chosen;
}
}
}
}
return null;
}
// Segunda tentativa de aloca��o
public int[] policy2(int numberOfSlots, List<int[]> freeSpectrumBands, Circuit circuit, ControlPlane cp) {
// Verificando se requisição está dentro dos limites de amplitude do sinal
int maxAmplitude = circuit.getPair().getSource().getTxs().getMaxSpectralAmplitude();
if (numberOfSlots > maxAmplitude)
return null;
// Setando Divisores de Espectro
int maxSpectrumSize = circuit.getRoute().getLink(0).getCore(0).getNumOfSlots();
int minSpectrumRange = maxSpectrumSize / COREQUANTITY;
int t1 = minSpectrumRange * 2;
int t2 = minSpectrumRange * 4;
int t3 = minSpectrumRange * 6;
// Escolhendo Espectro
int chosen[] = null;
// Core 1 - 4 (BLUE) First Fit Depois de T1
if (circuit.getIndexCore() == 1 || circuit.getIndexCore() == 4) {
for (int[] band : freeSpectrumBands) {
if (band[1] - band[0] + 1 >= numberOfSlots) {
// Cenário 1 (Passa pelo T1)
if (band[0] <= t1 && band[1] >= t1 && (t1 + numberOfSlots - 1) < band[1]) {
chosen = new int[2];
chosen[0] = t1;
chosen[1] = chosen[0] + numberOfSlots - 1;
// System.out.println("2 - CORE [" + circuit.getIndexCore() + "] BLUE IN T1 FIST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1] + "] BandaCompleta ["
// + band[0] + " - " + band[1] + "]");
return chosen;
}
// Cenário 2 (Depois do t1)
else if (band[0] > t1) {
chosen = band.clone();
chosen[1] = chosen[0] + numberOfSlots - 1;
// System.out.println("2 - CORE [" + circuit.getIndexCore()
// + "] BLUE AFTER F1 FIST FIT REQUISI��O [" + numberOfSlots + "] ESPECTRO = [" + chosen[0]
// + " - " + chosen[1] + "] BandaCompleta [" + band[0] + " - " + band[1] + "]");
return chosen;
}
}
}
}
// Core 2 - 5 (ORANGE) Last Fit <- t1 | First Fit -> t2
else if (circuit.getIndexCore() == 2 || circuit.getIndexCore() == 5) {
// Primeiro Bloco Last Fit T1
int band[] = null;
// Percorrendo vetor de espectro livro de trás pra frente
for (int i = freeSpectrumBands.size() - 1; i >= 0; i--) {
band = freeSpectrumBands.get(i);
if (band[1] - band[0] + 1 >= numberOfSlots) {
// Cenário 1 ( Passando por T1)
if (band[0] <= t1 && band[1] >= t1 && (t1 - numberOfSlots) >= band[0]) {
chosen = new int[2];
chosen[1] = t1 - 1;
chosen[0] = chosen[1] - numberOfSlots + 1;
// System.out.println("2 - CORE [" + circuit.getIndexCore()
// + "] ORANGE IN T1 LAST FIT REQUISI��O [" + numberOfSlots + "] ESPECTRO = [" + chosen[0]
// + " - " + chosen[1] + "] BandaCompleta [" + band[0] + " - " + band[1] + "]");
return chosen;
}
// Cenário 2 (Antes de T1)
else if (band[1] < t1) {
chosen = band.clone();
chosen[0] = chosen[1] - numberOfSlots + 1;
// System.out.println(
// "2 - CORE [" + circuit.getIndexCore() + "] ORANGE BEFORE T1 LAST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1]
// + "] BandaCompleta [" + band[0] + " - " + band[1] + "]");
return chosen;
}
}
}
// Segundo Bloco First Fit T2
for (int[] band1 : freeSpectrumBands) {
if (band1[1] - band1[0] + 1 >= numberOfSlots) {
// Cenário 1 ( Passa pelo t2)
if (band1[0] <= t2 && band1[1] >= t2 && (t2 + numberOfSlots - 1) <= band1[1]) {
chosen = new int[2];
chosen[0] = t2;
chosen[1] = chosen[0] + numberOfSlots - 1;
// System.out.println("2 - CORE [" + circuit.getIndexCore()
// + "] ORANGE IN T2 FIST FIT REQUISI��O [" + numberOfSlots + "] ESPECTRO = [" + chosen[0]
// + " - " + chosen[1] + "] BandaCompleta [" + band[0] + " - " + band[1] + "]");
return chosen;
}
// Cenário 2 (Depois de t2)
else if (band1[0] >= t2) {
chosen = band1.clone();
chosen[1] = chosen[0] + numberOfSlots - 1;
// System.out.println(
// "2 - CORE [" + circuit.getIndexCore() + "] ORANGE AFTER T2 FIST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1]
// + "] BandaCompleta [" + band[0] + " - " + band[1] + "]");
return chosen;
}
}
}
}
// Core 3 - 6 (GREEN) Last Fit <- t2 | First Fit -> t3
else if (circuit.getIndexCore() == 3 || circuit.getIndexCore() == 6) {
// Primeiro Bloco Last Fit T2
int band[] = null;
// Percorrendo vetor de espectro livro de trás pra frente
for (int i = freeSpectrumBands.size() - 1; i >= 0; i--) {
band = freeSpectrumBands.get(i);
if (band[1] - band[0] + 1 >= numberOfSlots) {
// Cenário 1 ( Passando por T2)
if (band[0] <= t2 && band[1] >= t2 && (t2 - numberOfSlots) >= band[0]) {
chosen = new int[2];
chosen[1] = t2 - 1;
chosen[0] = chosen[1] - numberOfSlots + 1;
// System.out.println("2 - CORE [" + circuit.getIndexCore() + "] GREEN IN T2 LAST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1] + "] BandaCompleta ["
// + band[0] + " - " + band[1] + "]");
return chosen;
}
// Cenário 2 (Antes de T2)
else if (band[1] < t2) {
chosen = band.clone();
chosen[0] = chosen[1] - numberOfSlots + 1;
// System.out.println(
// "2 - CORE [" + circuit.getIndexCore() + "] GREEN BEFORE T2 LAST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1]
// + "] BandaCompleta [" + band[0] + " - " + band[1] + "]");
return chosen;
}
}
}
// Segundo Bloco First Fit T3
for (int[] band1 : freeSpectrumBands) {
if (band1[1] - band1[0] + 1 >= numberOfSlots) {
// Cenário 1 ( Passa pelo t3)
if (band1[0] <= t3 && band1[1] >= t3 && (t3 + numberOfSlots - 1) <= band1[1]) {
chosen = new int[2];
chosen[0] = t3;
chosen[1] = chosen[0] + numberOfSlots - 1;
// System.out.println("2 - CORE [" + circuit.getIndexCore()
// + "] GREEN IN T3 FIRST FIT REQUISI��O [" + numberOfSlots + "] ESPECTRO = [" + chosen[0]
// + " - " + chosen[1] + "] BandaCompleta [" + band[0] + " - " + band[1] + "]");
return chosen;
}
// Cenário 2 (Depois de t3)
else if (band1[0] >= t3) {
chosen = band1.clone();
chosen[1] = chosen[0] + numberOfSlots - 1;
// System.out.println(
// "2 - CORE [" + circuit.getIndexCore() + "] GREEN AFTER T3 FIRST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1]
// + "] BandaCompleta [" + band[0] + " - " + band[1] + "]");
return chosen;
}
}
}
}
// Core 0 CENTRAL(BLACK) Last Fit <- t3
else if (circuit.getIndexCore() == 0) {
int band[] = null;
for (int i = freeSpectrumBands.size() - 1; i >= 0; i--) {
band = freeSpectrumBands.get(i);
if (band[1] - band[0] + 1 >= numberOfSlots) {
// Cenário 1 ( Passa pelo t3)
if (band[0] <= t3 && band[1] >= t3 && (t3 - numberOfSlots) >= band[0]) {
chosen = new int[2];
chosen[1] = t3 - 1;
chosen[0] = chosen[1] - numberOfSlots + 1;
// System.out.println("2 - CORE [" + circuit.getIndexCore() + "] BLACK IN T3 LAST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1] + "] BandaCompleta ["
// + band[0] + " - " + band[1] + "]");
return chosen;
}
// Cenário 2 (Antes de t3)
else if (band[1] < t3) {
chosen = band.clone();
chosen[0] = chosen[1] - numberOfSlots + 1;
// System.out.println(
// "2 - CORE [" + circuit.getIndexCore() + "] BLACK BEFORE T3 LAST FIT REQUISI��O ["
// + numberOfSlots + "] ESPECTRO = [" + chosen[0] + " - " + chosen[1]
// + "] BandaCompleta [" + band[0] + " - " + band[1] + "]");
return chosen;
}
}
}
}
// Return null se não achar espectro disponível.
return null;
}
}