16f90fbc
Eduardo Eloy
database and impl...
|
1
2
|
import java.io.File;
import java.io.FileNotFoundException;
|
29a181fe
Eduardo Eloy
paretoworking and...
|
3
|
import java.util.ArrayList;
|
16f90fbc
Eduardo Eloy
database and impl...
|
4
5
6
|
import java.util.Scanner;
public class UG {
|
2cd288b3
Eduardo Eloy
project can now i...
|
7
8
9
|
int internalId;
int externalId;
|
16f90fbc
Eduardo Eloy
database and impl...
|
10
|
float area;
|
2cd288b3
Eduardo Eloy
project can now i...
|
11
|
int[] adj;
|
df0e5c82
Eduardo Eloy
added region para...
|
12
|
String region;
|
16f90fbc
Eduardo Eloy
database and impl...
|
13
|
int[] presc;
|
16f90fbc
Eduardo Eloy
database and impl...
|
14
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
15
16
17
18
|
int[][] years;
float[][] woodByPrescYear;
float[][] soillossByPrescYear;
String[][] thin_or_harv;
|
16f90fbc
Eduardo Eloy
database and impl...
|
19
|
|
44aa78ff
Eduardo Eloy
implementation at...
|
20
|
int[] wood_total;
|
2cd288b3
Eduardo Eloy
project can now i...
|
21
|
|
5276b92b
Eduardo Eloy
added multi-crite...
|
22
23
24
|
int[] perc_r0_total;
int[] perc_r5_total;
int[] perc_r10_total;
|
2cd288b3
Eduardo Eloy
project can now i...
|
25
|
|
5276b92b
Eduardo Eloy
added multi-crite...
|
26
|
int[] soilloss_total;
|
2cd288b3
Eduardo Eloy
project can now i...
|
27
|
|
a9dbe944
Eduardo Eloy
added new ways of...
|
28
29
30
|
float medx;
float medy;
|
2cd288b3
Eduardo Eloy
project can now i...
|
31
32
33
|
int time;
boolean valid;
|
0142c195
Eduardo Eloy
more solution res...
|
34
|
boolean treated;
|
16f90fbc
Eduardo Eloy
database and impl...
|
35
36
37
38
39
40
41
42
43
44
45
46
|
static public int[] returnInsertable(Scanner myReader){
String data = myReader.nextLine();
String[] str_split = data.split(",", 0);
int size = str_split.length;
int[] toInsert = new int [size];
for(int i=0; i<size; i++) {
toInsert[i] = Integer.parseInt(str_split[i]);
}
return toInsert;
}
|
44aa78ff
Eduardo Eloy
implementation at...
|
47
48
49
50
51
52
53
54
55
56
57
|
static public int[] returnInsertable2(Scanner myReader){
String data = myReader.nextLine();
String[] str_split = data.split(",", 0);
int size = str_split.length;
int[] toInsert = new int[size];
for(int i=0; i<size; i++) {
toInsert[i] = (int)Float.parseFloat(str_split[i]);
}
return toInsert;
}
|
2cd288b3
Eduardo Eloy
project can now i...
|
58
|
static public float[] returnInsertableFloat(Scanner myReader){
|
16f90fbc
Eduardo Eloy
database and impl...
|
59
60
61
|
String data = myReader.nextLine();
String[] str_split = data.split(",", 0);
int size = str_split.length;
|
2cd288b3
Eduardo Eloy
project can now i...
|
62
|
float[] toInsert = new float [size];
|
16f90fbc
Eduardo Eloy
database and impl...
|
63
|
for(int i=0; i<size; i++) {
|
2cd288b3
Eduardo Eloy
project can now i...
|
64
|
toInsert[i] = Float.parseFloat(str_split[i]);
|
16f90fbc
Eduardo Eloy
database and impl...
|
65
66
67
68
|
}
return toInsert;
}
|
2cd288b3
Eduardo Eloy
project can now i...
|
69
70
71
|
static public int[] adjacencyReader(Scanner adjacencies, Scanner borders, int minBorder){
String dataAdj = adjacencies.nextLine();
String[] str_splitA = dataAdj.split(",", 0);
|
16f90fbc
Eduardo Eloy
database and impl...
|
72
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
73
74
|
String dataBorders = borders.nextLine();
String[] str_splitB = dataBorders.split(",", 0);
|
16f90fbc
Eduardo Eloy
database and impl...
|
75
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
76
|
int size = str_splitA.length;
|
16f90fbc
Eduardo Eloy
database and impl...
|
77
78
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
79
80
81
|
int[] toInsert = new int [size];
toInsert[0] = -1;
int currentIndex = 0;
|
16f90fbc
Eduardo Eloy
database and impl...
|
82
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
83
84
85
86
87
88
89
90
|
for(int i=0; i<size; i++) {
if(Float.parseFloat(str_splitB[i]) > minBorder){
toInsert[currentIndex] = Integer.parseInt(str_splitA[i]);
currentIndex++;
}
}
return toInsert;
}
|
16f90fbc
Eduardo Eloy
database and impl...
|
91
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
92
93
94
|
static public int[] adjacencyReader(Scanner adjacencies, Scanner borders){
String dataAdj = adjacencies.nextLine();
String[] str_splitA = dataAdj.split(",", 0);
|
16f90fbc
Eduardo Eloy
database and impl...
|
95
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
96
97
|
String dataBorders = borders.nextLine();
String[] str_splitB = dataBorders.split(",", 0);
|
16f90fbc
Eduardo Eloy
database and impl...
|
98
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
99
|
int size = str_splitA.length;
|
16f90fbc
Eduardo Eloy
database and impl...
|
100
|
|
16f90fbc
Eduardo Eloy
database and impl...
|
101
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
102
103
104
|
int[] toInsert = new int [size];
toInsert[0] = -1;
int currentIndex = 0;
|
16f90fbc
Eduardo Eloy
database and impl...
|
105
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
106
107
108
109
|
for(int i=0; i<size; i++) {
if(Integer.parseInt(str_splitB[i]) >= 10){
toInsert[currentIndex] = Integer.parseInt(str_splitA[i]);
currentIndex++;
|
16f90fbc
Eduardo Eloy
database and impl...
|
110
|
}
|
2cd288b3
Eduardo Eloy
project can now i...
|
111
112
113
|
}
return toInsert;
}
|
16f90fbc
Eduardo Eloy
database and impl...
|
114
|
|
16f90fbc
Eduardo Eloy
database and impl...
|
115
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
static public int[] returnPeriods(String data){
String[] str_split = data.split(",", 0);
int size = str_split.length;
int[] toInsert = new int [size];
for(int i=0; i<size; i++) {
toInsert[i] = Integer.parseInt(str_split[i]);
}
return toInsert;
}
static public float[] returnByYear(String data){
String[] str_split = data.split(",", 0);
int size = str_split.length;
float[] toInsert = new float [size];
for(int i=0; i<size; i++) {
toInsert[i] = Float.parseFloat(str_split[i]);
|
16f90fbc
Eduardo Eloy
database and impl...
|
132
|
}
|
2cd288b3
Eduardo Eloy
project can now i...
|
133
|
return toInsert;
|
16f90fbc
Eduardo Eloy
database and impl...
|
134
135
|
}
|
2cd288b3
Eduardo Eloy
project can now i...
|
136
137
138
139
140
141
142
143
144
|
static public String[] returnByYearString(String data){
String[] str_split = data.split(",", 0);
int size = str_split.length;
String[] toInsert = new String [size];
for(int i=0; i<size; i++) {
toInsert[i] = (str_split[i]);
}
return toInsert;
}
|
16f90fbc
Eduardo Eloy
database and impl...
|
145
146
|
|
44aa78ff
Eduardo Eloy
implementation at...
|
147
|
static public void fillArray(UG[] array, String dir, int ugLimit) {
|
16f90fbc
Eduardo Eloy
database and impl...
|
148
149
150
151
|
int index = 0;
try { // idea: pass a directory, which should contain files called
// graph_init, ugs_init, ...
|
2cd288b3
Eduardo Eloy
project can now i...
|
152
153
154
155
156
|
File adj_init = new File(dir + "/adj_init.txt");
Scanner readerAdj = new Scanner(adj_init);
File borders_init = new File(dir + "/border_init.txt");
Scanner readerBorders = new Scanner(borders_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
157
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
158
159
|
File ext_init = new File(dir + "/external_init.txt");
Scanner readerExt = new Scanner(ext_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
160
|
|
df0e5c82
Eduardo Eloy
added region para...
|
161
162
163
|
File reg_init = new File(dir + "/region_init.txt");
Scanner readerReg = new Scanner(reg_init);
|
2cd288b3
Eduardo Eloy
project can now i...
|
164
165
|
File ugs_init = new File(dir + "/ugs_init.txt");
Scanner readerPresc = new Scanner(ugs_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
166
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
167
168
|
File years_init = new File(dir + "/years_init.txt");
Scanner readerYears = new Scanner(years_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
169
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
170
171
|
File area_init = new File(dir + "/area_init.txt");
Scanner readerArea = new Scanner(area_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
172
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
173
174
|
File wood_total_init = new File(dir + "/wood_total_init.txt");
Scanner readerWoodTotal = new Scanner(wood_total_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
175
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
176
177
|
File soilloss_init = new File(dir + "/soilloss_total_init.txt");
Scanner readerSoillossTotal = new Scanner(soilloss_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
178
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
179
180
|
File perc_r0_init = new File(dir + "/perc_r0_total_init.txt");
Scanner readerPerc_r0 = new Scanner(perc_r0_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
181
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
182
183
|
File perc_r5_init = new File(dir + "/perc_r5_total_init.txt");
Scanner readerPerc_r5 = new Scanner(perc_r5_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
184
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
185
186
|
File perc_r10_init = new File(dir + "/perc_r10_total_init.txt");
Scanner readerPerc_r10 = new Scanner(perc_r10_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
187
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
188
189
|
File wood_presc_init = new File(dir + "/wood_presc_init.txt");
Scanner readerWoodPresc = new Scanner(wood_presc_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
190
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
191
192
|
File thin_harv_init = new File(dir + "/thin_harv_init.txt");
Scanner readerThinHarv = new Scanner(thin_harv_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
193
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
194
|
|
a9dbe944
Eduardo Eloy
added new ways of...
|
195
196
197
198
199
200
|
File x_init = new File(dir + "/x_init.txt");
Scanner readerX = new Scanner(x_init);
File y_init = new File(dir + "/y_init.txt");
Scanner readerY = new Scanner(y_init);
|
2cd288b3
Eduardo Eloy
project can now i...
|
201
|
while (readerAdj.hasNextLine()) {
|
16f90fbc
Eduardo Eloy
database and impl...
|
202
|
UG toInsert = new UG();
|
44aa78ff
Eduardo Eloy
implementation at...
|
203
|
toInsert.valid = true;
|
0142c195
Eduardo Eloy
more solution res...
|
204
|
toInsert.treated = false;
|
2cd288b3
Eduardo Eloy
project can now i...
|
205
206
|
toInsert.internalId = index;
toInsert.adj = adjacencyReader(readerAdj, readerBorders, 50);
|
16f90fbc
Eduardo Eloy
database and impl...
|
207
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
208
209
|
toInsert.externalId = Integer.parseInt(readerExt.nextLine());
toInsert.area = Float.parseFloat(readerArea.nextLine());
|
a9dbe944
Eduardo Eloy
added new ways of...
|
210
211
|
toInsert.medx = Float.parseFloat(readerX.nextLine());
toInsert.medy = Float.parseFloat(readerY.nextLine());
|
df0e5c82
Eduardo Eloy
added region para...
|
212
213
|
toInsert.region = readerReg.nextLine();
|
2cd288b3
Eduardo Eloy
project can now i...
|
214
|
toInsert.presc = returnInsertable(readerPresc);
|
16f90fbc
Eduardo Eloy
database and impl...
|
215
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
216
217
218
219
220
221
222
223
|
String data = readerYears.nextLine();
String[] removeVSlash = data.split("\\|", 0);
String[] str_split = removeVSlash[1].split("/", 0);
int size = str_split.length;
toInsert.years = new int[size][];
for(int i = 0; i < size; i++) {
toInsert.years[i] = returnPeriods(str_split[i]);
|
16f90fbc
Eduardo Eloy
database and impl...
|
224
225
|
}
|
5276b92b
Eduardo Eloy
added multi-crite...
|
226
227
228
229
|
toInsert.soilloss_total = returnInsertable2(readerSoillossTotal);
toInsert.perc_r0_total = returnInsertable2(readerPerc_r0);
toInsert.perc_r5_total = returnInsertable2(readerPerc_r5);
toInsert.perc_r10_total = returnInsertable2(readerPerc_r10);
|
44aa78ff
Eduardo Eloy
implementation at...
|
230
|
toInsert.wood_total = returnInsertable2(readerWoodTotal);
|
16f90fbc
Eduardo Eloy
database and impl...
|
231
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
232
233
234
|
data = readerWoodPresc.nextLine();
String data2 = readerThinHarv.nextLine();
str_split = data.split("/", 0);
|
16f90fbc
Eduardo Eloy
database and impl...
|
235
|
|
2cd288b3
Eduardo Eloy
project can now i...
|
236
237
238
239
240
241
242
|
String[] str_split2 = data2.split("/", 0);
size = str_split.length;
int size2 = str_split2.length;
toInsert.woodByPrescYear = new float[size][];
toInsert.thin_or_harv = new String[size2][];
|
16f90fbc
Eduardo Eloy
database and impl...
|
243
244
245
|
for(int i = 0; i < size; i++) {
|
2cd288b3
Eduardo Eloy
project can now i...
|
246
247
|
toInsert.woodByPrescYear[i] = returnByYear(str_split[i]);
toInsert.thin_or_harv[i] = returnByYearString(str_split2[i]);
|
16f90fbc
Eduardo Eloy
database and impl...
|
248
249
|
}
|
a9dbe944
Eduardo Eloy
added new ways of...
|
250
|
|
44aa78ff
Eduardo Eloy
implementation at...
|
251
252
253
|
if(toInsert.adj[0] == -1 || index > ugLimit){
toInsert.valid = false;
}
|
16f90fbc
Eduardo Eloy
database and impl...
|
254
255
256
257
258
|
array[index] = toInsert;
index++;
}
|
2cd288b3
Eduardo Eloy
project can now i...
|
259
260
261
262
263
|
readerAdj.close();
readerPresc.close();
readerExt.close();
|
df0e5c82
Eduardo Eloy
added region para...
|
264
|
readerReg.close();
|
2cd288b3
Eduardo Eloy
project can now i...
|
265
266
267
268
269
270
271
272
273
274
|
readerBorders.close();
readerArea.close();
readerPerc_r0.close();
readerPerc_r5.close();
readerPerc_r10.close();
readerSoillossTotal.close();
readerThinHarv.close();
readerWoodPresc.close();
readerWoodTotal.close();
readerYears.close();
|
16f90fbc
Eduardo Eloy
database and impl...
|
275
276
277
278
279
280
281
|
} catch (FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
|
df0e5c82
Eduardo Eloy
added region para...
|
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
static public void fillArrayRegions(UG[] array, String dir, String region, int option) {
int index = 0;
try { // idea: pass a directory, which should contain files called
// graph_init, ugs_init, ...
File adj_init = new File(dir + "/adj_init.txt");
Scanner readerAdj = new Scanner(adj_init);
File borders_init = new File(dir + "/border_init.txt");
Scanner readerBorders = new Scanner(borders_init);
File ext_init = new File(dir + "/external_init.txt");
Scanner readerExt = new Scanner(ext_init);
File reg_init = new File(dir + "/region_init.txt");
Scanner readerReg = new Scanner(reg_init);
|
16f90fbc
Eduardo Eloy
database and impl...
|
298
|
|
df0e5c82
Eduardo Eloy
added region para...
|
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
|
File ugs_init = new File(dir + "/ugs_init.txt");
Scanner readerPresc = new Scanner(ugs_init);
File years_init = new File(dir + "/years_init.txt");
Scanner readerYears = new Scanner(years_init);
File area_init = new File(dir + "/area_init.txt");
Scanner readerArea = new Scanner(area_init);
File wood_total_init = new File(dir + "/wood_total_init.txt");
Scanner readerWoodTotal = new Scanner(wood_total_init);
File soilloss_init = new File(dir + "/soilloss_total_init.txt");
Scanner readerSoillossTotal = new Scanner(soilloss_init);
File perc_r0_init = new File(dir + "/perc_r0_total_init.txt");
Scanner readerPerc_r0 = new Scanner(perc_r0_init);
File perc_r5_init = new File(dir + "/perc_r5_total_init.txt");
Scanner readerPerc_r5 = new Scanner(perc_r5_init);
File perc_r10_init = new File(dir + "/perc_r10_total_init.txt");
Scanner readerPerc_r10 = new Scanner(perc_r10_init);
File wood_presc_init = new File(dir + "/wood_presc_init.txt");
Scanner readerWoodPresc = new Scanner(wood_presc_init);
File thin_harv_init = new File(dir + "/thin_harv_init.txt");
Scanner readerThinHarv = new Scanner(thin_harv_init);
|
a9dbe944
Eduardo Eloy
added new ways of...
|
329
330
331
332
333
|
File x_init = new File(dir + "/x_init.txt");
Scanner readerX = new Scanner(x_init);
File y_init = new File(dir + "/y_init.txt");
Scanner readerY = new Scanner(y_init);
|
df0e5c82
Eduardo Eloy
added region para...
|
334
335
336
337
338
339
340
341
342
343
|
while (readerAdj.hasNextLine()) {
UG toInsert = new UG();
toInsert.valid = true;
toInsert.treated = false;
toInsert.internalId = index;
toInsert.adj = adjacencyReader(readerAdj, readerBorders, 50);
toInsert.externalId = Integer.parseInt(readerExt.nextLine());
toInsert.area = Float.parseFloat(readerArea.nextLine());
|
a9dbe944
Eduardo Eloy
added new ways of...
|
344
345
346
|
toInsert.medx = Float.parseFloat(readerX.nextLine());
toInsert.medy = Float.parseFloat(readerY.nextLine());
|
df0e5c82
Eduardo Eloy
added region para...
|
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
|
toInsert.region = readerReg.nextLine();
toInsert.presc = returnInsertable(readerPresc);
String data = readerYears.nextLine();
String[] removeVSlash = data.split("\\|", 0);
String[] str_split = removeVSlash[1].split("/", 0);
int size = str_split.length;
toInsert.years = new int[size][];
for(int i = 0; i < size; i++) {
toInsert.years[i] = returnPeriods(str_split[i]);
}
toInsert.soilloss_total = returnInsertable2(readerSoillossTotal);
toInsert.perc_r0_total = returnInsertable2(readerPerc_r0);
toInsert.perc_r5_total = returnInsertable2(readerPerc_r5);
toInsert.perc_r10_total = returnInsertable2(readerPerc_r10);
toInsert.wood_total = returnInsertable2(readerWoodTotal);
data = readerWoodPresc.nextLine();
String data2 = readerThinHarv.nextLine();
str_split = data.split("/", 0);
String[] str_split2 = data2.split("/", 0);
size = str_split.length;
int size2 = str_split2.length;
toInsert.woodByPrescYear = new float[size][];
toInsert.thin_or_harv = new String[size2][];
for(int i = 0; i < size; i++) {
toInsert.woodByPrescYear[i] = returnByYear(str_split[i]);
toInsert.thin_or_harv[i] = returnByYearString(str_split2[i]);
}
if(option==0){
if(!region.equalsIgnoreCase(toInsert.region)){
//System.out.println(index);
toInsert.valid = false;
}
}
else {
if (region.equalsIgnoreCase(toInsert.region)) {
toInsert.valid = false;
//System.out.println(index);
}
}
|
a9dbe944
Eduardo Eloy
added new ways of...
|
399
|
|
df0e5c82
Eduardo Eloy
added region para...
|
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
|
if(toInsert.adj[0] == -1)
toInsert.valid = false;
array[index] = toInsert;
index++;
}
readerAdj.close();
readerPresc.close();
readerExt.close();
readerReg.close();
readerBorders.close();
readerArea.close();
readerPerc_r0.close();
readerPerc_r5.close();
readerPerc_r10.close();
readerSoillossTotal.close();
readerThinHarv.close();
readerWoodPresc.close();
readerWoodTotal.close();
readerYears.close();
} catch (FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
|
16f90fbc
Eduardo Eloy
database and impl...
|
430
|
|
29a181fe
Eduardo Eloy
paretoworking and...
|
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
|
static public void fillArraySpecific(UG[] array, String dir, ArrayList<Integer> list) {
int index = 0;
try { // idea: pass a directory, which should contain files called
// graph_init, ugs_init, ...
File adj_init = new File(dir + "/adj_init.txt");
Scanner readerAdj = new Scanner(adj_init);
File borders_init = new File(dir + "/border_init.txt");
Scanner readerBorders = new Scanner(borders_init);
File ext_init = new File(dir + "/external_init.txt");
Scanner readerExt = new Scanner(ext_init);
File reg_init = new File(dir + "/region_init.txt");
Scanner readerReg = new Scanner(reg_init);
File ugs_init = new File(dir + "/ugs_init.txt");
Scanner readerPresc = new Scanner(ugs_init);
File years_init = new File(dir + "/years_init.txt");
Scanner readerYears = new Scanner(years_init);
File area_init = new File(dir + "/area_init.txt");
Scanner readerArea = new Scanner(area_init);
File wood_total_init = new File(dir + "/wood_total_init.txt");
Scanner readerWoodTotal = new Scanner(wood_total_init);
File soilloss_init = new File(dir + "/soilloss_total_init.txt");
Scanner readerSoillossTotal = new Scanner(soilloss_init);
File perc_r0_init = new File(dir + "/perc_r0_total_init.txt");
Scanner readerPerc_r0 = new Scanner(perc_r0_init);
File perc_r5_init = new File(dir + "/perc_r5_total_init.txt");
Scanner readerPerc_r5 = new Scanner(perc_r5_init);
File perc_r10_init = new File(dir + "/perc_r10_total_init.txt");
Scanner readerPerc_r10 = new Scanner(perc_r10_init);
File wood_presc_init = new File(dir + "/wood_presc_init.txt");
Scanner readerWoodPresc = new Scanner(wood_presc_init);
File thin_harv_init = new File(dir + "/thin_harv_init.txt");
Scanner readerThinHarv = new Scanner(thin_harv_init);
|
a9dbe944
Eduardo Eloy
added new ways of...
|
478
479
480
481
482
483
|
File x_init = new File(dir + "/x_init.txt");
Scanner readerX = new Scanner(x_init);
File y_init = new File(dir + "/y_init.txt");
Scanner readerY = new Scanner(y_init);
|
29a181fe
Eduardo Eloy
paretoworking and...
|
484
485
486
487
488
489
490
491
492
493
|
while (readerAdj.hasNextLine()) {
UG toInsert = new UG();
toInsert.valid = true;
toInsert.treated = false;
toInsert.internalId = index;
toInsert.adj = adjacencyReader(readerAdj, readerBorders, 50);
toInsert.externalId = Integer.parseInt(readerExt.nextLine());
toInsert.area = Float.parseFloat(readerArea.nextLine());
|
a9dbe944
Eduardo Eloy
added new ways of...
|
494
495
|
toInsert.medx = Float.parseFloat(readerX.nextLine());
toInsert.medy = Float.parseFloat(readerY.nextLine());
|
29a181fe
Eduardo Eloy
paretoworking and...
|
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
|
toInsert.region = readerReg.nextLine();
toInsert.presc = returnInsertable(readerPresc);
String data = readerYears.nextLine();
String[] removeVSlash = data.split("\\|", 0);
String[] str_split = removeVSlash[1].split("/", 0);
int size = str_split.length;
toInsert.years = new int[size][];
for(int i = 0; i < size; i++) {
toInsert.years[i] = returnPeriods(str_split[i]);
}
toInsert.soilloss_total = returnInsertable2(readerSoillossTotal);
toInsert.perc_r0_total = returnInsertable2(readerPerc_r0);
toInsert.perc_r5_total = returnInsertable2(readerPerc_r5);
toInsert.perc_r10_total = returnInsertable2(readerPerc_r10);
toInsert.wood_total = returnInsertable2(readerWoodTotal);
data = readerWoodPresc.nextLine();
String data2 = readerThinHarv.nextLine();
str_split = data.split("/", 0);
String[] str_split2 = data2.split("/", 0);
size = str_split.length;
int size2 = str_split2.length;
toInsert.woodByPrescYear = new float[size][];
toInsert.thin_or_harv = new String[size2][];
for(int i = 0; i < size; i++) {
toInsert.woodByPrescYear[i] = returnByYear(str_split[i]);
toInsert.thin_or_harv[i] = returnByYearString(str_split2[i]);
}
|
a9dbe944
Eduardo Eloy
added new ways of...
|
534
|
|
29a181fe
Eduardo Eloy
paretoworking and...
|
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
|
if(!list.contains(toInsert.externalId)){
toInsert.valid = false;
}
array[index] = toInsert;
index++;
}
readerAdj.close();
readerPresc.close();
readerExt.close();
readerReg.close();
readerBorders.close();
readerArea.close();
readerPerc_r0.close();
readerPerc_r5.close();
readerPerc_r10.close();
readerSoillossTotal.close();
readerThinHarv.close();
readerWoodPresc.close();
readerWoodTotal.close();
readerYears.close();
} catch (FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
|
16f90fbc
Eduardo Eloy
database and impl...
|
566
|
}
|