MainRegion.java
25.3 KB
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
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
534
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
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
import org.chocosolver.solver.Model;
import org.chocosolver.solver.Solution;
import org.chocosolver.solver.Solver;
import org.chocosolver.solver.constraints.Constraint;
import org.chocosolver.solver.constraints.nary.nvalue.amnv.mis.F;
import org.chocosolver.solver.objective.ParetoOptimizer;
import org.chocosolver.solver.variables.IntVar;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class MainRegion {
public static void giveDomains (Model model, IntVar[] ugs, String dir, IntVar[] woodYield, IntVar[] soillossTotal,
IntVar[] perc_r_Total, IntVar[] biodiversity_total, IntVar[] cashflow_total, IntVar[] cstock_total,
IntVar[] npv_total, IntVar[] perc_rait_total, IntVar[] r_total,IntVar[] rait_total,IntVar[] sbiom_total, UG[] nodes, int R_option){
int index = 0;
try {
File allUg = new File(dir + "/ugs_init.txt");
Scanner readerUg = new Scanner(allUg);
File myObjWood = new File(dir + "/wood_total_init.txt");
Scanner myReaderWood = new Scanner(myObjWood);
File myObjSoil = new File(dir + "/soilloss_total_init.txt");
Scanner myReaderSoil = new Scanner(myObjSoil);
String percR_dir;
String bio_dir;
String cash_dir;
String cst_dir;
String npv_dir;
String percRait_dir;
String r_dir;
String rait_dir;
String sbi_dir;
int R;
switch(R_option) {
case 1:
percR_dir = "/perc_r5_total_init.txt";
bio_dir = "/biodiversity5_total_init.txt";
cash_dir = "/cashflow5_total_init.txt";
cst_dir = "/cstock5_total_init.txt";
npv_dir = "/npv5_total_init.txt";
percRait_dir = "/perc_rait5_total_init.txt";
r_dir = "/r5_total_init.txt";
rait_dir = "/rait5_total_init.txt";
sbi_dir = "/sbiom5_total_init.txt";
R = 5;
break;
case 2:
percR_dir = "/perc_r10_total_init.txt";
bio_dir = "/biodiversity10_total_init.txt";
cash_dir = "/cashflow10_total_init.txt";
cst_dir = "/cstock10_total_init.txt";
npv_dir = "/npv10_total_init.txt";
percRait_dir = "/perc_rait10_total_init.txt";
r_dir = "/r10_total_init.txt";
rait_dir = "/rait10_total_init.txt";
sbi_dir = "/sbiom10_total_init.txt";
R = 10;
break;
default:
percR_dir = "/perc_r0_total_init.txt";
bio_dir = "/biodiversity0_total_init.txt";
cash_dir = "/cashflow0_total_init.txt";
cst_dir = "/cstock0_total_init.txt";
npv_dir = "/npv0_total_init.txt";
percRait_dir = "/perc_rait0_total_init.txt";
r_dir = "/r0_total_init.txt";
rait_dir = "/rait0_total_init.txt";
sbi_dir = "/sbiom0_total_init.txt";
R = 0;
}
File myObjPerc_r = new File(dir + percR_dir);
Scanner myReaderPerc_r = new Scanner(myObjPerc_r);
File myObjBio = new File(dir + bio_dir);
Scanner myReaderBio = new Scanner(myObjBio);
File myObjCash = new File(dir + cash_dir);
Scanner myReaderCash = new Scanner(myObjCash);
File myObjCst = new File(dir + cst_dir);
Scanner myReaderCst = new Scanner(myObjCst);
File myObjNpv = new File(dir + npv_dir);
Scanner myReaderNpv = new Scanner(myObjNpv);
File myObjPerc_rait = new File(dir + percRait_dir);
Scanner myReaderPerc_rait = new Scanner(myObjPerc_rait);
File myObjR = new File(dir + r_dir);
Scanner myReaderR = new Scanner(myObjR);
File myObjRait = new File(dir + rait_dir);
Scanner myReaderRait = new Scanner(myObjRait);
File myObjSbi = new File(dir + sbi_dir);
Scanner myReaderSbi = new Scanner(myObjSbi);
while (readerUg.hasNextLine()) {
String dataUg = readerUg.nextLine();
String dataWood = myReaderWood.nextLine();
String dataSoil = myReaderSoil.nextLine();
String dataPerc_r = myReaderPerc_r.nextLine();
String dataBio = myReaderBio.nextLine();
String dataCash = myReaderCash.nextLine();
String dataCst = myReaderCst.nextLine();
String dataNpv = myReaderNpv.nextLine();
String dataPercRait = myReaderPerc_rait.nextLine();
String dataR = myReaderR.nextLine();
String dataRait = myReaderRait.nextLine();
String dataSbi = myReaderSbi.nextLine();
if(nodes[index].valid) {
String[] str_split = dataUg.split(",", 0);
String[] str_split_wood = dataWood.split(",", 0);
String[] str_split_soil = dataSoil.split(",", 0);
String[] str_split_percr = dataPerc_r.split(",", 0);
String[] str_split_bio = dataBio.split(",", 0);
String[] str_split_cash = dataCash.split(",", 0);
String[] str_split_cst = dataCst.split(",", 0);
String[] str_split_npv = dataNpv.split(",", 0);
String[] str_split_percRait = dataPercRait.split(",", 0);
String[] str_split_r = dataR.split(",", 0);
String[] str_split_rait = dataRait.split(",", 0);
String[] str_split_sbi = dataSbi.split(",", 0);
int size = str_split.length;
int[] toInsert = new int[size];
int[] toInsertWood = new int[size];
int[] toInsertSoil = new int[size];
int[] toInsertPercR = new int[size];
int[] toInsertBio = new int[size];
int[] toInsertCash = new int[size];
int[] toInsertCst = new int[size];
int[] toInsertNpv = new int[size];
int[] toInsertPercRait = new int[size];
int[] toInsertR = new int[size];
int[] toInsertRait = new int[size];
int[] toInsertSbi = new int[size];
for (int i = 0; i < size; i++) {
toInsert[i] = Integer.parseInt(str_split[i]);
toInsertWood[i] = (int) Float.parseFloat(str_split_wood[i]);
toInsertSoil[i] = (int) Float.parseFloat(str_split_soil[i]);
toInsertPercR[i] = (int) Float.parseFloat(str_split_percr[i]);
toInsertBio[i] = (int) Float.parseFloat(str_split_bio[i]);
toInsertCash[i] = (int) Float.parseFloat(str_split_cash[i]);
toInsertCst[i] = (int) Float.parseFloat(str_split_cst[i]);
toInsertNpv[i] = (int) Float.parseFloat(str_split_npv[i]);
toInsertPercRait[i] = (int) Float.parseFloat(str_split_percRait[i]);
toInsertR[i] = (int) Float.parseFloat(str_split_r[i]);
toInsertRait[i] = (int) Float.parseFloat(str_split_rait[i]);
toInsertSbi[i] = (int) Float.parseFloat(str_split_sbi[i]);
}
ugs[index] = model.intVar("UG_" + (index), toInsert);
woodYield[index] = model.intVar("Wood_Yield_" + (index), toInsertWood);
soillossTotal[index] = model.intVar("Soilloss_" + (index), toInsertSoil);
perc_r_Total[index] = model.intVar("RiskPercentileR"+R+":" + (index), toInsertPercR);
biodiversity_total[index] = model.intVar("BiodiversityR"+R+":" + (index), toInsertBio);
cashflow_total[index] = model.intVar("CashflowR"+R+":" + (index), toInsertCash);
cstock_total[index] = model.intVar("CstockR"+R+":" + (index), toInsertCst);
npv_total[index] = model.intVar("NpvR"+R+":" + (index), toInsertNpv);
perc_rait_total[index] = model.intVar("Perc_RaitR"+R+":" + (index), toInsertPercRait);
r_total[index] = model.intVar("RiskR"+R+":" + (index), toInsertR);
rait_total[index] = model.intVar("RaitR"+R+":" + (index), toInsertRait);
sbiom_total[index] = model.intVar("SbiomR"+R+":" + (index), toInsertSbi);
}
else {
ugs[index] = model.intVar("UG_"+(index), 0);
woodYield[index] = model.intVar("Wood_Yield_"+(index), 0);
soillossTotal[index] = model.intVar("Soilloss_" + (index), 0);
perc_r_Total[index] = model.intVar("RiskPercentileR"+R+":" + (index), 0);
biodiversity_total[index] = model.intVar("BiodiversityR"+R+":" + (index), 0);
cashflow_total[index] = model.intVar("CashflowR"+R+":" + (index), 0);
cstock_total[index] = model.intVar("CstockR"+R+":" + (index), 0);
npv_total[index] = model.intVar("NpvR"+R+":" + (index), 0);
perc_rait_total[index] = model.intVar("Perc_RaitR"+R+":" + (index), 0);
r_total[index] = model.intVar("RiskR"+R+":" + (index), 0);
rait_total[index] = model.intVar("RaitR"+R+":" + (index), 0);
sbiom_total[index] = model.intVar("SbiomR"+R+":" + (index), 0);
}
index++;
}
readerUg.close();
myReaderWood.close();
myReaderSoil.close();
myReaderPerc_r.close();
myReaderBio.close();
myReaderCash.close();
myReaderCst.close();
myReaderNpv.close();
myReaderPerc_rait.close();
myReaderRait.close();
myReaderR.close();
myReaderSbi.close();
} catch (FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
int areaLimit = Integer.parseInt(args[0]);
String fileDirectory = args[1];
String region = (args[2]);
int option = Integer.parseInt(args[3]);
String criterion = args[5];
int R_option = Integer.parseInt(args[4]);
int R;
switch(R_option) {
case 1:
R = 5;
break;
case 2:
R = 10;
break;
default:
R = 0;}
/*Set Flags
0-woodYield
1-Soil Loss
2-Perc_r
3-Biodiversity
4-Cashflow
5-Carbon Stock
6-NPV
7-Perc_rait
8-R
9-Rait
10-Sbiom
*/
String[] varNames = new String[]{"WoodYield","SoilLoss","Perc_r","Biodiversity","Cashflow","CarbonStock","NPV","Perc_rait","R","Rait","Sbiom"};
ArrayList<Boolean> flags = new ArrayList<Boolean>();
for(int i = 0; i < 11; i++) {
flags.add(false);
}
int toOptimizeLen = 0;
for(int i = 6; i < args.length; i++) {
flags.set(Integer.parseInt(args[i]), true);
toOptimizeLen++;
}
Model m = new Model("Forest Management");
BufferedReader reader = new BufferedReader(new FileReader(fileDirectory + "/ugs_init.txt"));
int nUgs = 0;
while (reader.readLine() != null) nUgs++;
reader.close();
UG[] nodes = new UG[nUgs];
UG.fillArrayRegions(nodes, fileDirectory, region, option);
IntVar[] ugs = new IntVar[nUgs]; // same for the constraint variable array
IntVar[] woodYield = new IntVar[nUgs];
IntVar[] soillossTotal = new IntVar[nUgs];
IntVar[] perc_r_Total = new IntVar[nUgs];
IntVar[] biodiversity_total = new IntVar[nUgs];
IntVar[] cashflow_total = new IntVar[nUgs];
IntVar[] cstock_total = new IntVar[nUgs];
IntVar[] npv_total = new IntVar[nUgs];
IntVar[] perc_rait_total = new IntVar[nUgs];
IntVar[] r_total = new IntVar[nUgs];
IntVar[] rait_total = new IntVar[nUgs];
IntVar[] sbiom_total = new IntVar[nUgs];
giveDomains(m, ugs, fileDirectory, woodYield, soillossTotal, perc_r_Total, biodiversity_total, cashflow_total, cstock_total,
npv_total, perc_rait_total, r_total, rait_total, sbiom_total, nodes, R_option); // reads the ugs_init file and initializes each variable with its possible prescription values as domain
System.out.println("running");
for(int ugIndex = 0; ugIndex < nodes.length; ugIndex++) { //loops through every UG
//the propagator takes as parameters the index of the UG we are starting out from
//the nodes with all the info, the constraint variable array and the area limit
if(nodes[ugIndex].valid) {
new Constraint("Area Limit Constraint", new CustomPropagator2(ugIndex, nodes, ugs, areaLimit)).post();
}
}
int valids = 0;
for(int i = 0; i < nodes.length; i++){
if(nodes[i].valid) {
valids++;
//System.out.println(nodes[i].internalId);
}
}
for(int i = 0; i < nodes.length; i++){
if(nodes[i].valid) {
IntVar prescIndex = m.intVar(0, 255);
m.element(ugs[i], nodes[i].presc, prescIndex).post();
m.element(woodYield[i], nodes[i].wood_total, prescIndex).post();
m.element(soillossTotal[i], nodes[i].soilloss_total, prescIndex).post();
switch(R_option) {
case 1:
m.element(perc_r_Total[i], nodes[i].perc_r5_total, prescIndex).post();
m.element(biodiversity_total[i], nodes[i].biodiversity5_total, prescIndex).post();
m.element(cashflow_total[i], nodes[i].cashflow5_total, prescIndex).post();
m.element(cstock_total[i], nodes[i].cstock5_total, prescIndex).post();
m.element(npv_total[i], nodes[i].npv5_total, prescIndex).post();
m.element(perc_rait_total[i], nodes[i].perc_rait5_total, prescIndex).post();
m.element(r_total[i], nodes[i].r5_total, prescIndex).post();
m.element(rait_total[i], nodes[i].rait5_total, prescIndex).post();
m.element(sbiom_total[i], nodes[i].sbiom5_total, prescIndex).post();
break;
case 2:
m.element(perc_r_Total[i], nodes[i].perc_r10_total, prescIndex).post();
m.element(biodiversity_total[i], nodes[i].biodiversity10_total, prescIndex).post();
m.element(cashflow_total[i], nodes[i].cashflow10_total, prescIndex).post();
m.element(cstock_total[i], nodes[i].cstock10_total, prescIndex).post();
m.element(npv_total[i], nodes[i].npv10_total, prescIndex).post();
m.element(perc_rait_total[i], nodes[i].perc_rait10_total, prescIndex).post();
m.element(r_total[i], nodes[i].r10_total, prescIndex).post();
m.element(rait_total[i], nodes[i].rait10_total, prescIndex).post();
m.element(sbiom_total[i], nodes[i].sbiom10_total, prescIndex).post();
break;
default:
m.element(perc_r_Total[i], nodes[i].perc_r0_total, prescIndex).post();
m.element(biodiversity_total[i], nodes[i].biodiversity0_total, prescIndex).post();
m.element(cashflow_total[i], nodes[i].cashflow0_total, prescIndex).post();
m.element(cstock_total[i], nodes[i].cstock0_total, prescIndex).post();
m.element(npv_total[i], nodes[i].npv0_total, prescIndex).post();
m.element(perc_rait_total[i], nodes[i].perc_rait0_total, prescIndex).post();
m.element(r_total[i], nodes[i].r0_total, prescIndex).post();
m.element(rait_total[i], nodes[i].rait0_total, prescIndex).post();
m.element(sbiom_total[i], nodes[i].sbiom0_total, prescIndex).post();
}
}
else{
m.arithm(woodYield[i], "=", 0).post();
m.arithm(soillossTotal[i], "=", 0).post();
m.arithm(perc_r_Total[i], "=", 0).post();
m.arithm(biodiversity_total[i], "=",0).post();
m.arithm(cashflow_total[i], "=",0).post();
m.arithm(cstock_total[i], "=",0).post();
m.arithm(npv_total[i], "=",0).post();
m.arithm(perc_rait_total[i], "=",0).post();
m.arithm(r_total[i], "=",0).post();
m.arithm(rait_total[i], "=",0).post();
m.arithm(sbiom_total[i], "=",0).post();
}
}
IntVar woodSum = m.intVar("WOOD_SUM", 0, 99999999);
IntVar soilSum = m.intVar("SOIL_SUM", -99999999, 99999999);
IntVar percRSum = m.intVar("RiskPercentile_R"+R, 0, 99999999);
IntVar bioSum = m.intVar("BiodiversityR"+R, 0, 99999999);
IntVar cashSum = m.intVar("CashflowR"+R,0, 99999999);
IntVar cstockSum = m.intVar("CstockR"+R,0, 99999999);
IntVar npvSum = m.intVar("NpvR"+R,0, 99999999);
IntVar percRaitSum = m.intVar("PercRaitR"+R,0, 99999999);
IntVar rSum = m.intVar("RiskR"+R,0, 99999999);
IntVar raitSum = m.intVar("RaitR"+R,0, 99999999);
IntVar sbiomSum = m.intVar("SbiomR"+R,0, 99999999);
if(flags.get(0))
m.sum(woodYield,"=", woodSum).post();
if(flags.get(1))
m.sum(soillossTotal,"=", soilSum).post();
if(flags.get(2))
m.sum(perc_r_Total,"=", percRSum).post();
if(flags.get(3))
m.sum(biodiversity_total, "=", bioSum).post();
if(flags.get(4))
m.sum(cashflow_total, "=", cashSum).post();
if(flags.get(5))
m.sum(cstock_total, "=", cstockSum).post();
if(flags.get(6))
m.sum(npv_total, "=", npvSum).post();
if(flags.get(7))
m.sum(perc_rait_total, "=", percRaitSum).post();
if(flags.get(8))
m.sum(r_total, "=", rSum).post();
if(flags.get(9))
m.sum(rait_total, "=", raitSum).post();
if(flags.get(10))
m.sum(sbiom_total, "=", sbiomSum).post();
IntVar[] toOptimize = new IntVar[toOptimizeLen];
IntVar[] allSums = new IntVar[]{woodSum, soilSum, percRSum, bioSum,cashSum,cstockSum,npvSum,percRaitSum,rSum,raitSum,sbiomSum};
IntVar[][] allTotals = new IntVar[][]{woodYield, soillossTotal,perc_r_Total,biodiversity_total,cashflow_total,cstock_total,npv_total,perc_rait_total,r_total,rait_total,sbiom_total};
// Single Criterion Optimization
if(criterion.equalsIgnoreCase("single")) {
//m.setObjective(Model.MAXIMIZE, woodSum);
//m.setObjective(Model.MAXIMIZE, soilSum);
//m.setObjective(Model.MAXIMIZE, percRSum);
Solver s = m.getSolver();
if (s.solve()) {
FileWriter outputPairs = new FileWriter("outputPairs.csv");
for (int i = 0; i < ugs.length; i++) {
if (nodes[i].valid) {
System.out.print(ugs[i] + ", ");
for (int j = 0; j < flags.size(); j++) {
if (flags.get(j))
System.out.print(allTotals[j][i] +",");
}
System.out.println("end");
outputPairs.write(nodes[i].externalId + "," + ugs[i].getValue() + "\n");
}
}
outputPairs.close();
System.out.println(woodSum);
System.out.println(soilSum);
System.out.println(percRSum);
}
}
else {
//Multi Criterion with Pareto
int index = 0;
for(int i = 0; i<flags.toArray().length; i++){
if(flags.get(i)){
toOptimize[index] = allSums[i];
index++;
}
}
//ParetoOptimizer po = new ParetoOptimizer(Model.MAXIMIZE, new IntVar[]{woodSum, soilToMaximize, percToMaximize});
ParetoOptimizer po = new ParetoOptimizer(Model.MAXIMIZE, toOptimize);
Solver solver = m.getSolver();
solver.plugMonitor(po);
FileWriter nonPareto = new FileWriter("nonPareto.csv");
for (int i = 0; i < flags.size(); i++) {
if (flags.get(i)) {
nonPareto.write(varNames[i]+",");
}
}
nonPareto.write("end\n");
FileWriter allSolutionPairs = new FileWriter("allSolutionPairs.csv");
// optimization
//(System.currentTimeMillis()-startTime)<18000000
int l = 1;
long startTime = System.currentTimeMillis(); //fetch starting time
try{
while(solver.solve() & (System.currentTimeMillis()-startTime)<32400000)
{
//System.out.println(l);
for (int i = 0; i < flags.size(); i++) {
if(flags.get(i))
nonPareto.write(allSums[i].getValue()+",");
}
nonPareto.write("end\n");
allSolutionPairs.write(l+", ");
for (int i = 0; i < flags.size(); i++) {
if(flags.get(i))
allSolutionPairs.write(varNames[i] +":"+ allSums[i].getValue()+",");
}
allSolutionPairs.write("end\n");
for(int i = 0; i < nodes.length; i++){
if(nodes[i].valid){
allSolutionPairs.write(nodes[i].externalId+","+ugs[i].getValue()+"\n");
}
}
l++;
for(int i = 0; i < nodes.length; i++){
if(nodes[i].valid){
System.out.print(ugs[i] + ", ");
for (int j = 0; j < flags.size(); j++) {
if(flags.get(j))
System.out.print(varNames[j] +":"+ allTotals[j][i].getValue()+",");
}
System.out.println("end");
}
}
l++;
}
}
catch (OutOfMemoryError e){
System.out.println("Reached Exception");
}
nonPareto.close();
//allSolutionPairs.close();
List<Solution> paretoFront = po.getParetoFront();
System.out.println("The pareto front has " + paretoFront.size() + " solutions : ");
FileWriter outputPairs = new FileWriter("outputPairsSpecif.csv");
FileWriter pareto = new FileWriter("pareto.csv");
for (int i = 0; i < flags.size(); i++) {
if (flags.get(i)) {
pareto.write(varNames[i]+",");
}
}
pareto.write("end\n");
int l2 = 0;
for (Solution so : paretoFront) {
for (int i = 0; i < flags.size(); i++) {
if (flags.get(i))
System.out.print(varNames[i]+"="+so.getIntVal(allSums[i])+",");
}
System.out.println("end");
outputPairs.write("Pareto Solution: " + l2+",");
for (int i = 0; i < flags.size(); i++) {
if (flags.get(i))
outputPairs.write(varNames[i]+":"+so.getIntVal(allSums[i])+",");
}
outputPairs.write("end\n");
for (int i = 0; i < ugs.length; i++) {
if (nodes[i].valid) {
System.out.print(i+"_"+so.getIntVal(ugs[i])+", ");
for (int j = 0; j < flags.size(); j++) {
if (flags.get(j))
System.out.print(varNames[j]+":"+so.getIntVal(allTotals[j][i])+",");
}
System.out.println("end");
outputPairs.write(nodes[i].externalId + "," +so.getIntVal(ugs[i]) + "\n");
}
}
for (int i = 0; i < flags.size(); i++) {
if(flags.get(i))
pareto.write(so.getIntVal(allSums[i])+",");
}
pareto.write("end\n");
l2++;
}
outputPairs.close();
pareto.close();
System.out.println(l + " solutions");
}
}
}